Commit Graph

2739 Commits

Author SHA1 Message Date
Luca Bacci
51cbb63cd5 Add support for TLS callbacks on Windows 2023-10-03 10:25:06 +02:00
Emmanuele Bassi
9723c5595c ci: Use meson compile rather than bare ninja
This makes it more consistent with `meson setup` in the rest of the
file.
2023-08-16 13:07:05 +01:00
René de Hesselle
0c73ff3a08 meson: Use 'meson setup' to configure
This removes a deprecation warning when using 'meson' without 'setup'.
2023-08-16 13:06:40 +01:00
Simon McVittie
be2c9220d6 testutils: Factor out g_test_disable_crash_reporting()
We're already repeating this in 4 places, and in a subsequent commit
I'll extend it to do more.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-26 15:41:47 +01:00
Philip Withnall
9b80774ca7 Merge branch 'fileinfo-filepath' into 'main'
gfileinfo: add file_path methods for language bindings

See merge request GNOME/glib!3461
2023-07-22 05:27:12 +00:00
Jason Francis
04b683c34f gfileinfo: add file_path methods for language bindings
Including some tests by Philip Withnall.
2023-07-21 21:24:50 +01:00
Philip Withnall
28ad519ff8 gdbus-codegen: Fix some minor typos in the documentation
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-06-27 14:23:01 +01:00
Emmanuele Bassi
6fc6d9ea3e Merge branch 'ebassi/keyfile-docs' into 'main'
docs: Use the type name as the section name for GKeyFile

See merge request GNOME/glib!3453
2023-05-31 01:05:34 +00:00
Emmanuele Bassi
23a9dbdaf6 Allow proper introspection of GTypeValueTable
The introspection scanner cannot deal very well with function pointers
into a plain structure. In order to document the various function
pointers in GTypeValueTable we need to create typed callbacks, and
use them to replace the anonymous function pointers inside the
structure. This not only allows us to properly document the function
pointers, but it also allows us to annotate the arguments and return
value of those function pointers.

See also: https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/400#note_1721707
2023-05-30 14:38:16 +01:00
Emmanuele Bassi
28e8f5c136 docs: Rename the GBookmarkFile section
Use the type name, to ensure that the section docblock gets merged into
the type docblock in the introspection data.

Helps: #2961
2023-05-30 13:33:45 +01:00
Emmanuele Bassi
4386d912d7 docs: Use the type name as the section name for GKeyFile
Without this, the section docblock for GKeyFile disappears into the
ether when generating the introspection data.

Helps: #2961
2023-05-30 12:46:30 +01:00
Philip Withnall
153c7f7b99 Merge branch 'wip/p3732/truncate-middle' into 'main'
gutf8: Add a g_utf8_truncate_middle() function

See merge request GNOME/glib!3440
2023-05-30 11:02:03 +00:00
Guido Günther
b3b23072f3 gactionmap: Add g_action_map_remove_action_entries()
Since we have a convenience method to add actions let's allow to remove
them just as easily. This makes resource cleanup as simple as initially
adding the entries.
2023-05-26 10:30:40 +01:00
Peter Eisenmann
cd3837174b gutf8: Add a g_utf8_truncate_middle() function
Adds a helper to truncate UTF8 strings in the middle, allowing to make
them fit certain size constraints.

This function is modeled after similar functionality that has existed
since 2008 in nautilus and in eel before that.
2023-05-25 00:36:56 +02:00
Sonny Piers
0b73d72a44 gio: Add g_file_new_build_filenamev 2023-05-23 10:14:28 +00:00
Peter Eisenmann
afdab4f493 gstring: add g_string_new_take
Adds a GString constructor that takes over ownership of an existing,
dynamically allocated, string.
2023-05-16 11:27:45 +01:00
Philip Withnall
eee3885077 Merge branch 'gtk-plus' into 'main'
Rename GTK+ to GTK (mostly comments and documentation)

See merge request GNOME/glib!3429
2023-05-10 08:39:58 +00:00
Philip Withnall
329213f742 Merge branch 'main' into 'main'
gtestutils: Improve g_assert_cmpuint

Closes #2997

See merge request GNOME/glib!3424
2023-05-10 08:35:27 +00:00
Arnaud Rebillout
f722f11e57 Rename GTK+ to GTK (mostly comments and documentation)
GTK lost it's '+' suffix back in 2019, according to
<https://mail.gnome.org/archives/gtk-devel-list/2019-February/msg00000.html>

This commit can be re-generated with:

    git grep -l GTK+ \
    | grep -v -e ^NEWS -e ^glib/tests/collate.c \
    | xargs sed -i 's/GTK+/GTK/g'

Most of the changes are in comments and documentation.
2023-05-10 10:56:44 +07:00
Eric Blake
2ab2ce57e6 gtestutils: Improve g_assert_cmpuint
While x86_64 has enough precision in long double to do a round trip
from guint64 to long double and back, this is platform-specific, and
is a disservice to users trying to debug failing unit tests on other
architectures where it loses precision for g_assert_cmp{int,uint,hex}.
See also https://bugzilla.gnome.org/show_bug.cgi?id=788385 which
mentions having to add casts to specifically silence the compiler on
platforms where the precision loss occurs.

