[gobject-introspection] scanner: Fall back to searching all includes when uncertain
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] scanner: Fall back to searching all includes when uncertain
- Date: Tue, 7 Sep 2010 16:36:36 +0000 (UTC)
commit 2bba09d8304039551c841a9d7d75cbde45e3e804
Author: Colin Walters <walters verbum org>
Date: Tue Sep 7 12:34:16 2010 -0400
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.
giscanner/transformer.py | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index f78407a..8a80e23 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]