scanner: Support _get_gtype() as a GType creation suffix
authorColin Walters <walters@verbum.org>
Fri, 3 Jun 2011 21:32:15 +0000 (17:32 -0400)
committerColin Walters <walters@verbum.org>
Fri, 3 Jun 2011 21:33:16 +0000 (17:33 -0400)
Based on a patch by Giovanni Campagna <gcampagna@src.gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=646635

giscanner/gdumpparser.py
giscanner/maintransformer.py
tests/scanner/Regress-1.0-expected.gir
tests/scanner/regress.c
tests/scanner/regress.h

index eb43a5f..7e8f31f 100644 (file)
@@ -205,7 +205,7 @@ blob containing data gleaned from GObject's primitive introspection."""
         symbol = func.symbol
         if symbol.startswith('_'):
             return
-        elif symbol.endswith('_get_type'):
+        elif (symbol.endswith('_get_type') or symbol.endswith('_get_gtype')):
             self._initparse_get_type_function(func)
 
     def _initparse_get_type_function(self, func):
@@ -306,14 +306,17 @@ blob containing data gleaned from GObject's primitive introspection."""
         get_type = xmlnode.attrib['get-type']
         (ns, name) = self._transformer.split_csymbol(get_type)
         assert ns is self._namespace
-        if name == 'get_type':
+        if name in ('get_type', '_get_gtype'):
             message.fatal("""The GObject name %r isn't compatibile
 with the configured identifier prefixes:
   %r
 The class would have no name.  Most likely you want to specify a
 different --identifier-prefix.""" % (xmlnode.attrib['name'], self._namespace.identifier_prefixes))
-        assert name.endswith('_get_type')
-        return (get_type, name[:-len('_get_type')])
+        if name.endswith('_get_type'):
+            type_suffix = '_get_type'
+        else:
+            type_suffix = '_get_gtype'
+        return (get_type, name[:-len(type_suffix)])
 
     def _introspect_object(self, xmlnode):
         type_name = xmlnode.attrib['name']
index bc795c0..dd20af1 100644 (file)
@@ -900,7 +900,9 @@ _split_uscored_by_type(text_buffer_try_new) -> (ast.Class(TextBuffer), 'try_new'
     def _pair_function(self, func):
         """Check to see whether a toplevel function should be a
 method or constructor of some type."""
-        if func.symbol.endswith('_get_type') or func.symbol.startswith('_'):
+        if (func.symbol.endswith('_get_type')
+            or func.symbol.endswith('_get_gtype')
+            or func.symbol.startswith('_')):
             return
         (ns, subsymbol) = self._transformer.split_csymbol(func.symbol)
         assert ns == self._namespace
index c67de86..6302579 100644 (file)
@@ -985,7 +985,7 @@ TpAccount::status-changed</doc>
     <record name="TestSimpleBoxedA"
             c:type="RegressTestSimpleBoxedA"
             glib:type-name="RegressTestSimpleBoxedA"
-            glib:get-type="regress_test_simple_boxed_a_get_type"
+            glib:get-type="regress_test_simple_boxed_a_get_gtype"
             c:symbol-prefix="test_simple_boxed_a">
       <field name="some_int" writable="1">
         <type name="gint" c:type="gint"/>
index 7756f20..447d37c 100644 (file)
@@ -1425,7 +1425,7 @@ regress_test_simple_boxed_a_free (RegressTestSimpleBoxedA *a)
 }
 
 GType
-regress_test_simple_boxed_a_get_type (void)
+regress_test_simple_boxed_a_get_gtype (void)
 {
   static GType our_type = 0;
 
@@ -1783,7 +1783,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass)
                    0     /* n_params */,
                    NULL  /* param_types */);
 
-  param_types[0] = regress_test_simple_boxed_a_get_type() | G_SIGNAL_TYPE_STATIC_SCOPE;
+  param_types[0] = regress_test_simple_boxed_a_get_gtype() | G_SIGNAL_TYPE_STATIC_SCOPE;
   klass->test_signal_with_static_scope_arg =
     g_signal_newv ("test-with-static-scope-arg",
                    G_TYPE_FROM_CLASS (gobject_class),
index 9f32640..3721354 100644 (file)
@@ -251,7 +251,8 @@ struct _RegressTestSimpleBoxedA
   RegressTestEnum some_enum;
 };
 
-GType                   regress_test_simple_boxed_a_get_type     (void);
+/* Intentionally uses _get_gtype */
+GType                   regress_test_simple_boxed_a_get_gtype     (void);
 RegressTestSimpleBoxedA *regress_test_simple_boxed_a_copy         (RegressTestSimpleBoxedA *a);
 gboolean                regress_test_simple_boxed_a_equals       (RegressTestSimpleBoxedA *a,
                                                           RegressTestSimpleBoxedA *other_a);