[gobject-introspection] scanner: Mark '_'-prefixed fields as introspectable=0
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] scanner: Mark '_'-prefixed fields as introspectable=0
- Date: Thu, 9 Sep 2010 19:10:32 +0000 (UTC)
commit 79e0ea087341e09e4bbbbc77479a3e91fb824446
Author: Colin Walters <walters verbum org>
Date: Thu Sep 9 15:09:39 2010 -0400
scanner: Mark '_'-prefixed fields as introspectable=0
Typically these contain reserved callbacks; in any case we take
a leading underscore to mean 'private'.
giscanner/maintransformer.py | 16 ++++++++++++++++
tests/scanner/Regress-1.0-expected.gir | 14 ++++++++++++++
tests/scanner/regress.h | 4 ++++
3 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index a60b9bb..33d301b 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -55,6 +55,9 @@ class MainTransformer(object):
alias = ast.Alias('AttributeSet', target=ast.TYPE_ANY)
self._namespace.append(alias, replace=True)
+ # Some initial namespace surgery
+ self._namespace.walk(self._pass_fixup_hidden_fields)
+
# We have a rough tree which should have most of of the types
# we know about. Let's attempt closure; walk over all of the
# Type() types and see if they match up with something.
@@ -99,6 +102,19 @@ class MainTransformer(object):
# Private
+ def _pass_fixup_hidden_fields(self, node, chain):
+ """Hide all callbacks starting with _; the typical
+usage is void (*_gtk_reserved1)(void);"""
+ if not isinstance(node, (ast.Class, ast.Interface,
+ ast.Record, ast.Union)):
+ return True
+ for field in node.fields:
+ if (field.name.startswith('_')
+ and field.anonymous_node is not None
+ and isinstance(field.anonymous_node, ast.Callback)):
+ field.introspectable = False
+ return True
+
def _get_validate_parameter_name(self, parent, param_name, origin):
try:
param = parent.get_parameter(param_name)
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 6ae7172..7831411 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -629,6 +629,20 @@ case.</doc>
<field name="test_signal_with_static_scope_arg">
<type name="guint" c:type="guint"/>
</field>
+ <field name="_regress_reserved1" introspectable="0">
+ <callback name="_regress_reserved1">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ </callback>
+ </field>
+ <field name="_regress_reserved2" introspectable="0">
+ <callback name="_regress_reserved2">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ </callback>
+ </field>
</record>
<record name="TestSimpleBoxedA"
c:type="RegressTestSimpleBoxedA"
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 8140d88..9887758 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -291,6 +291,10 @@ struct _RegressTestObjClass
guint test_signal;
guint test_signal_with_static_scope_arg;
+
+ /* Should be replaced with simple "gpointer" and not be callback */
+ void (*_regress_reserved1) (void);
+ void (*_regress_reserved2) (void);
};
GType regress_test_obj_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]