diff options
author | Colin Walters <walters@verbum.org> | 2010-09-09 15:09:39 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-09-09 15:09:39 -0400 |
commit | 79e0ea087341e09e4bbbbc77479a3e91fb824446 (patch) | |
tree | bfa6b0d966dc0c07cbea1eb57da26118b6c1b609 /giscanner | |
parent | a9dc0722ae291fc0644cebc9f2ec3bb61b0d9d87 (diff) |
scanner: Mark '_'-prefixed fields as introspectable=0
Typically these contain reserved callbacks; in any case we take
a leading underscore to mean 'private'.
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/maintransformer.py | 16 |
1 files changed, 16 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) |