import xml.parsers.expat
import re
import sys
-import copy
license = """/* Generated code, see v3d_packet_v21.xml, v3d_packet_v33.xml and gen_pack_header.py */
"""
self.type = attrs["type"]
if self.type == 'bool' and self.start != self.end:
- print("#error Field {} has bool type but more than one bit of size".format(self.name));
+ print("#error Field {} has bool type but more than one bit of size".format(self.name))
if "prefix" in attrs:
self.prefix = safe_name(attrs["prefix"]).upper()
last_byte = field.end // 8
for b in range(first_byte, last_byte + 1):
- if not b in bytes:
+ if b not in bytes:
bytes[b] = self.Byte()
bytes[b].fields.append(field)
for index in range(self.length):
# Handle MBZ bytes
- if not index in bytes:
+ if index not in bytes:
print(" cl[%2d] = 0;" % index)
continue
byte = bytes[index]
byte_start = index * 8
- v = None
prefix = " cl[%2d] =" % index
field_index = 0
print("/* unhandled field %s, type %s */\n" % (name, field.type))
s = None
- if not s == None:
+ if s is not None:
shift = byte_start - field_byte_start + extra_shift
if shift:
s = "%s >> %d" % (s, shift)
convert = "__gen_unpack_sfixed"
else:
print("/* unhandled field %s, type %s */\n" % (field.name, field.type))
- s = None
plusone = ""
if field.minus_one:
def emit_header(self, name):
default_fields = []
for field in self.group.fields:
- if not type(field) is Field:
+ if type(field) is not Field:
continue
- if field.default == None:
+ if field.default is None:
continue
default_fields.append(" .%-35s = %6d" % (field.name, field.default))
return
name = self.register
- if not self.reg_num == None:
+ if self.reg_num is not None:
print('#define %-33s 0x%04x' %
(self.gen_prefix(name + "_num"), self.reg_num))