gobject-introspection r659 - in trunk: . giscanner tests/scanner
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r659 - in trunk: . giscanner tests/scanner
- Date: Mon, 6 Oct 2008 18:58:46 +0000 (UTC)
Author: walters
Date: Mon Oct 6 18:58:46 2008
New Revision: 659
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=659&view=rev
Log:
Parse length= annotation as a parameter name, not a raw int.
Modified:
trunk/ChangeLog
trunk/giscanner/ast.py
trunk/giscanner/transformer.py
trunk/tests/scanner/annotation.c
Modified: trunk/giscanner/ast.py
==============================================================================
--- trunk/giscanner/ast.py (original)
+++ trunk/giscanner/ast.py Mon Oct 6 18:58:46 2008
@@ -182,6 +182,7 @@
self.element_type = element_type
self.zeroterminated = True
self.length_param_index = -1
+ self.length_param_name = None
def __repr__(self):
return 'Array(%r of %r)' % (self.name, self.element_type, )
Modified: trunk/giscanner/transformer.py
==============================================================================
--- trunk/giscanner/transformer.py (original)
+++ trunk/giscanner/transformer.py Mon Oct 6 18:58:46 2008
@@ -235,10 +235,32 @@
# 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)
@@ -370,8 +392,8 @@
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:
Modified: trunk/tests/scanner/annotation.c
==============================================================================
--- trunk/tests/scanner/annotation.c (original)
+++ trunk/tests/scanner/annotation.c Mon Oct 6 18:58:46 2008
@@ -229,8 +229,8 @@
/**
* 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
**/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]