aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_serializer.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py
index 8361cd3c266..fea2d9f6bf1 100644
--- a/src/vpp-api/python/vpp_papi/vpp_serializer.py
+++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py
@@ -93,6 +93,8 @@ class Packer(object):
class BaseTypes(Packer):
def __init__(self, type, elements=0, options=None):
+ self._type = type
+ self._elements = elements
base_types = {'u8': '>B',
'i8': '>b',
'string': '>s',
@@ -128,6 +130,11 @@ class BaseTypes(Packer):
c = types[f_type].__class__
return c(f_type, options=options)
+ def __repr__(self):
+ return "BaseTypes(type=%s, elements=%s, options=%s)" % (self._type,
+ self._elements,
+ self.options)
+
class String(Packer):
def __init__(self, name, num, options):
@@ -226,6 +233,11 @@ class FixedList_u8(Packer):
.format(self.name, len(data[offset:]), self.num))
return self.packer.unpack(data, offset)
+ def __repr__(self):
+ return "FixedList_u8(name=%s, field_type=%s, num=%s)" % (
+ self.name, self.field_type, self.num
+ )
+
class FixedList(Packer):
def __init__(self, name, field_type, num):
@@ -256,6 +268,10 @@ class FixedList(Packer):
total += size
return result, total
+ def __repr__(self):
+ return "FixedList_(name=%s, field_type=%s, num=%s)" % (
+ self.name, self.field_type, self.num )
+
class VLAList(Packer):
def __init__(self, name, field_type, len_field_name, index):
@@ -304,9 +320,17 @@ class VLAList(Packer):
total += size
return r, total
+ 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
+ )
+
class VLAList_legacy(Packer):
def __init__(self, name, field_type):
+ self.name = name
+ self.field_type = field_type
self.packer = types[field_type]
self.size = self.packer.size
@@ -334,6 +358,11 @@ class VLAList_legacy(Packer):
total += size
return r, total
+ def __repr__(self):
+ return "VLAList_legacy(name=%s, field_type=%s)" % (
+ self.name, self.field_type
+ )
+
class VPPEnumType(Packer):
def __init__(self, name, msgdef, options=None):
@@ -382,10 +411,16 @@ class VPPEnumType(Packer):
c = types[f_type].__class__
return c(f_type, types[f_type].msgdef, options=options)
+ def __repr__(self):
+ return "VPPEnumType(name=%s, msgdef=%s, options=%s)" % (
+ self.name, self.msgdef, self.options
+ )
+
class VPPUnionType(Packer):
def __init__(self, name, msgdef):
self.name = name
+ self.msgdef = msgdef
self.size = 0
self.maxindex = 0
fields = []
@@ -432,6 +467,9 @@ class VPPUnionType(Packer):
r.append(x)
return self.tuple._make(r), maxsize
+ def __repr__(self):
+ return"VPPUnionType(name=%s, msgdef=%r)" % (self.name, self.msgdef)
+
class VPPTypeAlias(Packer):
def __init__(self, name, msgdef, options=None):
@@ -487,6 +525,10 @@ class VPPTypeAlias(Packer):
return conversion_unpacker(t, self.name), size
return t, size
+ def __repr__(self):
+ return "VPPTypeAlias(name=%s, msgdef=%s, options=%s)" % (
+ self.name, self.msgdef, self.options)
+
class VPPType(Packer):
# Set everything up to be able to pack / unpack
@@ -609,6 +651,11 @@ class VPPType(Packer):
t = conversion_unpacker(t, self.name)
return t, total
+ def __repr__(self):
+ return "%s(name=%s, msgdef=%s)" % (
+ self.__class__.__name__, self.name, self.msgdef
+ )
+
class VPPMessage(VPPType):
pass