summaryrefslogtreecommitdiff
path: root/giscanner/girwriter.py
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu.duponchelle@opencreed.com>2015-07-15 13:11:45 +0200
committerMathieu Duponchelle <mathieu@centricular.com>2019-07-19 01:21:38 +0200
commit0f3efc9058e2f249e84c02840fd96b6a413a9201 (patch)
treeea4628119b6573901c3426a16a74fced1c9c7822 /giscanner/girwriter.py
parenta62855702c3bc0b10370ef25d622a32e227283bd (diff)
downloadgobject-introspection-0f3efc9058e2f249e84c02840fd96b6a413a9201.tar.gz
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.
Diffstat (limited to 'giscanner/girwriter.py')
-rw-r--r--giscanner/girwriter.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 91875a2d..d1333cb7 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -90,6 +90,8 @@ class GIRWriter(XMLWriter):
def _write_node(self, node):
if isinstance(node, ast.Function):
self._write_function(node)
+ elif isinstance(node, ast.FunctionMacro):
+ self._write_function_macro(node)
elif isinstance(node, ast.Enum):
self._write_enum(node)
elif isinstance(node, ast.Bitfield):
@@ -222,6 +224,15 @@ class GIRWriter(XMLWriter):
attrs.append(('moved-to', func.moved_to))
self._write_callable(func, tag_name, attrs)
+ def _write_function_macro(self, macro):
+ attrs = [('name', macro.name),
+ ('c:identifier', macro.symbol)]
+ self._append_version(macro, attrs)
+ self._append_node_generic(macro, attrs)
+ with self.tagcontext('function-macro', attrs):
+ self._write_generic(macro)
+ self._write_untyped_parameters(macro)
+
def _write_method(self, method):
self._write_function(method, tag_name='method')
@@ -255,6 +266,20 @@ class GIRWriter(XMLWriter):
for parameter in callable.parameters:
self._write_parameter(callable, parameter)
+ def _write_untyped_parameters(self, macro):
+ if not macro.parameters:
+ return
+ with self.tagcontext('parameters'):
+ for parameter in macro.parameters:
+ self._write_untyped_parameter(macro, parameter)
+
+ def _write_untyped_parameter(self, macro, parameter):
+ attrs = []
+ if parameter.argname is not None:
+ attrs.append(('name', parameter.argname))
+ with self.tagcontext('parameter', attrs):
+ self._write_generic(parameter)
+
def _write_parameter(self, parent, parameter, nodename='parameter'):
attrs = []
if parameter.argname is not None: