Commit Graph

29722 Commits

Author SHA1 Message Date
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
543fea1df7 girmodule: Simplify a branch in gi_ir_module_new()
`g_strdup(NULL)` is guaranteed to return `NULL`, so there’s no need to
branch to handle that.

Add a stub private doc comment to hold a `(nullable)` annotation for
that argument, though, so that information isn’t lost.

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

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
db0f69fbb8 girepository: Use G_DECLARE_FINAL_TYPE for GIRepository
Might as well move to a modern way of declaring GObjects. This means
that `GIRepository` is no longer derivable, but it would be a bit
unexpected if anyone was deriving from it.

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

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
e301782865 girnode: Fix a couple of leaks from GIIrNode subclasses
Found by code inspection rather than hitting them at runtime.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
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
7262f5ab14 Merge branch '3234-libgirepository-refcount-cycle' into 'main'
gibaseinfo: Break refcount cycle with GIRepository

Closes #3234

See merge request GNOME/glib!3852
2024-01-25 22:52:17 +00:00
Philip Withnall
7eb69d279d gibaseinfo: Break refcount cycle with GIRepository
By shifting responsibility for ensuring that the lifetime of a
`GIRepository` always exceeds the lifetime of any of its `GIBaseInfo`s
to the user.

Keeping a weak ref from each `GIBaseInfo` to its `GIRepository` would be
too expensive (`GIBaseInfo`s are supposed to be cheap to create and
destroy, as they are used within function calls in language bindings).

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

Fixes: #3234
2024-01-25 22:03:57 +00:00
Philip Withnall
01ef6bb49e Merge branch 'fix-post-merge-ci' into 'main'
ci: Fix post-merge CI pipelines

See merge request GNOME/glib!3851
2024-01-25 20:48:08 +00:00
Philip Withnall
c89b282623 ci: Fix post-merge CI pipelines
Don’t allow the `pages` job to be run (even manually) on post-merge
pipelines. It’s not particularly useful, and GitLab doesn’t like having
a manual job with unsatisfied dependencies in a pipeline:
```
'pages' job needs 'coverage' job, but 'coverage' is not in any previous stage
'pages' job needs 'style-check-advisory' job, but 'style-check-advisory' is not in any previous stage
```

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3847#note_1986044

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-25 20:31:34 +00:00
Philip Withnall
e04886aeb2 Merge branch 'optional-ci-runs' into 'main'
ci: Add ability to run manually some specific jobs

See merge request GNOME/glib!3847
2024-01-25 20:24:53 +00:00
Philip Withnall
7bb8a22494 Merge branch 'th/strdup-in-ascii-strdown' into 'main'
[th/strdup-in-ascii-strdown] glib: use g_strdup() in g_ascii_strdown(),g_ascii_strup()

See merge request GNOME/glib!3850
2024-01-25 20:19:25 +00:00
Thomas Haller
6955c25e85 glib: use g_strdup() in g_ascii_strdown(),g_ascii_strup()
g_strndup() internally uses strncpy(), while g_strdup() uses memcpy().
Most likely, memcpy() is faster.

Instead of strlen()+g_strndup(), use  g_strdup() as we don't need the
length.
2024-01-25 20:11:48 +01:00
Marco Trevisan (Treviño)
99c8f7fafc ci: Run docs and coverity builds only on schedules in default branch
Also allow running them manually if required, but this still needs to be
done from a GNOME/glib:main pipeline.
2024-01-25 17:56:36 +01:00
Marco Trevisan (Treviño)
11616b0145 ci: Allow to run jobs that only run in origin repos manually 2024-01-25 17:56:36 +01:00
Marco Trevisan (Treviño)
2a532e19cd ci: Add ability to run manually some specific jobs
In some merge requests there are bits (such as memory leaks) that we may want
to test before merging and that the schedules will run them.

As per this add a rule to make them manual, and apply it to some jobs.
2024-01-25 17:46:59 +01:00
Philip Withnall
96b1298871 Merge branch 'improve-documentation' into 'main'
gprintf/gstrfuncs: Improve and port doc comments to gi-docgen

