diff options
author | Kristian H. Kristensen <[email protected]> | 2016-11-29 21:07:57 -0800 |
---|---|---|
committer | Kristian H. Kristensen <[email protected]> | 2017-11-21 11:15:06 -0800 |
commit | 24609377f97f541197fe88bd5de3327faa926f57 (patch) | |
tree | d3666017045589d244e5da754376ce0909f81cd6 /src | |
parent | beaea7abfa9f25460284f739fa50050a889ce6cd (diff) |
intel/genxml: Add helpers for determining field type
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/genxml/gen_pack_header.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/intel/genxml/gen_pack_header.py b/src/intel/genxml/gen_pack_header.py index 405f600174d..1a5d193d228 100644 --- a/src/intel/genxml/gen_pack_header.py +++ b/src/intel/genxml/gen_pack_header.py @@ -247,6 +247,17 @@ class Field(object): self.type = 'sfixed' self.fractional_size = int(sfixed_match.group(2)) + def is_builtin_type(self): + builtins = [ 'address', 'bool', 'float', 'ufixed', + 'offset', 'sfixed', 'offset', 'int', 'uint', 'mbo' ] + return self.type in builtins + + def is_struct_type(self): + return self.type in self.parser.structs + + def is_enum_type(self): + return self.type in self.parser.enums + def emit_template_struct(self, dim): if self.type == 'address': type = '__gen_address_type' @@ -266,9 +277,9 @@ class Field(object): type = 'int32_t' elif self.type == 'uint': type = 'uint32_t' - elif self.type in self.parser.structs: + elif self.is_struct_type(): type = 'struct ' + self.parser.gen_prefix(safe_name(self.type)) - elif self.type in self.parser.enums: + elif self.is_enum_type(): type = 'enum ' + self.parser.gen_prefix(safe_name(self.type)) elif self.type == 'mbo': return @@ -387,7 +398,7 @@ class Group(object): if len(dw.fields) == 1: field = dw.fields[0] name = field.name + field.dim - if field.type in self.parser.structs and field.start % 32 == 0: + if field.is_struct_type() and field.start % 32 == 0: print("") print(" %s_pack(data, &dw[%d], &values->%s);" % (self.parser.gen_prefix(safe_name(field.type)), index, name)) @@ -397,7 +408,7 @@ class Group(object): # to the dword for those fields. field_index = 0 for field in dw.fields: - if type(field) is Field and field.type in self.parser.structs: + if type(field) is Field and field.is_struct_type(): name = field.name + field.dim print("") print(" uint32_t v%d_%d;" % (index, field_index)) @@ -435,7 +446,7 @@ class Group(object): elif field.type == "uint": non_address_fields.append("__gen_uint(values->%s, %d, %d)" % \ (name, field.start - dword_start, field.end - dword_start)) - elif field.type in self.parser.enums: + elif field.is_enum_type(): non_address_fields.append("__gen_uint(values->%s, %d, %d)" % \ (name, field.start - dword_start, field.end - dword_start)) elif field.type == "int": @@ -455,7 +466,7 @@ class Group(object): elif field.type == 'sfixed': non_address_fields.append("__gen_sfixed(values->%s, %d, %d, %d)" % \ (name, field.start - dword_start, field.end - dword_start, field.fractional_size)) - elif field.type in self.parser.structs: + elif field.is_struct_type(): non_address_fields.append("__gen_uint(v%d_%d, %d, %d)" % \ (index, field_index, field.start - dword_start, field.end - dword_start)) field_index = field_index + 1 |