Type: fix
Change-Id: I91063e2096fb09c34898a611184c8381fccdb333
Signed-off-by: Ole Troan <ot@cisco.com>
raise NotImplementedError
# override as appropriate in subclasses
raise NotImplementedError
# override as appropriate in subclasses
- def _get_packer_with_options(self, f_type, options):
+ @staticmethod
+ def _get_packer_with_options(f_type, options):
return types[f_type]
def get_packer_with_options(self, f_type, options):
if options is not None:
try:
return types[f_type]
def get_packer_with_options(self, f_type, options):
if options is not None:
try:
- return self._get_packer_with_options(f_type, options)
+ c = types[f_type].__class__
+ return c._get_packer_with_options(f_type, options)
except IndexError:
raise VPPSerializerValueError(
"Options not supported for {}{} ({})".
except IndexError:
raise VPPSerializerValueError(
"Options not supported for {}{} ({})".
- format(f_type, types[f_type].__class__,
- options))
+ format(f_type, types[f_type].__class__,
+ options))
def unpack(self, data, offset, result=None, ntc=False):
return self.packer.unpack_from(data, offset)[0], self.packer.size
def unpack(self, data, offset, result=None, ntc=False):
return self.packer.unpack_from(data, offset)[0], self.packer.size
- def _get_packer_with_options(self, f_type, options):
- c = types[f_type].__class__
- return c(f_type, options=options)
+ @staticmethod
+ def _get_packer_with_options(f_type, options):
+ return BaseTypes(f_type, options=options)
def __repr__(self):
return "BaseTypes(type=%s, elements=%s, options=%s)" % (self._type,
def __repr__(self):
return "BaseTypes(type=%s, elements=%s, options=%s)" % (self._type,
return '', 0
p = BaseTypes('u8', length)
x, size = p.unpack(data, offset + length_field_size)
return '', 0
p = BaseTypes('u8', length)
x, size = p.unpack(data, offset + length_field_size)
- #x2 = x.split(b'\0', 1)[0]
return (x.decode('ascii', errors='replace'), size + length_field_size)
return (x.decode('ascii', errors='replace'), size + length_field_size)
def __repr__(self):
return "FixedList_(name=%s, field_type=%s, num=%s)" % (
def __repr__(self):
return "FixedList_(name=%s, field_type=%s, num=%s)" % (
- self.name, self.field_type, self.num )
+ self.name, self.field_type, self.num)
def __repr__(self):
return "VLAList(name=%s, field_type=%s, " \
"len_field_name=%s, index=%s)" % (
def __repr__(self):
return "VLAList(name=%s, field_type=%s, " \
"len_field_name=%s, index=%s)" % (
- self.name, self.field_type, self.length_field, self.index
- )
+ self.name, self.field_type, self.length_field, self.index
+ )
class VLAList_legacy(Packer):
class VLAList_legacy(Packer):
x, size = types[self.enumtype].unpack(data, offset)
return self.enum(x), size
x, size = types[self.enumtype].unpack(data, offset)
return self.enum(x), size
- def _get_packer_with_options(self, f_type, options):
- c = types[f_type].__class__
- return c(f_type, types[f_type].msgdef, options=options)
+ @staticmethod
+ def _get_packer_with_options(f_type, options):
+ return VPPEnumType(f_type, types[f_type].msgdef, options=options)
def __repr__(self):
return "VPPEnumType(name=%s, msgdef=%s, options=%s)" % (
def __repr__(self):
return "VPPEnumType(name=%s, msgdef=%s, options=%s)" % (
return self.packer.pack(data, kwargs)
return self.packer.pack(data, kwargs)
- def _get_packer_with_options(self, f_type, options):
- c = types[f_type].__class__
- return c(f_type, types[f_type].msgdef, options=options)
+ @staticmethod
+ def _get_packer_with_options(f_type, options):
+ return VPPTypeAlias(f_type, types[f_type].msgdef, options=options)
def unpack(self, data, offset=0, result=None, ntc=False):
if ntc is False and self.name in vpp_format.conversion_unpacker_table:
def unpack(self, data, offset=0, result=None, ntc=False):
if ntc is False and self.name in vpp_format.conversion_unpacker_table: