aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-api/java/jvpp/gen/dto_gen.py
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-04-26 12:09:05 +0200
committerEd Warnicke <hagbard@gmail.com>2016-05-02 20:58:54 +0000
commitd85036fd6bf25bb11a6f3fdfccf4425428834f28 (patch)
tree457505ac351630c88f60d33bddbf1d5789e34f46 /vpp-api/java/jvpp/gen/dto_gen.py
parentc5e8681b320884f780508458ebff873761d5e04a (diff)
HONEYCOMB-10: jVpp - the new java API. C code and jar file generation
Added comments generation for C and Java files. Change-Id: Ifb670a5592eb871bfe68804f0a8d8f9b5b14f00a Signed-off-by: Marek Gradzki <mgradzki@cisco.com> Signed-off-by: Ed Warnicke <eaw@cisco.com>
Diffstat (limited to 'vpp-api/java/jvpp/gen/dto_gen.py')
-rw-r--r--vpp-api/java/jvpp/gen/dto_gen.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/vpp-api/java/jvpp/gen/dto_gen.py b/vpp-api/java/jvpp/gen/dto_gen.py
index 17fde68a26d..378d279c6d0 100644
--- a/vpp-api/java/jvpp/gen/dto_gen.py
+++ b/vpp-api/java/jvpp/gen/dto_gen.py
@@ -20,7 +20,11 @@ dto_template = Template("""
package $base_package.$dto_package;
/**
- * $docs
+ * <p>This class represents $description.
+ * <br>It was generated by dto_gen.py based on $inputfile preparsed data:
+ * <pre>
+$docs
+ * </pre>
*/
public final class $cls_name implements $base_package.$dto_package.$base_type {
@@ -36,8 +40,7 @@ send_template = Template(""" @Override
return jvpp.$method_name($args);
}\n""")
-
-def generate_dtos(func_list, base_package, dto_package):
+def generate_dtos(func_list, base_package, dto_package, inputfile):
""" Generates dto objects in a dedicated package """
print "Generating DTOs"
@@ -60,6 +63,7 @@ def generate_dtos(func_list, base_package, dto_package):
methods = ""
base_type = ""
if util.is_reply(camel_case_dto_name):
+ description = "vpe.api reply DTO"
request_dto_name = get_request_name(camel_case_dto_name, func['name'])
if util.is_details(camel_case_dto_name):
# FIXME assumption that dump calls end with "Dump" suffix. Not enforced in vpe.api
@@ -75,11 +79,15 @@ def generate_dtos(func_list, base_package, dto_package):
args=args)
if util.is_dump(camel_case_dto_name):
base_type += "JVppDump"
+ description = "vpe.api dump request DTO"
else:
base_type += "JVppRequest"
+ description = "vpe.api request DTO"
dto_file = open(dto_path, 'w')
- dto_file.write(dto_template.substitute(docs='Generated from ' + str(func),
+ dto_file.write(dto_template.substitute(inputfile=inputfile,
+ description=description,
+ docs=util.api_message_to_javadoc(func),
cls_name=camel_case_dto_name,
fields=fields,
methods=methods,
@@ -89,13 +97,12 @@ def generate_dtos(func_list, base_package, dto_package):
dto_file.flush()
dto_file.close()
- flush_dump_reply_dtos()
+ flush_dump_reply_dtos(inputfile)
dump_dto_suffix = "ReplyDump"
dump_reply_artificial_dtos = {}
-
# Returns request name or special one from unconventional_naming_rep_req map
def get_request_name(camel_case_dto_name, func_name):
return util.underscore_to_camelcase_upper(
@@ -103,12 +110,14 @@ def get_request_name(camel_case_dto_name, func_name):
else util.remove_reply_suffix(camel_case_dto_name)
-def flush_dump_reply_dtos():
+def flush_dump_reply_dtos(inputfile):
for dump_reply_artificial_dto in dump_reply_artificial_dtos.values():
dto_path = os.path.join(dump_reply_artificial_dto['dto_package'],
dump_reply_artificial_dto['cls_name'] + ".java")
dto_file = open(dto_path, 'w')
- dto_file.write(dto_template.substitute(docs=dump_reply_artificial_dto['docs'],
+ dto_file.write(dto_template.substitute(inputfile=inputfile,
+ description="vpe.api dump reply wrapper",
+ docs=dump_reply_artificial_dto['docs'],
cls_name=dump_reply_artificial_dto['cls_name'],
fields=dump_reply_artificial_dto['fields'],
methods=dump_reply_artificial_dto['methods'],
@@ -133,7 +142,7 @@ def generate_dump_reply_dto(request_dto_name, base_package, dto_package, camel_c
dump_reply_artificial_dtos[request_dto_name]['fields'] = \
dump_reply_artificial_dtos[request_dto_name]['fields'] + '\n' + fields
else:
- dump_reply_artificial_dtos[request_dto_name] = ({'docs': 'Dump reply wrapper generated from ' + str(func),
+ dump_reply_artificial_dtos[request_dto_name] = ({'docs': util.api_message_to_javadoc(func),
'cls_name': cls_name,
'fields': fields,
'methods': "",