diff --git a/lib/Makefile.am b/lib/Makefile.am index 28babbd..1688dfa 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,17 +1,10 @@ -# Five files are generated by a python script: -# Used in client: -# -# * fcall-impr.h: contains the implementation of functions like -# `searpc_client_fcall__string_string`. These function is used by the -# client to pack the RPC call to json data. -# * searpc-fcall.h: constains the declaration of the functions in fcall-impr.h -# * searpc-dfun.h: contains macros like `SEARPC_CLIENT_DEFUN_INT__STRING(funcname)`. +# Two files are generated by a python script: # # Used in server: # # * searpc-signature.h: contains functions like `searpc_signature_int__string()`. -# * searpc-marshal.h: contains functions like `marshal_int__string()` +# * marshal.h: contains functions like `marshal_int__string()` # generated_sources = searpc-signature.h marshal.h @@ -41,16 +34,15 @@ libsearpc_la_LDFLAGS = -version-info 1:2:0 -no-undefined libsearpc_la_LIBADD = @GLIB_LIBS@ \ ${top_builddir}/json-glib/json-glib/libsearpc-json-glib.la -genrpc_files = gencode.py rpc_table.py +dist_bin_SCRIPTS = searpc-codegen.py -EXTRA_DIST = ${genrpc_files} +EXTRA_DIST = rpc_table.py gensource: ${generated_sources} -${generated_sources}: gencode.py rpc_table.py +${generated_sources}: searpc-codegen.py rpc_table.py @echo "[libsearpc]: generating rpc header files" - python gencode.py gen-signature > searpc-signature.h - python gencode.py gen-marshal > marshal.h + python searpc-codegen.py rpc_table.py @echo "[libsearpc]: done" -DISTCLEANFILES = ${generated_sources} \ No newline at end of file +DISTCLEANFILES = ${generated_sources} diff --git a/lib/gencode.py b/lib/searpc-codegen.py similarity index 86% rename from lib/gencode.py rename to lib/searpc-codegen.py index 565bd21..85aa4aa 100644 --- a/lib/gencode.py +++ b/lib/searpc-codegen.py @@ -101,16 +101,15 @@ def generate_marshal(ret_type, arg_types): def gen_marshal_functions(): from rpc_table import func_table + f = open('marshal.h', 'w') for item in func_table: - print generate_marshal(item[0], item[1]) + print >>f, generate_marshal(item[0], item[1]) + f.close() marshal_register_item = r""" { - MarshalItem *item = g_new0(MarshalItem, 1); - item->mfunc = ${marshal_name}; - item->signature = ${signature_name}(); - g_hash_table_insert (marshal_table, (gpointer)item->signature, item); + searpc_server_register_marshal (${signature_name}(), ${marshal_name}); } """ @@ -132,11 +131,13 @@ def generate_marshal_register_item(ret_type, arg_types): def gen_marshal_register_function(): from rpc_table import func_table - print "static void register_marshals(GHashTable *marshal_table)""" - print "{" + f = open('marshal.h', 'a') + print >>f, "static void register_marshals()""" + print >>f, "{" for item in func_table: - print generate_marshal_register_item(item[0], item[1]), - print "}" + print >>f, generate_marshal_register_item(item[0], item[1]), + print >>f, "}" + f.close() signature_template = r""" inline static gchar * @@ -165,16 +166,13 @@ def generate_signature(ret_type, arg_types): def gen_signature_list(): from rpc_table import func_table + f = open('searpc-signature.h', 'w') for item in func_table: - print generate_signature(item[0], item[1]) + print >>f,generate_signature(item[0], item[1]) + f.close() if __name__ == "__main__": - command = sys.argv[1] - if command == "gen-marshal": - gen_marshal_functions() - gen_marshal_register_function() - elif command == "gen-signature": - gen_signature_list() - else: - print "Unknown command %s" % (command) + gen_marshal_functions() + gen_marshal_register_function() + gen_signature_list()