Commit Graph

2272 Commits

Author SHA1 Message Date
Philip Withnall
aec0f4d938 gstrvbuilder: Add a boxed type so it can be introspected properly
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-23 12:36:11 +00:00
Philip Withnall
3c42b9c3ee gdir: Add refcounting support and a boxed type
This allows the methods for `GDir` to be introspected. While we don’t
expect languages which use the introspection bindings to use `GDir`,
full introspection support is necessary for the `GDir` documentation to
be correctly built with gi-docgen.

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

Helps: #3037
2023-11-23 12:34:39 +00:00
Philip Withnall
69b83a830c Merge branch 'hmac-introspection' into 'main'
ghmac: Add a boxed type for GHmac and fix introspection build accordingly

See merge request GNOME/glib!3711
2023-11-21 12:55:30 +00:00
Lukáš Tyrychtr
a473d5aea0 mkenums: Allow , in a character literal
This required adding a higher precedence character literal choice.

Fixes #3103
2023-11-21 11:54:42 +00:00
Philip Withnall
4ef365e5d0 ghmac: Add a boxed type so it can be introspected properly
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-15 11:09:39 +00:00
Philip Withnall
08f914b290 gobject: Ensure gobject from builddir is used when generating GLib-2.0.gir
Otherwise the installed one will be used, which will mean that new API
will not be available when linking.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-15 11:09:39 +00:00
Philip Withnall
e87f8e9c5a Merge branch '3158-info-critical' into 'main'
gio-tool-info: Fix critical warning when --attributes are specified and add basic unit tests

Closes #3158

See merge request GNOME/glib!3684
2023-11-07 14:37:11 +00:00
Philip Withnall
077104e63b tests: Run processes under test with G_DEBUG=fatal-warnings
Modify all the similar Python test wrappers to set
`G_DEBUG=fatal-warnings` in the environment of the program being tested,
so we can catch unexpected warnings/criticals.

Adding this because I noticed it was missing, not because I noticed a
warning/critical was being ignored.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Alexander Slobodeniuk
7880d87091 gvalue: add g_value_steal_string()
This call is needed to avoid an extra copy after
serialization of the data.
2023-11-04 10:40:30 +00:00
Kleis Auke Wolthuizen
9ec6c19342 gsignalgroup: Avoid function call with side effect in g_return_* macro 2023-11-01 10:53:55 +00:00
Alex Richardson
a121b1bf71 Change GType print placeholders to G_GUINTPTR_FORMAT
GType is not guaranteed to be the same as gsize, but it is representable
as guintptr.
2023-10-25 12:01:02 +01:00
Alex Richardson
d0e03f0930 GType: introduce GTYPE_TO_POINTER/GPOINTER_TO_TYPE
On CHERI-enabled systems we use uintptr_t as the underlying storage for
GType and therefore casting to gsize strips the upper bits from a pointer.
Fix this by casting via uintptr_t instead and introduce a new set of
macros to convert between GType and pointers.
2023-10-25 12:01:02 +01:00
Alex Richardson
4b111f1650 GType: Use guintptr as the underlying storage if larger than gsize
This is required for CHERI systems such as Arm Morello, where gsize is
not large enough to hold a pointer. As GType can contain pointers, we
have to use guintptr instead.
2023-10-24 12:14:37 +01:00
Philip Withnall
70c66766f7 Merge branch 'atomic-uintptr' into 'main'
gatomic: Use g(u)intptr where appropriate

See merge request GNOME/glib!3143
2023-10-24 10:49:30 +00:00
Philip Withnall
5ae6bcb728 docs: Move the value collection documentation to Markdown
It needs to be in a separate page because it’s all macros and they have
no type/class associated with them.

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

Helps: #3037
2023-10-23 13:18:13 +01:00
Philip Withnall
016aacbda8 gobject: Fix invalid doc links
Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-10-23 11:26:53 +01:00
Emmanuele Bassi
fe32c3f5c5 Generate introspection data
Currently, the introspection data for GLib and its sub-libraries is
generated by gobject-introspection, to avoid the cyclic dependency
between the two projects.

Since gobject-introspection is generally available on installed systems,
we can check for its presence, and generate the introspection data
directly from GLib.

This does introduce a cyclic dependency, which is why it's possible to
build GLib without introspection, then build gobject-introspection, and
finally rebuild GLib.

