+2008-10-06 Colin Walters <walters@verbum.org>
+
+ * giscanner/transformer.py: Parse length= annotation as
+ a parameter name, not a raw int.
+ * tests/*: Update.
+
2008-10-03 Colin Walters <walters@verbum.org>
Bug 551744: Non-GObject types aren't aggregating ctors and methods
# No version, just include str
node.deprecated = deprecated_value.strip()
+ def _pair_array(self, params, array):
+ if not array.type.length_param_name:
+ return
+ target_name = array.type.length_param_name
+ for i, param in enumerate(params):
+ if param.name == array.type.length_param_name:
+ array.type.length_param_index = i
+ return
+ raise ValueError("Unmatched length parameter name %r"\
+ % (target_name, ))
+
+ def _pair_annotations(self, params):
+ names = {}
+ for param in params:
+ if param.name in names:
+ raise ValueError("Duplicate parameter name %r"\
+ % (param.name, ))
+ names[param.name] = 1
+ if isinstance(param.type, Array):
+ self._pair_array(params, param)
+
def _create_function(self, symbol):
directives = symbol.directives()
parameters = list(self._create_parameters(
symbol.base_type, directives))
+ self._pair_annotations(parameters)
return_ = self._create_return(symbol.base_type.base_type,
directives.get('return', []))
name = self._strip_namespace_func(symbol.ident)
elif option == 'notransfer':
param.transfer = False
elif isinstance(ptype, Array) and option.startswith('length'):
- (_, index) = option.split('=')
- ptype.length_param_index = int(index)
+ (_, index_param) = option.split('=')
+ ptype.length_param_name = index_param
elif option == 'allow-none':
param.allow_none = True
else:
/**
* annotation_object_compute_sum_n:
* @object: a #GObject
- * @nums: <array,length=2>: Sequence of numbers
- * @nums: Length of number array
+ * @nums: <array,length=n_nums>: Sequence of numbers
+ * @n_nums: Length of number array
*
* Test taking an array with length parameter
**/