def _generate_future_jvpp_callback_methods(model): methods = [] for msg in model.messages: if is_control_ping(msg) or is_control_ping_reply(msg): # Skip control_ping managed by jvpp registry. continue if is_dump(msg) or is_request(msg): continue # Generate callbacks for all messages except for dumps and requests (handled by vpp, not client). template = None request_dto = None if is_details(msg): template = _FUTURE_JVPP_FACADE_DETAILS_CALLBACK_TEMPLATE request_dto = msg.request_java elif is_reply(msg): template = _FUTURE_JVPP_FACADE_REPLY_CALLBACK_TEMPLATE request_dto = msg.request_java elif is_event(msg): template = _FUTURE_JVPP_FACADE_EVENT_CALLBACK_TEMPLATE else: raise TypeError("Unknown message type %s", msg) methods.append(template.substitute( plugin_package=model.plugin_package, callback_dto=msg.java_name_upper, request_dto=request_dto, callback_dto_field=msg.java_name_lower, )) return "".join(methods)
def _generate_dump_reply_wrappers(work_dir, model, logger): for msg in model.messages: if is_details(msg): logger.debug("Generating ReplyDump DTO for message %s", msg) details_class = msg.java_name_upper dto = _REPLY_DUMP_TEMPLATE.substitute( plugin_package=model.plugin_package, json_filename=model.json_api_files, json_definition=msg.doc, details_class=details_class, details_field=msg.java_name_lower, dump_class=msg.request_java) with open("%s/%sReplyDump.java" % (work_dir, details_class), "w") as f: f.write(dto)
def _generate_message_dtos(work_dir, model, logger): for msg in model.messages: logger.debug("Generating DTO for message %s", msg) class_name = msg.java_name_upper if is_control_ping(msg) or is_control_ping_reply(msg): # Skip control_ping managed by jvpp registry. continue if is_request(msg): dto = _generate_request_dto(msg, model, base_type="JVppRequest") elif is_dump(msg): dto = _generate_request_dto(msg, model, base_type="JVppDump") elif is_reply(msg) or is_details(msg): dto = _generate_reply_dto(msg, model) elif is_event(msg): dto = _generate_event_dto(msg, model) else: logger.warn( "Failed to generate DTO for: %s. Message type is not supported." % msg) continue with open("%s/%s.java" % (work_dir, class_name), "w") as f: f.write(dto)