From 0f3efc9058e2f249e84c02840fd96b6a413a9201 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 15 Jul 2015 13:11:45 +0200 Subject: scanner: parse and expose function macros This is useful for documentation tools, and other utilities that rely on full introspection of the C API of a given library. --- giscanner/maintransformer.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'giscanner/maintransformer.py') diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index e1536b93..9468751d 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -176,6 +176,16 @@ class MainTransformer(object): block = self._blocks.get(node.symbol) self._apply_annotations_callable(node, chain, block) + def _apply_annotations_function_macro(self, node, chain): + block = self._blocks.get(node.symbol) + for param in node.parameters: + if block: + doc_param = block.params.get(param.argname) + if doc_param: + param.doc = doc_param.description + param.doc_position = doc_param.position + self._apply_annotations_annotated(node, block) + def _pass_read_annotations_early(self, node, chain): if isinstance(node, ast.Record): if node.ctype is not None: @@ -215,6 +225,8 @@ class MainTransformer(object): self._apply_annotations_alias(node, chain) if isinstance(node, ast.Function): self._apply_annotations_function(node, chain) + if isinstance(node, ast.FunctionMacro): + self._apply_annotations_function_macro(node, chain) if isinstance(node, ast.Callback): self._apply_annotations_callable(node, chain, block=self._get_block(node)) if isinstance(node, (ast.Class, ast.Interface, ast.Union, ast.Enum, -- cgit v1.2.1