+2009-01-21 Johan Dahlin <jdahlin@async.com.br>
+
+ Bug 562622 – Errordomains missing
+
+ * giscanner/girwriter.py:
+ * giscanner/glibast.py:
+ * giscanner/glibtransformer.py:
+ * tests/scanner/Makefile.am:
+ * tests/scanner/foo-1.0-expected.gir:
+ * tests/scanner/foo-1.0-expected.tgir:
+ * tests/scanner/foo.c (foo_error_get_type), (foo_error_quark):
+ * tests/scanner/foo.h:
+
2009-01-20 Johan Dahlin <jdahlin@async.com.br>
* giscanner/scannerlexer.l:
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))
+
with self.tagcontext('enumeration', attrs):
for member in enum.members:
self._write_member(member)
self.ctype = type_name
self.type_name = type_name
self.get_type = get_type
+ self.error_quark = None
def __repr__(self):
return 'GlibEnum(%r, %r, %r)' % (self.name, self.members,
self._uscore_type_names = {}
self._binary = None
self._get_type_functions = []
+ self._error_quark_functions = []
self._gtype_data = {}
self._failed_types = {}
self._boxed_types = {}
self._pair_class_record(node)
for (ns, alias) in self._names.aliases.itervalues():
self._resolve_alias(alias)
-
+ self._resolve_quarks()
self._print_statistics()
# Fourth pass: ensure all types are known
if not self._noclosure:
no_uscore_prefixed = (prefix + '_' + to_underscores(suffix)).lower()
self._uscore_type_names[no_uscore_prefixed] = node
+ def _resolve_quarks(self):
+ for node in self._error_quark_functions:
+ short = node.symbol[:-len('_quark')]
+ enum = self._uscore_type_names.get(short)
+ if enum is not None:
+ enum.error_quark = node.symbol
+
# Helper functions
def _resolve_gtypename(self, gtype_name):
def _execute_binary(self):
in_path = os.path.join(self._binary.tmpdir, 'types.txt')
f = open(in_path, 'w')
+ # TODO: Introspect GQuark functions
for func in self._get_type_functions:
f.write(func)
f.write('\n')
return
if self._parse_get_type_function(func):
return
+ if self._parse_error_quark_function(func):
+ return
self._add_attribute(func)
self._get_type_functions.append(symbol)
return True
+ def _parse_error_quark_function(self, func):
+ if not func.symbol.endswith('_error_quark'):
+ return False
+ if func.parameters:
+ return False
+ if func.retval.type.name not in ['GLib.Quark',
+ 'GQuark']:
+ return False
+
+ self._error_quark_functions.append(func)
+ return True
+
def _name_is_internal_gtype(self, giname):
try:
node = self._get_attribute(giname)
TGIRS = $(GIRS:.gir=.tgir)
CHECKTGIRS = $(GIRS:.gir=.tgir.check)
EXPECTEDTGIRS = $(GIRS:.gir=-expected.tgir)
-CLEANFILES = $(TYPELIBS) $(GIRS) $(TGIRS)
-BUILT_SOURCES = $(TYPELIBS) $(GIRS)
+CLEANFILES = $(TYPELIBS) $(GIRS)
+BUILT_SOURCES = $(TYPELIBS) $(GIRS) $(TGIRS)
EXTRA_DIST = $(EXPECTEDGIRS) $(EXPECTEDTGIRS)
annotation-1.0.gir: libannotation.la annotation.c annotation.h utility-1.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile
$(DEBUG) $(top_builddir)/tools/g-ir-generate --includedir=. --includedir=$(top_builddir)/gir $< -o $@
%.tgir.check: %.tgir
- @diff -u -U 10 $(srcdir)/$*-expected.tgir $*.tgir && echo "* $*.tgir"
+ @diff -u -U 10 $(srcdir)/$*-expected.tgir $*.tgir; \
+ if test "$$?" = "0"; then \
+ echo "* $*.tgir"; \
+ rm -f $*.tgir; \
+ fi
check-local: pre-check
check-local: $(CHECKGIRS) $(CHECKTGIRS) $(TYPELIBS)
-CLEANFILES += $(TGIRS)
check-local: post-check
</parameter>
</parameters>
</function>
+ <enumeration name="Error"
+ glib:type-name="FooError"
+ glib:get-type="foo_error_get_type"
+ c:type="FooError"
+ glib:error-quark="foo_error_quark">
+ <member name="good"
+ value="0"
+ c:identifier="FOO_ERROR_GOOD"
+ glib:nick="good"/>
+ <member name="bad"
+ value="1"
+ c:identifier="FOO_ERROR_BAD"
+ glib:nick="bad"/>
+ <member name="ugly"
+ value="2"
+ c:identifier="FOO_ERROR_UGLY"
+ glib:nick="ugly"/>
+ </enumeration>
<constant name="SUCCESS_INT" value="4408">
<type name="int"/>
</constant>
</parameter>
</parameters>
</function>
+ <enumeration name="Error" glib:type-name="FooError" glib:get-type="foo_error_get_type">
+ <member name="good" value="0"/>
+ <member name="bad" value="1"/>
+ <member name="ugly" value="2"/>
+ </enumeration>
<constant name="SUCCESS_INT" value="4408">
<type name="int"/>
</constant>
return our_type;
}
+GType
+foo_error_get_type (void)
+{
+ static GType etype = 0;
+ if (G_UNLIKELY(etype == 0)) {
+ static const GEnumValue values[] = {
+ { FOO_ERROR_GOOD, "FOO_ERROR_GOOD", "good" },
+ { FOO_ERROR_BAD, "FOO_ERROR_BAD", "bad" },
+ { FOO_ERROR_UGLY, "FOO_ERROR_UGLY", "ugly" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static (g_intern_static_string ("FooError"), values);
+ }
+ return etype;
+}
+
+GQuark
+foo_error_quark (void)
+{
+ return g_quark_from_static_string ("foo-error-quark");
+}
+
void foo_test_const_char_param (const char * param);
void foo_test_const_struct_param (const FooStruct * param);
+typedef enum {
+ FOO_ERROR_GOOD,
+ FOO_ERROR_BAD,
+ FOO_ERROR_UGLY
+} FooError;
+GType foo_error_get_type (void);
+
+GQuark foo_error_quark (void);
+
#endif /* __FOO_OBJECT_H__ */