You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2014/06/15 21:51:46 UTC

git commit: THRIFT-2520 cpp:cob_style generates incorrect .tcc file

Repository: thrift
Updated Branches:
  refs/heads/master 746952efc -> 63fcb7e75


THRIFT-2520 cpp:cob_style generates incorrect .tcc file

This closes #118

commit 22d266eefaf16f21ffd0ad193a6a54403de65197
Author: N.Sukegawa <ns...@gmail.com>
Date: 2014-05-07T19:36:43Z


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/63fcb7e7
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/63fcb7e7
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/63fcb7e7

Branch: refs/heads/master
Commit: 63fcb7e756a88adca994111e1d9bc0c3c5186c36
Parents: 746952e
Author: Roger Meier <ro...@bufferoverflow.ch>
Authored: Sun Jun 15 21:48:59 2014 +0200
Committer: Roger Meier <ro...@bufferoverflow.ch>
Committed: Sun Jun 15 21:51:32 2014 +0200

----------------------------------------------------------------------
 .gitignore                                   |  3 +++
 compiler/cpp/src/generate/t_cpp_generator.cc | 17 ++++++++-------
 lib/cpp/test/Makefile.am                     |  8 ++++++-
 lib/cpp/test/link/LinkTest.cpp               | 22 +++++++++++++++++++
 lib/cpp/test/link/TemplatedService1.cpp      | 26 +++++++++++++++++++++++
 lib/cpp/test/link/TemplatedService2.cpp      | 26 +++++++++++++++++++++++
 test/cpp/Makefile.am                         |  4 +++-
 7 files changed, 96 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/63fcb7e7/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 9a08cbe..19386da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,8 @@ Makefile
 Makefile.in
 autom4te.cache
 node_modules
+compile
+test-driver
 
 .sonar
 .DS_Store
@@ -84,6 +86,7 @@ node_modules
 /lib/cpp/test/UnitTests
 /lib/cpp/test/ZlibTest
 /lib/cpp/test/concurrency_test
+/lib/cpp/test/link_test
 /lib/cpp/test/processor_test
 /lib/cpp/test/tests.xml
 /lib/cpp/concurrency_test

http://git-wip-us.apache.org/repos/asf/thrift/blob/63fcb7e7/compiler/cpp/src/generate/t_cpp_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc
index 771af46..c171a53 100755
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -119,7 +119,7 @@ class t_cpp_generator : public t_oop_generator {
                                       bool read=true,
                                       bool write=true,
                                       bool swap=false);
-  void generate_struct_definition   (std::ofstream& out, t_struct* tstruct, bool setters=true);
+  void generate_struct_definition   (std::ofstream& out, std::ofstream& force_cpp_out, t_struct* tstruct, bool setters=true);
   void generate_copy_constructor     (std::ofstream& out, t_struct* tstruct);
   void generate_assignment_operator  (std::ofstream& out, t_struct* tstruct);
   void generate_struct_fingerprint   (std::ofstream& out, t_struct* tstruct, bool is_definition);
@@ -805,7 +805,7 @@ void t_cpp_generator::generate_forward_declaration(t_struct* tstruct) {
 void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception) {
   generate_struct_declaration(f_types_, tstruct, is_exception,
                              false, true, true, true);
-  generate_struct_definition(f_types_impl_, tstruct);
+  generate_struct_definition(f_types_impl_, f_types_impl_, tstruct);
   generate_struct_fingerprint(f_types_impl_, tstruct, true);
   generate_local_reflection(f_types_, tstruct, false);
   generate_local_reflection(f_types_impl_, tstruct, true);
@@ -1138,6 +1138,7 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
 }
 
 void t_cpp_generator::generate_struct_definition(ofstream& out,
+                                                 ofstream& force_cpp_out,
                                                  t_struct* tstruct,
                                                  bool setters) {
   // Get members
@@ -1147,13 +1148,13 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
 
   // Destructor
   if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
-    out <<
+    force_cpp_out <<
       endl <<
       indent() << tstruct->get_name() << "::~" << tstruct->get_name() << "() throw() {" << endl;
     indent_up();
 
     indent_down();
-    out << indent() << "}" << endl << endl;
+    force_cpp_out << indent() << "}" << endl << endl;
   }
 
   // Create a setter function for each field
