diff options
author | Colin Walters <walters@verbum.org> | 2013-02-23 16:41:10 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2013-02-26 16:25:10 -0500 |
commit | f7619e7452850fa8e92b5a560c8919c012002c1b (patch) | |
tree | a8b5a8b949840b41e393f67ab0e4623dc2f942a6 /giscanner | |
parent | 9faf4b4e9eac13ceb9d8c214554d5ee2a384dc28 (diff) | |
download | gobject-introspection-f7619e7452850fa8e92b5a560c8919c012002c1b.tar.gz |
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
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/transformer.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py index d6a5f8f9..e05249c3 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) |