1
0
mirror of https://github.com/haiwen/libsearpc.git synced 2025-07-31 04:49:43 +00:00

[lib] fix searpc codegen issue

This commit is contained in:
Chilledheart 2014-07-23 14:56:35 +08:00
parent 80b7355592
commit 2b71149baf
5 changed files with 27 additions and 13 deletions

4
.gitignore vendored
View File

@ -44,8 +44,12 @@ pysearpc/rpc_table.py
*.pc
demo/searpc-marshal.h
demo/searpc-signature.h
demo/rpc_table.stamp
demo/rpc_table.tmp
tests/searpc-marshal.h
tests/searpc-signature.h
tests/rpc_table.stamp
tests/rpc_table.tmp
tests/clar.suite

View File

@ -6,8 +6,6 @@ before_install:
- sudo apt-get install libjansson-dev
- git clean -x -f
- ./autogen.sh
- cd demo && python ../lib/searpc-codegen.py rpc_table.py && cd -
- cd tests && python ../lib/searpc-codegen.py rpc_table.py && cd -
script:
- ./configure
- make -j8

View File

@ -29,12 +29,19 @@ EXTRA_DIST = rpc_table.py
gensource: ${generated_sources}
${generated_sources}: ${top_srcdir}/demo/rpc_table.py
rpc_table.stamp: ${top_srcdir}/demo/rpc_table.py ${top_srcdir}/lib/searpc-codegen.py
@rm -f rpc_table.tmp
@touch rpc_table.tmp
@echo "[libsearpc]: generating rpc header files"
@PYTHON@ ${top_srcdir}/lib/searpc-codegen.py ${top_srcdir}/demo/rpc_table.py
@echo "[libsearpc]: done"
@mv -f rpc_table.tmp $@
${generated_sources}: rpc_table.stamp
clean-local:
rm -f ${generated_sources}
rm -f rpc_table.pyc
rm -f rpc_table.stamp
rm -f rpc_table.tmp

View File

@ -100,12 +100,10 @@ def generate_marshal(ret_type, arg_types):
func_call=func_call,
convert_ret=convert_ret)
def gen_marshal_functions():
def gen_marshal_functions(f):
from rpc_table import func_table
f = open('searpc-marshal.h', 'w')
for item in func_table:
print >>f, generate_marshal(item[0], item[1])
f.close()
marshal_register_item = r"""
@ -130,15 +128,13 @@ def generate_marshal_register_item(ret_type, arg_types):
marshal_name=marshal_name,
signature_name=signature_name)
def gen_marshal_register_function():
def gen_marshal_register_function(f):
from rpc_table import func_table
f = open('searpc-marshal.h', 'a')
print >>f, "static void register_marshals()"""
print >>f, "{"
for item in func_table:
print >>f, generate_marshal_register_item(item[0], item[1]),
print >>f, "}"
f.close()
signature_template = r"""
inline static gchar *
@ -190,6 +186,8 @@ if __name__ == "__main__":
from rpc_table import func_table
# gen code
gen_marshal_functions()
gen_marshal_register_function()
marshal = open('searpc-marshal.h', 'w')
gen_marshal_functions(marshal)
gen_marshal_register_function(marshal)
marshal.close()
gen_signature_list()

View File

@ -22,10 +22,15 @@ EXTRA_DIST = rpc_table.py generate.py
gensource: ${generated_sources} ${clar_suite_sources}
${generated_sources}: $(top_srcdir)/tests/rpc_table.py
rpc_table.stamp: ${top_srcdir}/tests/rpc_table.py ${top_srcdir}/lib/searpc-codegen.py
@rm -f rpc_table.tmp
@touch rpc_table.tmp
@echo "[libsearpc]: generating rpc header files"
@PYTHON@ ${top_srcdir}/lib/searpc-codegen.py $(top_srcdir)/tests/rpc_table.py
@PYTHON@ ${top_srcdir}/lib/searpc-codegen.py ${top_srcdir}/tests/rpc_table.py
@echo "[libsearpc]: done"
@mv -f rpc_table.tmp $@
${generated_sources}: rpc_table.stamp
${clar_suite_sources}: $(top_srcdir)/tests/generate.py
@PYTHON@ $(top_srcdir)/tests/generate.py
@ -33,5 +38,7 @@ ${clar_suite_sources}: $(top_srcdir)/tests/generate.py
clean-local:
rm -f ${generated_sources}
rm -f rpc_table.pyc
rm -f rpc_table.stamp
rm -f rpc_table.tmp
rm -f generate.pyc