You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2020/11/01 17:13:07 UTC
[thrift] branch master updated (997e2d4 -> 196254b)
This is an automated email from the ASF dual-hosted git repository.
jensg pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git.
from 997e2d4 fix warning in c_glib from add max_message_size code
new dca58db THRIFT-5290 Adjusting cpp *.cproj options according to LEGAL-538
new 196254b THRIFT-5302 Add recursive function name uniqueness check Patch: wangliming07 <wa...@58.com>
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
compiler/cpp/compiler.vcxproj | 2 +-
compiler/cpp/src/thrift/parse/t_program.h | 5 +++-
compiler/cpp/src/thrift/parse/t_service.h | 49 +++++++++++++++++++++++++++++--
3 files changed, 51 insertions(+), 5 deletions(-)
[thrift] 01/02: THRIFT-5290 Adjusting cpp *.cproj options according
to LEGAL-538
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
commit dca58db2b0bd101d4c2ea83bd6cd8eca0e886751
Author: Jens Geyer <je...@apache.org>
AuthorDate: Sun Nov 1 18:06:52 2020 +0100
THRIFT-5290 Adjusting cpp *.cproj options according to LEGAL-538
---
compiler/cpp/compiler.vcxproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler/cpp/compiler.vcxproj b/compiler/cpp/compiler.vcxproj
index 53574b2..dc9793f 100644
--- a/compiler/cpp/compiler.vcxproj
+++ b/compiler/cpp/compiler.vcxproj
@@ -171,7 +171,7 @@
<PreprocessorDefinitions>WIN32;MINGW;YY_NO_UNISTD_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>thrift\windows\config.h</ForcedIncludeFiles>
<CompileAs>CompileAsCpp</CompileAs>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
[thrift] 02/02: THRIFT-5302 Add recursive function name uniqueness
check Patch: wangliming07
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
commit 196254ba393a7e70e91fcf3c35026c82fb64f7fa
Author: wangliming07 <wa...@58.com>
AuthorDate: Thu Oct 29 13:50:25 2020 +0800
THRIFT-5302 Add recursive function name uniqueness check
Patch: wangliming07 <wa...@58.com>
This closes #2268
---
compiler/cpp/src/thrift/parse/t_program.h | 5 +++-
compiler/cpp/src/thrift/parse/t_service.h | 49 +++++++++++++++++++++++++++++--
2 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/compiler/cpp/src/thrift/parse/t_program.h b/compiler/cpp/src/thrift/parse/t_program.h
index 140dc35..b6b1332 100644
--- a/compiler/cpp/src/thrift/parse/t_program.h
+++ b/compiler/cpp/src/thrift/parse/t_program.h
@@ -112,7 +112,10 @@ public:
objects_.push_back(tx);
xceptions_.push_back(tx);
}
- void add_service(t_service* ts) { services_.push_back(ts); }
+ void add_service(t_service* ts) {
+ ts->validate_unique_members();
+ services_.push_back(ts);
+ }
// Programs to include
std::vector<t_program*>& get_includes() { return includes_; }
diff --git a/compiler/cpp/src/thrift/parse/t_service.h b/compiler/cpp/src/thrift/parse/t_service.h
index a43a515..f405c15 100644
--- a/compiler/cpp/src/thrift/parse/t_service.h
+++ b/compiler/cpp/src/thrift/parse/t_service.h
@@ -38,13 +38,56 @@ public:
void set_extends(t_service* extends) { extends_ = extends; }
void add_function(t_function* func) {
+ if (get_function_by_name(func->get_name()) != NULL) {
+ throw "Function " + func->get_name() + " is already defined";
+ }
+ functions_.push_back(func);
+ }
+
+ void validate_unique_members() {
std::vector<t_function*>::const_iterator iter;
for (iter = functions_.begin(); iter != functions_.end(); ++iter) {
- if (func->get_name() == (*iter)->get_name()) {
- throw "Function " + func->get_name() + " is already defined";
+ // throw exception when there is a conflict of names with super class
+ if (extends_ != NULL) {
+ if (extends_->get_function_by_name((*iter)->get_name()) != NULL) {
+ throw "Function " + (*iter)->get_name() + " is already defined in service " + name_;
+ }
}
}
- functions_.push_back(func);
+ }
+
+ t_function* get_function_by_name(std::string func_name) {
+ if (extends_ != NULL) {
+ t_function* func = NULL;
+ if ((func = extends_->get_function_by_name(func_name)) != NULL) {
+ return func;
+ }
+ }
+
+ std::vector<t_function*>::const_iterator iter;
+ for (iter = functions_.begin(); iter != functions_.end(); ++iter) {
+ if ((*iter)->get_name() == func_name) {
+ return *iter;
+ }
+ }
+ return NULL;
+ }
+
+ const t_function* get_function_by_name(std::string func_name) const {
+ if (extends_ != NULL) {
+ t_function* func = NULL;
+ if ((func = extends_->get_function_by_name(func_name)) != NULL) {
+ return func;
+ }
+ }
+
+ std::vector<t_function*>::const_iterator iter;
+ for (iter = functions_.begin(); iter != functions_.end(); ++iter) {
+ if ((*iter)->get_name() == func_name) {
+ return *iter;
+ }
+ }
+ return NULL;
}
const std::vector<t_function*>& get_functions() const { return functions_; }