Commit Graph

16 Commits

Author SHA1 Message Date
Philip Withnall
c8132fdf78 girepository: Rename gi_arg_info_load_type() to gi_arg_info_load_type_info()
So that it matches `gi_arg_info_get_type_info()`. We can’t use
`gi_arg_info_get_type()` because that collides with the `GType` getter
for the type.

Spotted by Philip Chimento.

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

Fixes: #3243
2024-02-05 15:13:46 +00:00
Philip Chimento
3a01629955 girepository: Fix copy-paste error in type check macro
GI_IS_REGISTERED_TYPE_INFO() wasn't working because it was actually
defined to be the same as GI_IS_OBJECT_INFO().

Add some desultory type-checking assertions to the repository tests.
2024-02-04 10:16:31 -08:00
Philip Withnall
2a99d4b168 girepository: Expose GITypeInfo and GIArgInfo as stack allocatable
There are a handful of APIs in libgirepository which are used on
performance-sensitive code paths in language bindings (such as looking
at arguments when doing function calls). Historically libgirepository
has provided a stack-allocated variant for them, which avoids returning
a newly allocated `GIBaseInfo`. Since moving to glib.git and porting to
`GTypeInstance`, that stack allocated version has been broken.

This commit fixes it, by exposing obfuscated stack allocatable versions
of `GITypeInfo` and `GIArgInfo`, which are the two `GIBaseInfo`
subtypes which can be returned by the stack allocation functions.

The commit includes unit tests for them.

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

Fixes: #3217
2024-01-31 15:49:38 +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 Chimento
cda9ebeb03 tests: Port over some GIRepository tests from g-i 1.x
These tests come from gobject-introspection/tests/repository/. They
include whatever wasn't already covered by the existing tests.

The original files didn't have copyright information. That's been
reconstructed from commit messages of commits that added a test or a
substantial part of one.
2024-01-23 22:04:52 -08:00
Philip Chimento
3c984faf23 tests: Use runtime casts
Using casts like GI_OBJECT_INFO() that log a critical when the
introspection info is of the wrong type, will help to locate bugs.
2024-01-23 22:04:52 -08:00
Philip Chimento
b8a65edb01 tests: Use fixture in GIRepository tests
This deduplicates some code and will allow writing further tests more
easily.
2024-01-23 22:04:52 -08:00
Philip Withnall
9cbe5ae67d tests: Add tests for several GIBaseInfo subclasses
They get at least these `GIBaseInfo` subclasses up to a reasonable (but
not complete) coverage level.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-18 13:15:22 +00:00
Philip Withnall
9debaffe0e gibaseinfo: Remove need for casting for gi_base_info_ref() and unref()
Just like is done with `g_object_{ref,unref}()`, make these functions
take a `void*` rather than a `GIBaseInfo*`, since they’ll most likely be
called with a type which is derived from `GIBaseInfo*` rather than a
`GIBaseInfo*` itself.

Add some runtime type checks to make up for lowering the compile time
type safety.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
Marco Trevisan (Treviño)
d78b6c55bc girepository/tests: Add further checks on GObject methods infos 2024-01-15 21:26:42 +00:00
Philip Withnall
ec3fb9a48c Merge branch 'glib-gir-sources' into 'main'
gobject: Make GLib-2.0 gir build depend on GObject dependency

See merge request GNOME/glib!3772
2023-12-22 14:45:37 +00:00
Marco Trevisan (Treviño)
3ec0192970 girepository: Use newer API to create null-terminated ptr array for dependencies
And add a test for this.
2023-12-21 14:14:27 +01:00
Marco Trevisan (Treviño)
2c00c7c924 girepository: Use an array to iterate over and return the search paths
We used to store the search paths into a GSList but this is not
efficient for various reasons, so replace this with an array so that we
can replace return just a GStrv in the public API.
2023-12-21 14:14:27 +01:00
Marco Trevisan (Treviño)
9c4ff01feb build: Move gir generation to an introspection folder
Generating gir and typelib files has inter-dependencies that may depend
on other elements.

For example, glib requires gobject and gdump generated files require
gmodule, so we've a cyclic dependency because gmodule requires gobject,
that requires glib.

To prevent this, let's just generate the introspection files at once in
a different meson file so that we don't have to deal with this.

As per this we could even revert commit fa37ab6d0 since gio is now
compiled before the gir files.
2023-12-20 21:35:53 +01:00
Marco Trevisan (Treviño)
cd8f511262 girepository: Return enumerated versions as a GStrv
Returning list of strings is a bad idea, so let's do not now since
we're exposing the API for the first time.
2023-12-20 21:02:48 +01:00
Philip Withnall
e699037fef girepository: Add a couple of very simple unit tests
For the moment, this is enough to roughly verify that the port to
`GTypeInstance` has not massively broken things. It’s not anywhere near
sufficient to qualify as a proper test suite though.

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

Helps: #3155
2023-12-12 16:58:27 +00:00