[Mesa-dev] [PATCH 1/4] gen_pack_header: Add helpers for determining field type
Kristian H. Kristensen
hoegsberg at gmail.com
Wed Nov 30 06:06:39 UTC 2016
Signed-off-by: Kristian H. Kristensen <hoegsberg at gmail.com>
---
src/intel/genxml/gen_pack_header.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/intel/genxml/gen_pack_header.py b/src/intel/genxml/gen_pack_header.py
index 1024745..001ad17 100644
--- a/src/intel/genxml/gen_pack_header.py
+++ b/src/intel/genxml/gen_pack_header.py
@@ -246,6 +246,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'
@@ -265,9 +276,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
@@ -381,7 +392,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))
@@ -391,7 +402,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))
@@ -428,7 +439,7 @@ class Group(object):
elif field.type == "uint":
s = "__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():
s = "__gen_uint(values->%s, %d, %d)" % \
(name, field.start - dword_start, field.end - dword_start)
elif field.type == "int":
@@ -448,7 +459,7 @@ class Group(object):
elif field.type == 'sfixed':
s = "__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():
s = "__gen_uint(v%d_%d, %d, %d)" % \
(index, field_index, field.start - dword_start, field.end - dword_start)
field_index = field_index + 1
--
2.9.3
More information about the mesa-dev
mailing list