Commit Graph

16 Commits

Author SHA1 Message Date
Philip Withnall
0909b2e3ac girnode: Improve int types in GIIrNodeUnion
`GIIrNodeUnion` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

As part of this, switch from `atoi()` to `g_ascii_string_to_unsigned()`
for parsing the relevant fields from a GIR XML file. This means we now
get error handling for invalid integers.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-26 09:29:30 +00:00
Philip Withnall
2e7518bcc1 girnode: Improve int types in GIIrNodeEnum
`GIIrNodeEnum` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-26 09:29:30 +00:00
Philip Withnall
501ff95cea girnode: Improve int types in GIIrNodeField
`GIIrNodeField` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

As part of this, switch from `atoi()` to `g_ascii_string_to_unsigned()`
for parsing the relevant fields from a GIR XML file. This means we now
get error handling for invalid integers.

This also includes some offset validity changes which were forgotten
from commit 515b3fc1dc.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
48d9f356c3 girnode: Improve int types in GIIrNodeVFunc
`GIIrNodeVFunc` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

As part of this, switch from `atoi()` to `g_ascii_string_to_unsigned()`
for parsing the relevant fields from a GIR XML file. This means we now
get error handling for invalid integers.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
468b926c2b girnode: Improve int types in GIIrNodeSignal
`class_closure` isn’t actually meaningfully set anywhere in the code yet
(there are FIXME comments), so I’m not sure of the best type for it. But
generally `unsigned` is more widely used than signed `int`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
e7f26b1440 girnode: Improve int types in GIIrNodeType
`GIIrNodeType` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

As part of this, switch from `atoi()` to `g_ascii_string_to_unsigned()`
for parsing the relevant fields from a GIR XML file. This means we now
get error handling for invalid integers.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
2c2712e310 girnode: Document ownership and element types of internal structs
This is just for future reference for people reading the code in future.
I was going through and checking to see if any of them needed to be made
`const` (none of them did).

I did find a couple of memory leaks though; see the following commits.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
515b3fc1dc giroffsets: Uniformly handle alignments as size_t
Do this by tracking the state of the size/alignment calculations
separately, rather than bunging it into the `alignment` field using
magic values.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3155
2024-01-18 13:09:29 +00:00
Marco Trevisan (Treviño)
6cc655f86e girepository: Use single-bit sized elements for the GIIrNode structures
Leave to the compiler some more hints to optimize these structures for
being packed when possible.
2024-01-16 18:56:57 +01:00
Marco Trevisan (Treviño)
b68857e707 giroffsets: Use size types for size and alignments
Note that for alignments we should actually use size_t, but this would
imply some refactors since this value can be acually set to -1 in our
implementation.

So we use gssize for now, that at least on gcc is defined.
2024-01-16 18:55:45 +01:00
Marco Trevisan (Treviño)
c8aecbb834 girepository: Use uint8_t pointers instead of guchar 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
9f33015a25 girrepository: Use standard int sized types instead of g[u]int* 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
8891429a5b girepository: Use char instead of glib-specific gchar 2024-01-16 18:40:42 +01:00
Philip Withnall
2b544c3f66 girepository: Remove _ prefix from private functions
Now that libgirepository uses `GI_AVAILABLE_IN_*` macros, that’s what
controls symbol visibility. The `_` prefixes are redundant, and out of
keeping with the rest of GLib.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2023-11-08 15:23:31 +00:00
Philip Withnall
b32da06a7c girepository: Rename symbols to the GI namespace
Rather than a mix of structs being in `GI` and their methods being in
`g_`.

We’ve chosen not to use the `g_` namespace because a number of the
libgirepository class names are quite generic, so we’d end up with
confusing symbols like `GScopeType` and `GArgument`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2023-11-08 15:05:20 +00:00
Emmanuele Bassi
b0f4a6bcc4 gir: Rename girnode.h to girnode-private.h
It's a private header.
2023-11-08 00:09:04 +00:00