From: David Reiss Date: Sat, 7 Feb 2009 02:37:05 +0000 (+0000) Subject: THRIFT-310. python: Generate valid code for empty services X-Git-Tag: 0.2.0~315 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=8cee47cf5e7f0b17aadd5895d632901d828b0554;p=common%2Fthrift.git THRIFT-310. python: Generate valid code for empty services git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@741832 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc index f0f076bf..02370565 100644 --- a/compiler/cpp/src/generate/t_py_generator.cc +++ b/compiler/cpp/src/generate/t_py_generator.cc @@ -890,6 +890,11 @@ void t_py_generator::generate_service_interface(t_service* tservice) { indent() << "def " << function_signature(*f_iter) << ":" << endl << indent() << " pass" << endl << endl; } + if (functions.empty()) { + f_service_ << + indent() << "pass" << endl; + } + indent_down(); f_service_ << endl; diff --git a/test/DebugProtoTest.thrift b/test/DebugProtoTest.thrift index 2d2e1208..e730b22e 100644 --- a/test/DebugProtoTest.thrift +++ b/test/DebugProtoTest.thrift @@ -82,6 +82,8 @@ service Srv { i32 Janky(i32 arg) } +service EmptyService {} + // The only purpose of this thing is to increase the size of the generated code // so that ZlibTest has more highly compressible data to play with. struct BlowUp { diff --git a/test/py/Makefile.am b/test/py/Makefile.am index 252f586b..6daa26d9 100644 --- a/test/py/Makefile.am +++ b/test/py/Makefile.am @@ -3,10 +3,12 @@ THRIFT = $(top_srcdir)/compiler/cpp/thrift py_unit_tests = \ SerializationTest.py \ TestEof.py \ + TestSyntax.py \ RunClientServer.py thrift_gen = \ - gen-py/ThriftTest/__init__.py + gen-py/ThriftTest/__init__.py \ + gen-py/DebugProtoTest/__init__.py helper_scripts= \ TestClient.py \ @@ -20,7 +22,7 @@ check_SCRIPTS= \ TESTS= $(py_unit_tests) -gen-py/ThriftTest/__init__.py: ../ThriftTest.thrift +gen-py/%/__init__.py: ../%.thrift $(THRIFT) --gen py $< clean-local: diff --git a/test/py/TestSyntax.py b/test/py/TestSyntax.py new file mode 100755 index 00000000..29214194 --- /dev/null +++ b/test/py/TestSyntax.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +import sys, glob +sys.path.insert(0, './gen-py') +sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0]) + +# Just import these generated files to make sure they are syntactically valid +from DebugProtoTest import EmptyService