diff options
author | Jason Ekstrand <[email protected]> | 2017-03-29 20:39:18 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-04-07 22:34:04 -0700 |
commit | b85d75b3e82bd737db125b6f698f77632755e94f (patch) | |
tree | ecbd6d8130c3c9fc126c021fbd2afefa28eda410 /src/intel | |
parent | f97e251ab200802feb0784c795fa06153ae6861e (diff) |
intel/genxml/bits: Emit per-container _length helpers
Reviewed-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/genxml/gen_bits_header.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/intel/genxml/gen_bits_header.py b/src/intel/genxml/gen_bits_header.py index fc31baa1b88..ac8ec4c41f4 100644 --- a/src/intel/genxml/gen_bits_header.py +++ b/src/intel/genxml/gen_bits_header.py @@ -107,6 +107,11 @@ ${item.token_name}_${prop}(const struct gen_device_info *devinfo) extern "C" { #endif % for _, container in sorted(containers.iteritems(), key=itemgetter(0)): + +/* ${container.name} */ + +${emit_per_gen_prop_func(container, 'length')} + % for _, field in sorted(container.fields.iteritems(), key=itemgetter(0)): /* ${container.name}::${field.name} */ @@ -191,8 +196,15 @@ class Container(object): def __init__(self, name): self.name = name + self.token_name = safe_name(name) + self.length_by_gen = {} self.fields = {} + def add_gen(self, gen, xml_attrs): + assert isinstance(gen, Gen) + if 'length' in xml_attrs: + self.length_by_gen[gen] = xml_attrs['length'] + def get_field(self, field_name, create=False): if field_name not in self.fields: if create: @@ -201,6 +213,27 @@ class Container(object): return None return self.fields[field_name] + def has_prop(self, prop): + if prop == 'length': + return bool(self.length_by_gen) + else: + raise ValueError('Invalid property: "{0}"'.format(prop)) + + def iter_prop(self, prop): + if prop == 'length': + return self.length_by_gen.iteritems() + else: + raise ValueError('Invalid property: "{0}"'.format(prop)) + + def get_prop(self, prop, gen): + if not isinstance(gen, Gen): + gen = Gen(gen) + + if prop == 'length': + return self.length_by_gen.get(gen, 0) + else: + raise ValueError('Invalid property: "{0}"'.format(prop)) + class Field(object): def __init__(self, container, name): @@ -277,6 +310,7 @@ class XmlParser(object): if name not in self.containers: self.containers[name] = Container(name) self.container = self.containers[name] + self.container.add_gen(self.gen, attrs) def start_field(self, attrs): if self.container is None: |