By having introspection data available during the GLib build, we can do
things like generating documentation; validating newly added API; and
close the loop between adding new API and it becoming available to non-C
consumers of the C ABI (i.e. language bindings).
2023-10-23 11:26:53 +01:00
Emmanuele Bassi
47faa032cb docs: Remove duplicate docblocks
The g_cclosure_marshal_* symbols are already documented in gmarshal.c.
2023-10-23 10:25:31 +01:00
Emmanuele Bassi
c86f469c1e Ignore autocleanups when generating introspection data 2023-10-23 10:25:30 +01:00
Emmanuele Bassi
0f8aaee2bf Add missing annotation separator 2023-10-23 10:25:30 +01:00
Emmanuele Bassi
fb84bad077 Remove unnecessary annotation
All pointer-based properties are nullable by definition, and the
`nullable` annotation is not accepted at the identifier level.
2023-10-23 10:25:30 +01:00
Damien Zammit
f25a9ca10c Initial test of Hurd CI - (run_tests.sh status ignored) 2023-10-18 23:33:04 +00:00
Matthias Clasen
bedf11b330 docs: Move the GClosure SECTION
Move the contents to the struct docs.

Helps: #3037
2023-10-16 23:35:05 +01:00
Matthias Clasen
7eba4e8f49 docs: Move the GTypeModule SECTION
Move the content to the struct docs.

Helps: #3037
2023-10-16 23:34:59 +01:00
Matthias Clasen
bc084d8780 docs: Move the GTypePlugin SECTION
Move the contents to the struct docs.

Helps: #3037
2023-10-16 23:34:53 +01:00
Matthias Clasen
8009afe73d docs: Move the GParamSpec SECTION
Move the content to the struct docs. Also drop the paramspecs SECTION,
as it was largely duplicated information.

Helps: #3037
2023-10-16 23:34:48 +01:00
Matthias Clasen
6e1d5302ed docs: Move the GSignalGroup SECTION
Move the contents to the struct docs.

Helps: #3037
2023-10-16 23:34:44 +01:00
Matthias Clasen
36d65922e2 docs: Move the GValueArray SECTION
Move the contents to the struct docs.

Helps: #3037
2023-10-16 23:34:39 +01:00
Matthias Clasen
95717eacea docs: Move the signal SECTION
Move the content to the new signals.md file.

Helps: #3037
2023-10-16 23:34:35 +01:00
Matthias Clasen
f3eac349f9 docs: Move the GType SECTION
Move the contents to the new types.md files.

Helps: #3037
2023-10-16 23:34:29 +01:00
Matthias Clasen
f471ebd300 docs: Move the GObject SECTION
Move the contents into the struct docs.

Helps: #3037
2023-10-16 23:34:24 +01:00
Matthias Clasen
89fe3bc4e4 docs: Move the GBindingGroup SECTION
Move the content to the struct docs.

Helps: #3037
2023-10-16 23:34:20 +01:00
Matthias Clasen
e7720a2c1a docs: Move the GBinding SECTION
Move the content into the struct docs.

Helps: #3037
2023-10-16 23:34:04 +01:00
Matthias Clasen
4411023462 docs: Move GValue documentation to Markdown
Helps: #3037
2023-10-11 14:01:29 +01:00
Matthias Clasen
e298f1a078 docs: Move floating refs documentation to Markdown
And add some new sections on strategies for avoiding designing APIs
around floating refs.

Helps: #3037
2023-10-11 14:01:29 +01:00
Matthias Clasen
58019515d6 docs: Move enum type documentation to Markdown
Helps: #3037
2023-10-11 14:01:29 +01:00
Matthias Clasen
24e93078d3 docs: Move boxed type documentation to Markdown
And add some additional new content and examples.

Helps: #3037
2023-10-11 14:01:29 +01:00
Alex Richardson
ab7e584e9f Cast via guintptr when adding/removing bitsflags on pointers
Round-tripping pointers via gsize is not guaranteed to work (the C standard
only requires this for (u)inptr_t) and in fact breaks on CHERI-enabled
systems such as Arm Morello where pointers are 128-bits but size_t is 64.
This means the current casts would strip the high bits of the pointer and
return a non-dereferenceable value. Fix this by casting the operand that
holds the pointer to guintptr instead of gsize.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-10-10 08:30:46 -07:00
Alex Richardson
5ecd3cbe52 gobject: use g_once_init_enter_pointer for GType initializers
GType is either an integer or a pointer, so we have to use the _pointer
version here to support architectures such as Morello.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
See also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3578
2023-10-04 14:50:54 +01:00
Alex Richardson
a1dfecf11f Use g_once_init_{enter,leave}_pointer where appropriate
This should not result in any functional changes, but will eventually
allow glib to be functional on CHERI-enabled systems such as Morello.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-10-04 13:57:16 +01:00
Philip Withnall
3d99d02112 Merge branch 'wip/chergert/make-gtype-create-instance-fast' into 'main'
gobject: cache flags needed for g_type_create_instance()

