From 951e7f9f02be67e17a06bb62473a7055942af30c Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 25 Aug 2008 13:21:53 +0000 Subject: [PATCH] More correctly pair methods; if we have a symbol that starts with e.g. 2008-08-25 Colin Walters * giscanner/glibtransformer.py: More correctly pair methods; if we have a symbol that starts with e.g. hippo_canvas look for a matching HippoCanvas class before accepting e.g. HippoCanvasImage. svn path=/trunk/; revision=490 --- ChangeLog | 7 +++++++ giscanner/glibtransformer.py | 32 ++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1122cbaa..19f7fa6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-08-25 Colin Walters + + * giscanner/glibtransformer.py: More correctly pair + methods; if we have a symbol that starts with + e.g. hippo_canvas look for a matching HippoCanvas + class before accepting e.g. HippoCanvasImage. + 2008-08-24 Colin Walters * tools/g-ir-scanner: Filter out unknown options from diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py index ca5296e7..ca9fc574 100644 --- a/giscanner/glibtransformer.py +++ b/giscanner/glibtransformer.py @@ -248,6 +248,11 @@ class GLibTransformer(object): return self._parse_method_common(func, False) def _parse_method_common(self, func, is_method): + # Skip _get_type functions, we processed them + # already + if func.symbol.endswith('_get_type'): + return None + if not is_method: target_arg = func.retval else: @@ -278,15 +283,24 @@ class GLibTransformer(object): prefix = func.symbol[:new_idx] klass = None - for key in self._uscore_type_names: - klass = None - if key.startswith(prefix): - klass = self._uscore_type_names.get(key) - if (klass is not None and - isinstance(klass, (GLibObject, GLibBoxed, - GLibInterface))): - break + def valid_matching_klass(tclass): + return (tclass is not None and + isinstance(tclass, (GLibObject, GLibBoxed, + GLibInterface)) and + not isinstance(tclass, GLibEnum)) + + # First look for an exact match; + klass = self._uscore_type_names.get(prefix) + # Now try searching for a prefix as a last resort + if klass is None or not valid_matching_klass(klass): + for key in self._uscore_type_names: + klass = None + if key.startswith(prefix): + klass = self._uscore_type_names.get(key) + if valid_matching_klass(klass): + break + # Enums can't have ctors or methods if klass is None: return @@ -646,9 +660,11 @@ class GLibTransformer(object): self._validating = True while True: initlen = len(nodes) + def count_type(otype): return len([x for x in nodes if isinstance(x[1], otype)]) + objectcount = count_type(GLibObject) ifacecount = count_type(GLibInterface) enumcount = count_type(GLibEnum) -- 2.34.1