Meanwhile, g_assert_cmpuint() does an unsigned comparison, but outputs
signed values if the comparison fails, which is confusing.

Fix both issues by introducing a new g_assertion_message_cmpint()
function with a new 'u' numtype.  For backwards compatibility, the
macros still call into the older g_assertion_message_cmpnum() when not
targetting 2.78, and that function still works when passed 'i' and 'x'
types even though code compiled for 2.78 and later will never invoke
it with numtype anything other than 'f'.  Note that g_assert_cmpmem
can also take advantage of the new code, even though in practice,
comparison between two size_t values representing array lengths that
can actually be compiled is unlikely to have ever hit the precision
loss.  The macros in signals.c test code does not have to worry about
versioning, since it is not part of the glib library proper.

Closes #2997
Signed-off-by: Eric Blake <eblake@redhat.com>
2023-05-09 08:28:09 -05:00
Marco Trevisan
08aee6b5f4 Merge branch 'unixfdlist-again' into 'main'
docs: Don’t ignore gunixfdlist.h when building docs on Windows

See merge request GNOME/glib!3409
2023-05-09 12:53:19 +00:00
Philip Withnall
63e1e83c33 Merge branch 'wip/p3732/timeout-seconds-once' into 'main'
add g_timeout_add_seconds_once

See merge request GNOME/glib!3383
2023-05-09 12:50:39 +00:00
Patrick Griffis
de2ff26454 Merge branch '116-utf8-docs' into 'main'
docs: Document high-level UTF-8 requirements for GLib

Closes #116

See merge request GNOME/glib!3414
2023-05-02 19:20:30 +00:00
Philip Withnall
377e8a2d9e docs: Update various broken/redirected links
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-02 14:26:52 +01:00
Peter Eisenmann
3abf23b2a7 add g_timeout_add_seconds_once
Add a new call combing behaviors of g_timeout_add_seconds and
g_timeout_add_once.
2023-05-02 13:42:54 +02:00
Philip Withnall
0e941418d1 docs: Document high-level UTF-8 requirements for GLib
I’ve finally found the right place in the docs to put this stuff.

This doesn’t auto-link this section from every string in the GLib
documentation, but I think that at this point (with gtk-doc in
maintenance mode, and gi-docgen not fully applied to GLib) I don’t think
we can do any better. The perfect is the enemy of the good, and having
this stuff documented somewhere means that someone can link to it from
multiple places in future *somehow*.

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

Fixes: #116
2023-05-02 10:41:50 +01:00
Patrick Griffis
f009d8e368 Merge branch '2289-setuid-docs' into 'main'
docs: Document that GIO should not be used in privileged processes

Closes #2289

See merge request GNOME/glib!3413
2023-04-29 03:28:10 +00:00
Philip Withnall
f42e04d247 docs: Document that GIO should not be used in privileged processes
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2289
2023-04-28 11:11:03 +01:00
Philip Withnall
e43b2452b9 docs: Add high-level documentation about malloc failure
While I’m here.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-28 11:01:25 +01:00
Philip Withnall
3b9fc71644 docs: Mention that calls after fork() must be async-signal-safe
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2958
2023-04-28 11:00:33 +01:00
Philip Withnall
9b8369852b Merge branch 'html-doc-flag' into 'main'
meson: wrap html documentation generation with gtk_doc option

See merge request GNOME/glib!3399
2023-04-28 01:09:04 +00:00
James Knight
0fa17ec3c7 meson: wrap html documentation generation with gtk_doc option
By default, if a host environment has the `rst2html5` application
available, builds will automatically perform some HTML documentation
generation from the documentation's glib reference content (e.g.
creating `gvariant-specification-1.0.html`). The creation of this
documentation is not required for all use cases.

This commit tweaks the building of the HTML-based GLIB specification
document to be guarded by `gtk_doc`.

Signed-off-by: James Knight <james.d.knight@live.com>
2023-04-27 20:23:30 -04:00
Philip Withnall
7922d3200c Merge branch 'resolver-thread-pool' into 'main'
gthreadedresolver: Switch to using a separate thread pool and support timeouts

See merge request GNOME/glib!3397
2023-04-27 12:46:53 +00:00
Philip Withnall
bf92bae481 gresolver: Add GResolver:timeout property
Without a timeout, some lookup requests can go on forever, typically due
to bugs in underlying systems.

This can have particularly significant effects on the Happy Eyeballs
algorithm in `GSocketClient`, which relies on multiple name lookups as
its first step.

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

Helps: #2866
2023-04-27 12:23:25 +01:00
Emmanuele Bassi
e2e93056f2 Add init macros for refcounting types
We need a way to initialise refcounted types placed in static storage,
or on the stack. Using proper macros avoids knowing the magic constant
used for grefcount and gatomicrefcount.
2023-04-24 12:48:32 +01:00
Philip Withnall
da35056247 Merge branch 'registry-settings-root-key' into 'main'
gregistrysettingsbackend: Allow a different root key path

