Commit Graph

2670 Commits

Author SHA1 Message Date
Philip Withnall
19353017a7 build: Use fs.copyfile() instead of configure_file()
Because Meson complains about using `configure_file(copy: true)`.

Includes improvements by Xavier Claessens.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-23 10:40:32 +00:00
Matthias Clasen
fd0dd9e93c gobject: Add G_TYPE_FLAG_DEPRECATED
This can be used to mark entire types as deprecated,
and trigger a warning when they are instantiated
and `G_ENABLE_DIAGNOSTIC=1` is set in the environment.

There's currently no convenient macros for defining
types with the new flag, but you can do:

```c
_G_DEFINE_TYPE_EXTENDED_BEGIN (GtkAppChooserWidget,
                               gtk_app_chooser_widget,
                               GTK_TYPE_WIDGET,
                               G_TYPE_FLAG_DEPRECATED)
...
_G_DEFINE_TYPE_EXTENDED_END ()
```

Includes a unit test by Philip Withnall.
2022-11-09 12:07:31 +00:00
Philip Withnall
1e7b20d68a Merge branch 'variant-spec-updates' into 'main'
docs: Add licensing/copyright data to GVariant specification and fix various formatting issues

See merge request GNOME/glib!3048
2022-11-08 16:13:59 +00:00
Philip Withnall
b7c497eedb docs: Fix a broken link in the GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
e039a30ef1 docs: Add a manual revision history to the GVariant Specification
This will make it clear what the bigger changes are between versions.
Kind of like a `NEWS` file for the specification.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
f518d78fd7 docs: Add links to the D-Bus specification to the GVariant Specification
This should clarify object paths and signatures a little, if anyone
needs that. This introduces no semantic changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
227bb51a74 docs: Change ‘DBus’ to ‘D-Bus’ in the GVariant Specification
That’s how it’s meant to be formatted.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
bf4bab98f7 docs: Fix forall formatting in GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
106ef532fc docs: Improve Python code snippet formatting in GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
fa823ea3b4 docs: Minor improvement of word choice in the GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
950e8991cd docs: Remove another dangling reference from the GVariant Specification
This is another reference to an omitted part of Allison’s thesis.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
6d8349a9ff docs: Fix subsection capitalisation consistency in GVariant Spec
The other subheadings here are in Title Case.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
59620c9cf8 docs: Fix a cross-reference to a Figure in the GVariant Specification
reStructuredText doesn’t support cross-references unless always built
with Sphinx (as I understand it). `rst2html5` doesn‘t support them.

So reword this (currently manual) cross-reference so it’s less awkward.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
aa568abb97 docs: Fix a minor typo in the GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
ca45f84789 docs: Fix references to omitted requirements in GVariant Specification
I believe the specification was originally a shorter extract of
Allison’s thesis. This left a few dangling references to requirements
which were listed in a part of the thesis not included in the
specification.

Reword them slightly so they’re not quite so awkward.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
e34fdb0cd5 docs: Add licensing/copyright data to GVariant specification
The licensing for the original GVariant specification was not specified
in the original PDF.

However, CC-BY-SA-3.0 has been agreed by Allison, the sole copyright
holder, here:

https://gitlab.gnome.org/Teams/documentation/developer-www/-/merge_requests/108/#note_1586866

The diagrams were redrawn by me, so their licensing/copyright status is
clear.

Tested with `reuse lint` to ensure the data is machine-readable.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
9ebb491d55 Revert "meson: Define G_OS_DARWIN when compiling under OSX or iOS"
This reverts commit e85635daa0.

See the previous revert for rationale.

Fixes: #2802
2022-11-07 11:30:32 +00:00
Philip Withnall
0e9e51767a Merge branch 'variant-docs' into 'main'
docs: Convert GVariant Specification to reStructuredText

