From e49301ebd157057864dbd98dae558a3e7c6c4e9b Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Fri, 25 Sep 2020 16:33:46 +0100 Subject: [PATCH] codegen: Make "output_attrs" variable global Allows to reuse it. Signed-off-by: Frediano Ziglio Acked-by: Victor Toso --- python_modules/ptypes.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py index eba26a6..91bd0cd 100644 --- a/python_modules/ptypes.py +++ b/python_modules/ptypes.py @@ -86,6 +86,16 @@ attributes_with_arguments=set([ 'virtual', ]) +# these attributes specify output format, only one can be set +output_attributes = set([ + 'end', + 'to_ptr', + 'as_ptr', + 'ptr_array', + 'zero', + 'chunk', +]) + def fix_attributes(attribute_list, valid_attributes=valid_attributes_generic): attrs = {} for attr in attribute_list: @@ -100,9 +110,8 @@ def fix_attributes(attribute_list, valid_attributes=valid_attributes_generic): raise Exception("Attribute %s has more than 1 argument" % name) attrs[name] = lst - # these attributes specify output format, only one can be set - output_attrs = set(['end', 'to_ptr', 'as_ptr', 'ptr_array', 'zero', 'chunk']) - if len(output_attrs.intersection(attrs.keys())) > 1: + # only one output attribute can be set + if len(output_attributes.intersection(attrs.keys())) > 1: raise Exception("Multiple output type attributes specified %s" % output_attrs) return attrs