From 7a0de29433983f36e612da08c0b1b9519df993a8 Mon Sep 17 00:00:00 2001 From: Andreas Hartmetz Date: Tue, 9 Jul 2013 22:38:29 +0200 Subject: [PATCH] Allow a custom terminator and support valueless keys better. --- specs/stdapi.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/specs/stdapi.py b/specs/stdapi.py index 5d5d570..88711e1 100644 --- a/specs/stdapi.py +++ b/specs/stdapi.py @@ -272,7 +272,7 @@ class Array(Type): class AttribArray(Type): - def __init__(self, keyType, valueTypes, isConst = True): + def __init__(self, keyType, valueTypes, isConst = True, terminator = '0'): if isConst: Type.__init__(self, (Pointer(Const(Int))).expr) else: @@ -280,6 +280,11 @@ class AttribArray(Type): self.type = (Pointer(Const(Int))) # for function prototypes and such self.keyType = keyType self.valueTypes = valueTypes + self.terminator = terminator + self.hasKeysWithoutValues = False + for key, value in valueTypes: + if value is None: + self.hasKeysWithoutValues = True def visit(self, visitor, *args, **kwargs): return visitor.visitAttribArray(self, *args, **kwargs) @@ -796,7 +801,8 @@ class Traverser(Visitor): def visitAttribArray(self, attribs, *args, **kwargs): for key, valueType in attribs.valueTypes: - self.visit(valueType, *args, **kwargs) + if valueType is not None: + self.visit(valueType, *args, **kwargs) def visitBlob(self, array, *args, **kwargs): pass -- 2.43.0