See merge request GNOME/glib!3595
2023-10-03 09:45:27 +00:00
Christian Hergert
ab2fe494a4 gobject: inline G_TYPE_IS() macros within gtype.c
If you take a release build (--buildtype=release) previously of GLib,
functions such as g_type_create_instance() would call out to
g_type_test_flags() which you can see by disassembling and looking for the
call instruction to <g_type_test_flags> via the library ABI.

Now that the previous commit allows checking abstract and deprecated flags
it makes sense to let the compiler optimize those checks into a single
pass. This is only possible if the functions themselves are inlined.

Additionally, any time we have the same TypeNode we would want to be able
to reuse that node rather than re-locate it.
2023-10-03 09:44:32 +01:00
Christian Hergert
5de7dd5a4b gobject: cache flags needed for g_type_create_instance()
Every call to g_type_create_instance() currently will incur a RWLock at
least once, but usually twice to test for both G_TYPE_FLAG_ABSTRACT and
G_TYPE_FLAG_DEPRECATED.

Additionally, each call to g_type_instance_free() also checks for these.
That results in a synchronization of GTypeInstance creation across all
threads as well as being a huge amount of overhead when creating instances
like GskRenderNode.

With this patch in place, the next two biggest issues are
g_type_class_ref() and g_type_test_flags() not getting inlined within
gtype.c in release builds. We can address that separately though.

Sysprof shows that the RWLock, with this patch in place, falls off the
profiles.
2023-10-03 09:44:32 +01:00
Philip Withnall
83eb8fc359 Merge branch 'wip/chergert/separate-gweakref-from-gweaknotify-gdata' into 'main'
gobject: Separate GWeakRef from GWeakNotify

See merge request GNOME/glib!3316
2023-10-03 08:43:37 +00:00
Emmanuele Bassi
70585f9a48 Add value annotation to G_TYPE_FUNDAMENTAL_MAX
The introspection parser isn't good enough to expand the shift symbol,
which means G_TYPE_FUNDAMENTAL_MAX is evaluated as (255 << 0).

We can use the `(value)` annotation to force the symbol value in the
introspection data.

See: GNOME/gobject-introspection#473
2023-10-02 01:29:50 +01:00
Alex Richardson
2787e59a77 CHERI: silence two pedantic warnings
When building for CHERI with additional warning flags, implicitly
converting uintptr_t to an integer type that can't store a pointer
results in a compiler warnings. Silence two of these by adding
explicit casts.
2023-09-12 10:23:20 -07:00
Christian Hergert
eb8a33625e gobject: Separate GWeakRef from GWeakNotify
This patch is based upon Garrett Regier's work from 2015 to provide
some reliability and predictability to how disposal handles weak
reference state.

A primary problem is that GWeakRef and GWeakNotify state is shared and
therefore you cannot rely on GWeakRef status due to a GWeakNotify
calling into second-degree code.

It's important to ensure that both weak pointer locations and GWeakRef
will do the proper thing before user callbacks are executed during
disposal. Otherwise, user callbacks cannot rely on the status of their
weak pointers. That would be mostly okay but becomes an issue when
second degree objects are then disposed before any notification of
dependent object disposal.

Consider objects A and B.

`A` contains a reference to `B` and `B` contains a `GWeakRef` to `A`.
When `A` is disposed, `B` may be disposed as a consequence but has not
yet been notified that `A` has been disposed. It's `GWeakRef` may also
cause liveness issues if `GWeakNotify` on `A` result in tertiary code
running which wants to interact with `B`.

This example is analagous to how `GtkTextView` and `GtkTextBuffer` work
in text editing applications.

To provide application and libraries the ability to handle this using
already existing API, `GWeakRef` is separated into it's own GData quark
so that weak locations and `GWeakRef` are cleared before user code is
executed as a consequence of `GData` cleanup.

# Conflicts:
#	gobject/tests/signals.c
2023-08-25 14:25:47 -07:00
Philip Withnall
c2df874e0b tests: Add some more tests for g_type_query()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-30 13:51:00 +03:00
Philip Withnall
d9b23c5466 gtype: Allow g_type_query() to be called on dynamic types
There’s no reason that anyone can think of that this should be
disallowed. It’s useful for language runtimes like GJS to be able to
find out the allocation size of dynamic GObjects.

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

Fixes: #623
2023-07-30 11:25:42 +03:00
Chun-wei Fan
cb1eb57581 gobject tests: Fix running custom-dispatch on 32-bit Windows
UAC will terminate this test program from running in 32-bit x86 builds as
it believes that it will alter Windows.  In order to make this run, we
create a manifest file for 32-bit Windows builds in order to tell UAC
that this program should not need admin privileges.

This will allow the entire test suite for GLib to run on 32-bit Windows
builds.
2023-06-30 11:32:54 +08:00