See merge request GNOME/glib!3807
2024-01-25 12:16:57 +00:00
velsinki
66cd331172 gstrfuncs: Improve and port doc comments to gi-docgen
This fixes many things from the port to gi-docgen, but also improves
documentation more generally.

Main improvements/fixes:
- Fix links to functions, constants, etc.
- Rewrite code syntax to work with Markdown
- Reduce indentation (do not indent by 4 to prevent code blocks)
- Remove redundant text such as "can be NULL" or "should be freed"
- Move text from large return info texts to main function text
- Remove periods at the end of parameter and return descriptions
- Do not capitalize the first word of a parameter or return description
- Try to improve consistency between docs for similar functions
- Convert %TRUE and %FALSE into true and false
- Convert other uses of `%` and `#` into inline code

Helps: #3037
2024-01-25 11:35:48 +00:00
velsinki
a834b8b038 gstrfuncs: Add missing (array) annotations to GStrv comparison functions 2024-01-25 11:35:12 +00:00
velsinki
dc7331f4fb gstrfuncs: Add missing (optional) annotation to g_str_tokenize_and_fold() 2024-01-25 11:33:09 +00:00
velsinki
2d5955c4f3 gstrfuncs: Add missing (array) annotation to g_strv_length() 2024-01-25 11:32:56 +00:00
velsinki
b869908f16 gstrfuncs: Add missing (array) annotations to g_strdupv() and g_strjoinv() 2024-01-25 11:29:52 +00:00
velsinki
8689a1f8b7 gstrfuncs: Add missing (nullable) annotations to g_strndup() 2024-01-25 11:25:09 +00:00
velsinki
2d5f608454 gstrfuncs: Add missing (transfer) and (nullable) annotations to g_memdup() 2024-01-25 11:22:54 +00:00
velsinki
16ea531ecb gstrfuncs: Add missing (array) annotation to g_strfreev() 2024-01-25 11:20:00 +00:00
velsinki
8d2d12bd52 gprintf: Port doc comments to gi-docgen
Fixes broken links, and removes `%` and `#` notation in favor of inline
code, and limits indentation to two to prevent accidental formatting.

Fixes some style issues too, mainly removing periods at the end of
parameter and return descriptions.

Also removes trailing whitespace from the doc comments.

Helps: #3037
2024-01-25 11:19:23 +00:00
velsinki
2b22befc4f gprintf: Add missing (out) annotation to g_vasprintf() 2024-01-25 11:19:23 +00:00
Philip Withnall
c92c1502d2 Merge branch 'remove-deprecated-girepository-flags' into 'main'
girepository: Remove GI_FUNCTION_THROWS and GI_VFUNC_THROWS flags

See merge request GNOME/glib!3849
2024-01-25 11:02:28 +00:00
Philip Chimento
ad9cd1762a girepository: Remove GI_FUNCTION_THROWS and GI_VFUNC_THROWS flags
These flags were replaced by gi_callable_info_can_throw_error() in
girepository 1.x, but the flags were maintained for backwards
compatibility. No need to hold on to them in the 2.x API.

Note that these flags are also still maintained as separate bits in the
binary format, which is not changing. So, they still need to be read
from FunctionBlob and VFuncBlob if the bit is not set in SignatureBlob.

This is an API break for girepository 2.x, which is OK because the API
has never been released yet.
2024-01-24 20:45:28 -08:00
Marco Trevisan
856850ab15 Merge branch 'fix-introspection-build-windows' into 'main'
Fix build with introspection on Windows

See merge request GNOME/glib!3848
2024-01-24 18:20:04 +00:00
Luca Bacci
f7c4825d91 Fix build with introspection on Windows 2024-01-24 18:16:58 +01:00
Philip Withnall
b3abf56ced Merge branch 'girepository-tests' into 'main'
Add more test coverage for girepository

See merge request GNOME/glib!3843
2024-01-24 08:41:23 +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 Chimento
d41f05e9cf build: Add libffi dependency to girepository/function-info test
I found that this dependency is needed for girffi.h to find ffi.h.
2024-01-23 21:59:38 -08:00
Philip Chimento
28835733a2 tests: Fix defaultvalue test on macOS
Without these includes, the g_osx_app_info_get_type() in
giotypefuncs.inc is missing a declaration.
2024-01-23 21:35:54 -08:00
Philip Withnall
01e197868d Merge branch '3218-girepository-stack-allocations' into 'main'
gibaseinfo: Fix use of stack-allocated GIBaseInfos

Closes #3218

See merge request GNOME/glib!3846
2024-01-23 23:08:41 +00:00
Philip Withnall
9b5d008f60 girffi: Rename gi_function_invoker_destroy() to …_clear()
This brings its naming more in line with modern GLib conventions.

This is an API break, but libgirepository is not API frozen yet.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-23 22:55:35 +00:00
Philip Withnall
3e157c688e girffi: Add a test for gi_function_info_prep_invoker()
This test case was originally written by Philip Chimento as a reproducer
for #3218. Let’s add it to the test suite to catch regressions in
stack-allocated `GIBaseInfo` handling.

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

Helps: #3218
2024-01-23 18:10:03 +00:00
Philip Withnall
998baf9afb girffi: Expand docs for gi_function_info_prep_invoker()
Mention that the returned `GIFunctionInvoker` needs to be cleared.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-23 18:09:28 +00:00
Philip Withnall
bf4cf2d464 gibaseinfo: Fix use of stack-allocated GIBaseInfos
Most of the code for handling stack-allocated infos was correct, it was
just missing code to initialise the `GTypeInstance` member.

Since `GTypeInstance` isn’t really designed for stack allocation, this
is a little hacky — it requires setting up the member within
`GTypeInstance` manually. It works, though.

The externally visible consequence of this, though, is that
stack-allocated `GIBaseInfo`s now need to be cleared when they’re
finished being used. This allows the `GTypeClass` ref to be dropped.

All users of the stack-allocated APIs in libgirepository will need to
adapt to this change.

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

Fixes: #3218
2024-01-23 18:07:17 +00:00
Philip Withnall
eb94acce21 gibaseinfo: Make gi_info_init() take a GType rather than a GIInfoType
This is one more step towards removing `GIInfoType`, and will also help
in a following commit which will directly make use of the `GType`.

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

Helps: #3218
2024-01-23 18:06:08 +00:00
Philip Withnall
c8c1febc7d gibaseinfo: Fix a double-unref with stack-allocated GIBaseInfos
As documented in the commit, the internal members of `GIBaseInfo` are
not reffed if the `GIBaseInfo` is stack-allocated, as the caller can be
relied on to ensure their lifetime exceeds that of the `GIBaseInfo`.

Make sure that’s actually reflected in the code.

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

Helps: #3218
2024-01-23 17:55:26 +00:00
Philip Withnall
a3da3a032c gibaseinfo: Change argument type for gi_type_info_init()
Make it take a `GITypeInfo` rather than a `GIBaseInfo`, because that’s
what it actually operates on.

This is an internal API, so this isn’t an API break.

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

Helps: #3218
2024-01-23 17:53:15 +00:00
Philip Withnall
fee9223e74 Merge branch '2887-memory-monitor-tests' into 'main'
tests: Fix race condition in memory-monitor-dbus.test

Closes #2887

See merge request GNOME/glib!3844
2024-01-23 11:16:52 +00:00
Philip Withnall
67a9fbf1fa tests: Wait for memory monitor to be able to handle signals before testing
This fixes a race condition which frequently caused the
`memory-monitor-dbus.py` test to fail.

The registration of the `LowMemoryMonitor` object on the bus, and the
`GMemoryMonitorDBus`’s connection to the warning signal raced, such that
it was possible for the mock `LowMemoryMonitor` to emit a warning signal
before the `GMemoryMonitorDBus` proxy was listening, and hence the proxy
would never see the signal.

Fix this by explicitly synchronising the two before proceeding to the
tests.

Make the same changes in the `memory-monitor-portal.py` test too, even
though that one was not failing. This should remove the need for a 2s
wait on every test run.

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

Fixes: #2887
2024-01-23 11:02:48 +00:00