From: José Fonseca Date: Wed, 24 Nov 2010 16:42:52 +0000 (+0000) Subject: Handle arrays better. X-Git-Url: https://git.cworth.org/git?p=apitrace;a=commitdiff_plain;h=e89a8004d76ff8b743446057475c5855bb5f1e1e Handle arrays better. --- diff --git a/helpers/spec.py b/helpers/spec.py index 7c4e5c2..c4f2df5 100755 --- a/helpers/spec.py +++ b/helpers/spec.py @@ -182,25 +182,29 @@ class SpecParser(LineParser): extra += ', sideeffects=False' print ' %s(%s, "%s%s", [%s]%s),' % (constructor, ret_type, self.prefix, function_name, ', '.join(args), extra) + array_re = re.compile(r'^array\s+\[(.*)\]$') + def parse_arg(self, arg_name, arg_type): base_type, inout, kind = arg_type.split(' ', 2) base_type = self.parse_type(base_type) + if kind == 'value': arg_type = base_type elif kind == 'reference': + arg_type = 'Pointer(%s)' % base_type if inout == 'in': - arg_type = 'Const(Pointer(%s))' % base_type - elif inout == 'out': - arg_type = 'Pointer(%s)' % base_type - else: - assert False + arg_type = 'Const(%s)' % arg_type elif kind.startswith("array"): - if inout == 'in': - arg_type = 'Const(Array(%s))' % base_type - elif inout == 'out': - arg_type = 'Array(%s)' % base_type + mo = self.array_re.match(kind) + if mo: + length = mo.group(1) + arg_type = 'Array(%s, "%s")' % (base_type, length) else: - assert False + arg_type = 'OpaquePointer(%s)' % base_type + if inout == 'in': + arg_type = 'Const(%s)' % arg_type + else: + assert False arg = '(%s, "%s")' % (arg_type, arg_name) if inout == 'out':