[gobject-introspection] scanner: Synthesize argument names if we don't see one
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] scanner: Synthesize argument names if we don't see one
- Date: Tue, 26 Feb 2013 21:25:28 +0000 (UTC)
commit f7619e7452850fa8e92b5a560c8919c012002c1b
Author: Colin Walters <walters verbum org>
Date: Sat Feb 23 16:41:10 2013 -0500
scanner: Synthesize argument names if we don't see one
While this is a bit lame, we need to do something. We preserve the
warning message.
https://bugzilla.gnome.org/show_bug.cgi?id=694593
giscanner/transformer.py | 16 ++++++++++------
.../Regress.FooObject.take_all.page | 2 +-
tests/scanner/Regress-1.0-expected.gir | 4 ++--
tests/scanner/WarnLib-1.0-expected.gir | 12 ++++++------
4 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index d6a5f8f..e05249c 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -481,8 +481,8 @@ raise ValueError."""
def _create_parameters(self, symbol, base_type):
# warn if we see annotations for unknown parameters
param_names = set(child.ident for child in base_type.child_list)
- for child in base_type.child_list:
- yield self._create_parameter(symbol, child)
+ for i, child in enumerate(base_type.child_list):
+ yield self._create_parameter(symbol, i, child)
def _synthesize_union_type(self, symbol, parent_symbol):
# Synthesize a named union so that it can be referenced.
@@ -695,16 +695,20 @@ raise ValueError."""
return container
return ast.Type(ctype=ctype, is_const=is_const, complete_ctype=complete_ctype)
- def _create_parameter(self, parent_symbol, symbol):
+ def _create_parameter(self, parent_symbol, index, symbol):
if symbol.type == CSYMBOL_TYPE_ELLIPSIS:
ptype = ast.Varargs()
else:
ptype = self._create_type_from_base(symbol.base_type, is_parameter=True)
- if symbol.ident is None and symbol.base_type and symbol.base_type.type != CTYPE_VOID:
- message.warn_symbol(parent_symbol, "missing parameter name; undocumentable")
+ if symbol.ident is None:
+ if symbol.base_type and symbol.base_type.type != CTYPE_VOID:
+ message.warn_symbol(parent_symbol, "missing parameter name; undocumentable")
+ ident = 'arg%d' % (index, )
+ else:
+ ident = symbol.ident
- return ast.Parameter(symbol.ident, ptype)
+ return ast.Parameter(ident, ptype)
def _create_return(self, source_type):
typeval = self._create_type_from_base(source_type, is_return=True)
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooObject.take_all.page
b/tests/scanner/Regress-1.0-C-expected/Regress.FooObject.take_all.page
index 649824f..3947b3c 100644
--- a/tests/scanner/Regress-1.0-C-expected/Regress.FooObject.take_all.page
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooObject.take_all.page
@@ -49,7 +49,7 @@ void regress_foo_object_take_all (RegressFooObject* object,
</item>
<item>
-<title><code>None</code></title>
+<title><code>arg2</code></title>
</item>
<item>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index b238631..a957824 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -1472,7 +1472,7 @@ uses a C sugar return type.</doc>
<parameter name="x" transfer-ownership="none">
<type name="gint" c:type="int"/>
</parameter>
- <parameter transfer-ownership="none">
+ <parameter name="arg2" transfer-ownership="none">
<varargs>
</varargs>
</parameter>
@@ -1902,7 +1902,7 @@ exposed to language bindings.</doc>
<parameter name="param" transfer-ownership="none">
<type name="utf8" c:type="const char*"/>
</parameter>
- <parameter transfer-ownership="none">
+ <parameter name="arg1" transfer-ownership="none">
<varargs>
</varargs>
</parameter>
diff --git a/tests/scanner/WarnLib-1.0-expected.gir b/tests/scanner/WarnLib-1.0-expected.gir
index 3f8be71..e4a9a9b 100644
--- a/tests/scanner/WarnLib-1.0-expected.gir
+++ b/tests/scanner/WarnLib-1.0-expected.gir
@@ -29,10 +29,10 @@ and/or use gtk-doc annotations. -->
<instance-parameter name="self" transfer-ownership="none">
<type name="Whatever" c:type="WarnLibWhatever*"/>
</instance-parameter>
- <parameter transfer-ownership="none">
+ <parameter name="arg1" transfer-ownership="none">
<type name="gint" c:type="int"/>
</parameter>
- <parameter transfer-ownership="none">
+ <parameter name="arg2" transfer-ownership="none">
<type name="gpointer" c:type="gpointer"/>
</parameter>
</parameters>
@@ -45,10 +45,10 @@ and/or use gtk-doc annotations. -->
<instance-parameter name="self" transfer-ownership="none">
<type name="Whatever" c:type="WarnLibWhatever*"/>
</instance-parameter>
- <parameter transfer-ownership="none">
+ <parameter name="arg1" transfer-ownership="none">
<type name="gint" c:type="int"/>
</parameter>
- <parameter transfer-ownership="none">
+ <parameter name="arg2" transfer-ownership="none">
<type name="gpointer" c:type="gpointer"/>
</parameter>
</parameters>
@@ -69,10 +69,10 @@ and/or use gtk-doc annotations. -->
<parameter name="self" transfer-ownership="none">
<type name="Whatever" c:type="WarnLibWhatever*"/>
</parameter>
- <parameter transfer-ownership="none">
+ <parameter name="arg1" transfer-ownership="none">
<type name="gint" c:type="int"/>
</parameter>
- <parameter transfer-ownership="none">
+ <parameter name="arg2" transfer-ownership="none">
<type name="gpointer" c:type="gpointer"/>
</parameter>
</parameters>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]