mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +01:00
codegen: fix array out-param annotations
When using gdbus-codegen to produce generated code for a method with an out parameter with a signature like 'as', make sure to include an "(array)" annotation for that parameter. (Reworked by Philip Withnall to improve code formatting.) https://bugzilla.gnome.org/show_bug.cgi?id=741167
This commit is contained in:
parent
2a0db6d868
commit
d35d9b7911
@ -1395,7 +1395,7 @@ class CodeGenerator:
|
||||
' * @proxy: A #%sProxy.\n'
|
||||
%(i.name_lower, m.name_lower, i.camel_name))
|
||||
for a in m.out_args:
|
||||
self.c.write(' * @out_%s: (out): Return location for return parameter or %%NULL to ignore.\n'%(a.name))
|
||||
self.c.write(' * @out_%s: (out)%s: Return location for return parameter or %%NULL to ignore.\n'%(a.name, ' ' + a.array_annotation if a.array_annotation else ''))
|
||||
if unix_fd:
|
||||
self.c.write(' * @out_fd_list: (out): Return location for a #GUnixFDList or %NULL.\n')
|
||||
self.c.write(self.docbook_gen.expand(
|
||||
@ -1450,7 +1450,7 @@ class CodeGenerator:
|
||||
if unix_fd:
|
||||
self.c.write(' * @fd_list: (nullable): A #GUnixFDList or %NULL.\n')
|
||||
for a in m.out_args:
|
||||
self.c.write(' * @out_%s: (out): Return location for return parameter or %%NULL to ignore.\n'%(a.name))
|
||||
self.c.write(' * @out_%s: (out)%s: Return location for return parameter or %%NULL to ignore.\n'%(a.name, ' ' + a.array_annotation if a.array_annotation else ''))
|
||||
if unix_fd:
|
||||
self.c.write(' * @out_fd_list: (out): Return location for a #GUnixFDList or %NULL.\n')
|
||||
self.c.write(self.docbook_gen.expand(
|
||||
|
@ -54,6 +54,8 @@ class Arg:
|
||||
self.format_out = '@' + self.signature
|
||||
self.gvariant_get = 'XXX'
|
||||
self.gvalue_get = 'g_value_get_variant'
|
||||
self.array_annotation = ''
|
||||
|
||||
if not utils.lookup_annotation(self.annotations, 'org.gtk.GDBus.C.ForceGVariant'):
|
||||
if self.signature == 'b':
|
||||
self.ctype_in_g = 'gboolean '
|
||||
@ -200,6 +202,7 @@ class Arg:
|
||||
self.format_out = '^as'
|
||||
self.gvariant_get = 'g_variant_get_strv'
|
||||
self.gvalue_get = 'g_value_get_boxed'
|
||||
self.array_annotation = '(array zero-terminated=1)'
|
||||
elif self.signature == 'ao':
|
||||
self.ctype_in_g = 'const gchar *const *'
|
||||
self.ctype_in = 'const gchar *const *'
|
||||
@ -211,6 +214,7 @@ class Arg:
|
||||
self.format_out = '^ao'
|
||||
self.gvariant_get = 'g_variant_get_objv'
|
||||
self.gvalue_get = 'g_value_get_boxed'
|
||||
self.array_annotation = '(array zero-terminated=1)'
|
||||
elif self.signature == 'aay':
|
||||
self.ctype_in_g = 'const gchar *const *'
|
||||
self.ctype_in = 'const gchar *const *'
|
||||
@ -222,6 +226,8 @@ class Arg:
|
||||
self.format_out = '^aay'
|
||||
self.gvariant_get = 'g_variant_get_bytestring_array'
|
||||
self.gvalue_get = 'g_value_get_boxed'
|
||||
self.array_annotation = '(array zero-terminated=1)'
|
||||
|
||||
|
||||
class Method:
|
||||
def __init__(self, name):
|
||||
|
@ -172,7 +172,12 @@ on_handle_test_non_primitive_types (FooiGenBar *object,
|
||||
s = g_strjoinv (", ", (gchar **) array_of_bytestrings);
|
||||
g_string_append_printf (str, "array_of_bytestrings: [%s] ", s);
|
||||
g_free (s);
|
||||
foo_igen_bar_complete_test_non_primitive_types (object, invocation, str->str);
|
||||
foo_igen_bar_complete_test_non_primitive_types (object, invocation,
|
||||
array_of_strings,
|
||||
array_of_objpaths,
|
||||
array_of_signatures,
|
||||
array_of_bytestrings,
|
||||
str->str);
|
||||
g_string_free (str, TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
@ -700,7 +705,12 @@ check_bar_proxy (FooiGenBar *proxy,
|
||||
const gchar *array_of_strings[3] = {"one", "two", NULL};
|
||||
const gchar *array_of_strings_2[3] = {"one2", "two2", NULL};
|
||||
const gchar *array_of_objpaths[3] = {"/one", "/one/two", NULL};
|
||||
GVariant *array_of_signatures = NULL;
|
||||
const gchar *array_of_bytestrings[3] = {"one\xff", "two\xff", NULL};
|
||||
gchar **ret_array_of_strings = NULL;
|
||||
gchar **ret_array_of_objpaths = NULL;
|
||||
GVariant *ret_array_of_signatures = NULL;
|
||||
gchar **ret_array_of_bytestrings = NULL;
|
||||
guchar ret_val_byte;
|
||||
gboolean ret_val_boolean;
|
||||
gint16 ret_val_int16;
|
||||
@ -888,6 +898,7 @@ check_bar_proxy (FooiGenBar *proxy,
|
||||
g_assert (ret);
|
||||
|
||||
error = NULL;
|
||||
array_of_signatures = g_variant_ref_sink (g_variant_new_parsed ("[@g 'ass', 'git']"));
|
||||
ret = foo_igen_bar_call_test_non_primitive_types_sync (proxy,
|
||||
g_variant_new_parsed ("{'one': 'red',"
|
||||
" 'two': 'blue'}"),
|
||||
@ -896,8 +907,12 @@ check_bar_proxy (FooiGenBar *proxy,
|
||||
g_variant_new_parsed ("(42, 'foo', 'bar')"),
|
||||
array_of_strings,
|
||||
array_of_objpaths,
|
||||
g_variant_new_parsed ("[@g 'ass', 'git']"),
|
||||
array_of_signatures,
|
||||
array_of_bytestrings,
|
||||
&ret_array_of_strings,
|
||||
&ret_array_of_objpaths,
|
||||
&ret_array_of_signatures,
|
||||
&ret_array_of_bytestrings,
|
||||
&s,
|
||||
NULL, /* GCancellable */
|
||||
&error);
|
||||
@ -905,6 +920,24 @@ check_bar_proxy (FooiGenBar *proxy,
|
||||
g_assert_no_error (error);
|
||||
g_assert (ret);
|
||||
|
||||
g_assert_nonnull (ret_array_of_strings);
|
||||
g_assert_cmpuint (g_strv_length ((gchar **) ret_array_of_strings), ==,
|
||||
g_strv_length ((gchar **) array_of_strings));
|
||||
g_assert_nonnull (ret_array_of_objpaths);
|
||||
g_assert_cmpuint (g_strv_length ((gchar **) ret_array_of_objpaths), ==,
|
||||
g_strv_length ((gchar **) array_of_objpaths));
|
||||
g_assert_nonnull (ret_array_of_signatures);
|
||||
g_assert_true (g_variant_equal (ret_array_of_signatures, array_of_signatures));
|
||||
g_assert_nonnull (ret_array_of_bytestrings);
|
||||
g_assert_cmpuint (g_strv_length ((gchar **) ret_array_of_bytestrings), ==,
|
||||
g_strv_length ((gchar **) array_of_bytestrings));
|
||||
|
||||
g_clear_pointer (&ret_array_of_strings, g_strfreev);
|
||||
g_clear_pointer (&ret_array_of_objpaths, g_strfreev);
|
||||
g_clear_pointer (&ret_array_of_signatures, g_variant_unref);
|
||||
g_clear_pointer (&ret_array_of_bytestrings, g_strfreev);
|
||||
g_clear_pointer (&s, g_free);
|
||||
|
||||
/* Check that org.freedesktop.DBus.Error.UnknownMethod is returned on
|
||||
* unimplemented methods.
|
||||
*/
|
||||
@ -1049,6 +1082,7 @@ check_bar_proxy (FooiGenBar *proxy,
|
||||
|
||||
/* cleanup */
|
||||
g_free (data);
|
||||
g_variant_unref (array_of_signatures);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
@ -50,9 +50,13 @@
|
||||
<arg direction="in" type="a{s(ii)}" name="dict_s_to_pairs" />
|
||||
<arg direction="in" type="(iss)" name="a_struct" />
|
||||
<arg direction="in" type="as" name="array_of_strings" />
|
||||
<arg direction="out" type="as" name="ret_array_of_strings" />
|
||||
<arg direction="in" type="ao" name="array_of_objpaths" />
|
||||
<arg direction="out" type="ao" name="ret_array_of_objpaths" />
|
||||
<arg direction="in" type="ag" name="array_of_signatures" />
|
||||
<arg direction="out" type="ag" name="ret_array_of_signatures" />
|
||||
<arg direction="in" type="aay" name="array_of_bytestrings" />
|
||||
<arg direction="out" type="aay" name="ret_array_of_bytestrings" />
|
||||
<arg direction="out" type="ay" name="result" />
|
||||
</method>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user