diff options
author | 2019-09-11 17:49:08 +0200 | |
---|---|---|
committer | 2019-09-12 13:17:40 +0200 | |
commit | e6a5712624186d4162cbba8e49ff15362aeda17d (patch) | |
tree | b5ced6fc0c1b5d635ce1cc6780d570ec91daa77c /src/vpp-api/python/vpp_papi/vpp_serializer.py | |
parent | 4b943d632864949310da4c88ea00e59f6043ae40 (diff) |
api: split vl_api_prefix into two
One type for address with prefix and one type for prefix.
Ticket: VPP-1769
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: Icfec51d9b7d5cde1d69fbecdd97498688ab7b295
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/vpp-api/python/vpp_papi/vpp_serializer.py')
-rw-r--r-- | src/vpp-api/python/vpp_papi/vpp_serializer.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py index ec6a06bb3d5..00ed8632916 100644 --- a/src/vpp-api/python/vpp_papi/vpp_serializer.py +++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py @@ -414,7 +414,7 @@ class VPPTypeAlias(object): self.name = name t = vpp_get_type(msgdef['type']) if not t: - raise ValueError() + raise ValueError('No such type: {}'.format(msgdef['type'])) if 'length' in msgdef: if msgdef['length'] == 0: raise ValueError() @@ -429,6 +429,7 @@ class VPPTypeAlias(object): self.size = t.size types[name] = self + self.toplevelconversion = False def __call__(self, args): self.options = args @@ -445,8 +446,13 @@ class VPPTypeAlias(object): return self.packer.pack(data, kwargs) def unpack(self, data, offset=0, result=None, ntc=False): + if ntc == False and self.name in vpp_format.conversion_unpacker_table: + # Disable type conversion for dependent types + ntc = True + self.toplevelconversion = True t, size = self.packer.unpack(data, offset, result, ntc=ntc) - if not ntc: + if self.toplevelconversion: + self.toplevelconversion = False return conversion_unpacker(t, self.name), size return t, size @@ -513,6 +519,7 @@ class VPPType(object): self.size = size self.tuple = collections.namedtuple(name, self.fields, rename=True) types[name] = self + self.toplevelconversion = False def __call__(self, args): self.options = args @@ -551,6 +558,11 @@ class VPPType(object): # Return a list of arguments result = [] total = 0 + if ntc == False and self.name in vpp_format.conversion_unpacker_table: + # Disable type conversion for dependent types + ntc = True + self.toplevelconversion = True + for p in self.packers: x, size = p.unpack(data, offset, result, ntc) if type(x) is tuple and len(x) == 1: @@ -559,7 +571,9 @@ class VPPType(object): offset += size total += size t = self.tuple._make(result) - if not ntc: + + if self.toplevelconversion: + self.toplevelconversion = False t = conversion_unpacker(t, self.name) return t, total |