Fix glib:error-quark scanning for unregistered enum types
[gnome.gobject-introspection] / giscanner / girwriter.py
index 7697a2d..8088628 100644 (file)
@@ -152,6 +152,8 @@ and/or use gtk-doc annotations. ''')
         self.write_tag('alias', attrs)
 
     def _write_callable(self, callable, tag_name, extra_attrs):
+        if callable.skip:
+            return
         attrs = [('name', callable.name)]
         attrs.extend(extra_attrs)
         if callable.doc:
@@ -276,10 +278,10 @@ and/or use gtk-doc annotations. ''')
             attrs.extend([('glib:type-name', enum.type_name),
                           ('glib:get-type', enum.get_type),
                           ('c:type', enum.ctype)])
-            if enum.error_quark:
-                attrs.append(('glib:error-quark', enum.error_quark))
         else:
             attrs.append(('c:type', enum.symbol))
+        if hasattr(enum, 'error_quark') and enum.error_quark:
+            attrs.append(('glib:error-quark', enum.error_quark))
 
         with self.tagcontext('enumeration', attrs):
             self._write_attributes(enum)
@@ -304,6 +306,8 @@ and/or use gtk-doc annotations. ''')
                 self._write_member(member)
 
     def _write_member(self, member):
+        if member.skip:
+            return
         attrs = [('name', member.name),
                  ('value', str(member.value)),
                  ('c:identifier', member.symbol)]
@@ -376,6 +380,8 @@ and/or use gtk-doc annotations. ''')
                 self._write_method(method)
 
     def _write_property(self, prop):
+        if prop.skip:
+            return
         attrs = [('name', prop.name)]
         self._append_version(prop, attrs)
         self._append_deprecated(prop, attrs)
@@ -409,6 +415,7 @@ and/or use gtk-doc annotations. ''')
                 ('glib:get-type', boxed.get_type)]
 
     def _write_record(self, record, extra_attrs=[]):
+        is_gtype_struct = False
         attrs = list(extra_attrs)
         if record.name is not None:
             attrs.append(('name', record.name))
@@ -418,6 +425,7 @@ and/or use gtk-doc annotations. ''')
             attrs.append(('disguised', '1'))
         if isinstance(record, GLibRecord):
             if record.is_gtype_struct_for:
+                is_gtype_struct = True
                 attrs.append(('glib:is-gtype-struct-for',
                               record.is_gtype_struct_for))
         if record.doc:
@@ -430,7 +438,7 @@ and/or use gtk-doc annotations. ''')
             self._write_attributes(record)
             if record.fields:
                 for field in record.fields:
-                    self._write_field(field)
+                    self._write_field(field, is_gtype_struct)
             for method in record.constructors:
                 self._write_constructor(method)
             for method in record.methods:
@@ -458,13 +466,20 @@ and/or use gtk-doc annotations. ''')
             for method in union.methods:
                 self._write_method(method)
 
-    def _write_field(self, field):
+    def _write_field(self, field, is_gtype_struct=False):
         if isinstance(field, Function):
             self._write_method(field)
             return
 
         if isinstance(field, Callback):
-            self._write_callback(field)
+            attrs = [('name', field.name)]
+            with self.tagcontext('field', attrs):
+                self._write_attributes(field)
+                if is_gtype_struct:
+                    self._write_callback(field)
+                else:
+                    attrs = [('name', 'any'), ('c:type', 'pointer')]
+                    self.write_tag('type', attrs)
         elif isinstance(field, Struct):
             self._write_record(field)
         elif isinstance(field, Union):
@@ -484,6 +499,8 @@ and/or use gtk-doc annotations. ''')
                 self._write_type(field.type)
 
     def _write_signal(self, signal):
+        if signal.skip:
+            return
         attrs = [('name', signal.name)]
         if signal.doc:
             attrs.append(('doc', signal.doc))