diff options
-rw-r--r-- | giscanner/ast.py | 1 | ||||
-rw-r--r-- | giscanner/girparser.py | 1 | ||||
-rw-r--r-- | giscanner/girwriter.py | 2 | ||||
-rw-r--r-- | giscanner/introspectablepass.py | 10 | ||||
-rw-r--r-- | giscanner/maintransformer.py | 6 | ||||
-rw-r--r-- | tests/scanner/Foo-1.0-expected.gir | 4 | ||||
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 3 |
7 files changed, 22 insertions, 5 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index 8ca3a4dd..252c86b4 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -569,6 +569,7 @@ class Function(Callable): self.is_constructor = False self.shadowed_by = None # C symbol string self.shadows = None # C symbol string + self.moved_to = None # namespaced function name string def clone(self): clone = copy.copy(self) diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 51de1b15..41e2abda 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -303,6 +303,7 @@ class GIRParser(object): func.shadows = node.attrib.get('shadows', None) func.shadowed_by = node.attrib.get('shadowed-by', None) + func.moved_to = node.attrib.get('moved-to', None) parameters_node = node.find(_corens('parameters')) if (parameters_node is not None): diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index b3b74357..ce173fd4 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -178,6 +178,8 @@ and/or use gtk-doc annotations. ''') attrs.append(('shadowed-by', func.shadowed_by)) elif func.shadows: attrs.append(('shadows', func.shadows)) + if func.moved_to is not None: + attrs.append(('moved-to', func.moved_to)) self._write_callable(func, tag_name, attrs) def _write_method(self, method): diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py index 36d70b20..ebb1dedc 100644 --- a/giscanner/introspectablepass.py +++ b/giscanner/introspectablepass.py @@ -37,6 +37,7 @@ class IntrospectablePass(object): self._namespace.walk(self._introspectable_callable_analysis) self._namespace.walk(self._introspectable_callable_analysis) self._namespace.walk(self._introspectable_pass3) + self._namespace.walk(self._remove_non_reachable_backcompat_copies) def _parameter_warning(self, parent, param, text, position=None): # Suppress VFunctions and Callbacks warnings for now @@ -221,3 +222,12 @@ class IntrospectablePass(object): for sig in obj.signals: self._introspectable_callable_analysis(sig, [obj]) return True + + def _remove_non_reachable_backcompat_copies(self, obj, stack): + if obj.skip: + return False + if (isinstance(obj, ast.Function) + and not obj.introspectable + and obj.moved_to is not None): + self._namespace.remove(obj) + return True diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 40dda294..1d26bf18 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -1016,9 +1016,9 @@ method or constructor of some type.""" new_func = func.clone() new_func.name = funcname node.static_methods.append(new_func) - # TODO: flag func as a backwards-comptability kludge (and maybe - # prune it in the introspectable pass if we would have - # introspectable=0 anyway). + # flag the func as a backwards-comptability kludge (thus it will + # get pruned in the introspectable pass if introspectable=0). + func.moved_to = node.name + '.' + new_func.name return True return False diff --git a/tests/scanner/Foo-1.0-expected.gir b/tests/scanner/Foo-1.0-expected.gir index 950648dc..06d15c36 100644 --- a/tests/scanner/Foo-1.0-expected.gir +++ b/tests/scanner/Foo-1.0-expected.gir @@ -985,7 +985,8 @@ exposed to language bindings.</doc> </return-value> </function> <function name="interface_static_method" - c:identifier="foo_interface_static_method"> + c:identifier="foo_interface_static_method" + moved-to="Interface.static_method"> <return-value transfer-ownership="none"> <type name="none" c:type="void"/> </return-value> @@ -1017,6 +1018,7 @@ exposed to language bindings.</doc> </function> <function name="rectangle_new" c:identifier="foo_rectangle_new" + moved-to="Rectangle.new" introspectable="0"> <doc xml:whitespace="preserve">This is a C convenience constructor; we have to (skip) it because it's not a boxed type.</doc> diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index 9b4ae8f8..33ceeaec 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -2372,7 +2372,8 @@ You will give me your credit card number.</doc> </parameters> </function> <function name="test_simple_boxed_a_const_return" - c:identifier="regress_test_simple_boxed_a_const_return"> + c:identifier="regress_test_simple_boxed_a_const_return" + moved-to="TestSimpleBoxedA.const_return"> <return-value transfer-ownership="none"> <type name="TestSimpleBoxedA" c:type="RegressTestSimpleBoxedA*"/> </return-value> |