def emit_rpc_source_python(rpc_source, rpc_table, fpath): with open(fpath, "w") as f: f = SourceFile(f) f.writeln("import os") f.writeln("from simplerpc.marshal import Marshal") f.writeln("from simplerpc.future import Future") f.writeln() for struct in rpc_source.structs: emit_struct_python(struct, f) for service in rpc_source.services: emit_service_and_proxy_python(service, f, rpc_table)
def emit_rpc_source_cpp(rpc_source, rpc_table, fpath, cpp_header, cpp_footer): with open(fpath, "w") as f: f = SourceFile(f) f.writeln("#pragma once") f.writeln() # f.writeln('#include "rpc/server.h"') f.writeln('#include "rrr.hpp"') f.writeln() f.writeln("#include <errno.h>") f.writeln() f.write(cpp_header) f.writeln() if rpc_source.namespace != None: f.writeln(" ".join(map(lambda x:"namespace %s {" % x, rpc_source.namespace))) f.writeln() for struct in rpc_source.structs: emit_struct(struct, f) for service in rpc_source.services: emit_service_and_proxy(service, f, rpc_table) if rpc_source.namespace != None: f.writeln(" ".join(["}"] * len(rpc_source.namespace)) + " // namespace " + "::".join(rpc_source.namespace)) f.writeln() f.writeln() f.write(cpp_footer) f.writeln()