See merge request GNOME/glib!3306
2023-04-14 17:00:01 +00:00
Dario Saccavino
fee0a7679a gregistrysettingsbackend: Allow a different root key path 2023-04-14 17:00:01 +00:00
Xavier Claessens
8d27474631 doc: Workaround missing API index 2023-04-14 17:08:35 +01:00
Philip Withnall
e993e27782 docs: Add 2.78 release series documentation pages to the build
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-14 16:09:34 +01:00
Philip Withnall
783f1b8640 gtype: Improve documentation for G_TYPE_IS_CLASSED and interfaces
The documentation previously implicitly said in a few places that
interfaces are classed, but reading through the implementation of
`GType`, I don’t think they are. If they were, the registration of the
fundamental `G_TYPE_INTERFACE` in `gobject_init()` would specify
`G_TYPE_FLAG_CLASSED`. It only specifies `G_TYPE_FLAG_DERIVABLE`.

I think this makes sense, because you can’t subclass an interface.
Subclassing is a key property of being classed.

Tweak the `GType` tutorial to remove that implicit statement, and expand
the documentation for `G_TYPE_IS_CLASSED`.

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

Fixes: #252
2023-04-13 15:37:00 +01:00
Sam Thursfield
2d216d4d8c Link goption documentation to GOptionContext type
This makes the goption overview visible in the gi-docgen docs as part of
the GOptionContext type. Previously it was not visible anywhere.

Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2953
2023-03-23 14:01:45 +00:00
Maciej S. Szmigiero
14b5207bfa Add g_unix_open_pipe_internal () for pipes with the close-on-exec flag
Based on the existing g_unix_open_pipe () but for internal use where
returning a raw errno is needed, not a GError.
2023-02-21 12:42:55 +00:00
Emmanuele Bassi
b5a3297dca docs: Add GPathBuf to the API reference 2023-02-09 13:36:51 +00:00
Philip Withnall
329843f682 gmem: Add g_free_sized() and g_aligned_free_sized()
These wrap `free_sized()` and `free_aligned_sized()`, which are present
in C23[1]. This means that user code can start to use them without checking
for C23 support everywhere first.

It also means we can use them internally in GSlice to get a bit of
performance for the code which still uses it.

See https://en.cppreference.com/w/c/memory/free_aligned_sized and
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2699.htm.

[1]: Specifically, section 7.24.3.4 of the latest C23 draft at
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3088.pdf.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-02-02 12:30:59 +00:00
Natanael Copa
45b5a6c1e5 gslice: Remove slice allocator and use malloc() instead
Keep the API for ABI compatibility.

See
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2935#note_1650099
for a summary of the reasoning for this change:
 - The performance of system-provided allocators has improved since
   GSlice was written, and they are now similarly as performant, or more
   performant, than GSlice.
 - The code is unmaintained and nobody understands it.
 - It doesn’t integrate with tooling and system security features which
   have been written for the system `malloc()` implementation (such as
   sanitisers, valgrind, etc.).
 - It’s confusing for developers: should they use `g_slice_new()` or
   `g_new()`?
 - GSlice is faster than the libc allocator for allocating and
   (particularly) freeing linked lists, but since these are a rubbish
   data structure, that’s not a great thing to optimise for.

For the cases where application performance is negatively impacted by
the implementation of GSlice being dropped (and we don’t think there’ll
be many), applications can use a drop-in `malloc()` replacement which is
more suited to their particular workload. Choosing an allocator in GLib
to suit all application workloads is not possible.

Including documentation updates and cleanups by Philip Withnall.

Fixes: #1079
2023-01-25 13:49:09 +00:00
Matthias Clasen
58dd3d3965 Add g_string_free_and_steal 2023-01-19 14:47:11 +00:00
Philip Withnall
73fa684e30 Merge branch 'ptr-array-sort-values' into 'main'
garray: Add g_ptr_array_sort_values[_with_data]() wrappers

See merge request GNOME/glib!3155
2023-01-06 12:09:37 +00:00
Marco Trevisan (Treviño)
0ffd23cac4 garray: Add g_ptr_array_sort_values[_with_data]() wrappers
Historically GPtrArray made possible to compare pointers of pointers values
that it holds, however this is inconvenient in most cases as it requires
wrapper functions and not friendly castings.

So, add two functions that allow to perform the comparisons between the
pointer values that a GPtrArray holds following the same syntax that we
share everywhere in the codebase.
2023-01-06 11:46:01 +00:00
Philip Withnall
5e378c775a Merge branch 'ptr-array-new-take' into 'main'
garray: Add more G(Ptr)Array constructors to take or copy C arrays

See merge request GNOME/glib!3128
2022-12-21 18:34:13 +00:00
Marco Trevisan (Treviño)
b15040215a garray: Add g_array_new_take() and g_array_new_take_zero_terminated()
Make it easy to handle C arrays using GArray API stealing data from other
sources.
2022-12-21 11:40:39 +00:00