Sergey Bugaev [Sun, 1 Mar 2026 16:21:20 +0000 (19:21 +0300)]
gvariant: Simplify variant type check
Even when we don't have one of the basic types, we still have a compile-
time known type string. No need to dynamically allocate anything, just
use G_VARIANT_TYPE () to cast it into a GVariantType.
Sergey Bugaev [Thu, 12 Jun 2025 14:34:47 +0000 (17:34 +0300)]
gdbus: Allow DBusConnection and DBusMethodInvocation parameters
This is a way for the server implementation to get hold of the
connection that the current method is being invoked on (which may be
important if it's exported on multiple connections, or just to avoid
global variables), for instance to export other objects, or make proxy
calls, on this connection. A full DBusMethodInvocation object can also
be requested in the same way.
Suggested-by: Ivan Molodetskikh <yalterz@gmail.com>
Sergey Bugaev [Sun, 8 Mar 2026 10:09:58 +0000 (13:09 +0300)]
gdbus: Reimplement method calls using g_dbus_proxy_call
This essentially undoes commit 28fdeeb23dffc8555bc844d225c6e08e2aef95bd
"D-Bus: Use lowlevel message API for method calls in GDBus clients",
whose commit message mentions that this was required for file descriptor
passing. Indeed in 2010, there was no *_with_unix_fd_list methods on
GDBusProxy; those are new in GLib 2.30 (2011). We require GLib 2.56, so
we can rely on those methods being present. This commit implements both
fd-passing an regular D-Bus methods on top of the various variants of
g_dbus_proxy_call methods.
In addition to both the generated code being simpler, this brings the
important functionality of type-checking the reply message.
Sergey Bugaev [Mon, 23 Mar 2026 05:58:25 +0000 (08:58 +0300)]
gdbus: Use GLib.VariantType for D-Bus signature type
The only complication here is that we can't easily use
g_variant_new_signature to construct one, since it takes an unowned
string, we have an owned one from g_variant_type_dup_string, and the way
the module is structured, it's hard to add clean-up code after producing
the desired value. So, we call the lower level g_variant_new_from_data
API instead, transferring ownership of our string, the same way as the
serialize_buffer_array code path does.
Eri the Switch [Sun, 22 Dec 2024 14:36:20 +0000 (17:36 +0300)]
gdbus: Do not provide unintended read/write access to properties
This avoids ignoring private accessibily and construct-only flags
of property accessors.
The definition of DBus interfaces is guarded by expecting public
or protected property accessors. This restriction was not present
on the server side where a class declaration might be used.
girparser: Respect the get-property and set-property attributes
Sometimes we can't quite guess the right getter/setter for a property
based on name alone. The get-property/set-property attributes, when they
are present, are supposed to specify just the right functions.
Now that we can recognize property accessors with non-default names when
they are marked up explicitly, we should store those their names.
See https://gitlab.gnome.org/GNOME/vala/issues/1212 and
https://gitlab.gnome.org/GNOME/gobject-introspection/issues/13
To catch this, introduce a new virtual method, transfer_compatible (),
which is overriden in Vala.ArrayType to check for element type
ownership, and use it throughout.
Sergey Bugaev [Mon, 26 May 2025 06:55:32 +0000 (09:55 +0300)]
glib-2.0: Fix *.add_once () callbacks
These callbacks have scope=async, not scope=call. In Vala, the latter is
what passing an unowned delegate implies, while scope=async is achieved
with an owned delegate marked [CCode (scope = "async")].
Sergey Bugaev [Sat, 24 May 2025 10:22:55 +0000 (13:22 +0300)]
parser: Fix statement error recovery
Parser.rollback () can only be used to move *backward* through tokens,
not forward. When we run into a ParseError while parsing a statement,
'begin' points to the start of the statement, and 'e_begin' to the error
location inside the statement. 'rollback (begin)' is then justified,
since we're rolling back to the start of the statement; but moving to
'e_begin' again can not be done with 'rollback (e_begin)'.
Because we failed to seek forward, an syntax error could send us into an
infinite loop. Use Parser.jump () instead, which moves forward through
tokens.
codegen: Return default_value_on_error on precondition failures
This way, we get -1 for integers, G_TYPE_INVALID for GType, etc. The
returned value doesn't really matter since this is an assertion failure
in any case, but this is what's usually done in C code.
codegen: Propagate default_value_on_error from parent struct
Like it's already done for default_value. This in particular should
impact tests/structs/gtype-base-struct.vala when we set the default
values for GLib.Type.
girparser: Respect given lower_case_cprefix metadata all the way
GIR allows to define multiple prefixes in "c:identifier-prefixes".
Vala is blindly taking the first one which worked well so far, but
can go very wrong. So allow overriding this information of the
root namespace for real.