1
0
mirror of https://github.com/haiwen/libsearpc.git synced 2025-09-09 16:49:27 +00:00

searpc-codegen load function table from any py file

This commit is contained in:
plt
2012-09-11 16:12:24 +08:00
parent 97db61a6de
commit d1256247ee

View File

@@ -166,7 +166,6 @@ def generate_signature(ret_type, arg_types):
return template.substitute(signature_name=signature_name, args=args)
def gen_signature_list():
from rpc_table import func_table
f = open('searpc-signature.h', 'w')
for item in func_table:
print >>f,generate_signature(item[0], item[1])
@@ -175,6 +174,22 @@ def gen_signature_list():
if __name__ == "__main__":
sys.path.append(os.getcwd())
# load function table
if len(sys.argv) == 2:
abspath = os.path.abspath(sys.argv[1])
d = os.path.dirname(abspath)
f = os.path.basename(abspath)
mod = f[:f.rfind('.')]
sys.path.append(d)
print "load func_table from %s" % (abspath)
rpc_mod = __import__(mod, globals(), locals(), [], -1)
func_table = rpc_mod.func_table
else:
# load from default rpc_table.py
from rpc_table import func_table
# gen code
gen_marshal_functions()
gen_marshal_register_function()
gen_signature_list()