THRIFT-2520 cpp:cob_style generates incorrect .tcc file

This closes #118

commit 22d266eefaf16f21ffd0ad193a6a54403de65197
Author: N.Sukegawa <nsukeg@gmail.com>
Date: 2014-05-07T19:36:43Z
This commit is contained in:
Roger Meier 2014-06-15 21:48:59 +02:00
parent 746952efc1
commit 63fcb7e756
7 changed files with 96 additions and 10 deletions

3
.gitignore vendored
View File

@ -27,6 +27,8 @@ Makefile
Makefile.in Makefile.in
autom4te.cache autom4te.cache
node_modules node_modules
compile
test-driver
.sonar .sonar
.DS_Store .DS_Store
@ -84,6 +86,7 @@ node_modules
/lib/cpp/test/UnitTests /lib/cpp/test/UnitTests
/lib/cpp/test/ZlibTest /lib/cpp/test/ZlibTest
/lib/cpp/test/concurrency_test /lib/cpp/test/concurrency_test
/lib/cpp/test/link_test
/lib/cpp/test/processor_test /lib/cpp/test/processor_test
/lib/cpp/test/tests.xml /lib/cpp/test/tests.xml
/lib/cpp/concurrency_test /lib/cpp/concurrency_test

View File

@ -119,7 +119,7 @@ class t_cpp_generator : public t_oop_generator {
bool read=true, bool read=true,
bool write=true, bool write=true,
bool swap=false); 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_copy_constructor (std::ofstream& out, t_struct* tstruct);
void generate_assignment_operator (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); 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) { void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception) {
generate_struct_declaration(f_types_, tstruct, is_exception, generate_struct_declaration(f_types_, tstruct, is_exception,
false, true, true, true); 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_struct_fingerprint(f_types_impl_, tstruct, true);
generate_local_reflection(f_types_, tstruct, false); generate_local_reflection(f_types_, tstruct, false);
generate_local_reflection(f_types_impl_, tstruct, true); 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, void t_cpp_generator::generate_struct_definition(ofstream& out,
ofstream& force_cpp_out,
t_struct* tstruct, t_struct* tstruct,
bool setters) { bool setters) {
// Get members // Get members
@ -1147,13 +1148,13 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
// Destructor // Destructor
if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) { if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
out << force_cpp_out <<
endl << endl <<
indent() << tstruct->get_name() << "::~" << tstruct->get_name() << "() throw() {" << endl; indent() << tstruct->get_name() << "::~" << tstruct->get_name() << "() throw() {" << endl;
indent_up(); indent_up();
indent_down(); indent_down();
out << indent() << "}" << endl << endl; force_cpp_out << indent() << "}" << endl << endl;
} }
// Create a setter function for each field // 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? // TODO(dreiss): Why is this stuff not in generate_function_helpers?
ts->set_name(tservice->get_name() + "_" + (*f_iter)->get_name() + "_args"); ts->set_name(tservice->get_name() + "_" + (*f_iter)->get_name() + "_args");
generate_struct_declaration(f_header_, ts, false); 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_reader(out, ts);
generate_struct_writer(out, ts); generate_struct_writer(out, ts);
ts->set_name(tservice->get_name() + "_" + (*f_iter)->get_name() + "_pargs"); ts->set_name(tservice->get_name() + "_" + (*f_iter)->get_name() + "_pargs");
generate_struct_declaration(f_header_, ts, false, true, false, true); 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); generate_struct_writer(out, ts, true);
ts->set_name(name_orig); 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_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_reader(out, &result);
generate_struct_result_writer(out, &result); generate_struct_result_writer(out, &result);
result.set_name(tservice->get_name() + "_" + tfunction->get_name() + "_presult"); result.set_name(tservice->get_name() + "_" + tfunction->get_name() + "_presult");
generate_struct_declaration(f_header_, &result, false, true, true, gen_cob_style_); 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); generate_struct_reader(out, &result, true);
if (gen_cob_style_) { if (gen_cob_style_) {
generate_struct_writer(out, &result, true); generate_struct_writer(out, &result, true);

View File

@ -63,7 +63,8 @@ check_PROGRAMS = \
TransportTest \ TransportTest \
ZlibTest \ ZlibTest \
TFileTransportTest \ TFileTransportTest \
UnitTests UnitTests \
link_test
# disable these test ... too strong # disable these test ... too strong
# processor_test # processor_test
# concurrency_test # concurrency_test
@ -195,6 +196,11 @@ concurrency_test_SOURCES = \
concurrency_test_LDADD = \ concurrency_test_LDADD = \
$(top_builddir)/lib/cpp/libthrift.la $(top_builddir)/lib/cpp/libthrift.la
link_test_SOURCES = \
link/LinkTest.cpp \
link/TemplatedService1.cpp \
link/TemplatedService2.cpp
processor_test_SOURCES = \ processor_test_SOURCES = \
processor/ProcessorTest.cpp \ processor/ProcessorTest.cpp \
processor/EventLog.cpp \ processor/EventLog.cpp \

View File

@ -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;
}

View File

@ -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"

View File

@ -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"

View File

@ -20,10 +20,12 @@
noinst_LTLIBRARIES = libtestgencpp.la libstresstestgencpp.la noinst_LTLIBRARIES = libtestgencpp.la libstresstestgencpp.la
nodist_libtestgencpp_la_SOURCES = \ nodist_libtestgencpp_la_SOURCES = \
gen-cpp/ThriftTest_constants.cpp \ gen-cpp/ThriftTest_constants.cpp \
gen-cpp/ThriftTest_types.cpp \
gen-cpp/ThriftTest_constants.h \ gen-cpp/ThriftTest_constants.h \
gen-cpp/ThriftTest_types.cpp \
gen-cpp/ThriftTest_types.h \ gen-cpp/ThriftTest_types.h \
gen-cpp/ThriftTest_types.tcc \ gen-cpp/ThriftTest_types.tcc \
gen-cpp/ThriftTest.cpp \
gen-cpp/ThriftTest.h \
gen-cpp/ThriftTest.tcc \ gen-cpp/ThriftTest.tcc \
src/ThriftTest_extras.cpp src/ThriftTest_extras.cpp