From: Stef Walter Date: Wed, 10 Aug 2011 13:04:55 +0000 (+0200) Subject: Make the Transformer respect 'skip' annotations X-Git-Tag: GOBJECT_INTROSPECTION_1_29_17~83 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d19fcd098ed69d9216efbf68fc8ae4ba57d09638;p=platform%2Fupstream%2Fgobject-introspection.git Make the Transformer respect 'skip' annotations * In order to suppress unnecessary warnings on macros which are skipped at later passes of the scanning, we use the annotations to skip AST stuff being created for symbols that are skipped. --- diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py index eb081f4..52ee4cc 100644 --- a/giscanner/scannermain.py +++ b/giscanner/scannermain.py @@ -393,14 +393,15 @@ def scanner_main(args): ss = create_source_scanner(options, args) + ap = AnnotationParser() + blocks = ap.parse(ss.get_comments()) + # Transform the C symbols into AST nodes + transformer.set_annotations(blocks) transformer.parse(ss.get_symbols()) shlibs = create_binary(transformer, options, args) - ap = AnnotationParser() - blocks = ap.parse(ss.get_comments()) - main = MainTransformer(transformer, blocks) main.transform() diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 7db7982..6689fc7 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -54,6 +54,7 @@ class Transformer(object): self._include_names = set() # string namespace self._includepaths = [] self._passthrough_mode = False + self._annotations = {} def get_includes(self): return self._include_names @@ -67,6 +68,9 @@ class Transformer(object): def set_passthrough_mode(self): self._passthrough_mode = True + def set_annotations(self, annotations): + self._annotations = annotations + def _append_new_node(self, node): original = self._namespace.get(node.name) # Special case constants here; we allow duplication to sort-of @@ -313,7 +317,10 @@ raise ValueError.""" elif stype == CSYMBOL_TYPE_UNION: return self._create_union(symbol) elif stype == CSYMBOL_TYPE_CONST: - return self._create_const(symbol) + # Don't parse constants which are marked (skip) + docblock = self._annotations.get(symbol.ident) + if not docblock or not 'skip' in docblock.options: + return self._create_const(symbol) # Ignore variable declarations in the header elif stype == CSYMBOL_TYPE_OBJECT: pass