summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
f7f1334)
Change-Id: If20d2fbab9b854b7db276c81918fdff6abcb8385
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
tname = o.__class__.__name__
output += duplicate_wrapper_head(o.name)
if tname == 'Enum':
tname = o.__class__.__name__
output += duplicate_wrapper_head(o.name)
if tname == 'Enum':
- output += "typedef enum {\n"
+ if o.enumtype == 'u32':
+ output += "typedef enum {\n"
+ else:
+ output += "typedef enum __attribute__((__packed__)) {\n"
+
for b in o.block:
output += " %s = %s,\n" % (b[0], b[1])
output += '} vl_api_%s_t;\n' % o.name
for b in o.block:
output += " %s = %s,\n" % (b[0], b[1])
output += '} vl_api_%s_t;\n' % o.name
+ if o.enumtype != 'u32':
+ size1 = 'sizeof(vl_api_%s_t)' % o.name
+ size2 = 'sizeof(%s)' % o.enumtype
+ err_str = 'size of API enum %s is wrong' % o.name
+ output += 'STATIC_ASSERT(%s == %s, "%s");\n' % (size1, size2, err_str)
else:
if tname == 'Union':
output += "typedef VL_API_PACKED(union _vl_api_%s {\n" % o.name
else:
if tname == 'Union':
output += "typedef VL_API_PACKED(union _vl_api_%s {\n" % o.name
class VPPEnumType(object):
def __init__(self, name, msgdef):
self.size = types['u32'].size
class VPPEnumType(object):
def __init__(self, name, msgdef):
self.size = types['u32'].size
e_hash = {}
for f in msgdef:
if type(f) is dict and 'enumtype' in f:
if f['enumtype'] != 'u32':
e_hash = {}
for f in msgdef:
if type(f) is dict and 'enumtype' in f:
if f['enumtype'] != 'u32':
- raise NotImplementedError
+ self.size = types[f['enumtype']].size
+ self.enumtype = f['enumtype']
continue
ename, evalue = f
e_hash[ename] = evalue
continue
ename, evalue = f
e_hash[ename] = evalue
return True
def pack(self, data, kwargs=None):
return True
def pack(self, data, kwargs=None):
- return types['u32'].pack(data)
+ return types[self.enumtype].pack(data)
def unpack(self, data, offset=0, result=None, ntc=False):
def unpack(self, data, offset=0, result=None, ntc=False):
- x, size = types['u32'].unpack(data, offset)
+ x, size = types[self.enumtype].unpack(data, offset)
return self.enum(x), size
return self.enum(x), size