diff options
author | Johan Dahlin <jdahlin@async.com.br> | 2009-01-12 20:54:11 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2009-01-12 20:54:11 +0000 |
commit | 3e466d06a81200d7ff3a7958b8a5fea52caf5b12 (patch) | |
tree | 65478d6480126ce01e1f89774de57bed418e4d01 /giscanner | |
parent | a48cf353b4d2e056f80c7aaa4cabb3fe84648662 (diff) | |
download | gobject-introspection-3e466d06a81200d7ff3a7958b8a5fea52caf5b12.tar.gz |
Bug 566419 – Element type of arrays not properly handled in all cases
2009-01-12 Johan Dahlin <jdahlin@async.com.br>
Bug 566419 – Element type of arrays not properly handled in all cases
* giscanner/annotationparser.py:
* tests/scanner/annotation-1.0-expected.gir:
* tests/scanner/annotation-1.0-expected.tgir:
* tests/scanner/annotation.c (annotation_object_set_data),
(annotation_object_set_data2), (annotation_object_set_data3):
* tests/scanner/annotation.h:
Based on patch by Andreas Rottmann
svn path=/trunk/; revision=1019
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/annotationparser.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index 630508a9..89d4b334 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -329,7 +329,7 @@ class AnnotationApplier(object): parent, node, options) if container_type is not None: node.type = container_type - if not node.direction: + if node.direction is None: node.direction = self._guess_direction(node) node.transfer = self._extract_transfer(parent, node, options) if 'allow-none' in options: @@ -383,18 +383,34 @@ class AnnotationApplier(object): def _parse_array(self, parent, node, options): array_opt = options.get('array') if array_opt: - values = array_opt.all() + array_values = array_opt.all() else: - values = {} - container_type = Array(node.type.ctype, node.type.name) - if 'zero-terminated' in values: - container_type.zeroterminated = values.get( + array_values = {} + + element_type = options.get('element-type') + if element_type is not None: + element_type_name = element_type.one() + else: + element_type_name = node.type.name + + container_type = Array(node.type.ctype, + element_type_name) + if 'zero-terminated' in array_values: + container_type.zeroterminated = array_values.get( 'zero-terminated') == '1' - length = values.get('length') + length = array_values.get('length') if length is not None: param_index = parent.get_parameter_index(length) container_type.length_param_index = param_index - container_type.size = values.get('fized-size') + # For in parameters we're incorrectly deferring + # char/unsigned char to utf8 when a length annotation + # is specified. + if (isinstance(node, Parameter) and + node.type.name == 'utf8' and + self._guess_direction(node) == PARAM_DIRECTION_IN): + # FIXME: unsigned char/guchar should be uint8 + container_type.element_type = 'int8' + container_type.size = array_values.get('fized-size') return container_type def _parse_element_type(self, parent, node, options): |