]> git.0d.be Git - empathy.git/blobdiff - tools/glib-client-gen.py
disable tab coding style check for now
[empathy.git] / tools / glib-client-gen.py
index fede212dca495e268f76342eb192dffbae2bc859..701fcafeb24cba428d8d2502add470fc96ddd615 100644 (file)
@@ -57,9 +57,13 @@ class Generator(object):
             self.proxy_arg = 'gpointer '
 
     def h(self, s):
+        if isinstance(s, unicode):
+            s = s.encode('utf-8')
         self.__header.append(s)
 
     def b(self, s):
+        if isinstance(s, unicode):
+            s = s.encode('utf-8')
         self.__body.append(s)
 
     def get_iface_quark(self):
@@ -195,7 +199,7 @@ class Generator(object):
                     self.b('  g_value_set_int (args->values + %d, %s);'
                            % (i, name))
                 elif gtype == 'G_TYPE_UINT64':
-                    self.b('  g_value_set_uint (args->values + %d, %s);'
+                    self.b('  g_value_set_uint64 (args->values + %d, %s);'
                            % (i, name))
                 elif gtype == 'G_TYPE_DOUBLE':
                     self.b('  g_value_set_double (args->values + %d, %s);'
@@ -656,13 +660,18 @@ class Generator(object):
             self.b(' * @%s: Used to pass an \'in\' argument: %s'
                    % (name, xml_escape(get_docstring(elt) or '(Undocumented)')))
 
-        self.b(' * @callback: called when the method call succeeds or fails')
-        self.b(' * @user_data: user-supplied data passed to the callback')
+        self.b(' * @callback: called when the method call succeeds or fails;')
+        self.b(' *   may be %NULL to make a "fire and forget" call with no ')
+        self.b(' *   reply tracking')
+        self.b(' * @user_data: user-supplied data passed to the callback;')
+        self.b(' *   must be %NULL if @callback is %NULL')
         self.b(' * @destroy: called with the user_data as argument, after the')
-        self.b(' *   call has succeeded, failed or been cancelled')
-        self.b(' * @weak_object: A #GObject which will be weakly referenced; ')
-        self.b(' *   if it is destroyed, this callback will automatically be')
-        self.b(' *   disconnected')
+        self.b(' *   call has succeeded, failed or been cancelled;')
+        self.b(' *   must be %NULL if @callback is %NULL')
+        self.b(' * @weak_object: If not %NULL, a #GObject which will be ')
+        self.b(' *   weakly referenced; if it is destroyed, this call ')
+        self.b(' *   will automatically be cancelled. Must be %NULL if ')
+        self.b(' *   @callback is %NULL')
         self.b(' *')
         self.b(' * Start a %s method call.' % member)
         self.b(' *')
@@ -703,6 +712,12 @@ class Generator(object):
         self.b('')
         self.b('  g_return_val_if_fail (%s (proxy), NULL);'
                % self.proxy_assert)
+        self.b('  g_return_val_if_fail (callback != NULL || '
+               'user_data == NULL, NULL);')
+        self.b('  g_return_val_if_fail (callback != NULL || '
+               'destroy == NULL, NULL);')
+        self.b('  g_return_val_if_fail (callback != NULL || '
+               'weak_object == NULL, NULL);')
         self.b('')
         self.b('  iface = tp_proxy_borrow_interface_by_id (')
         self.b('      (TpProxy *) proxy,')
@@ -723,6 +738,10 @@ class Generator(object):
                 self.b('            0,')
 
         self.b('            error, user_data, weak_object);')
+        self.b('')
+        self.b('      if (destroy != NULL)')
+        self.b('        destroy (user_data);')
+        self.b('')
         self.b('      g_error_free (error);')
         self.b('      return NULL;')
         self.b('    }')
@@ -794,8 +813,8 @@ class Generator(object):
 
             self.b('    %s*%s;' % (ctype, name))
 
-        self.b('    gboolean success:1;')
-        self.b('    gboolean completed:1;')
+        self.b('    unsigned success:1;')
+        self.b('    unsigned completed:1;')
         self.b('} _%s_%s_run_state_%s;'
                % (self.prefix_lc, iface_lc, member_lc))