See merge request GNOME/glib!3044
2022-11-02 09:40:24 +00:00
Emmanuele Bassi
c33edff7fa Apply 2 suggestion(s) to 1 file(s) 2022-11-01 17:38:22 +00:00
Philip Withnall
088df783c0 docs: Convert GVariant Specification to reStructuredText
This is a verbatim conversion of the GVariant Specification from
https://people.gnome.org/~desrt/gvariant-serialisation.pdf /
https://raw.githubusercontent.com/ostreedev/gvariant-rs/master/docs/gvariant-serialisation.pdf
to reStructuredText.

This is for several reasons:
 1. The canonical copy has gone offline due to people.gnome.org being
    shut down.
 2. GLib is the reference implementation of GVariant, so should probably
    host the specification (unless someone wants to host it on
    freedesktop-specs).
 3. Moving it out of a PDF and into reStructuredText should allow for
    amendments. The specification has a few problems, typos and
    oversights in its original form, and it would be good to canonically
    fix them without having to write a separate addendum document.

This conversion is verbatim, and does not change the content of the
document at all, even to fix typos and broken links (which there are a
small number of in the PDF).

This describes what I’m labelling as version 1.0 of the GVariant
serialisation format. Updates to the specification can bump this version
number, in subsequent commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-01 13:12:53 +00:00
Matthias Clasen
99c7d60869 gtask: Add g_task_set_static_name()
Similar to g_source_set_static_name, this avoids
strdup overhead for debug-only information in
possibly hot code paths.

We also add a macro wrapper for g_task_set_name that
uses __builtin_constant_p to decide whether to use
g_task_set_name or g_task_set_static_name.
2022-11-01 11:48:38 +00:00
Robert Ancell
568763e776 gio: Create a sandbox checking function 2022-11-01 10:20:36 +00:00
Marco Trevisan (Treviño)
b9e085537d meson: Expose library build type as global variables
Given that it can be computed using an error-prone strings comparisons it
is better to provide a variable everywhere, so that we don't have the
risk of comparing values that are always false.
2022-10-31 14:08:31 +01:00
Simon McVittie
b393413321 gstdio: Add g_clear_fd() and g_autofd
Inspired by libglnx's glnx_close_fd() and glnx_autofd, these let us
have the same patterns as g_clear_object() and g_autoptr(GObject), but
for file descriptors. g_clear_fd() is cross-platform, while g_autofd
is syntactic sugar requiring a supported compiler (gcc or clang).

Now that g_close() checks for EBADF as a programming error, we can
implement the equivalent of glnx_autofd as an inline function without
needing to have errno and EBADF in the header file.

g_clear_fd() is like glnx_close_fd(), but with error checking.
The private _g_clear_fd_ignore_error() function used to implement
g_autofd is a closer equivalent of glnx_close_fd().

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-26 19:05:33 +01:00
Marco Trevisan (Treviño)
e85635daa0 meson: Define G_OS_DARWIN when compiling under OSX or iOS
It has enough differences to expose it as an unix-subtype.
2022-10-20 03:37:03 +02:00
Philip Withnall
5215463a03 Merge branch 'wip/chergert/g_set_str' into 'main'
strfuncs: add g_set_str()

Closes #2747

See merge request GNOME/glib!2927
2022-10-15 22:30:18 +00:00
Marco Trevisan (Treviño)
60c935a9c4 gboxed: Add GBookmarkFile as Boxed types
Now that we've a copy function we can define it as a boxed type, making
it fully introspectable.
2022-10-14 16:40:56 +01:00
Marco Trevisan (Treviño)
2e8375daa0 gbookmarkfile: Add copy function
GBookmarkFile has everything for being introspectable, but it lacks a
GType, because it can't be copied. So provide a copy function that
deeply copies all the bookmark structures.

Add tests for this.
2022-10-14 16:39:20 +01:00
Christian Hergert
49ae9b490d strfuncs: add g_set_str()
This is like our other suite of g_set_*() based APIs to simplify and
improve correctness of setters for fields, properties, and more.

This implementation specifically handles setting string values that may
point to an offset within the current string by copying before free.

