X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=blobdiff_plain;f=src%2Fvpp-api%2Fpython%2Fvpp_papi%2Fvpp_serializer.py;h=a001cca565aae923164f76ae4c92d8375dd24dfa;hp=bd0f73803dacee3bff54aedcbd58f61d305fb078;hb=53fffa1;hpb=4f10db317382832068d67b5d19be4a696d80c19a diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py index bd0f73803da..a001cca565a 100644 --- a/src/vpp-api/python/vpp_papi/vpp_serializer.py +++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py @@ -79,7 +79,7 @@ class FixedList_u8(object): self.packer = BaseTypes(field_type, num) self.size = self.packer.size - def pack(self, list, kwargs): + def pack(self, list, kwargs = None): """Packs a fixed length bytestring. Left-pads with zeros if input data is too short.""" if not list: @@ -277,6 +277,18 @@ class VPPUnionType(object): return self.tuple._make(r), maxsize +def VPPTypeAlias(name, msgdef): + t = vpp_get_type(msgdef['type']) + if not t: + raise ValueError() + if 'length' in msgdef: + if msgdef['length'] == 0: + raise ValueError() + types[name] = FixedList(name, msgdef['type'], msgdef['length']) + else: + types[name] = t + + class VPPType(object): # Set everything up to be able to pack / unpack def __init__(self, name, msgdef):