You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dr...@apache.org on 2009/02/07 03:37:05 UTC

svn commit: r741832 - in /incubator/thrift/trunk: compiler/cpp/src/generate/t_py_generator.cc test/DebugProtoTest.thrift test/py/Makefile.am test/py/TestSyntax.py

Author: dreiss
Date: Sat Feb  7 02:37:05 2009
New Revision: 741832

URL: http://svn.apache.org/viewvc?rev=741832&view=rev
Log:
THRIFT-310. python: Generate valid code for empty services

Added:
    incubator/thrift/trunk/test/py/TestSyntax.py   (with props)
Modified:
    incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc
    incubator/thrift/trunk/test/DebugProtoTest.thrift
    incubator/thrift/trunk/test/py/Makefile.am

Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc?rev=741832&r1=741831&r2=741832&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc Sat Feb  7 02:37:05 2009
@@ -890,6 +890,11 @@
       indent() << "def " << function_signature(*f_iter) << ":" << endl <<
       indent() << "  pass" << endl << endl;
   }
+  if (functions.empty()) {
+    f_service_ <<
+      indent() << "pass" << endl;
+  }
+
   indent_down();
   f_service_ <<
     endl;

Modified: incubator/thrift/trunk/test/DebugProtoTest.thrift
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/test/DebugProtoTest.thrift?rev=741832&r1=741831&r2=741832&view=diff
==============================================================================
--- incubator/thrift/trunk/test/DebugProtoTest.thrift (original)
+++ incubator/thrift/trunk/test/DebugProtoTest.thrift Sat Feb  7 02:37:05 2009
@@ -82,6 +82,8 @@
   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 {

Modified: incubator/thrift/trunk/test/py/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/test/py/Makefile.am?rev=741832&r1=741831&r2=741832&view=diff
==============================================================================
--- incubator/thrift/trunk/test/py/Makefile.am (original)
+++ incubator/thrift/trunk/test/py/Makefile.am Sat Feb  7 02:37:05 2009
@@ -3,10 +3,12 @@
 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 @@
 TESTS= $(py_unit_tests)
 
 
-gen-py/ThriftTest/__init__.py: ../ThriftTest.thrift
+gen-py/%/__init__.py: ../%.thrift
 	$(THRIFT) --gen py $<
 
 clean-local:

Added: incubator/thrift/trunk/test/py/TestSyntax.py
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/test/py/TestSyntax.py?rev=741832&view=auto
==============================================================================
--- incubator/thrift/trunk/test/py/TestSyntax.py (added)
+++ incubator/thrift/trunk/test/py/TestSyntax.py Sat Feb  7 02:37:05 2009
@@ -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

Propchange: incubator/thrift/trunk/test/py/TestSyntax.py
------------------------------------------------------------------------------
    svn:executable = *