gdbus-codegen: Use the non-pointer type for ctype_out

The out type can be different from the in types in their qualifiers and
thus are not always simply a reference to the in type. However, the out
types used to include the reference instead of the "base" type because
the code generator always used them in places where we actually needed a
reference to the out type (e.g. as out params).

For example, the codegen here generates:

    gboolean dex_dbus_ping_pong_call_ping_sync (
        DexDbusPingPong *proxy,
        const gchar *arg_name,
        gchar ** out_pong,
        GCancellable *cancellable,
        GError **error);

Where `gchar **` is the out type. If we want to codegen a function which
returns the out params in a struct, it would need to look like this:

    typedef struct _DexDbusPingPongPingResult
    {
      gchar * pong;
    } DexDbusPingPongPingResult;

Where neither the out type `gchar **` nor the in type `const gchar *` is
appropriate.

This changes the ctype_out to be the base type, and makes the codegen
add the reference explicitly.
This commit is contained in:
Sebastian Wick
2025-09-16 12:06:21 +02:00
committed by Philip Withnall
parent 051273272d
commit ad42abd311
2 changed files with 21 additions and 21 deletions

View File

@@ -325,7 +325,7 @@ class HeaderCodeGenerator:
" %s *proxy" % (i.name_lower, m.name_lower, i.camel_name)
)
for a in m.out_args:
self.outfile.write(",\n %sout_%s" % (a.ctype_out, a.name))
self.outfile.write(",\n %s* out_%s" % (a.ctype_out, a.name))
if m.unix_fd:
self.outfile.write(",\n GUnixFDList **out_fd_list")
self.outfile.write(
@@ -351,7 +351,7 @@ class HeaderCodeGenerator:
if m.unix_fd:
self.outfile.write(",\n GUnixFDList *fd_list")
for a in m.out_args:
self.outfile.write(",\n %sout_%s" % (a.ctype_out, a.name))
self.outfile.write(",\n %s* out_%s" % (a.ctype_out, a.name))
if m.unix_fd:
self.outfile.write(",\n GUnixFDList **out_fd_list")
self.outfile.write(
@@ -2856,7 +2856,7 @@ class CodeGenerator:
" %s *proxy" % (i.name_lower, m.name_lower, i.camel_name)
)
for a in m.out_args:
self.outfile.write(",\n %sout_%s" % (a.ctype_out, a.name))
self.outfile.write(",\n %s* out_%s" % (a.ctype_out, a.name))
if m.unix_fd:
self.outfile.write(",\n GUnixFDList **out_fd_list")
self.outfile.write(
@@ -2944,7 +2944,7 @@ class CodeGenerator:
if m.unix_fd:
self.outfile.write(",\n GUnixFDList *fd_list")
for a in m.out_args:
self.outfile.write(",\n %sout_%s" % (a.ctype_out, a.name))
self.outfile.write(",\n %s* out_%s" % (a.ctype_out, a.name))
if m.unix_fd:
self.outfile.write(",\n GUnixFDList **out_fd_list")
self.outfile.write(