Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
API: Use string type instead of u8.
[vpp.git]
/
src
/
tools
/
vppapigen
/
vppapigen_c.py
diff --git
a/src/tools/vppapigen/vppapigen_c.py
b/src/tools/vppapigen/vppapigen_c.py
index
2a66ff3
..
e189b02
100644
(file)
--- a/
src/tools/vppapigen/vppapigen_c.py
+++ b/
src/tools/vppapigen/vppapigen_c.py
@@
-3,7
+3,8
@@
import datetime
import os
import time
import os
import time
-datestring = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
+datestring = datetime.datetime.utcfromtimestamp(
+ int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
input_filename = 'inputfil'
top_boilerplate = '''\
/*
input_filename = 'inputfil'
top_boilerplate = '''\
/*
@@
-85,8
+86,8
@@
def msg_name_crc_list(s, suffix):
def duplicate_wrapper_head(name):
def duplicate_wrapper_head(name):
- s = "#ifndef defined_%s\n" % name
- s += "#define defined_%s\n" % name
+ s = "#ifndef
_vl_api_
defined_%s\n" % name
+ s += "#define
_vl_api_
defined_%s\n" % name
return s
return s
@@
-94,6
+95,13
@@
def duplicate_wrapper_tail():
return '#endif\n\n'
return '#endif\n\n'
+def api2c(fieldtype):
+ mappingtable = {'string': 'vl_api_string_t', }
+ if fieldtype in mappingtable:
+ return mappingtable[fieldtype]
+ return fieldtype
+
+
def typedefs(objs, aliases, filename):
name = filename.replace('.', '_')
output = '''\
def typedefs(objs, aliases, filename):
name = filename.replace('.', '_')
output = '''\
@@
-130,12
+138,12
@@
def typedefs(objs, aliases, filename):
output += "typedef VL_API_PACKED(struct _vl_api_%s {\n" % o.name
for b in o.block:
if b.type == 'Field':
output += "typedef VL_API_PACKED(struct _vl_api_%s {\n" % o.name
for b in o.block:
if b.type == 'Field':
- output += " %s %s;\n" % (
b.fieldtype
, b.fieldname)
+ output += " %s %s;\n" % (
api2c(b.fieldtype)
, b.fieldname)
elif b.type == 'Array':
if b.lengthfield:
elif b.type == 'Array':
if b.lengthfield:
- output += " %s %s[0];\n" % (
b.fieldtype
, b.fieldname)
+ output += " %s %s[0];\n" % (
api2c(b.fieldtype)
, b.fieldname)
else:
else:
- output += " %s %s[%s];\n" % (
b.fieldtype
, b.fieldname,
+ output += " %s %s[%s];\n" % (
api2c(b.fieldtype)
, b.fieldname,
b.length)
else:
raise ValueError("Error in processing array type %s" % b)
b.length)
else:
raise ValueError("Error in processing array type %s" % b)