[gobject-introspection] scanner: Automatically skip callables which contain a skipped node
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] scanner: Automatically skip callables which contain a skipped node
- Date: Tue, 7 Sep 2010 19:16:48 +0000 (UTC)
commit 7b4425d68f9fc8e7d798af1539e71d88530ad944
Author: Colin Walters <walters verbum org>
Date: Tue Sep 7 15:13:06 2010 -0400
scanner: Automatically skip callables which contain a skipped node
For legacy library author convenience, propagate (skip) on e.g.
structures to all callables which use them.
giscanner/introspectablepass.py | 19 +++++++++++++++++++
tests/scanner/Regress-1.0-expected.gir | 30 ++++++++++++++++++++++++++++++
tests/scanner/regress.h | 16 ++++++++++++++++
3 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index 6653c09..290f1d2 100644
--- a/giscanner/introspectablepass.py
+++ b/giscanner/introspectablepass.py
@@ -30,6 +30,7 @@ class IntrospectablePass(object):
# Public API
def validate(self):
+ self._namespace.walk(self._propagate_callable_skips)
self._namespace.walk(self._analyze_node)
self._namespace.walk(self._introspectable_callable_analysis)
self._namespace.walk(self._introspectable_callable_analysis)
@@ -143,6 +144,24 @@ class IntrospectablePass(object):
return False
return target.introspectable and (not target.skip)
+ def _propagate_parameter_skip(self, parent, node):
+ if node.type.target_giname is not None:
+ target = self._transformer.lookup_typenode(node.type)
+ if target is None:
+ return
+ else:
+ return
+
+ if target.skip:
+ parent.skip = True
+
+ def _propagate_callable_skips(self, obj, stack):
+ if isinstance(obj, ast.Callable):
+ for param in obj.parameters:
+ self._propagate_parameter_skip(obj, param)
+ self._propagate_parameter_skip(obj, obj.retval)
+ return True
+
def _analyze_node(self, obj, stack):
if obj.skip:
return False
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 8067b12..3fce12b 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -15,6 +15,18 @@ and/or use gtk-doc annotations. -->
shared-library="libregress.so"
c:identifier-prefixes="Regress"
c:symbol-prefixes="regress">
+ <record name="SkippedStructure"
+ c:type="RegressSkippedStructure"
+ introspectable="0">
+ <doc xml:whitespace="preserve">This should be skipped, and moreover, all function which
+use it should be.</doc>
+ <field name="x" writable="1">
+ <type name="gint" c:type="int"/>
+ </field>
+ <field name="v" writable="1">
+ <type name="gdouble" c:type="double"/>
+ </field>
+ </record>
<record name="TestBoxed"
c:type="RegressTestBoxed"
glib:type-name="RegressTestBoxed"
@@ -831,6 +843,24 @@ case.</doc>
</parameter>
</parameters>
</function>
+ <function name="random_function_with_skipped_structure"
+ c:identifier="regress_random_function_with_skipped_structure"
+ introspectable="0">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="x" transfer-ownership="none">
+ <type name="gint" c:type="int"/>
+ </parameter>
+ <parameter name="foo" transfer-ownership="none">
+ <type name="SkippedStructure" c:type="RegressSkippedStructure*"/>
+ </parameter>
+ <parameter name="v" transfer-ownership="none">
+ <type name="gdouble" c:type="double"/>
+ </parameter>
+ </parameters>
+ </function>
<function name="set_abort_on_error"
c:identifier="regress_set_abort_on_error">
<return-value transfer-ownership="none">
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index a1b48f2..6fed4ca 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -508,4 +508,20 @@ void regress_test_torture_signature_2 (int x,
GValue *regress_test_date_in_gvalue (void);
GValue *regress_test_strv_in_gvalue (void);
+/**
+ * RegressSkippedStructure: (skip)
+ *
+ * This should be skipped, and moreover, all function which
+ * use it should be.
+ */
+typedef struct
+{
+ int x;
+ double v;
+} RegressSkippedStructure;
+
+void regress_random_function_with_skipped_structure (int x,
+ RegressSkippedStructure *foo,
+ double v);
+
#endif /* __GITESTTYPES_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]