[gobject-introspection/wip/docs-3: 1/3] 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/wip/docs-3: 1/3] scanner: Synthesize argument names if we don't see one
- Date: Sat, 23 Feb 2013 22:57:31 +0000 (UTC)
commit cd6a3b65305c4ba09b0fe5bd64790768433b507f
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.
giscanner/transformer.py | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index d6a5f8f..44e3b62 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]