mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
gdbus-codegen: process C.UnixFD annotation in one place
This will make it simpler to enable this behaviour based on the method signature. https://gitlab.gnome.org/GNOME/glib/issues/1726
This commit is contained in:
parent
7b26d427b0
commit
9b827e5674
@ -112,14 +112,11 @@ class HeaderCodeGenerator:
|
|||||||
if len(i.methods) > 0:
|
if len(i.methods) > 0:
|
||||||
self.outfile.write('\n')
|
self.outfile.write('\n')
|
||||||
for m in i.methods:
|
for m in i.methods:
|
||||||
unix_fd = False
|
|
||||||
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
|
|
||||||
unix_fd = True
|
|
||||||
key = (m.since, '_method_%s'%m.name_lower)
|
key = (m.since, '_method_%s'%m.name_lower)
|
||||||
value = ' gboolean (*handle_%s) (\n'%(m.name_lower)
|
value = ' gboolean (*handle_%s) (\n'%(m.name_lower)
|
||||||
value += ' %s *object,\n'%(i.camel_name)
|
value += ' %s *object,\n'%(i.camel_name)
|
||||||
value += ' GDBusMethodInvocation *invocation'%()
|
value += ' GDBusMethodInvocation *invocation'%()
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
value += ',\n GUnixFDList *fd_list'
|
value += ',\n GUnixFDList *fd_list'
|
||||||
for a in m.in_args:
|
for a in m.in_args:
|
||||||
value += ',\n %sarg_%s'%(a.ctype_in, a.name)
|
value += ',\n %sarg_%s'%(a.ctype_in, a.name)
|
||||||
@ -176,15 +173,12 @@ class HeaderCodeGenerator:
|
|||||||
self.outfile.write('\n')
|
self.outfile.write('\n')
|
||||||
self.outfile.write('/* D-Bus method call completion functions: */\n')
|
self.outfile.write('/* D-Bus method call completion functions: */\n')
|
||||||
for m in i.methods:
|
for m in i.methods:
|
||||||
unix_fd = False
|
|
||||||
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
|
|
||||||
unix_fd = True
|
|
||||||
if m.deprecated:
|
if m.deprecated:
|
||||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||||
self.outfile.write('void %s_complete_%s (\n'
|
self.outfile.write('void %s_complete_%s (\n'
|
||||||
' %s *object,\n'
|
' %s *object,\n'
|
||||||
' GDBusMethodInvocation *invocation'%(i.name_lower, m.name_lower, i.camel_name))
|
' GDBusMethodInvocation *invocation'%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList *fd_list')
|
self.outfile.write(',\n GUnixFDList *fd_list')
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(',\n %s%s'%(a.ctype_in, a.name))
|
self.outfile.write(',\n %s%s'%(a.ctype_in, a.name))
|
||||||
@ -212,9 +206,6 @@ class HeaderCodeGenerator:
|
|||||||
self.outfile.write('\n')
|
self.outfile.write('\n')
|
||||||
self.outfile.write('/* D-Bus method calls: */\n')
|
self.outfile.write('/* D-Bus method calls: */\n')
|
||||||
for m in i.methods:
|
for m in i.methods:
|
||||||
unix_fd = False
|
|
||||||
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
|
|
||||||
unix_fd = True
|
|
||||||
# async begin
|
# async begin
|
||||||
if m.deprecated:
|
if m.deprecated:
|
||||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||||
@ -222,7 +213,7 @@ class HeaderCodeGenerator:
|
|||||||
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
for a in m.in_args:
|
for a in m.in_args:
|
||||||
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
|
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList *fd_list')
|
self.outfile.write(',\n GUnixFDList *fd_list')
|
||||||
self.outfile.write(',\n'
|
self.outfile.write(',\n'
|
||||||
' GCancellable *cancellable,\n'
|
' GCancellable *cancellable,\n'
|
||||||
@ -236,7 +227,7 @@ class HeaderCodeGenerator:
|
|||||||
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(',\n %sout_%s'%(a.ctype_out, a.name))
|
self.outfile.write(',\n %sout_%s'%(a.ctype_out, a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList **out_fd_list')
|
self.outfile.write(',\n GUnixFDList **out_fd_list')
|
||||||
self.outfile.write(',\n'
|
self.outfile.write(',\n'
|
||||||
' GAsyncResult *res,\n'
|
' GAsyncResult *res,\n'
|
||||||
@ -249,11 +240,11 @@ class HeaderCodeGenerator:
|
|||||||
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
for a in m.in_args:
|
for a in m.in_args:
|
||||||
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
|
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList *fd_list')
|
self.outfile.write(',\n GUnixFDList *fd_list')
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(',\n %sout_%s'%(a.ctype_out, a.name))
|
self.outfile.write(',\n %sout_%s'%(a.ctype_out, a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList **out_fd_list')
|
self.outfile.write(',\n GUnixFDList **out_fd_list')
|
||||||
self.outfile.write(',\n'
|
self.outfile.write(',\n'
|
||||||
' GCancellable *cancellable,\n'
|
' GCancellable *cancellable,\n'
|
||||||
@ -1153,9 +1144,6 @@ class CodeGenerator:
|
|||||||
|
|
||||||
if len(i.methods) > 0:
|
if len(i.methods) > 0:
|
||||||
for m in i.methods:
|
for m in i.methods:
|
||||||
unix_fd = False
|
|
||||||
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
|
|
||||||
unix_fd = True
|
|
||||||
self.generate_args('_%s_method_info_%s_IN_ARG'%(i.name_lower, m.name_lower), m.in_args)
|
self.generate_args('_%s_method_info_%s_IN_ARG'%(i.name_lower, m.name_lower), m.in_args)
|
||||||
self.generate_args('_%s_method_info_%s_OUT_ARG'%(i.name_lower, m.name_lower), m.out_args)
|
self.generate_args('_%s_method_info_%s_OUT_ARG'%(i.name_lower, m.name_lower), m.out_args)
|
||||||
|
|
||||||
@ -1181,7 +1169,7 @@ class CodeGenerator:
|
|||||||
self.outfile.write(' },\n'
|
self.outfile.write(' },\n'
|
||||||
' "handle-%s",\n'
|
' "handle-%s",\n'
|
||||||
' %s\n'
|
' %s\n'
|
||||||
%(m.name_hyphen, 'TRUE' if unix_fd else 'FALSE'))
|
%(m.name_hyphen, 'TRUE' if m.unix_fd else 'FALSE'))
|
||||||
self.outfile.write('};\n'
|
self.outfile.write('};\n'
|
||||||
'\n')
|
'\n')
|
||||||
|
|
||||||
@ -1399,16 +1387,13 @@ class CodeGenerator:
|
|||||||
if len(i.methods) > 0:
|
if len(i.methods) > 0:
|
||||||
self.outfile.write(' /* GObject signals for incoming D-Bus method calls: */\n')
|
self.outfile.write(' /* GObject signals for incoming D-Bus method calls: */\n')
|
||||||
for m in i.methods:
|
for m in i.methods:
|
||||||
unix_fd = False
|
|
||||||
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
|
|
||||||
unix_fd = True
|
|
||||||
self.outfile.write(self.docbook_gen.expand(
|
self.outfile.write(self.docbook_gen.expand(
|
||||||
' /**\n'
|
' /**\n'
|
||||||
' * %s::handle-%s:\n'
|
' * %s::handle-%s:\n'
|
||||||
' * @object: A #%s.\n'
|
' * @object: A #%s.\n'
|
||||||
' * @invocation: A #GDBusMethodInvocation.\n'
|
' * @invocation: A #GDBusMethodInvocation.\n'
|
||||||
%(i.camel_name, m.name_hyphen, i.camel_name), False))
|
%(i.camel_name, m.name_hyphen, i.camel_name), False))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' * @fd_list: (nullable): A #GUnixFDList or %NULL.\n')
|
self.outfile.write(' * @fd_list: (nullable): A #GUnixFDList or %NULL.\n')
|
||||||
for a in m.in_args:
|
for a in m.in_args:
|
||||||
self.outfile.write(' * @arg_%s: Argument passed by remote caller.\n'%(a.name))
|
self.outfile.write(' * @arg_%s: Argument passed by remote caller.\n'%(a.name))
|
||||||
@ -1421,7 +1406,7 @@ class CodeGenerator:
|
|||||||
' * Returns: %%TRUE if the invocation was handled, %%FALSE to let other signal handlers run.\n'
|
' * Returns: %%TRUE if the invocation was handled, %%FALSE to let other signal handlers run.\n'
|
||||||
%(i.name, m.name, i.name_lower, m.name_lower), False))
|
%(i.name, m.name, i.name_lower, m.name_lower), False))
|
||||||
self.write_gtkdoc_deprecated_and_since_and_close(m, self.outfile, 2)
|
self.write_gtkdoc_deprecated_and_since_and_close(m, self.outfile, 2)
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
extra_args = 2
|
extra_args = 2
|
||||||
else:
|
else:
|
||||||
extra_args = 1
|
extra_args = 1
|
||||||
@ -1436,7 +1421,7 @@ class CodeGenerator:
|
|||||||
' %d,\n'
|
' %d,\n'
|
||||||
' G_TYPE_DBUS_METHOD_INVOCATION'
|
' G_TYPE_DBUS_METHOD_INVOCATION'
|
||||||
%(m.name_hyphen, i.camel_name, m.name_lower, len(m.in_args) + extra_args))
|
%(m.name_hyphen, i.camel_name, m.name_lower, len(m.in_args) + extra_args))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(', G_TYPE_UNIX_FD_LIST')
|
self.outfile.write(', G_TYPE_UNIX_FD_LIST')
|
||||||
for a in m.in_args:
|
for a in m.in_args:
|
||||||
self.outfile.write(', %s'%(a.gtype))
|
self.outfile.write(', %s'%(a.gtype))
|
||||||
@ -1662,9 +1647,6 @@ class CodeGenerator:
|
|||||||
|
|
||||||
def generate_method_calls(self, i):
|
def generate_method_calls(self, i):
|
||||||
for m in i.methods:
|
for m in i.methods:
|
||||||
unix_fd = False
|
|
||||||
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
|
|
||||||
unix_fd = True
|
|
||||||
# async begin
|
# async begin
|
||||||
self.outfile.write('/**\n'
|
self.outfile.write('/**\n'
|
||||||
' * %s_call_%s:\n'
|
' * %s_call_%s:\n'
|
||||||
@ -1672,7 +1654,7 @@ class CodeGenerator:
|
|||||||
%(i.name_lower, m.name_lower, i.camel_name))
|
%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
for a in m.in_args:
|
for a in m.in_args:
|
||||||
self.outfile.write(' * @arg_%s: Argument to pass with the method invocation.\n'%(a.name))
|
self.outfile.write(' * @arg_%s: Argument to pass with the method invocation.\n'%(a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' * @fd_list: (nullable): A #GUnixFDList or %NULL.\n')
|
self.outfile.write(' * @fd_list: (nullable): A #GUnixFDList or %NULL.\n')
|
||||||
self.outfile.write(self.docbook_gen.expand(
|
self.outfile.write(self.docbook_gen.expand(
|
||||||
' * @cancellable: (nullable): A #GCancellable or %%NULL.\n'
|
' * @cancellable: (nullable): A #GCancellable or %%NULL.\n'
|
||||||
@ -1691,14 +1673,14 @@ class CodeGenerator:
|
|||||||
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
for a in m.in_args:
|
for a in m.in_args:
|
||||||
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
|
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList *fd_list')
|
self.outfile.write(',\n GUnixFDList *fd_list')
|
||||||
self.outfile.write(',\n'
|
self.outfile.write(',\n'
|
||||||
' GCancellable *cancellable,\n'
|
' GCancellable *cancellable,\n'
|
||||||
' GAsyncReadyCallback callback,\n'
|
' GAsyncReadyCallback callback,\n'
|
||||||
' gpointer user_data)\n'
|
' gpointer user_data)\n'
|
||||||
'{\n')
|
'{\n')
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' g_dbus_proxy_call_with_unix_fd_list (G_DBUS_PROXY (proxy),\n')
|
self.outfile.write(' g_dbus_proxy_call_with_unix_fd_list (G_DBUS_PROXY (proxy),\n')
|
||||||
else:
|
else:
|
||||||
self.outfile.write(' g_dbus_proxy_call (G_DBUS_PROXY (proxy),\n')
|
self.outfile.write(' g_dbus_proxy_call (G_DBUS_PROXY (proxy),\n')
|
||||||
@ -1712,7 +1694,7 @@ class CodeGenerator:
|
|||||||
self.outfile.write('),\n'
|
self.outfile.write('),\n'
|
||||||
' G_DBUS_CALL_FLAGS_NONE,\n'
|
' G_DBUS_CALL_FLAGS_NONE,\n'
|
||||||
' -1,\n')
|
' -1,\n')
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' fd_list,\n')
|
self.outfile.write(' fd_list,\n')
|
||||||
self.outfile.write(' cancellable,\n'
|
self.outfile.write(' cancellable,\n'
|
||||||
' callback,\n'
|
' callback,\n'
|
||||||
@ -1726,7 +1708,7 @@ class CodeGenerator:
|
|||||||
%(i.name_lower, m.name_lower, i.camel_name))
|
%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(' * @out_%s: (out) (optional)%s: Return location for return parameter or %%NULL to ignore.\n'%(a.name, ' ' + a.array_annotation if a.array_annotation else ''))
|
self.outfile.write(' * @out_%s: (out) (optional)%s: Return location for return parameter or %%NULL to ignore.\n'%(a.name, ' ' + a.array_annotation if a.array_annotation else ''))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' * @out_fd_list: (out) (optional): Return location for a #GUnixFDList or %NULL to ignore.\n')
|
self.outfile.write(' * @out_fd_list: (out) (optional): Return location for a #GUnixFDList or %NULL to ignore.\n')
|
||||||
self.outfile.write(self.docbook_gen.expand(
|
self.outfile.write(self.docbook_gen.expand(
|
||||||
' * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to %s_call_%s().\n'
|
' * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to %s_call_%s().\n'
|
||||||
@ -1742,14 +1724,14 @@ class CodeGenerator:
|
|||||||
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(',\n %sout_%s'%(a.ctype_out, a.name))
|
self.outfile.write(',\n %sout_%s'%(a.ctype_out, a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList **out_fd_list')
|
self.outfile.write(',\n GUnixFDList **out_fd_list')
|
||||||
self.outfile.write(',\n'
|
self.outfile.write(',\n'
|
||||||
' GAsyncResult *res,\n'
|
' GAsyncResult *res,\n'
|
||||||
' GError **error)\n'
|
' GError **error)\n'
|
||||||
'{\n'
|
'{\n'
|
||||||
' GVariant *_ret;\n')
|
' GVariant *_ret;\n')
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' _ret = g_dbus_proxy_call_with_unix_fd_list_finish (G_DBUS_PROXY (proxy), out_fd_list, res, error);\n')
|
self.outfile.write(' _ret = g_dbus_proxy_call_with_unix_fd_list_finish (G_DBUS_PROXY (proxy), out_fd_list, res, error);\n')
|
||||||
else:
|
else:
|
||||||
self.outfile.write(' _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);\n')
|
self.outfile.write(' _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);\n')
|
||||||
@ -1777,11 +1759,11 @@ class CodeGenerator:
|
|||||||
%(i.name_lower, m.name_lower, i.camel_name))
|
%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
for a in m.in_args:
|
for a in m.in_args:
|
||||||
self.outfile.write(' * @arg_%s: Argument to pass with the method invocation.\n'%(a.name))
|
self.outfile.write(' * @arg_%s: Argument to pass with the method invocation.\n'%(a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' * @fd_list: (nullable): A #GUnixFDList or %NULL.\n')
|
self.outfile.write(' * @fd_list: (nullable): A #GUnixFDList or %NULL.\n')
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(' * @out_%s: (out) (optional)%s: Return location for return parameter or %%NULL to ignore.\n'%(a.name, ' ' + a.array_annotation if a.array_annotation else ''))
|
self.outfile.write(' * @out_%s: (out) (optional)%s: Return location for return parameter or %%NULL to ignore.\n'%(a.name, ' ' + a.array_annotation if a.array_annotation else ''))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' * @out_fd_list: (out): Return location for a #GUnixFDList or %NULL.\n')
|
self.outfile.write(' * @out_fd_list: (out): Return location for a #GUnixFDList or %NULL.\n')
|
||||||
self.outfile.write(self.docbook_gen.expand(
|
self.outfile.write(self.docbook_gen.expand(
|
||||||
' * @cancellable: (nullable): A #GCancellable or %%NULL.\n'
|
' * @cancellable: (nullable): A #GCancellable or %%NULL.\n'
|
||||||
@ -1799,18 +1781,18 @@ class CodeGenerator:
|
|||||||
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
for a in m.in_args:
|
for a in m.in_args:
|
||||||
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
|
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList *fd_list')
|
self.outfile.write(',\n GUnixFDList *fd_list')
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(',\n %sout_%s'%(a.ctype_out, a.name))
|
self.outfile.write(',\n %sout_%s'%(a.ctype_out, a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList **out_fd_list')
|
self.outfile.write(',\n GUnixFDList **out_fd_list')
|
||||||
self.outfile.write(',\n'
|
self.outfile.write(',\n'
|
||||||
' GCancellable *cancellable,\n'
|
' GCancellable *cancellable,\n'
|
||||||
' GError **error)\n'
|
' GError **error)\n'
|
||||||
'{\n'
|
'{\n'
|
||||||
' GVariant *_ret;\n')
|
' GVariant *_ret;\n')
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' _ret = g_dbus_proxy_call_with_unix_fd_list_sync (G_DBUS_PROXY (proxy),\n')
|
self.outfile.write(' _ret = g_dbus_proxy_call_with_unix_fd_list_sync (G_DBUS_PROXY (proxy),\n')
|
||||||
else:
|
else:
|
||||||
self.outfile.write(' _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),\n')
|
self.outfile.write(' _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),\n')
|
||||||
@ -1824,7 +1806,7 @@ class CodeGenerator:
|
|||||||
self.outfile.write('),\n'
|
self.outfile.write('),\n'
|
||||||
' G_DBUS_CALL_FLAGS_NONE,\n'
|
' G_DBUS_CALL_FLAGS_NONE,\n'
|
||||||
' -1,\n')
|
' -1,\n')
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' fd_list,\n'
|
self.outfile.write(' fd_list,\n'
|
||||||
' out_fd_list,\n')
|
' out_fd_list,\n')
|
||||||
self.outfile.write(' cancellable,\n'
|
self.outfile.write(' cancellable,\n'
|
||||||
@ -1849,15 +1831,12 @@ class CodeGenerator:
|
|||||||
|
|
||||||
def generate_method_completers(self, i):
|
def generate_method_completers(self, i):
|
||||||
for m in i.methods:
|
for m in i.methods:
|
||||||
unix_fd = False
|
|
||||||
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
|
|
||||||
unix_fd = True
|
|
||||||
self.outfile.write('/**\n'
|
self.outfile.write('/**\n'
|
||||||
' * %s_complete_%s:\n'
|
' * %s_complete_%s:\n'
|
||||||
' * @object: A #%s.\n'
|
' * @object: A #%s.\n'
|
||||||
' * @invocation: (transfer full): A #GDBusMethodInvocation.\n'
|
' * @invocation: (transfer full): A #GDBusMethodInvocation.\n'
|
||||||
%(i.name_lower, m.name_lower, i.camel_name))
|
%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' * @fd_list: (nullable): A #GUnixFDList or %NULL.\n')
|
self.outfile.write(' * @fd_list: (nullable): A #GUnixFDList or %NULL.\n')
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(' * @%s: Parameter to return.\n'%(a.name))
|
self.outfile.write(' * @%s: Parameter to return.\n'%(a.name))
|
||||||
@ -1872,14 +1851,14 @@ class CodeGenerator:
|
|||||||
'%s_complete_%s (\n'
|
'%s_complete_%s (\n'
|
||||||
' %s *object,\n'
|
' %s *object,\n'
|
||||||
' GDBusMethodInvocation *invocation'%(i.name_lower, m.name_lower, i.camel_name))
|
' GDBusMethodInvocation *invocation'%(i.name_lower, m.name_lower, i.camel_name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(',\n GUnixFDList *fd_list')
|
self.outfile.write(',\n GUnixFDList *fd_list')
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(',\n %s%s'%(a.ctype_in, a.name))
|
self.outfile.write(',\n %s%s'%(a.ctype_in, a.name))
|
||||||
self.outfile.write(')\n'
|
self.outfile.write(')\n'
|
||||||
'{\n')
|
'{\n')
|
||||||
|
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write(' g_dbus_method_invocation_return_value_with_unix_fd_list (invocation,\n'
|
self.outfile.write(' g_dbus_method_invocation_return_value_with_unix_fd_list (invocation,\n'
|
||||||
' g_variant_new ("(')
|
' g_variant_new ("(')
|
||||||
else:
|
else:
|
||||||
@ -1890,7 +1869,7 @@ class CodeGenerator:
|
|||||||
self.outfile.write(')"')
|
self.outfile.write(')"')
|
||||||
for a in m.out_args:
|
for a in m.out_args:
|
||||||
self.outfile.write(',\n %s'%(a.name))
|
self.outfile.write(',\n %s'%(a.name))
|
||||||
if unix_fd:
|
if m.unix_fd:
|
||||||
self.outfile.write('),\n fd_list);\n')
|
self.outfile.write('),\n fd_list);\n')
|
||||||
else:
|
else:
|
||||||
self.outfile.write('));\n')
|
self.outfile.write('));\n')
|
||||||
|
@ -260,6 +260,7 @@ class Method:
|
|||||||
self.doc_string = ''
|
self.doc_string = ''
|
||||||
self.since = ''
|
self.since = ''
|
||||||
self.deprecated = False
|
self.deprecated = False
|
||||||
|
self.unix_fd = False
|
||||||
|
|
||||||
def post_process(self, interface_prefix, cns, cns_upper, cns_lower, containing_iface):
|
def post_process(self, interface_prefix, cns, cns_upper, cns_lower, containing_iface):
|
||||||
if len(self.doc_string) == 0:
|
if len(self.doc_string) == 0:
|
||||||
@ -291,6 +292,9 @@ class Method:
|
|||||||
if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true':
|
if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true':
|
||||||
self.deprecated = True
|
self.deprecated = True
|
||||||
|
|
||||||
|
if utils.lookup_annotation(self.annotations, 'org.gtk.GDBus.C.UnixFD'):
|
||||||
|
self.unix_fd = True
|
||||||
|
|
||||||
for a in self.annotations:
|
for a in self.annotations:
|
||||||
a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
|
a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
|
||||||
|
|
||||||
|
@ -2588,6 +2588,31 @@ test_standalone_interface_info (void)
|
|||||||
g_clear_object (&skel);
|
g_clear_object (&skel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
static gboolean
|
||||||
|
handle_hello_fd (FooiGenFDPassing *object,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
GUnixFDList *fd_list,
|
||||||
|
const gchar *arg_greeting)
|
||||||
|
{
|
||||||
|
foo_igen_fdpassing_complete_hello_fd (object, invocation, fd_list, arg_greeting);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test that generated code for methods includes GUnixFDList arguments if
|
||||||
|
* the method is explicitly annotated as C.UnixFD.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
test_unix_fd_list (void)
|
||||||
|
{
|
||||||
|
FooiGenFDPassingIface iface;
|
||||||
|
|
||||||
|
/* This method is explicitly annotated. */
|
||||||
|
iface.handle_hello_fd = handle_hello_fd;
|
||||||
|
|
||||||
|
(void) iface;
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -2603,6 +2628,7 @@ main (int argc,
|
|||||||
g_test_add_func ("/gdbus/codegen/autocleanups", test_autocleanups);
|
g_test_add_func ("/gdbus/codegen/autocleanups", test_autocleanups);
|
||||||
g_test_add_func ("/gdbus/codegen/deprecations", test_deprecations);
|
g_test_add_func ("/gdbus/codegen/deprecations", test_deprecations);
|
||||||
g_test_add_func ("/gdbus/codegen/standalone-interface-info", test_standalone_interface_info);
|
g_test_add_func ("/gdbus/codegen/standalone-interface-info", test_standalone_interface_info);
|
||||||
|
g_test_add_func ("/gdbus/codegen/unix-fd-list", test_unix_fd_list);
|
||||||
|
|
||||||
return session_bus_run ();
|
return session_bus_run ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user