summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-09-07 12:34:16 -0400
committerColin Walters <walters@verbum.org>2010-09-07 12:36:19 -0400
commit2bba09d8304039551c841a9d7d75cbde45e3e804 (patch)
treeab1e7d675f2dabc3889f46e269ce4a9d81e9821b
parent94c627ea578572bc91c596cae3624d241b1c1f99 (diff)
downloadgobject-introspection-2bba09d8304039551c841a9d7d75cbde45e3e804.tar.gz
scanner: Fall back to searching all includes when uncertain
The scanner by default tries hard to ensure that we know immediately from seeing an identifier "FooBarBaz" that the namespace is "Foo". But libraries using --accept-unprefixed here screws this over. Potentially we could add --unstripped-identifier-prefix, but it's ugly. The best long term fix is to fix the namespacing in the library.
-rw-r--r--giscanner/transformer.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index f78407a8..8a80e23f 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -731,13 +731,26 @@ Note that type resolution may not succeed."""
typeval.ctype = None
return typeval
+ def _resolve_type_from_ctype_all_namespaces(self, typeval, pointer_stripped):
+ # If we can't determine the namespace from the type name,
+ # fall back to trying all of our includes. An example of this is mutter,
+ # which has nominal namespace of "Meta", but a few classes are
+ # "Mutter". We don't export that data in introspection currently.
+ # Basically the library should be fixed, but we'll hack around it here.
+ for namespace in self._includes.itervalues():
+ target = namespace.get_by_ctype(pointer_stripped)
+ if target:
+ typeval.target_giname = '%s.%s' % (namespace.name, target.name)
+ return True
+ return False
+
def _resolve_type_from_ctype(self, typeval):
assert typeval.ctype is not None
pointer_stripped = typeval.ctype.replace('*', '')
try:
matches = self.split_ctype_namespaces(pointer_stripped)
except ValueError, e:
- return False
+ return self._resolve_type_from_ctype_all_namespaces(typeval, pointer_stripped)
target_giname = None
for namespace, name in matches:
target = namespace.get(name)