strcmp() is used directly (as opposed to g_strcmp0() due to it being in
gtestutils.h as well as to increase the chance that the compiler will
hoist the implementation.

Fixes #2747
2022-10-14 16:24:41 +01:00
Philip Withnall
05714bf635 docs: Add 2.76 release series documentation pages to the build
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-14 16:03:29 +01:00
Xavier Claessens
dcfc9f689e Fix symbol visibility macros on Windows
There is currently no `dllimport` attribute on any of our function,
which prevents MSVC to optimize function calls.

To fix that issue, we need to redeclare all our visibility macros for
each of our libraries, because when compiling e.g. GIO code, we need
dllimport in GLIB headers and dllexport in GIO headers. That means they
cannot use the same GLIB_AVAILABLE_* macro.

Since that's a lot of boilerplate to copy/paste after each version bump,
this MR generate all those macros using a python script.

Also simplify the meson side by using `gnu_symbol_visibility : 'hidden'`
keyword argument instead of passing the cflag manually.

This leaves only API index to add manually into glib-docs.xml when
bumping GLib version. That file cannot be generated because Meson does
not allow passing a buit file to gnome.gtkdoc()'s main_xml kwarg
unfortunately.
2022-10-13 20:53:56 -04:00
Emmanuele Bassi
32edf9c01a Build API docs only with shared libraries
Building the references requires libraries with all their symbols
available. Passing `-Dgtk_doc=true` and `-Ddefault_library=static`
should be considered a configuration error.
2022-09-14 15:03:43 +01:00
Marco Trevisan (Treviño)
ea0617e993 docs: Add --delete option to gio-tool attributes documentation
It was added via !2845 but not documented.
2022-08-05 22:36:06 +02:00
Michael Catanzaro
61a843564d Improve default value of glib_debug option
glib_debug is an auto option. This is clever because it allows us to
guess the best default based on the build type, while also allowing an
easy way to override if the guess is not good. Sadly, the attempt to
guess based on the build type does not work well. For example, it
considers debugoptimized builds to be debug builds, but despite the
name, it is definitely a release build type (except on Windows, which
we'll ignore here). The minsize build type has the exact same problem.
The debug option is true for both build types, but this only controls
whether debuginfo is enabled, not whether debug extras are enabled.

The plain build type has a different problem: debug is off, but the
optimization option is off too, even though plain builds are distro
builds are will almost always use optimization.

I've outlined an argument for why we should make these changes here:
https://blogs.gnome.org/mcatanzaro/2022/07/15/best-practices-for-build-options/

Specifically, Rule 4 shows all the build types and whether they
correspond to release builds or debug builds. Rule 6 argues that we
should provide good defaults for plain builds.
2022-08-03 17:07:13 -05:00
Aleksei Rybalkin
8d5a44dc8f replace pcre1 with pcre2 2022-07-12 11:46:34 +00:00
Philip Withnall
8385f52db7 Merge branch 'inline-macros' into 'main'
gmacros: Provide platform-independent G_ALWAYS_INLINE and G_NO_INLINE

See merge request GNOME/glib!2781
2022-07-06 13:40:10 +00:00
Marco Trevisan (Treviño)
15cd0f0461 gmacros: Provide platform-independent G_ALWAYS_INLINE and G_NO_INLINE
We had gcc-only implementations for them while both can be used in all
the supported platforms we have.

So let's just provide generic definitions, while we keep the old ones
for both consistency and retro-compatibility.
2022-07-06 14:57:06 +02:00
Emmanuele Bassi
fa05ebe27c docs: Mention alternatives for defining enumeration types
We should mention glib-mkenums in the documentation for
G_DEFINE_ENUM_TYPE and G_DEFINE_FLAGS_TYPE.

We should also mention the macros in the documentation for glib-mkenums.

This way, developers can choose the most appropriate tool for their use
case.
2022-06-30 01:46:54 +01:00
Emmanuele Bassi
28edd84e77 docs: Add the new G_DEFINE macros for enumeration types 2022-06-30 01:46:54 +01:00
Philip Withnall
e5ccbe09da Merge branch 'atomic-exchange-pre-value' into 'main'
gatomic: Add Compare and Exchange functions that returns the previous value

See merge request GNOME/glib!2766
2022-06-23 13:19:05 +00:00
Philip Withnall
5655af6ada Merge branch 'more-async-gfile' into 'main'
gfile (and GAppInfo): Add some missing async APIs and ensure async calls always use them

See merge request GNOME/glib!2717
2022-06-23 11:49:55 +00:00
Marco Trevisan (Treviño)
bfdeb37f6e gatomic: Add Compare and Exchange functions that returns the previous value
Atomic primitives allow to do conditional compare and exchange but also
to get the value that was previously stored in the atomic variable.

Now, we provided an exchange function that allows to do an exchange if
the atomic value matches an expected value but we had no way to know
at the same time what was the value in the atomic at the moment of the
exchange try, an this can be useful in case that the operation fails,
for example if the current value is still acceptable for us, allowing
to do a kind of "OR" check:

  gint old_value;
  gint valid_value = 222;
  while (!g_atomic_pointer_compare_and_exchange_value (&atomic,
                                                       valid_value, 555,
                                                       &old_value)
    {
      if (old_value == 555 || old_value == 222)
        valid_value = old_value;
    }
2022-06-22 23:01:19 +02:00
Marco Trevisan (Treviño)
8aee5fc628 GAppInfo: Add async API to get default Application for URI scheme
Make possible to fetch the default application for URI scheme in a
thread without using blocking I/O.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
44dbd43170 GAppInfo: Add async API to get default Application for content type
Make possible to fetch the Application for default content type in a
thread without using blocking I/O.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
22e951e6ac gfile: Add Async API to create a temporary directory and return as GFile
While it's possible to create a directory synchronously via
g_dir_make_tmp(), there's no such API that performs it asynchronously.

So implement it using GFile, using a thread to perform such task.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
fa24391529 gfile: Add API to create a new temporary file asynchronously
Make possible to create a new gfile with a temporary name in async
way, using the same API of g_file_new_tmp().
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
b64fd312da gerror: Add an utility function to get the GIO Error from GFileError
When GIO functions are using GLib file utils functions we expect to
return a GIO Error, so provide a way to map such error values.
2022-06-22 20:07:25 +02:00
Eli Schwartz
24ec80cfb4
meson: simplify iconv lookups using Meson's builtin dependency lookup
iconv is complicated to look up. That complexity now resides in
Meson, since 0.60.0, via a `dependency('iconv')` lookup, so use that
instead.

No effort is made to support the old option for which type of iconv to
use. It was a false choice, because if only one was available, then
that's the only one you can use, and if both are available, the external
iconv shadows the builtin one and renders the builtin one unusable,
so there is still only one you can use.

This meant that when configuring glib with -Diconv=libc on systems that
had an external iconv, the configure check would detect a valid libc
iconv, try to use it, and then fail during the build because iconv.h
belongs to the external iconv and generates machine code using the
external iconv ABI, but fails to link to the iconv `find_library()`.
Meson handles this transparently.
2022-06-16 12:04:59 -04:00
Philip Withnall
b3f49d08a6 build: Move gvdb to a subproject
Rather than carrying the copylib around inside GLib, which is a pain to
synchronise and affects our code coverage statistics.

This requires updating the CI images to cache the new subproject,
including updating the `cache-subprojects.sh` script to pull in git
submodules.

It also requires adding `gioenumtypes_dep` to be added to the
dependencies list of `libgio`, since it needs to be build before GVDB as
it’s pulled in by the GIO headers which GVDB includes.

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

Helps: #2603
2022-06-16 10:12:07 +01:00
Marco Trevisan (Treviño)
04718a9692 gfile: Implement interface API to make symbolic links asynchronously
The interface was ready for this API but it was not provided.

So implement this, using a thread that calls the sync API for now.

Add tests.

Helps with: GNOME/glib#157
2022-06-15 19:49:38 +02:00