@@ -1886,12 +1887,12 @@ void t_cpp_generator::generate_service_helpers(t_service* tservice) {
     // TODO(dreiss): Why is this stuff not in generate_function_helpers?
     ts->set_name(tservice->get_name() + "_" + (*f_iter)->get_name() + "_args");
     generate_struct_declaration(f_header_, ts, false);
-    generate_struct_definition(out, ts, false);
+    generate_struct_definition(out, f_service_, ts, false);
     generate_struct_reader(out, ts);
     generate_struct_writer(out, ts);
     ts->set_name(tservice->get_name() + "_" + (*f_iter)->get_name() + "_pargs");
     generate_struct_declaration(f_header_, ts, false, true, false, true);
-    generate_struct_definition(out, ts, false);
+    generate_struct_definition(out, f_service_, ts, false);
     generate_struct_writer(out, ts, true);
     ts->set_name(name_orig);
 
@@ -3343,13 +3344,13 @@ void t_cpp_generator::generate_function_helpers(t_service* tservice,
   }
 
   generate_struct_declaration(f_header_, &result, false);
-  generate_struct_definition(out, &result, false);
+  generate_struct_definition(out, f_service_, &result, false);
   generate_struct_reader(out, &result);
   generate_struct_result_writer(out, &result);
 
   result.set_name(tservice->get_name() + "_" + tfunction->get_name() + "_presult");
   generate_struct_declaration(f_header_, &result, false, true, true, gen_cob_style_);
-  generate_struct_definition(out, &result, false);
+  generate_struct_definition(out, f_service_, &result, false);
   generate_struct_reader(out, &result, true);
   if (gen_cob_style_) {
     generate_struct_writer(out, &result, true);

http://git-wip-us.apache.org/repos/asf/thrift/blob/63fcb7e7/lib/cpp/test/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/cpp/test/Makefile.am b/lib/cpp/test/Makefile.am
index 7850a16..3c97452 100755
--- a/lib/cpp/test/Makefile.am
+++ b/lib/cpp/test/Makefile.am
@@ -63,7 +63,8 @@ check_PROGRAMS = \
 	TransportTest \
 	ZlibTest \
 	TFileTransportTest \
-	UnitTests
+	UnitTests \
+	link_test
 # disable these test ... too strong
 #       processor_test
 #	concurrency_test
@@ -195,6 +196,11 @@ concurrency_test_SOURCES = \
 concurrency_test_LDADD = \
   $(top_builddir)/lib/cpp/libthrift.la
 
+link_test_SOURCES = \
+  link/LinkTest.cpp \
+  link/TemplatedService1.cpp \
+  link/TemplatedService2.cpp
+
 processor_test_SOURCES = \
 	processor/ProcessorTest.cpp \
 	processor/EventLog.cpp \

http://git-wip-us.apache.org/repos/asf/thrift/blob/63fcb7e7/lib/cpp/test/link/LinkTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/link/LinkTest.cpp b/lib/cpp/test/link/LinkTest.cpp
new file mode 100644
index 0000000..18e14d1
--- /dev/null
+++ b/lib/cpp/test/link/LinkTest.cpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+int main(int, char**) {
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/63fcb7e7/lib/cpp/test/link/TemplatedService1.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/link/TemplatedService1.cpp b/lib/cpp/test/link/TemplatedService1.cpp
new file mode 100644
index 0000000..da1790b
--- /dev/null
+++ b/lib/cpp/test/link/TemplatedService1.cpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * This file is a part of a link test that makes sure generated
+ * templated service headers can be included from multiple
+ * implementation files.
+ */
+
+#include "gen-cpp/ParentService.h"

http://git-wip-us.apache.org/repos/asf/thrift/blob/63fcb7e7/lib/cpp/test/link/TemplatedService2.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/link/TemplatedService2.cpp b/lib/cpp/test/link/TemplatedService2.cpp
new file mode 100644
index 0000000..da1790b
--- /dev/null
+++ b/lib/cpp/test/link/TemplatedService2.cpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * This file is a part of a link test that makes sure generated
+ * templated service headers can be included from multiple
+ * implementation files.
+ */
+
+#include "gen-cpp/ParentService.h"

http://git-wip-us.apache.org/repos/asf/thrift/blob/63fcb7e7/test/cpp/Makefile.am
----------------------------------------------------------------------
diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am
index 347b175..66f8c1e 100755
--- a/test/cpp/Makefile.am
+++ b/test/cpp/Makefile.am
@@ -20,10 +20,12 @@
 noinst_LTLIBRARIES = libtestgencpp.la libstresstestgencpp.la
 nodist_libtestgencpp_la_SOURCES = \
 	gen-cpp/ThriftTest_constants.cpp \
-	gen-cpp/ThriftTest_types.cpp \
 	gen-cpp/ThriftTest_constants.h \
+	gen-cpp/ThriftTest_types.cpp \
 	gen-cpp/ThriftTest_types.h \
 	gen-cpp/ThriftTest_types.tcc \
+	gen-cpp/ThriftTest.cpp \
+	gen-cpp/ThriftTest.h \
 	gen-cpp/ThriftTest.tcc \
 	src/ThriftTest_extras.cpp