Commit Graph

21 Commits

Author SHA1 Message Date
Ville Skyttä
b20647c2e2 docs: spelling and grammar fixes
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2024-04-01 11:01:06 +00:00
Philip Withnall
f4f38c233f girepository: Move internal gi_typelib_blob_type_to_info_type() function
`GITypeInfo` isn’t defined in `libgirepository-internals`, and that was
forcing us to do some header includes which violated the layering
between `libigrepository-internals` and `libgirepository`. Fix that by
moving the helper function to the header/source where `GITypeInfo` is
defined.

This fixes commit 54f156bd63.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-14 11:52:33 +00:00
Philip Withnall
54f156bd63 gitypelib: Explicitly convert from GITypelibBlobType to GIInfoType
When creating `GIBaseInfo` instances from binary blobs, so far the code
has used an undocumented implicit conversion from one enum type to the
other. That’s a bit nasty, as it means the two enum types need to be
kept in sync (without that need being documented).

Introduce an explicit conversion function to make things more explicit.
Currently it does nothing, but in an upcoming commit it will be used to
deprecate a blob type.

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

Helps: #3245
2024-02-12 13:15:38 +00:00
Philip Withnall
e1cff511e5 Merge branch '3155-union-tests' into 'main'
gitypes: Fix integer values of GIInfoType and add unit tests for GIUnionInfo

See merge request GNOME/glib!3888
2024-02-08 10:25:13 +00:00
Philip Withnall
5cc5f413f5 gitypelib: Switch to refcounting
Since `GITypelib` is exposed in the public libgirepository API, it needs
to be a boxed type. So we either need to add a `copy` method to mirror
the existing `free` method, or switch to refcounting. The latter option
seems better, since a `GITypelib` contains internal state about open
`GModule`s and the semantics for copying that would be potentially
complex.

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

Helps: #3155
2024-02-07 21:07:18 +00:00
Philip Withnall
c8946b8a92 gitypes: Fix integer values of GIInfoType
This effectively reverts commit 0910e2f6ad. I thought that `GIInfoType`
was decoupled from `GITypelibBlobType`, but it turns out that
`girepository.c` calls `gi_info_new_full()` with blob types, implicitly
converting them to info types.

This was causing anything with a type higher than the `INVALID_0` value
to be loaded as the wrong type.

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

Helps: #3155
2024-02-06 13:40:20 +00:00
Philip Withnall
80f9153a7f girepository: Move search and library paths into GIRepository
Rather than them being set and stored globally, make them members of
`GIRepository`. This helps us move away from the concept of a global
singleton `GIRepository`.

This is slightly complicated by the fact that the library paths are
needed within the module loading code in `GITypelib`, but at that point
the `GITypelib` doesn’t have access to its parent `GIRepository` to call
`gi_repository_get_library_path()`, so we have to cache them in
`typelib->library_paths`.

It also means that it’s no longer possible to retrieve the ‘unset’ paths
from the globals, so the test for that is removed from
`repository-search-paths.c`.

This commit makes some API breaks, but that’s OK because libgirepository
has not been in a stable release yet.

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

Helps: #3155
2024-01-26 12:08:17 +00:00
Philip Withnall
1eec66c898 gitypelib: Replace multiple constructors with gi_typelib_new_from_bytes()
`GBytes` provides a way of handling const memory blobs, stolen memory
blobs, and mapped files. Rather than having `GITypelib` implement all of
those itself, just take a `GBytes` as input.

This is an API break, but libgirepository hasn’t been in a stable
release yet.

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

Helps: #3155
2024-01-26 09:51:13 +00:00
Marco Trevisan (Treviño)
223acf44ba gitypelib: Replace gi_typelib_check_format with compile-time static checks only
There's no much time to have checks at runtime when the compiler can
make sure that the structures size match the expected ones.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
bc2e4b3de5 girrepository: Replace usage of gsize with standard size_t
We just do a safe s/gsize/size_t/ replacement here without doing any
changes to places in which different size of size_t and gsize may be
actually different and create troubles.
2024-01-16 18:40:42 +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
Marco Trevisan (Treviño)
91fc45ea57 girepository: Replace tabs with spaces in indentation
We don't use tabs anywhere and the mixed setup just makes many editors
to cry. So let's just replace the tabs with 8 spaces.
2024-01-16 17:30:37 +01:00
Philip Withnall
513e178144 gitypelib: Rename gi_typelib_check_sanity() to gi_typelib_check_format()
It’s more descriptive and less offensive.

This is not an API break as it’s not a public API.

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

Helps: #3155
2024-01-05 13:51:28 +00:00
Philip Withnall
5ccb2d7a06 gitypelib: Port documentation to gi-docgen and update
Review and update the documentation, making sure it’s complete,
formatted in gi-docgen format, and has all appropriate GIR annotations
and `Since:` lines.

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

Helps: #3155
2023-12-18 14:14:16 +00: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
b3dfaf5e97 gir: Use pragma once for the inclusion guard 2023-11-07 18:23:17 +00:00
Philip Withnall
844544f72c girepository: Add SPDX license header to all obvious files
Add the SPDX license runes to all the files which have an obvious
copyright header already. This is a mechanical edit.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3155
2023-10-25 17:10:10 +01:00
Emmanuele Bassi
03d6c16434 Move girepository 2023-10-15 17:56:05 +01:00