summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-11-16 11:54:46 -0500
committerColin Walters <walters@verbum.org>2010-11-16 11:54:46 -0500
commit70910a9b3235cedbcc42ef47e92a53341dc9e660 (patch)
tree89d744119c4c87ece02b98033c485e0b19f221ce
parente4b6098e55307f602c179f37d59fbc6d0d965267 (diff)
downloadgobject-introspection-70910a9b3235cedbcc42ef47e92a53341dc9e660.tar.gz
scanner: Fall back to default uscoring for method pairing if possible
The commit to use the c_symbol_prefix works in every case, except for gdk_window_object_get_type(), which screws us. Fall back to the old heuristic in this case.
-rw-r--r--giscanner/maintransformer.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index af98a14c..517ddb2d 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -915,16 +915,26 @@ method or constructor of some type."""
if first.type.ctype.count('*') != 1:
return False
+ # Here we check both the c_symbol_prefix and (if that fails),
+ # attempt to do a default uscoring of the type. The reason we
+ # look at a default underscore transformation is for
+ # gdk_window_object_get_type(), which says to us that the
+ # prefix is "gdk_window_object", when really it's just
+ # "gdk_window". Possibly need an annotation to override this.
+ prefix_matches = False
+ uscored_prefix = None
if hasattr(target, 'c_symbol_prefix') and target.c_symbol_prefix is not None:
- uscored = target.c_symbol_prefix
- else:
- uscored = self._uscored_identifier_for_type(first.type)
- if not subsymbol.startswith(uscored):
- return False
+ prefix_matches = subsymbol.startswith(target.c_symbol_prefix)
+ if prefix_matches:
+ uscored_prefix = target.c_symbol_prefix
+ if not prefix_matches:
+ uscored_prefix = self._uscored_identifier_for_type(first.type)
+ if not subsymbol.startswith(uscored_prefix):
+ return False
func.instance_parameter = func.parameters.pop(0)
subsym_idx = func.symbol.find(subsymbol)
self._namespace.float(func)
- func.name = func.symbol[(subsym_idx + len(uscored) + 1):]
+ func.name = func.symbol[(subsym_idx + len(uscored_prefix) + 1):]
target.methods.append(func)
func.is_method = True
return True