summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml9
-rwxr-xr-xMakefile.am8
-rwxr-xr-xappveyor.yml8
-rw-r--r--build/cmake/DefineOptions.cmake9
-rw-r--r--build/cmake/DefinePlatformSpecifc.cmake8
-rw-r--r--compiler/cpp/CMakeLists.txt94
-rw-r--r--compiler/cpp/Makefile.am131
-rw-r--r--compiler/cpp/README.md4
-rw-r--r--compiler/cpp/src/Makefile.am48
-rw-r--r--compiler/cpp/src/thrift/common.cc4
-rw-r--r--compiler/cpp/src/thrift/logging.cc5
-rw-r--r--compiler/cpp/src/thrift/main.cc21
-rw-r--r--compiler/cpp/src/thrift/parse/t_const_value.h9
-rw-r--r--compiler/cpp/src/thrift/parse/t_scope.h9
-rw-r--r--compiler/cpp/src/thrift/plugin/Makefile.am47
-rw-r--r--compiler/cpp/src/thrift/plugin/plugin.cc511
-rw-r--r--compiler/cpp/src/thrift/plugin/plugin.h44
-rw-r--r--compiler/cpp/src/thrift/plugin/plugin.thrift207
-rw-r--r--compiler/cpp/src/thrift/plugin/plugin_output.cc455
-rw-r--r--compiler/cpp/src/thrift/plugin/plugin_output.h38
-rw-r--r--compiler/cpp/src/thrift/plugin/type_util.h95
-rw-r--r--compiler/cpp/test/CMakeLists.txt46
-rw-r--r--compiler/cpp/test/Makefile.am32
-rw-r--r--compiler/cpp/test/cpp_plugin_test.cmake45
-rwxr-xr-xcompiler/cpp/test/cpp_plugin_test.sh27
-rw-r--r--compiler/cpp/test/plugin/conversion_test.cc498
-rw-r--r--compiler/cpp/test/plugin/cpp_plugin.cc43
-rwxr-xr-xcompiler/cpp/test/plugin_stability_test.sh32
-rwxr-xr-xconfigure.ac16
-rw-r--r--lib/Makefile.am3
-rwxr-xr-xlib/cpp/Makefile.am4
31 files changed, 36 insertions, 2474 deletions
diff --git a/.travis.yml b/.travis.yml
index aecdd130a..4a399a60e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -130,15 +130,6 @@ jobs:
- JOB="CMake"
- BUILD_ARG="-DCMAKE_BUILD_TYPE=Release"
- # C++ specific options: compiler plug-in, threading model
- - script: build/docker/run.sh
- env:
- - JOB="C++ (Std Thread) and Plugin"
- - SCRIPT="cmake.sh"
- - BUILD_LIBS="CPP TESTING TUTORIALS"
- - BUILD_ARG="-DWITH_PLUGIN=ON -DWITH_PYTHON=OFF -DWITH_C_GLIB=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
- - BUILD_ENV="-e CC=clang -e CXX=clang++"
-
# ------------------------- phase: dist -------------------------
- script: build/docker/run.sh
env:
diff --git a/Makefile.am b/Makefile.am
index 104d3705a..1f2d4836a 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,15 +19,7 @@
ACLOCAL_AMFLAGS = -I ./aclocal
-if WITH_PLUGIN
-# To enable bootstrap, build order is lib/cpp -> compiler -> others
-SUBDIRS = lib/cpp compiler/cpp lib
-if WITH_TESTS
-SUBDIRS += lib/cpp/test
-endif
-else
SUBDIRS = compiler/cpp lib
-endif
if WITH_TESTS
SUBDIRS += test
diff --git a/appveyor.yml b/appveyor.yml
index 6cbabf1ee..2dee45fa8 100755
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -45,7 +45,7 @@ environment:
PYTHON_VERSION: 3.6
QT_VERSION: 5.10
ZLIB_VERSION: 1.2.11
- DISABLED_TESTS: StressTestNonBlocking
+ DISABLED_TESTS: (concurrency_test|StressTestNonBlocking)
- PROFILE: MSVC2015
PLATFORM: x86
@@ -56,18 +56,18 @@ environment:
PYTHON_VERSION: 3.5
QT_VERSION: 5.8
ZLIB_VERSION: 1.2.8
- DISABLED_TESTS: StressTestNonBlocking
+ DISABLED_TESTS: (concurrency_test|StressTestNonBlocking)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- PROFILE: MINGW
PLATFORM: x64
CONFIGURATION: RelWithDebInfo
- DISABLED_TESTS: StressTestNonBlocking
+ DISABLED_TESTS: (concurrency_test|StressTestNonBlocking)
- PROFILE: CYGWIN
PLATFORM: x64
CONFIGURATION: RelWithDebInfo
- DISABLED_TESTS: (ZlibTest|OpenSSLManualInitTest|TNonblockingServerTest|StressTestNonBlocking)
+ DISABLED_TESTS: (concurrency_test|ZlibTest|OpenSSLManualInitTest|TNonblockingServerTest|StressTestNonBlocking)
install:
- cd %APPVEYOR_BUILD_FOLDER%
diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake
index 2c8ea5050..eea0b2915 100644
--- a/build/cmake/DefineOptions.cmake
+++ b/build/cmake/DefineOptions.cmake
@@ -79,8 +79,6 @@ if(WITH_CPP)
endif()
CMAKE_DEPENDENT_OPTION(BUILD_CPP "Build C++ library" ON
"BUILD_LIBRARIES;WITH_CPP" OFF)
-CMAKE_DEPENDENT_OPTION(WITH_PLUGIN "Build compiler plugin support" OFF
- "BUILD_COMPILER;BUILD_CPP" OFF)
# C GLib
option(WITH_C_GLIB "Build C (GLib) Thrift library" ON)
@@ -149,14 +147,13 @@ message(STATUS "----------------------------------------------------------")
message(STATUS "Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
message(STATUS "Thrift package version: ${PACKAGE_VERSION}")
message(STATUS "Build configuration Summary")
-if (UNIX)
- message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
-endif ()
message(STATUS " Build compiler: ${BUILD_COMPILER}")
-message(STATUS " Build compiler plugin support: ${WITH_PLUGIN}")
message(STATUS " Build libraries: ${BUILD_LIBRARIES}")
message(STATUS " Build tests: ${BUILD_TESTING}")
MESSAGE_DEP(HAVE_COMPILER "Disabled because BUILD_THRIFT=OFF and no valid THRIFT_COMPILER is given")
+if (UNIX)
+ message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
+endif ()
message(STATUS " Language libraries:")
message(STATUS " Build as3 library: ${BUILD_AS3}")
MESSAGE_DEP(WITH_AS3 "Disabled by WITH_AS3=OFF")
diff --git a/build/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake
index 298780c97..b87fd6524 100644
--- a/build/cmake/DefinePlatformSpecifc.cmake
+++ b/build/cmake/DefinePlatformSpecifc.cmake
@@ -94,11 +94,3 @@ endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif()
-
-# Building WITH_PLUGIN requires boost memory operations, for now, and gcc >= 4.8
-if (WITH_PLUGIN)
- if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8")
- message(SEND_ERROR "Thrift compiler plug-in support is not possible with older gcc ( < 4.8 ) compiler")
- endif()
-endif()
-
diff --git a/compiler/cpp/CMakeLists.txt b/compiler/cpp/CMakeLists.txt
index 372cbab75..6f7ae5d7e 100644
--- a/compiler/cpp/CMakeLists.txt
+++ b/compiler/cpp/CMakeLists.txt
@@ -106,51 +106,10 @@ THRIFT_ADD_COMPILER(xsd "Enable compiler for XSD" ON)
# we also add the current binary directory for generated files
include_directories(${CMAKE_CURRENT_BINARY_DIR} src)
-if(NOT DEFINED WITH_PLUGIN OR NOT ${WITH_PLUGIN})
- list(APPEND thrift-compiler_SOURCES ${compiler_core})
-endif()
+list(APPEND thrift-compiler_SOURCES ${compiler_core})
add_executable(thrift-compiler ${thrift-compiler_SOURCES})
-if(${WITH_PLUGIN})
- add_executable(thrift-bootstrap ${compiler_core}
- src/thrift/main.cc
- src/thrift/audit/t_audit.cpp
- src/thrift/generate/t_cpp_generator.cc
- )
- target_link_libraries(thrift-bootstrap parse)
-
- set(PLUGIN_GEN_SOURCES
- ${CMAKE_CURRENT_BINARY_DIR}/thrift/plugin/plugin_types.h
- ${CMAKE_CURRENT_BINARY_DIR}/thrift/plugin/plugin_types.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/thrift/plugin/plugin_constants.h
- ${CMAKE_CURRENT_BINARY_DIR}/thrift/plugin/plugin_constants.cpp
- )
-
- file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thrift/plugin)
- add_custom_command(OUTPUT ${PLUGIN_GEN_SOURCES}
- DEPENDS thrift-bootstrap src/thrift/plugin/plugin.thrift
- COMMAND thrift-bootstrap -gen cpp
- -out ${CMAKE_CURRENT_BINARY_DIR}/thrift/plugin
- ${CMAKE_CURRENT_SOURCE_DIR}/src/thrift/plugin/plugin.thrift
- )
-
- include_directories(../../lib/cpp/src)
-
- include(ThriftMacros)
- ADD_LIBRARY_THRIFT(thriftc
- ${compiler_core}
- ${PLUGIN_GEN_SOURCES}
- src/thrift/logging.cc
- src/thrift/plugin/plugin_output.cc
- src/thrift/plugin/plugin.cc
- )
- TARGET_INCLUDE_DIRECTORIES_THRIFT(thriftc PUBLIC ${Boost_INCLUDE_DIRS})
- TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftc thrift PUBLIC)
- target_compile_definitions(thrift-compiler PUBLIC THRIFT_ENABLE_PLUGIN)
- LINK_AGAINST_THRIFT_LIBRARY(thrift-compiler thriftc)
-endif()
-
set_target_properties(thrift-compiler PROPERTIES RUNTIME_OUTPUT_DIRECTORY bin/)
set_target_properties(thrift-compiler PROPERTIES OUTPUT_NAME thrift)
@@ -158,57 +117,6 @@ target_link_libraries(thrift-compiler parse)
install(TARGETS thrift-compiler DESTINATION bin)
-if(${WITH_PLUGIN})
- # Install the headers
- install(FILES
- "src/thrift/common.h"
- "src/thrift/globals.h"
- "src/thrift/logging.h"
- "src/thrift/main.h"
- "src/thrift/platform.h"
- "${CMAKE_BINARY_DIR}/compiler/cpp/thrift/version.h"
- DESTINATION "${INCLUDE_INSTALL_DIR}/thrift")
- install(FILES
- "src/thrift/audit/t_audit.h"
- DESTINATION "${INCLUDE_INSTALL_DIR}/thrift/audit")
- install(FILES
- "src/thrift/generate/t_generator.h"
- "src/thrift/generate/t_generator_registry.h"
- "src/thrift/generate/t_html_generator.h"
- "src/thrift/generate/t_oop_generator.h"
- DESTINATION "${INCLUDE_INSTALL_DIR}/thrift/generate")
- install(FILES
- "src/thrift/parse/t_base_type.h"
- "src/thrift/parse/t_const.h"
- "src/thrift/parse/t_const_value.h"
- "src/thrift/parse/t_container.h"
- "src/thrift/parse/t_doc.h"
- "src/thrift/parse/t_enum.h"
- "src/thrift/parse/t_enum_value.h"
- "src/thrift/parse/t_field.h"
- "src/thrift/parse/t_function.h"
- "src/thrift/parse/t_list.h"
- "src/thrift/parse/t_map.h"
- "src/thrift/parse/t_program.h"
- "src/thrift/parse/t_scope.h"
- "src/thrift/parse/t_service.h"
- "src/thrift/parse/t_set.h"
- "src/thrift/parse/t_struct.h"
- "src/thrift/parse/t_typedef.h"
- "src/thrift/parse/t_type.h"
- DESTINATION "${INCLUDE_INSTALL_DIR}/thrift/parse")
- install(FILES
- "src/thrift/plugin/plugin.h"
- "src/thrift/plugin/plugin_output.h"
- "src/thrift/plugin/type_util.h"
- DESTINATION "${INCLUDE_INSTALL_DIR}/thrift/plugin")
-if(MSVC)
- install(FILES
- "src/thrift/windows/config.h"
- DESTINATION "${INCLUDE_INSTALL_DIR}/thrift/windows")
-endif()
-endif()
-
if(BUILD_TESTING)
add_subdirectory(test)
endif()
diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am
index 087f6bdbd..9b5742fe9 100644
--- a/compiler/cpp/Makefile.am
+++ b/compiler/cpp/Makefile.am
@@ -23,12 +23,7 @@
AUTOMAKE_OPTIONS = subdir-objects
-# Note on why we have src/thrift and src/thrift/plugin directories:
-# Since Automake supports only one set of BUILT_SOURCES per file and does not allow
-# SUBDIRS built before BUILT_SOURCES, we end up separate Makefile.am for each source
-# code generation, i.e. lex-yacc and Thrift, to achieve stable parallel make.
-
-SUBDIRS = src src/thrift/plugin .
+SUBDIRS = src .
if WITH_TESTS
SUBDIRS += test
endif
@@ -37,46 +32,40 @@ bin_PROGRAMS = thrift
thrift_OBJDIR = obj
-plugin_gen = src/thrift/plugin/plugin_types.h \
- src/thrift/plugin/plugin_types.cpp \
- src/thrift/plugin/plugin_constants.h \
- src/thrift/plugin/plugin_constants.cpp
-
-compiler_core = src/thrift/common.h \
+thrift_SOURCES = src/thrift/audit/t_audit.cpp \
+ src/thrift/audit/t_audit.h \
src/thrift/common.cc \
+ src/thrift/common.h \
src/thrift/generate/t_generator.cc \
+ src/thrift/generate/t_generator.h \
src/thrift/generate/t_generator_registry.h \
+ src/thrift/generate/t_html_generator.h \
+ src/thrift/generate/t_oop_generator.h \
src/thrift/globals.h \
- src/thrift/platform.h \
src/thrift/logging.h \
- src/thrift/parse/t_doc.h \
- src/thrift/parse/t_type.h \
+ src/thrift/main.cc \
+ src/thrift/main.h \
+ src/thrift/parse/parse.cc \
src/thrift/parse/t_base_type.h \
+ src/thrift/parse/t_const.h \
+ src/thrift/parse/t_const_value.h \
+ src/thrift/parse/t_container.h \
+ src/thrift/parse/t_doc.h \
src/thrift/parse/t_enum.h \
src/thrift/parse/t_enum_value.h \
- src/thrift/parse/t_typedef.h \
- src/thrift/parse/t_typedef.cc \
- src/thrift/parse/t_container.h \
- src/thrift/parse/t_list.h \
- src/thrift/parse/t_set.h \
- src/thrift/parse/t_map.h \
- src/thrift/parse/t_struct.h \
src/thrift/parse/t_field.h \
- src/thrift/parse/t_service.h \
src/thrift/parse/t_function.h \
+ src/thrift/parse/t_list.h \
+ src/thrift/parse/t_map.h \
src/thrift/parse/t_program.h \
src/thrift/parse/t_scope.h \
- src/thrift/parse/t_const.h \
- src/thrift/parse/t_const_value.h \
- src/thrift/parse/parse.cc \
- src/thrift/generate/t_generator.h \
- src/thrift/generate/t_oop_generator.h \
- src/thrift/generate/t_html_generator.h
-
-thrift_SOURCES = src/thrift/main.h \
- src/thrift/main.cc \
- src/thrift/audit/t_audit.cpp \
- src/thrift/audit/t_audit.h
+ src/thrift/parse/t_service.h \
+ src/thrift/parse/t_set.h \
+ src/thrift/parse/t_struct.h \
+ src/thrift/parse/t_type.h \
+ src/thrift/parse/t_typedef.cc \
+ src/thrift/parse/t_typedef.h \
+ src/thrift/platform.h
# Specific client generator source
thrift_SOURCES += src/thrift/generate/t_as3_generator.cc \
@@ -115,76 +104,6 @@ thrift_CPPFLAGS = -I$(srcdir)/src
thrift_CXXFLAGS = -Wall -Wextra -pedantic -Werror
thrift_LDADD = @LEXLIB@ src/thrift/libparse.a
-if !WITH_PLUGIN
-thrift_SOURCES += $(compiler_core)
-else
-
-lib_LTLIBRARIES = libthriftc.la
-
-thrift_CPPFLAGS += -DTHRIFT_ENABLE_PLUGIN=1
-thrift_LDADD += libthriftc.la
-
-nodist_libthriftc_la_SOURCES = $(plugin_gen)
-libthriftc_la_SOURCES = $(compiler_core) \
- src/thrift/plugin/type_util.h \
- src/thrift/plugin/plugin.h \
- src/thrift/plugin/plugin.cc \
- src/thrift/plugin/plugin_output.h \
- src/thrift/plugin/plugin_output.cc \
- src/thrift/plugin/plugin.thrift \
- src/thrift/logging.cc
-
-
-libthriftc_la_CPPFLAGS = -I$(srcdir)/src -Isrc -I$(top_builddir)/lib/cpp/src -DTHRIFT_ENABLE_PLUGIN=1
-libthriftc_la_CXXFLAGS = -Wall -Wextra -pedantic
-libthriftc_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la
-
-include_thriftdir = $(includedir)/thrift
-include_thrift_HEADERS = src/thrift/common.h \
- src/thrift/globals.h \
- src/thrift/logging.h \
- src/thrift/main.h \
- src/thrift/platform.h \
- src/thrift/version.h
-
-include_auditdir = $(include_thriftdir)/windows
-include_audit_HEADERS = src/thrift/audit/t_audit.h
-
-include_generatedir = $(include_thriftdir)/generate
-include_generate_HEADERS = src/thrift/generate/t_generator.h \
- src/thrift/generate/t_generator_registry.h \
- src/thrift/generate/t_oop_generator.h \
- src/thrift/generate/t_html_generator.h
-
-include_parsedir = $(include_thriftdir)/parse
-include_parse_HEADERS = src/thrift/parse/t_service.h \
- src/thrift/parse/t_program.h \
- src/thrift/parse/t_field.h \
- src/thrift/parse/t_scope.h \
- src/thrift/parse/t_typedef.h \
- src/thrift/parse/t_set.h \
- src/thrift/parse/t_const_value.h \
- src/thrift/parse/t_enum_value.h \
- src/thrift/parse/t_const.h \
- src/thrift/parse/t_list.h \
- src/thrift/parse/t_map.h \
- src/thrift/parse/t_container.h \
- src/thrift/parse/t_base_type.h \
- src/thrift/parse/t_enum.h \
- src/thrift/parse/t_function.h \
- src/thrift/parse/t_type.h \
- src/thrift/parse/t_doc.h \
- src/thrift/parse/t_struct.h
-
-include_plugindir = $(include_thriftdir)/plugin
-include_plugin_HEADERS = src/thrift/plugin/plugin.h \
- src/thrift/plugin/type_util.h \
- src/thrift/plugin/plugin_output.h
-
-include_windowsdir = $(include_thriftdir)/windows
-include_windows_HEADERS = src/thrift/windows/config.h
-endif
-
WINDOWS_DIST = \
compiler.sln \
compiler.vcxproj \
@@ -198,9 +117,9 @@ EXTRA_DIST = \
$(WINDOWS_DIST)
clean-local:
- $(RM) version.h $(plugin_gen)
+ $(RM) version.h
src/thrift/main.cc: src/thrift/version.h
style-local:
- $(CPPSTYLE_CMD)
+ $(CPPSTYLE_CMD)
diff --git a/compiler/cpp/README.md b/compiler/cpp/README.md
index 355191293..5c04cd869 100644
--- a/compiler/cpp/README.md
+++ b/compiler/cpp/README.md
@@ -67,7 +67,7 @@ brew install bison
```
mkdir cmake-build && cd cmake-build
-cmake -G "Xcode" -DWITH_PLUGIN=OFF ..
+cmake -G "Xcode" ..
cmake --build .
```
@@ -107,7 +107,7 @@ cmake --build .
```
mkdir cmake-vs
cd cmake-vs
-cmake -G "Visual Studio 15 2017" -DWITH_PLUGIN=OFF ..
+cmake -G "Visual Studio 15 2017" ..
```
- Now open the folder cmake-vs using Visual Studio.
diff --git a/compiler/cpp/src/Makefile.am b/compiler/cpp/src/Makefile.am
index bc2c5cbac..b3139e21d 100644
--- a/compiler/cpp/src/Makefile.am
+++ b/compiler/cpp/src/Makefile.am
@@ -37,51 +37,3 @@ thrift_libparse_a_SOURCES = thrift/thrifty.yy \
clean-local:
$(RM) thrift/thriftl.cc thrift/thrifty.cc thrift/thrifty.h thrift/thrifty.hh
-
-if WITH_PLUGIN
-noinst_PROGRAMS = thrift/thrift-bootstrap
-
-thrift_thrift_bootstrap_SOURCES = \
- thrift/common.h \
- thrift/common.cc \
- thrift/audit/t_audit.h \
- thrift/audit/t_audit.cpp \
- thrift/generate/t_generator.cc \
- thrift/generate/t_generator_registry.h \
- thrift/globals.h \
- thrift/platform.h \
- thrift/logging.h \
- thrift/parse/t_doc.h \
- thrift/parse/t_type.h \
- thrift/parse/t_base_type.h \
- thrift/parse/t_enum.h \
- thrift/parse/t_enum_value.h \
- thrift/parse/t_typedef.h \
- thrift/parse/t_typedef.cc \
- thrift/parse/t_container.h \
- thrift/parse/t_list.h \
- thrift/parse/t_set.h \
- thrift/parse/t_map.h \
- thrift/parse/t_struct.h \
- thrift/parse/t_field.h \
- thrift/parse/t_service.h \
- thrift/parse/t_function.h \
- thrift/parse/t_program.h \
- thrift/parse/t_scope.h \
- thrift/parse/t_const.h \
- thrift/parse/t_const_value.h \
- thrift/parse/parse.cc \
- thrift/generate/t_generator.h \
- thrift/generate/t_oop_generator.h \
- thrift/generate/t_html_generator.h \
- thrift/windows/config.h \
- thrift/version.h \
- thrift/generate/t_cpp_generator.cc \
- thrift/main.h \
- thrift/main.cc
-
-main.cc: version.h
-
-thrift_thrift_bootstrap_CXXFLAGS = -Wall -Wextra -pedantic
-thrift_thrift_bootstrap_LDADD = @LEXLIB@ thrift/libparse.a
-endif
diff --git a/compiler/cpp/src/thrift/common.cc b/compiler/cpp/src/thrift/common.cc
index 3a2b9d359..fb1832daf 100644
--- a/compiler/cpp/src/thrift/common.cc
+++ b/compiler/cpp/src/thrift/common.cc
@@ -58,10 +58,6 @@ void clearGlobals() {
}
/**
- * Those are not really needed for plugins but causes link errors without
- */
-
-/**
* The location of the last parsed doctext comment.
*/
int g_doctext_lineno;
diff --git a/compiler/cpp/src/thrift/logging.cc b/compiler/cpp/src/thrift/logging.cc
index f821f5fc5..4811c4ef1 100644
--- a/compiler/cpp/src/thrift/logging.cc
+++ b/compiler/cpp/src/thrift/logging.cc
@@ -17,17 +17,12 @@
* under the License.
*/
-/**
- * Logging functions copied from main.cc to avoid link errors for plugins
- */
-
#include "thrift/logging.h"
#include "thrift/globals.h"
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
-// TODO: make plugins accept log options from main compiler
int g_debug = 0;
int g_warn = 1;
int g_verbose = 0;
diff --git a/compiler/cpp/src/thrift/main.cc b/compiler/cpp/src/thrift/main.cc
index eddbd56b0..adcab83c1 100644
--- a/compiler/cpp/src/thrift/main.cc
+++ b/compiler/cpp/src/thrift/main.cc
@@ -53,9 +53,6 @@
#include "thrift/parse/t_scope.h"
#include "thrift/generate/t_generator.h"
#include "thrift/audit/t_audit.h"
-#ifdef THRIFT_ENABLE_PLUGIN
-#include "thrift/plugin/plugin_output.h"
-#endif
#include "thrift/version.h"
@@ -1007,26 +1004,8 @@ void generate(t_program* program, const vector<string>& generator_strings) {
t_generator* generator = t_generator_registry::get_generator(program, *iter);
if (generator == NULL) {
-#ifdef THRIFT_ENABLE_PLUGIN
- switch (plugin_output::delegateToPlugin(program, *iter)) {
- case plugin_output::PLUGIN_NOT_FOUND:
- pwarning(1, "Unable to get a generator for \"%s\".\n", iter->c_str());
- g_generator_failure = true;
- break;
- case plugin_output::PLUGIN_FAILURE:
- pwarning(1, "Plugin generator for \"%s\" failed.\n", iter->c_str());
- g_generator_failure = true;
- break;
- case plugin_output::PLUGIN_SUCCEESS:
- break;
- default:
- assert(false);
- break;
- }
-#else
pwarning(1, "Unable to get a generator for \"%s\".\n", iter->c_str());
g_generator_failure = true;
-#endif
} else if (generator) {
generator->validate_input();
pverbose("Generating \"%s\"\n", iter->c_str());
diff --git a/compiler/cpp/src/thrift/parse/t_const_value.h b/compiler/cpp/src/thrift/parse/t_const_value.h
index 6a114cf16..e5ecc1d6d 100644
--- a/compiler/cpp/src/thrift/parse/t_const_value.h
+++ b/compiler/cpp/src/thrift/parse/t_const_value.h
@@ -26,11 +26,6 @@
#include <vector>
#include <string>
-namespace plugin_output {
-template <typename From, typename To>
-void convert(From*, To&);
-}
-
/**
* A const value is something parsed that could be a map, set, list, struct
* or whatever.
@@ -204,10 +199,6 @@ private:
t_enum* enum_;
t_const_value_type valType_;
-
- // to read enum_
- template <typename From, typename To>
- friend void plugin_output::convert(From*, To&);
};
#endif
diff --git a/compiler/cpp/src/thrift/parse/t_scope.h b/compiler/cpp/src/thrift/parse/t_scope.h
index 6f160a5cc..137af8832 100644
--- a/compiler/cpp/src/thrift/parse/t_scope.h
+++ b/compiler/cpp/src/thrift/parse/t_scope.h
@@ -33,11 +33,6 @@
#include "thrift/parse/t_list.h"
#include "thrift/parse/t_set.h"
-namespace plugin_output {
-template <typename From, typename To>
-void convert(From*, To&);
-}
-
/**
* This represents a variable scope used for looking up predefined types and
* services. Typically, a scope is associated with a t_program. Scopes are not
@@ -179,10 +174,6 @@ private:
// Map of names to services
std::map<std::string, t_service*> services_;
-
- // to list map entries
- template <typename From, typename To>
- friend void plugin_output::convert(From*, To&);
};
#endif
diff --git a/compiler/cpp/src/thrift/plugin/Makefile.am b/compiler/cpp/src/thrift/plugin/Makefile.am
deleted file mode 100644
index e84cdbd9c..000000000
--- a/compiler/cpp/src/thrift/plugin/Makefile.am
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# 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.
-#
-#
-# Contains some contributions under the Thrift Software License.
-# Please see doc/old-thrift-license.txt in the Thrift distribution for
-# details.
-
-AUTOMAKE_OPTIONS = subdir-objects
-
-if WITH_PLUGIN
-plugin_gen = plugin_types.h \
- plugin_types.cpp \
- plugin_constants.h \
- plugin_constants.cpp
-
-BUILT_SOURCES = $(plugin_gen)
-gen.stamp: plugin.thrift $(top_builddir)/compiler/cpp/src/thrift/thrift-bootstrap
- @$(RM) -f gen.tmp
- @touch gen.tmp
- $(top_builddir)/compiler/cpp/src/thrift/thrift-bootstrap -gen cpp -out . $<
- @mv -f gen.tmp $@
-
-$(plugin_gen): gen.stamp
- @if test -f $@; then :; else \
- $(RM) -f gen.stamp; \
- $(MAKE) $(AM_MAKEFLAGS) gen.stamp; \
- fi
-
-clean-local:
- $(RM) version.h windows/version.h $(plugin_gen)
-endif
diff --git a/compiler/cpp/src/thrift/plugin/plugin.cc b/compiler/cpp/src/thrift/plugin/plugin.cc
deleted file mode 100644
index 7c4c432b0..000000000
--- a/compiler/cpp/src/thrift/plugin/plugin.cc
+++ /dev/null
@@ -1,511 +0,0 @@
-/*
- * 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.
- */
-
-#include "thrift/plugin/plugin.h"
-
-#ifdef _WIN32
-#include <fcntl.h>
-#include <io.h>
-#endif
-
-#include <cassert>
-#include <functional>
-#include <iostream>
-#include <memory>
-
-#include <boost/range/adaptor/map.hpp>
-#include <boost/range/algorithm/for_each.hpp>
-
-#include "thrift/generate/t_generator.h"
-#include "thrift/plugin/type_util.h"
-#include "thrift/protocol/TBinaryProtocol.h"
-#include "thrift/transport/TBufferTransports.h"
-#include "thrift/transport/TFDTransport.h"
-#include "thrift/plugin/plugin_types.h"
-
-namespace apache {
-namespace thrift {
-namespace plugin {
-
-using apache::thrift::protocol::TBinaryProtocol;
-using apache::thrift::transport::TFDTransport;
-using apache::thrift::transport::TFramedTransport;
-
-#define THRIFT_CONVERT_FORWARD(from_type) \
- template <> \
- typename ToType<from_type>::type* convert_forward<from_type>(const from_type& from)
-
-#define THRIFT_CONVERT_COMPLETE_DECL(from_type) \
- template <> \
- void convert(const from_type& from, ToType<from_type>::type* to)
-
-#define THRIFT_CONVERT_UNARY_DECL(from_type) \
- template <> \
- typename ToType<from_type>::type* convert<from_type>(const from_type& from)
-
-#define THRIFT_CONVERSION_DECL(from_type) \
- THRIFT_CONVERT_FORWARD(from_type); \
- THRIFT_CONVERT_COMPLETE_DECL(from_type); \
- THRIFT_CONVERT_UNARY_DECL(from_type)
-
-#define THRIFT_CONVERT_COMPLETE(from_type) \
- THRIFT_CONVERSION_DECL(from_type) { \
- ToType<from_type>::type* to = convert_forward(from); \
- convert(from, to); \
- return to; \
- } \
- THRIFT_CONVERT_COMPLETE_DECL(from_type)
-
-#define THRIFT_CONVERSION(from_type, ...) \
- THRIFT_CONVERT_FORWARD(from_type) { \
- (void)from; \
- return new ToType<from_type>::type(__VA_ARGS__); \
- } \
- THRIFT_CONVERT_COMPLETE(from_type)
-
-#define THRIFT_ASSIGN_DOC() \
- do { \
- if (from.__isset.doc) \
- to->set_doc(from.doc); \
- } while (0)
-
-#define THRIFT_ASSIGN_ANNOTATIONS() \
- THRIFT_ASSIGN_DOC(); \
- do { \
- if (from.__isset.annotations) \
- to->annotations_ = from.annotations; \
- } while (0)
-
-#define THRIFT_ASSIGN_METADATA() \
- do { \
- to->set_name(from.metadata.name); \
- if (from.metadata.__isset.doc) \
- to->set_doc(from.metadata.doc); \
- if (from.metadata.__isset.annotations) \
- to->annotations_ = from.metadata.annotations; \
- } while (0)
-
-::t_program* g_program = 0;
-
-template <typename C, typename S>
-struct TypeCache {
- C* operator[](const int64_t& k) {
- typename std::map<int64_t, C*>::iterator it = cache.find(k);
- if (it != cache.end()) {
- return it->second;
- } else {
- typename std::map<int64_t, S>::const_iterator cit = source->find(k);
- if (cit == source->end()) {
- throw ThriftPluginError("Type not found");
- }
- return (cache)[k] = convert_forward(cit->second);
- }
- }
-
- void compileAll() {
- boost::for_each(*source | boost::adaptors::map_keys,
- std::bind(&TypeCache::compile, this, std::placeholders::_1));
- }
-
- std::map<int64_t, S> const* source;
-
- void clear() {
- source = nullptr ;
- cache.clear() ;
- }
-
-protected:
- std::map<int64_t, C*> cache;
-
-private:
- void compile(const int64_t& k) {
- typename std::map<int64_t, S>::const_iterator cit = source->find(k);
- if (cit == source->end()) {
- throw ThriftPluginError("Type not found ");
- }
- convert(cit->second, (*this)[k]);
- }
-};
-std::map<int64_t, ::t_program*> g_program_cache;
-TypeCache< ::t_type, t_type> g_type_cache;
-TypeCache< ::t_const, t_const> g_const_cache;
-TypeCache< ::t_service, t_service> g_service_cache;
-
-void clear_global_cache() {
- g_type_cache.clear();
- g_const_cache.clear();
- g_service_cache.clear();
-}
-
-void set_global_cache(const TypeRegistry& from) {
- g_type_cache.source = &from.types;
- g_const_cache.source = &from.constants;
- g_service_cache.source = &from.services;
-
- g_type_cache.compileAll();
- g_const_cache.compileAll();
- g_service_cache.compileAll();
-}
-
-template <typename T>
-T* resolve_type(int64_t name) {
- return reinterpret_cast<T*>(g_type_cache[name]);
-}
-
-::t_const* resolve_const(int64_t name) {
- return g_const_cache[name];
-}
-
-::t_service* resolve_service(int64_t name) {
- return g_service_cache[name];
-}
-
-THRIFT_CONVERT_FORWARD(t_base_type) {
-#define T_BASETYPE_CASE(type) \
- case t_base::TYPE_##type: \
- t = ::t_base_type::TYPE_##type; \
- break
-
- ::t_base_type::t_base t = ::t_base_type::TYPE_VOID;
- bool is_binary = false;
- switch (from.value) {
- T_BASETYPE_CASE(VOID);
- T_BASETYPE_CASE(STRING);
- T_BASETYPE_CASE(BOOL);
- T_BASETYPE_CASE(I8);
- T_BASETYPE_CASE(I16);
- T_BASETYPE_CASE(I32);
- T_BASETYPE_CASE(I64);
- T_BASETYPE_CASE(DOUBLE);
- case t_base::TYPE_BINARY:
- t = ::t_base_type::TYPE_STRING;
- is_binary = true;
- break;
- }
- ::t_base_type* to = new ::t_base_type(from.metadata.name, t);
- to->set_binary(is_binary);
- return to;
-#undef T_BASETYPE_CASE
-}
-THRIFT_CONVERT_COMPLETE(t_base_type) {
- THRIFT_ASSIGN_METADATA();
-}
-
-THRIFT_CONVERT_FORWARD(t_typedef) {
- ::t_typedef* to;
- if (from.forward) {
- to = new ::t_typedef(g_program_cache[from.metadata.program_id], from.symbolic, true);
- } else {
- to = new ::t_typedef(g_program_cache[from.metadata.program_id],
- resolve_type< ::t_type>(from.type), from.symbolic);
- }
- return to;
-}
-THRIFT_CONVERT_COMPLETE(t_typedef) {
- THRIFT_ASSIGN_METADATA();
-}
-THRIFT_CONVERSION(t_enum_value, from.name, from.value) {
- assert(to);
- THRIFT_ASSIGN_ANNOTATIONS();
-}
-THRIFT_CONVERSION(t_enum, g_program_cache[from.metadata.program_id]) {
- assert(to);
- THRIFT_ASSIGN_METADATA();
- boost::for_each(from.constants | boost::adaptors::transformed(convert<t_enum_value>),
- std::bind(&::t_enum::append, to, std::placeholders::_1));
-}
-THRIFT_CONVERSION(t_list, resolve_type< ::t_type>(from.elem_type)) {
- assert(to);
- THRIFT_ASSIGN_METADATA();
- if (from.__isset.cpp_name)
- to->set_cpp_name(from.cpp_name);
-}
-THRIFT_CONVERSION(t_set, resolve_type< ::t_type>(from.elem_type)) {
- assert(to);
- THRIFT_ASSIGN_METADATA();
- if (from.__isset.cpp_name)
- to->set_cpp_name(from.cpp_name);
-}
-THRIFT_CONVERSION(t_map,
- resolve_type< ::t_type>(from.key_type),
- resolve_type< ::t_type>(from.val_type)) {
- assert(to);
- THRIFT_ASSIGN_METADATA();
- if (from.__isset.cpp_name)
- to->set_cpp_name(from.cpp_name);
-}
-THRIFT_CONVERSION(t_const_value, ) {
-#define T_CONST_VALUE_CASE(type) \
- if (from.__isset.type##_val) \
- to->set_##type(from.type##_val)
-
- assert(to);
- if (from.__isset.map_val) {
- to->set_map();
- for (std::map<t_const_value, t_const_value>::const_iterator it = from.map_val.begin();
- it != from.map_val.end(); it++) {
- to->add_map(convert(it->first), convert(it->second));
- }
- } else if (from.__isset.list_val) {
- to->set_list();
- boost::for_each(from.list_val | boost::adaptors::transformed(&convert<t_const_value>),
- std::bind(&::t_const_value::add_list, to, std::placeholders::_1));
- } else
- T_CONST_VALUE_CASE(string);
- else T_CONST_VALUE_CASE(integer);
- else T_CONST_VALUE_CASE(double);
- else if (from.__isset.const_identifier_val) {
- to->set_identifier(from.const_identifier_val.identifier_val) ;
- to->set_enum(resolve_type< ::t_enum>(from.const_identifier_val.enum_val)) ;
- }
-
-#undef T_CONST_VALUE_CASE
-}
-THRIFT_CONVERSION(t_field, resolve_type< ::t_type>(from.type), from.name, from.key) {
- assert(to);
- THRIFT_ASSIGN_ANNOTATIONS();
- to->set_reference(from.reference);
- to->set_req(static_cast< ::t_field::e_req>(from.req));
- if (from.__isset.value) {
- to->set_value(convert(from.value));
- }
-}
-THRIFT_CONVERSION(t_struct, g_program_cache[from.metadata.program_id]) {
- assert(to);
- THRIFT_ASSIGN_METADATA();
- to->set_union(from.is_union);
- to->set_xception(from.is_xception);
- boost::for_each(from.members | boost::adaptors::transformed(convert<t_field>),
- std::bind(&::t_struct::append, to, std::placeholders::_1));
-}
-THRIFT_CONVERSION(t_const,
- resolve_type< ::t_type>(from.type),
- from.name,
- convert<t_const_value>(from.value)) {
- assert(to);
- THRIFT_ASSIGN_DOC();
-}
-
-THRIFT_CONVERSION(t_function,
- resolve_type< ::t_type>(from.returntype),
- from.name,
- resolve_type< ::t_struct>(from.arglist),
- resolve_type< ::t_struct>(from.xceptions),
- from.is_oneway) {
- assert(to);
- THRIFT_ASSIGN_DOC();
-}
-
-THRIFT_CONVERSION(t_service, g_program_cache[from.metadata.program_id]) {
- assert(to);
- assert(from.metadata.program_id);
- assert(g_program_cache[from.metadata.program_id]);
- THRIFT_ASSIGN_METADATA();
-
- boost::for_each(from.functions | boost::adaptors::transformed(convert<t_function>),
- std::bind(&::t_service::add_function, to, std::placeholders::_1));
-
- if (from.__isset.extends_)
- to->set_extends(resolve_service(from.extends_));
-}
-
-THRIFT_CONVERT_FORWARD(t_type) {
-#define T_TYPE_CASE_FW_T(case, type) \
- if (from.__isset.case##_val) \
- return convert_forward<type>(from.case##_val)
-#define T_TYPE_CASE_FW(case) T_TYPE_CASE_FW_T(case, t_##case)
-
- T_TYPE_CASE_FW(base_type);
- T_TYPE_CASE_FW(typedef);
- T_TYPE_CASE_FW(enum);
- T_TYPE_CASE_FW(struct);
- T_TYPE_CASE_FW_T(xception, t_struct);
- T_TYPE_CASE_FW(list);
- T_TYPE_CASE_FW(set);
- T_TYPE_CASE_FW(map);
- T_TYPE_CASE_FW(service);
- throw ThriftPluginError("Invalid data: Type union has no value.");
-#undef T_TYPE_CASE_FW_T
-#undef T_TYPE_CASE_FW
-}
-THRIFT_CONVERT_COMPLETE(t_type) {
-#define T_TYPE_CASE_T(case, type) \
- else if (from.__isset.case##_val) \
- convert<type, ::type>(from.case##_val, reinterpret_cast< ::type*>(to))
-#define T_TYPE_CASE(case) T_TYPE_CASE_T(case, t_##case)
-
- if (false) {
- }
- T_TYPE_CASE(base_type);
- T_TYPE_CASE(typedef);
- T_TYPE_CASE(enum);
- T_TYPE_CASE(struct);
- T_TYPE_CASE_T(xception, t_struct);
- T_TYPE_CASE(list);
- T_TYPE_CASE(set);
- T_TYPE_CASE(map);
- T_TYPE_CASE(service);
- else {
- throw ThriftPluginError("Invalid data: Type union has no value.");
- }
-#undef T_TYPE_CASE_T
-#undef T_TYPE_CASE
-}
-
-THRIFT_CONVERSION(t_scope, ) {
- assert(to);
-#define T_SCOPE_RESOLVE(type, name, a) \
- for (std::vector<int64_t>::const_iterator it = from.name##s.begin(); it != from.name##s.end(); \
- it++) { \
- ::t_##type* t = resolve_##type a(*it); \
- to->add_##name(t->get_name(), t); \
- }
- T_SCOPE_RESOLVE(type, type, < ::t_type>);
- T_SCOPE_RESOLVE(const, constant, );
- T_SCOPE_RESOLVE(service, service, );
-#undef T_SCOPE_RESOLVE
-}
-
-THRIFT_CONVERT_FORWARD(t_program) {
- ::t_program* to = new ::t_program(from.path, from.name);
- for (std::vector<t_program>::const_iterator it = from.includes.begin(); it != from.includes.end();
- it++) {
- to->add_include(convert_forward(*it));
- }
- g_program_cache[from.program_id] = to;
- return to;
-}
-THRIFT_CONVERT_COMPLETE(t_program) {
- assert(to);
- g_program = to;
- convert<t_scope, ::t_scope>(from.scope, to->scope());
- THRIFT_ASSIGN_DOC();
-
- to->set_out_path(from.out_path, from.out_path_is_absolute);
-
- boost::for_each(from.typedefs | boost::adaptors::transformed(&resolve_type< ::t_typedef>),
- std::bind(&::t_program::add_typedef, to, std::placeholders::_1));
- boost::for_each(from.enums | boost::adaptors::transformed(&resolve_type< ::t_enum>),
- std::bind(&::t_program::add_enum, to, std::placeholders::_1));
- for (std::vector<int64_t>::const_iterator it = from.objects.begin(); it != from.objects.end();
- it++) {
- ::t_struct* t2 = resolve_type< ::t_struct>(*it);
- if (t2->is_xception()) {
- to->add_xception(t2);
- } else {
- to->add_struct(t2);
- }
- }
- boost::for_each(from.consts | boost::adaptors::transformed(&resolve_const),
- std::bind(&::t_program::add_const, to, std::placeholders::_1));
- boost::for_each(from.services | boost::adaptors::transformed(&resolve_service),
- std::bind(&::t_program::add_service, to, std::placeholders::_1));
-
- for (std::vector<t_program>::const_iterator it = from.includes.begin(); it != from.includes.end();
- it++) {
- convert(*it, g_program_cache[it->program_id]);
- }
- std::for_each(from.c_includes.begin(), from.c_includes.end(),
- std::bind(&::t_program::add_c_include, to, std::placeholders::_1));
- std::for_each(from.cpp_includes.begin(), from.cpp_includes.end(),
- std::bind(&::t_program::add_cpp_include, to, std::placeholders::_1));
- for (std::map<std::string, std::string>::const_iterator it = from.namespaces.begin();
- it != from.namespaces.end(); it++) {
- to->set_namespace(it->first, it->second);
- }
-
- to->set_include_prefix(from.include_prefix);
- to->set_namespace(from.namespace_);
-}
-
-int GeneratorPlugin::exec(int, char* []) {
-#ifdef _WIN32
- _setmode(fileno(stdin), _O_BINARY);
-#endif
- std::shared_ptr<TFramedTransport> transport(
- new TFramedTransport(std::make_shared<TFDTransport>(fileno(stdin))));
- TBinaryProtocol proto(transport);
- GeneratorInput input;
- try {
- input.read(&proto);
- } catch (std::exception& err) {
- std::cerr << "Error while receiving plugin data: " << err.what() << std::endl;
- return -1;
- }
- initGlobals();
- ::t_program* p = g_program = convert_forward(input.program);
- set_global_cache(input.type_registry);
- convert(input.program, p);
-
- int ret = generate(p, input.parsed_options);
- clearGlobals();
-
- return ret;
-}
-
-::t_const_value::t_const_value_type const_value_case(const t_const_value& v) {
- if (v.__isset.map_val)
- return ::t_const_value::CV_MAP;
- if (v.__isset.list_val)
- return ::t_const_value::CV_LIST;
- if (v.__isset.string_val)
- return ::t_const_value::CV_STRING;
- if (v.__isset.integer_val)
- return ::t_const_value::CV_INTEGER;
- if (v.__isset.double_val)
- return ::t_const_value::CV_DOUBLE;
- if (v.__isset.const_identifier_val)
- return ::t_const_value::CV_IDENTIFIER;
- throw ThriftPluginError("Unknown const value type");
-}
-
-bool t_const_value::operator<(const t_const_value& that) const {
- ::t_const_value::t_const_value_type t1 = const_value_case(*this);
- ::t_const_value::t_const_value_type t2 = const_value_case(that);
- if (t1 != t2)
- return t1 < t2;
- switch (t1) {
- case ::t_const_value::CV_INTEGER:
- return integer_val < that.integer_val;
- case ::t_const_value::CV_DOUBLE:
- return double_val < that.double_val;
- case ::t_const_value::CV_STRING:
- return string_val < that.string_val;
- case ::t_const_value::CV_MAP:
- if (that.map_val.empty())
- return false;
- else if (map_val.empty())
- return true;
- else
- return map_val.begin()->first < that.map_val.begin()->first;
- case ::t_const_value::CV_LIST:
- if (that.list_val.empty())
- return false;
- else if (list_val.empty())
- return true;
- else
- return list_val.front() < that.list_val.front();
- case ::t_const_value::CV_IDENTIFIER:
- return integer_val < that.integer_val;
- }
- throw ThriftPluginError("Unknown const value type");
-}
-}
-}
-}
diff --git a/compiler/cpp/src/thrift/plugin/plugin.h b/compiler/cpp/src/thrift/plugin/plugin.h
deleted file mode 100644
index 705cd41ff..000000000
--- a/compiler/cpp/src/thrift/plugin/plugin.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef T_PLUGIN_PLUGIN_H
-#define T_PLUGIN_PLUGIN_H
-
-#include "thrift/Thrift.h"
-
-class t_program;
-
-namespace apache {
-namespace thrift {
-namespace plugin {
-
-struct ThriftPluginError : public apache::thrift::TException {
- ThriftPluginError(const std::string& msg) : apache::thrift::TException(msg) {}
-};
-
-class GeneratorPlugin {
-public:
- int exec(int argc, char* argv[]);
- virtual int generate(::t_program*, const std::map<std::string, std::string>&) = 0;
-};
-}
-}
-}
-
-#endif
diff --git a/compiler/cpp/src/thrift/plugin/plugin.thrift b/compiler/cpp/src/thrift/plugin/plugin.thrift
deleted file mode 100644
index 6d98f9955..000000000
--- a/compiler/cpp/src/thrift/plugin/plugin.thrift
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.
- */
-
-namespace as3 org.apache.thrift.plugin
-namespace cpp apache.thrift.plugin
-namespace csharp Thrift.Plugin
-namespace d thrift.plugin
-namespace delphi Thrift.Plugin
-namespace erl thrift.plugin
-namespace go thrift
-namespace haxe org.apache.thrift.plugin
-namespace hs Thrift.Plugin
-namespace java org.apache.thrift.plugin
-namespace ocaml Thrift
-namespace perl Thrift.Plugin
-namespace php thrift.plugin
-namespace py thrift.plugin
-namespace rb Thrift
-
-typedef i64 t_program_id
-typedef i64 t_type_id
-typedef i64 t_const_id
-typedef i64 t_service_id
-
-enum t_base {
- TYPE_VOID
- TYPE_STRING
- TYPE_BOOL
- TYPE_I8
- TYPE_I16
- TYPE_I32
- TYPE_I64
- TYPE_DOUBLE
- TYPE_BINARY
-}
-
-struct TypeMetadata {
- 1: required string name
- 2: required t_program_id program_id
- 99: optional map<string, string> annotations
- 100: optional string doc
-}
-
-struct t_base_type {
- 1: required TypeMetadata metadata
- 2: required t_base value
-}
-
-struct t_list {
- 1: required TypeMetadata metadata
- 2: optional string cpp_name
- 3: required t_type_id elem_type
-}
-
-struct t_set {
- 1: required TypeMetadata metadata
- 2: optional string cpp_name
- 3: required t_type_id elem_type
-}
-
-struct t_map {
- 1: required TypeMetadata metadata
- 2: optional string cpp_name
- 3: required t_type_id key_type
- 4: required t_type_id val_type
-}
-
-struct t_typedef {
- 1: required TypeMetadata metadata
- 2: required t_type_id type
- 3: required string symbolic
- 4: required bool forward
-}
-
-struct t_enum_value {
- 1: required string name
- 2: required i32 value
- 99: optional map<string, string> annotations
- 100: optional string doc
-}
-struct t_enum {
- 1: required TypeMetadata metadata
- 2: required list<t_enum_value> constants
-}
-
-enum Requiredness {
- T_REQUIRED = 0
- T_OPTIONAL = 1
- T_OPT_IN_REQ_OUT = 2
-}
-
-struct t_const_identifier_value {
- 1: required string identifier_val
- 2: required t_type_id enum_val
-}
-
-union t_const_value {
- 1: optional map<t_const_value, t_const_value> map_val
- 2: optional list<t_const_value> list_val
- 3: optional string string_val
- 4: optional i64 integer_val
- 5: optional double double_val
- 8: optional t_const_identifier_value const_identifier_val
-}
-
-struct t_const {
- 1: required string name
- 2: required t_type_id type
- 3: required t_const_value value
- 100: optional string doc
-}
-struct t_field {
- 1: required string name
- 2: required t_type_id type
- 3: required i32 key
- 4: required Requiredness req
- 5: optional t_const_value value
- 10: required bool reference
- 99: optional map<string, string> annotations
- 100: optional string doc
-}
-struct t_struct {
- 1: required TypeMetadata metadata
- 2: required list<t_field> members
- 3: required bool is_union
- 4: required bool is_xception
-}
-struct t_function {
- 1: required string name
- 2: required t_type_id returntype
- 3: required t_type_id arglist
- 4: required t_type_id xceptions
- 5: required bool is_oneway
- 100: optional string doc
-}
-struct t_service {
- 1: required TypeMetadata metadata
- 2: required list<t_function> functions
- 3: optional t_service_id extends_
-}
-union t_type {
- 1: optional t_base_type base_type_val
- 2: optional t_typedef typedef_val
- 3: optional t_enum enum_val
- 4: optional t_struct struct_val
- 5: optional t_struct xception_val
- 6: optional t_list list_val
- 7: optional t_set set_val
- 8: optional t_map map_val
- 9: optional t_service service_val
-}
-struct t_scope {
- 1: required list<t_type_id> types
- 2: required list<t_const_id> constants
- 3: required list<t_service_id> services
-}
-
-struct TypeRegistry {
- 1: required map<t_type_id, t_type> types
- 2: required map<t_const_id, t_const> constants
- 3: required map<t_service_id, t_service> services
-}
-
-struct t_program {
- 1: required string name
- 2: required t_program_id program_id
- 3: required string path
- 4: required string namespace_
- 5: required string out_path
- 6: required bool out_path_is_absolute
- 8: required list<t_program> includes
- 9: required string include_prefix
- 10: required t_scope scope
-
- 11: required list<t_type_id> typedefs
- 12: required list<t_type_id> enums
- 13: required list<t_const_id> consts
- 14: required list<t_type_id> objects
- 15: required list<t_service_id> services
-
- 16: required map<string, string> namespaces
- 17: required list<string> cpp_includes
- 18: required list<string> c_includes
- 100: optional string doc
-}
-
-struct GeneratorInput {
- 1: required t_program program
- 2: required TypeRegistry type_registry
- 3: required map<string, string> parsed_options
-}
diff --git a/compiler/cpp/src/thrift/plugin/plugin_output.cc b/compiler/cpp/src/thrift/plugin/plugin_output.cc
deleted file mode 100644
index f8223dedc..000000000
--- a/compiler/cpp/src/thrift/plugin/plugin_output.cc
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * 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.
- */
-
-#ifdef _WIN32
-#include <cstdio>
-#include <fcntl.h>
-#include <io.h>
-#include <iostream>
-#define THRIFT_POPEN(cmd) _popen(cmd, "wb")
-#define THRIFT_PCLOSE _pclose
-#else
-#define THRIFT_POPEN(cmd) popen(cmd, "w")
-#define THRIFT_PCLOSE pclose
-#endif
-
-#include "thrift/plugin/plugin_output.h"
-
-#include <boost/range/adaptor/map.hpp>
-#include <boost/range/algorithm/copy.hpp>
-#include <boost/range/algorithm/transform.hpp>
-
-#include "thrift/generate/t_generator.h"
-#include "thrift/plugin/plugin.h"
-#include "thrift/plugin/type_util.h"
-#include "thrift/protocol/TBinaryProtocol.h"
-#include "thrift/transport/TBufferTransports.h"
-#include "thrift/transport/TFDTransport.h"
-
-#include "thrift/plugin/plugin_types.h"
-
-#include <memory>
-
-namespace plugin_output {
-
-template <typename From>
-typename apache::thrift::plugin::ToType<From>::type convert(From* from) {
- typename apache::thrift::plugin::ToType<From>::type to;
- convert(from, to);
- return to;
-}
-
-using apache::thrift::protocol::TBinaryProtocol;
-using std::make_shared;
-using std::shared_ptr;
-using apache::thrift::transport::TFDTransport;
-using apache::thrift::transport::TFramedTransport;
-
-using namespace apache::thrift;
-
-#define THRIFT_CONVERSION_N(from_type, to_type) \
- template <> \
- void convert<from_type, to_type>(from_type * from, to_type & to)
-#define THRIFT_CONVERSION(type) THRIFT_CONVERSION_N(::type, plugin::type)
-
-#define THRIFT_ASSIGN_N(from_name, to_name, prefix) \
- do { \
- if (from) \
- to.__set_##to_name(prefix(from->from_name)); \
- } while (0)
-
-#define THRIFT_ASSIGN(name) THRIFT_ASSIGN_N(get_##name(), name, )
-#define THRIFT_ASSIGN_CONVERT(type, from_name, to_name) \
- do { \
- if (from && from->from_name) { \
- to.__set_##to_name(convert(from->from_name)); \
- } \
- } while (0)
-
-#define THRIFT_ASSIGN_OPT(name) \
- do { \
- if (from->has_##name()) \
- THRIFT_ASSIGN(name); \
- } while (0)
-
-#define THRIFT_ASSIGN_LIST_N(type, from_name, to_name) \
- do { \
- if (from && !from->from_name.empty()) { \
- std::transform(from->from_name.begin(), \
- from->from_name.end(), \
- std::back_inserter(to.to_name), \
- convert< ::type>); \
- } \
- } while (0)
-
-#define THRIFT_ASSIGN_METADATA() convert(reinterpret_cast<t_type*>(from), to.metadata)
-
-// a generator of sequential unique identifiers for addresses -- so
-// that the TypeCache below can use those IDs instead of
-// addresses. This allows GeneratorInput's various
-// t_{program,type,etc}_id types to be dense consecutively-numbered
-// integers, instead of large random-seeming integers.
-//
-// Furthermore, this allows GeneratorInput to be deterministic (no
-// addresses, so no pseudo-randomness) and that means reproducibility
-// of output.
-const int64_t ONE_MILLION = 1000 * 1000;
-class id_generator {
-public:
- id_generator() : addr2id_(), next_id_(ONE_MILLION) {}
-
- void clear() {
- addr2id_.clear() ;
- next_id_ = ONE_MILLION ;
- }
-
- int64_t gensym(const int64_t addr) {
- if (!addr) return 0L ;
- std::map<int64_t, int64_t>::iterator it = addr2id_.find(addr);
- if (it != addr2id_.end()) return it->second ;
- int64_t id = next_id_++ ;
- addr2id_.insert(std::make_pair(addr, id)) ;
- return id ;
- }
-
- std::map<int64_t, int64_t> addr2id_ ;
- int64_t next_id_ ;
-} ;
-
-// To avoid multiple instances of same type, t_type, t_const and t_service are stored in one place
-// and referenced by ID.
-template <typename T>
-struct TypeCache {
- typedef typename plugin::ToType<T>::type to_type;
- id_generator idgen ;
- std::map<int64_t, to_type> cache;
-
- template <typename T2>
- int64_t store(T2* t) {
- intptr_t addr = reinterpret_cast<intptr_t>(t);
- if (!addr) return 0L ;
-
- int64_t id = idgen.gensym(addr) ;
- if (cache.end() != cache.find(id)) return id ;
-
- // HACK: fake resolve for recursive type
- cache.insert(std::make_pair(id, to_type()));
- // overwrite with true value
- cache[id] = convert(t);
- return id ;
- }
-
- void clear() { cache.clear() ; idgen.clear(); }
-};
-
-template <typename T>
-int64_t store_type(T* t);
-
-#define T_STORE(type) \
- TypeCache<t_##type> type##_cache; \
- template <> \
- plugin::t_##type##_id store_type<t_##type>(t_##type * t) { \
- return type##_cache.store<t_##type>(t); \
- }
-T_STORE(type)
-T_STORE(const)
-T_STORE(service)
-#undef T_STORE
-// this id_generator is for gensymm-ing t_program_id
-id_generator program_cache ;
-
-#define THRIFT_ASSIGN_ID_N(t, from_name, to_name) \
- do { \
- if (from && from->from_name) \
- to.__set_##to_name(store_type<t>(from->from_name)); \
- } while (0)
-
-#define THRIFT_ASSIGN_ID(name) THRIFT_ASSIGN_ID_N(t_type, get_##name(), name)
-
-#define THRIFT_ASSIGN_LIST_ID(t, name) \
- do { \
- if (from && !from->get_##name##s().empty()) { \
- std::transform(from->get_##name##s().begin(), \
- from->get_##name##s().end(), \
- std::back_inserter(to.name##s), \
- &store_type<t>); \
- } \
- } while (0)
-
-THRIFT_CONVERSION_N(::t_type, plugin::TypeMetadata) {
- to.program_id = program_cache.gensym(reinterpret_cast<int64_t>(from->get_program()));
- THRIFT_ASSIGN_N(annotations_, annotations, );
- if (from->has_doc()) {
- to.__set_doc(from->get_doc());
- }
- THRIFT_ASSIGN(name);
-}
-
-THRIFT_CONVERSION(t_typedef) {
- THRIFT_ASSIGN_METADATA();
- THRIFT_ASSIGN_ID(type);
- THRIFT_ASSIGN(symbolic);
- THRIFT_ASSIGN_N(is_forward_typedef(), forward, );
-}
-
-THRIFT_CONVERSION(t_enum_value) {
- THRIFT_ASSIGN_OPT(doc);
- THRIFT_ASSIGN(name);
- THRIFT_ASSIGN(value);
-}
-
-THRIFT_CONVERSION(t_enum) {
- THRIFT_ASSIGN_METADATA();
- THRIFT_ASSIGN_LIST_N(t_enum_value, get_constants(), constants);
-}
-
-THRIFT_CONVERSION(t_const_value) {
- switch (from->get_type()) {
- case t_const_value::CV_INTEGER:
- THRIFT_ASSIGN_N(get_integer(), integer_val, );
- break;
- case t_const_value::CV_DOUBLE:
- THRIFT_ASSIGN_N(get_double(), double_val, );
- break;
- case t_const_value::CV_STRING:
- THRIFT_ASSIGN_N(get_string(), string_val, );
- break;
- case t_const_value::CV_IDENTIFIER:
- if (from) {
- apache::thrift::plugin::t_const_identifier_value cidval ;
- if (from->enum_)
- cidval.__set_enum_val(store_type<t_type>(from->enum_));
- cidval.__set_identifier_val(from->get_identifier());
- to.__set_const_identifier_val(cidval) ;
- }
- break;
- case t_const_value::CV_MAP:
- to.__isset.map_val = true;
- if (from && !from->get_map().empty()) {
- for (std::map< ::t_const_value*, ::t_const_value*>::const_iterator it
- = from->get_map().begin();
- it != from->get_map().end();
- it++) {
- to.map_val.insert(std::make_pair(convert(it->first), convert(it->second)));
- }
- }
- break;
- case t_const_value::CV_LIST:
- to.__isset.list_val = true;
- THRIFT_ASSIGN_LIST_N(t_const_value, get_list(), list_val);
- break;
- default:
- throw plugin::ThriftPluginError("const value has no value");
- }
-}
-THRIFT_CONVERSION(t_const) {
- THRIFT_ASSIGN_OPT(doc);
- THRIFT_ASSIGN(name);
- THRIFT_ASSIGN_ID(type);
- THRIFT_ASSIGN_CONVERT(t_const_value, get_value(), value);
-}
-THRIFT_CONVERSION(t_field) {
- THRIFT_ASSIGN_OPT(doc);
- THRIFT_ASSIGN(name);
- THRIFT_ASSIGN(key);
- THRIFT_ASSIGN_N(get_req(), req, (plugin::Requiredness::type));
- THRIFT_ASSIGN(reference);
- THRIFT_ASSIGN_ID(type);
- THRIFT_ASSIGN_CONVERT(t_const_value, get_value(), value);
-}
-THRIFT_CONVERSION(t_struct) {
- THRIFT_ASSIGN_METADATA();
- THRIFT_ASSIGN_LIST_N(t_field, get_members(), members);
- THRIFT_ASSIGN_N(is_union(), is_union, );
- THRIFT_ASSIGN_N(is_xception(), is_xception, );
-}
-THRIFT_CONVERSION(t_function) {
- THRIFT_ASSIGN_OPT(doc);
- THRIFT_ASSIGN(name);
- THRIFT_ASSIGN_ID(returntype);
- THRIFT_ASSIGN_N(is_oneway(), is_oneway, );
- THRIFT_ASSIGN_ID(arglist);
- THRIFT_ASSIGN_ID(xceptions);
-}
-
-THRIFT_CONVERSION(t_list) {
- THRIFT_ASSIGN_METADATA();
- THRIFT_ASSIGN_OPT(cpp_name);
- THRIFT_ASSIGN_ID(elem_type);
-}
-THRIFT_CONVERSION(t_set) {
- THRIFT_ASSIGN_METADATA();
- THRIFT_ASSIGN_OPT(cpp_name);
- THRIFT_ASSIGN_ID(elem_type);
-}
-THRIFT_CONVERSION(t_map) {
- THRIFT_ASSIGN_METADATA();
- THRIFT_ASSIGN_OPT(cpp_name);
- THRIFT_ASSIGN_ID(key_type);
- THRIFT_ASSIGN_ID(val_type);
-}
-
-THRIFT_CONVERSION(t_service) {
- THRIFT_ASSIGN_METADATA();
- THRIFT_ASSIGN_LIST_N(t_function, get_functions(), functions);
- THRIFT_ASSIGN_ID_N(t_service, get_extends(), extends_);
-}
-
-THRIFT_CONVERSION(t_base_type) {
- THRIFT_ASSIGN_METADATA();
- if (from->is_binary()) {
- to.value = plugin::t_base::TYPE_BINARY;
- } else {
- switch (from->get_base()) {
-#define T_BASETYPE_CASE(name) \
- case t_base_type::TYPE_##name: \
- to.value = plugin::t_base::TYPE_##name; \
- break
- T_BASETYPE_CASE(VOID);
- T_BASETYPE_CASE(STRING);
- T_BASETYPE_CASE(BOOL);
- T_BASETYPE_CASE(I8);
- T_BASETYPE_CASE(I16);
- T_BASETYPE_CASE(I32);
- T_BASETYPE_CASE(I64);
- T_BASETYPE_CASE(DOUBLE);
- default:
- throw plugin::ThriftPluginError("Base type union has no value");
- break;
-#undef T_BASETYPE_CASE
- }
- }
-}
-THRIFT_CONVERSION(t_type) {
-#define T_CONVERT_UNION_N(name, type) \
- else if (from->is_##name()) { \
- to.__isset.name##_val = true; \
- convert(reinterpret_cast< ::type*>(from), to.name##_val); \
- }
-#define T_CONVERT_UNION(name) T_CONVERT_UNION_N(name, t_##name)
- if (false) {
- }
- T_CONVERT_UNION(base_type)
- T_CONVERT_UNION(typedef)
- T_CONVERT_UNION(enum)
- T_CONVERT_UNION(struct)
- T_CONVERT_UNION_N(xception, t_struct)
- T_CONVERT_UNION(list)
- T_CONVERT_UNION(set)
- T_CONVERT_UNION(map)
- T_CONVERT_UNION(service)
- else {
- throw plugin::ThriftPluginError("Type union has no value");
- }
-#undef T_CONVERT_UNION_N
-#undef T_CONVERT_UNION
-}
-
-THRIFT_CONVERSION(t_scope) {
-#define T_SCOPE_ASSIGN(name, type) \
- boost::copy(from->name##s_ | boost::adaptors::map_values \
- | boost::adaptors::transformed(&store_type<type>), \
- std::back_inserter(to.name##s))
- T_SCOPE_ASSIGN(type, t_type);
- T_SCOPE_ASSIGN(constant, t_const);
- T_SCOPE_ASSIGN(service, t_service);
-#undef T_SCOPE_ASSIGN
-}
-
-void get_global_cache(plugin::TypeRegistry& reg) {
- reg.types = type_cache.cache;
- reg.constants = const_cache.cache;
- reg.services = service_cache.cache;
-}
-
-void clear_global_cache() {
- type_cache.clear();
- const_cache.clear();
- service_cache.clear();
- program_cache.clear() ;
-}
-
-THRIFT_CONVERSION(t_program) {
- THRIFT_ASSIGN_CONVERT(t_scope, scope(), scope);
- THRIFT_ASSIGN(path);
- THRIFT_ASSIGN(out_path);
- THRIFT_ASSIGN(name);
- THRIFT_ASSIGN(include_prefix);
- THRIFT_ASSIGN(cpp_includes);
- THRIFT_ASSIGN(c_includes);
- THRIFT_ASSIGN(namespaces);
- THRIFT_ASSIGN_N(is_out_path_absolute(), out_path_is_absolute, );
- THRIFT_ASSIGN_N(get_namespace(), namespace_, );
- THRIFT_ASSIGN_LIST_ID(t_type, typedef);
- THRIFT_ASSIGN_LIST_ID(t_type, enum);
- THRIFT_ASSIGN_LIST_ID(t_type, object);
- THRIFT_ASSIGN_LIST_ID(t_const, const);
- THRIFT_ASSIGN_LIST_ID(t_service, service);
- THRIFT_ASSIGN_LIST_N(t_program, get_includes(), includes);
- to.program_id = program_cache.gensym(reinterpret_cast<plugin::t_program_id>(from));
-}
-
-PluginDelegateResult delegateToPlugin(t_program* program, const std::string& options) {
- std::string language;
- std::map<std::string, std::string> parsed_options;
- t_generator::parse_options(options, language, parsed_options);
- std::string cmd = "thrift-gen-";
- if (language.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-0123456789")
- != std::string::npos) {
- std::cerr << "Invalid language name" << std::endl;
- return PLUGIN_FAILURE;
- }
- cmd.append(language);
- FILE* fd = THRIFT_POPEN(cmd.c_str());
- if (fd) {
-#ifdef _WIN32
- _setmode(fileno(fd), _O_BINARY);
-#endif
- shared_ptr<TFramedTransport> transport(
- new TFramedTransport(make_shared<TFDTransport>(fileno(fd))));
- TBinaryProtocol proto(transport);
-
- plugin::GeneratorInput input;
- input.__set_parsed_options(parsed_options);
- clear_global_cache();
- convert(program, input.program);
- get_global_cache(input.type_registry);
- try {
- input.write(&proto);
- transport->flush();
- } catch (std::exception& err) {
- std::cerr << "Error while sending data to plugin: " << err.what() << std::endl;
- THRIFT_PCLOSE(fd);
- return PLUGIN_FAILURE;
- }
-
- // TODO: be prepared for hang or crash of child process
- int ret = THRIFT_PCLOSE(fd);
- if (!ret) {
- return PLUGIN_SUCCEESS;
- } else {
- std::cerr << "plugin process returned non zero exit code: " << ret << std::endl;
- return PLUGIN_FAILURE;
- }
- }
- clear_global_cache();
- return PLUGIN_NOT_FOUND;
-}
-}
-
diff --git a/compiler/cpp/src/thrift/plugin/plugin_output.h b/compiler/cpp/src/thrift/plugin/plugin_output.h
deleted file mode 100644
index eab2d1bfc..000000000
--- a/compiler/cpp/src/thrift/plugin/plugin_output.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef T_PLUGIN_PLUGIN_OUTPUT_H
-#define T_PLUGIN_PLUGIN_OUTPUT_H
-
-#include <string>
-
-class t_program;
-
-namespace plugin_output {
-
-enum PluginDelegateResult {
- PLUGIN_NOT_FOUND,
- PLUGIN_FAILURE,
- PLUGIN_SUCCEESS,
-};
-
-PluginDelegateResult delegateToPlugin(t_program* program, const std::string& options);
-}
-
-#endif
diff --git a/compiler/cpp/src/thrift/plugin/type_util.h b/compiler/cpp/src/thrift/plugin/type_util.h
deleted file mode 100644
index 996b5c666..000000000
--- a/compiler/cpp/src/thrift/plugin/type_util.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef T_PLUGIN_TYPE_UTIL_H
-#define T_PLUGIN_TYPE_UTIL_H
-
-namespace apache {
-namespace thrift {
-namespace plugin {
-
-template <typename From>
-struct ToType {};
-
-template <typename From>
-typename ToType<From>::type* convert_forward(const From&);
-
-template <typename From, typename To>
-void convert(const From&, To*);
-
-template <typename From>
-typename ToType<From>::type* convert(const From& from);
-
-class TypeRegistry;
-void set_global_cache(const TypeRegistry&);
-void clear_global_cache();
-}
-}
-}
-
-// conversion from raw compiler types to plugin wire type
-namespace plugin_output {
-
-template <typename From, typename To>
-void convert(From* from, To& to);
-
-template <typename From>
-typename apache::thrift::plugin::ToType<From>::type convert(From* from);
-
-void get_global_cache(apache::thrift::plugin::TypeRegistry&);
-void clear_global_cache();
-}
-
-#define THRIFT_TYPE_MAPPING(TYPE) \
- class TYPE; \
- namespace apache { \
- namespace thrift { \
- namespace plugin { \
- class TYPE; \
- template <> \
- struct ToType< ::TYPE> { \
- typedef TYPE type; \
- }; \
- template <> \
- struct ToType<TYPE> { \
- typedef ::TYPE type; \
- }; \
- } \
- } \
- }
-THRIFT_TYPE_MAPPING(t_base_type)
-THRIFT_TYPE_MAPPING(t_const)
-THRIFT_TYPE_MAPPING(t_const_value)
-THRIFT_TYPE_MAPPING(t_container)
-THRIFT_TYPE_MAPPING(t_doc)
-THRIFT_TYPE_MAPPING(t_enum)
-THRIFT_TYPE_MAPPING(t_enum_value)
-THRIFT_TYPE_MAPPING(t_field)
-THRIFT_TYPE_MAPPING(t_function)
-THRIFT_TYPE_MAPPING(t_list)
-THRIFT_TYPE_MAPPING(t_map)
-THRIFT_TYPE_MAPPING(t_program)
-THRIFT_TYPE_MAPPING(t_scope)
-THRIFT_TYPE_MAPPING(t_service)
-THRIFT_TYPE_MAPPING(t_set)
-THRIFT_TYPE_MAPPING(t_struct)
-THRIFT_TYPE_MAPPING(t_type)
-THRIFT_TYPE_MAPPING(t_typedef)
-#undef THRIFT_TYPE_MAPPING
-#endif
diff --git a/compiler/cpp/test/CMakeLists.txt b/compiler/cpp/test/CMakeLists.txt
index 373cb78f0..2bc7e9e69 100644
--- a/compiler/cpp/test/CMakeLists.txt
+++ b/compiler/cpp/test/CMakeLists.txt
@@ -23,50 +23,6 @@ REQUIRE_BOOST_HEADERS()
set(BOOST_COMPONENTS unit_test_framework)
REQUIRE_BOOST_LIBRARIES(BOOST_COMPONENTS)
-if(${WITH_PLUGIN})
- # Make sure gen-cpp files can be included
- include_directories("${CMAKE_CURRENT_BINARY_DIR}")
-
- set(plugintest_SOURCES
- plugin/conversion_test.cc
- )
- add_executable(plugintest ${plugintest_SOURCES})
- target_link_libraries(plugintest
- thriftc
- ${Boost_LIBRARIES}
- )
- add_test(NAME PluginUnitTest COMMAND plugintest)
-
- set(thrift-gen-mycpp_SOURCES
- ../src/thrift/generate/t_cpp_generator.cc
- plugin/cpp_plugin.cc
- )
- add_executable(thrift-gen-mycpp ${thrift-gen-mycpp_SOURCES})
- target_link_libraries(thrift-gen-mycpp thriftc)
-
- if(CMAKE_BUILD_TYPE STREQUAL "Debug")
- set(BUILDTYPE "Debug")
- else()
- # RelWithDebInfo generates binaries in "Release" directory too
- set(BUILDTYPE "Release")
- endif()
-
- set_directory_properties(PROPERTIES
- ADDITIONAL_MAKE_CLEAN_FILES gen-cpp
- ADDITIONAL_MAKE_CLEAN_FILES gen-mycpp)
-
- file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen-cpp)
- file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen-mycpp)
- add_test(NAME PluginIntegrationTest
- COMMAND ${CMAKE_COMMAND}
- -DTHRIFT_COMPILER=${THRIFT_COMPILER}
- -DBINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- -DBUILDTYPE=${BUILDTYPE}
- -DCURDIR=${CMAKE_CURRENT_BINARY_DIR}
- -DSRCDIR=${CMAKE_CURRENT_SOURCE_DIR}
- -P ${CMAKE_CURRENT_SOURCE_DIR}/cpp_plugin_test.cmake)
-endif()
-
file(GLOB KEYWORD_SAMPLES "${CMAKE_CURRENT_SOURCE_DIR}/keyword-samples/*.thrift")
foreach(LANG ${thrift_compiler_LANGS})
foreach(SAMPLE ${KEYWORD_SAMPLES})
@@ -84,4 +40,4 @@ if(PYTHONINTERP_FOUND)
add_test(NAME StalenessCheckTest COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/compiler/staleness_check.py ${THRIFT_COMPILER})
else()
message(WARNING "Skipping StalenessCheckTest as there is no python interpreter available.")
-endif() \ No newline at end of file
+endif()
diff --git a/compiler/cpp/test/Makefile.am b/compiler/cpp/test/Makefile.am
index b7fc91d35..962583424 100644
--- a/compiler/cpp/test/Makefile.am
+++ b/compiler/cpp/test/Makefile.am
@@ -26,35 +26,3 @@ AUTOMAKE_OPTIONS = subdir-objects serial-tests
AM_CPPFLAGS = $(BOOST_CPPFLAGS) -I$(top_srcdir)/compiler/cpp/src
AM_LDFLAGS = $(BOOST_LDFLAGS)
AM_CXXFLAGS = -Wall -Wextra -pedantic
-
-if WITH_PLUGIN
-check_PROGRAMS = plugintest
-
-noinst_PROGRAMS = thrift-gen-mycpp
-
-all-local: thrift-gen-bincat
-
-AM_CPPFLAGS += -I$(top_srcdir)/lib/cpp/src -I$(top_builddir)/lib/cpp/src
-
-plugintest_SOURCES = plugin/conversion_test.cc
-plugintest_LDADD = $(top_builddir)/compiler/cpp/libthriftc.la
-
-thrift_gen_mycpp_SOURCES = plugin/cpp_plugin.cc \
- plugin/t_cpp_generator.cc
-thrift_gen_mycpp_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/compiler/cpp -I$(top_srcdir)/compiler/cpp/src/generate
-thrift_gen_mycpp_LDADD = $(top_builddir)/compiler/cpp/libthriftc.la
-
-cpp_plugin_test.sh: thrift-gen-mycpp
-
-thrift-gen-bincat:
- cp bincat.sh $@
- chmod 755 $@
-
-plugin_stability_test.sh: thrift-gen-bincat
-
-TESTS = $(check_PROGRAMS) cpp_plugin_test.sh plugin_stability_test.sh
-
-clean-local:
- $(RM) -rf gen-cpp gen-mycpp gen-bincat thrift-gen-bincat
-
-endif
diff --git a/compiler/cpp/test/cpp_plugin_test.cmake b/compiler/cpp/test/cpp_plugin_test.cmake
deleted file mode 100644
index fd182818d..000000000
--- a/compiler/cpp/test/cpp_plugin_test.cmake
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# 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.
-#
-
-file(MAKE_DIRECTORY ${CURDIR}/gen-cpp)
-execute_process(COMMAND ${THRIFT_COMPILER} -r -out ${CURDIR}/gen-cpp -gen cpp ${SRCDIR}/../../../test/Include.thrift)
-if(EXITCODE)
- message(FATAL_ERROR "FAILED: \"${ARGV}\": \"${EXITCODE}\"")
-endif()
-if(WIN32)
- set(ENV{PATH} "${BINDIR}/${BUILDTYPE};${BINDIR};$ENV{PATH}")
-else()
- set(ENV{PATH} "${BINDIR}:$ENV{PATH}")
-endif()
-
-file(MAKE_DIRECTORY ${CURDIR}/gen-mycpp)
-execute_process(COMMAND ${THRIFT_COMPILER} -r -out ${CURDIR}/gen-mycpp -gen mycpp ${SRCDIR}/../../../test/Include.thrift RESULT_VARIABLE EXITCODE)
-if(EXITCODE)
- message(FATAL_ERROR "FAILED: \"${EXITCODE}\"")
-endif()
-
-find_program(DIFF diff)
-if(DIFF)
- execute_process(COMMAND ${DIFF} -urN gen-cpp gen-mycpp RESULT_VARIABLE EXITCODE)
- if(EXITCODE)
- message(FATAL_ERROR "FAILED: \"${EXITCODE}\"")
- endif()
-else()
- message(WARNING "diff executable is not available. Not validating plugin-generated code.")
-endif()
diff --git a/compiler/cpp/test/cpp_plugin_test.sh b/compiler/cpp/test/cpp_plugin_test.sh
deleted file mode 100755
index ddb2e0a09..000000000
--- a/compiler/cpp/test/cpp_plugin_test.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-#
-# 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 intended to be invoked by make.
-set -e
-mkdir -p gen-cpp gen-mycpp
-PATH=.:"$PATH" ../thrift -r -out gen-cpp -gen cpp ../../../test/Include.thrift
-PATH=.:"$PATH" ../thrift -r -out gen-mycpp -gen mycpp ../../../test/Include.thrift
-diff -urN gen-cpp gen-mycpp
diff --git a/compiler/cpp/test/plugin/conversion_test.cc b/compiler/cpp/test/plugin/conversion_test.cc
deleted file mode 100644
index 3c8d812cf..000000000
--- a/compiler/cpp/test/plugin/conversion_test.cc
+++ /dev/null
@@ -1,498 +0,0 @@
-/*
- * 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.
- */
-
-#include "thrift/parse/t_program.h"
-#include "thrift/plugin/type_util.h"
-#include "thrift/plugin/plugin_types.h"
-
-#include <map>
-#include <vector>
-
-#include <boost/preprocessor.hpp>
-#include <boost/test/included/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-
-using namespace apache::thrift;
-using namespace boost::unit_test;
-
-namespace test_data {
-#define T_TEST_TYPES \
- BOOST_PP_TUPLE_TO_LIST(14, \
- (program, \
- base_type, \
- enum_value, \
- enum, \
- const_value, \
- const, \
- list, \
- set, \
- map, \
- field, \
- struct, \
- typedef, \
- function, \
- service))
-#define T_DELETE_TESTDATA(r, d, elem) \
- for (std::vector<t_##elem*>::reverse_iterator it = elem##s.rbegin(); it != elem##s.rend(); it++) \
- delete *it;
-#define T_DECL_TESTDATA(r, d, elem) static std::vector< ::t_##elem*> elem##s;
-BOOST_PP_LIST_FOR_EACH(T_DECL_TESTDATA, _, T_TEST_TYPES)
-#undef T_DECL_TESTDATA
-
-bool has_data = false;
-void cleanup() {
- if (has_data) {
- has_data = false;
- BOOST_PP_LIST_FOR_EACH(T_DELETE_TESTDATA, _, T_TEST_TYPES)
- }
-}
-
-void init_programs() {
- programs.push_back(new t_program("prog path", "prog_name"));
-}
-
-void init_base_types() {
- base_types.push_back(new ::t_base_type("name0", ::t_base_type::TYPE_VOID));
- base_types.push_back(new ::t_base_type("name1", ::t_base_type::TYPE_STRING));
- base_types.push_back(new ::t_base_type("name2", ::t_base_type::TYPE_BOOL));
- base_types.push_back(new ::t_base_type("name3", ::t_base_type::TYPE_I8));
- base_types.push_back(new ::t_base_type("name4", ::t_base_type::TYPE_I16));
- base_types.push_back(new ::t_base_type("name5", ::t_base_type::TYPE_I32));
- base_types.push_back(new ::t_base_type("name6", ::t_base_type::TYPE_I64));
- base_types.push_back(new ::t_base_type("name7", ::t_base_type::TYPE_DOUBLE));
-}
-
-void init_const_values() {
- const_values.push_back(new t_const_value(42));
- const_values.push_back(new t_const_value("foo"));
- {
- t_const_value* x = new t_const_value;
- x->set_double(3.1415);
- const_values.push_back(x);
- }
- {
- t_const_value* x = new t_const_value;
- x->set_identifier("bar");
- x->set_enum(enums[0]);
- const_values.push_back(x);
- }
- {
- t_const_value* x = new t_const_value;
- x->set_map();
- x->add_map(const_values[0], const_values[1]);
- x->add_map(const_values[1], const_values[0]);
- const_values.push_back(x);
- }
- {
- t_const_value* x = new t_const_value;
- x->set_list();
- x->add_list(const_values[0]);
- x->add_list(const_values[1]);
- const_values.push_back(x);
- }
-}
-
-void init_consts() {
- // base_type/enum indexes for this and other tests are arbitrary
- consts.push_back(new t_const(base_types[2], "aaa", const_values[0]));
- consts.back()->set_doc("soem doc");
- consts.push_back(new t_const(base_types[3], "bbb", const_values[1]));
-}
-
-void init_enum_values() {
- enum_values.push_back(new t_enum_value("VAL1", 11));
- enum_values.back()->set_doc("enum doc 1");
- enum_values.back()->annotations_.insert(std::make_pair("anno1", "val1"));
-
- enum_values.push_back(new t_enum_value("VAL2", 22));
-}
-
-void init_enums() {
- enums.push_back(new t_enum(programs[0]));
- enums.back()->set_doc("enum doc 1");
- enums.back()->annotations_.insert(std::make_pair("anno1", "val1"));
- enums.back()->set_name("fooo");
- enums.back()->append(enum_values[0]);
- enums.back()->append(enum_values[1]);
-}
-
-void init_lists() {
- lists.push_back(new t_list(enums[0]));
- lists.push_back(new t_list(base_types[5]));
- lists.back()->set_cpp_name("list_cpp_name_1");
-}
-void init_sets() {
- sets.push_back(new t_set(base_types[4]));
- sets.push_back(new t_set(enums[0]));
- sets.back()->set_cpp_name("set_cpp_name_1");
-}
-void init_maps() {
- maps.push_back(new t_map(base_types[4], base_types[1]));
- maps.push_back(new t_map(base_types[5], enums[0]));
- maps.back()->set_cpp_name("map_cpp_name_1");
-}
-
-void init_typedefs() {
- typedefs.push_back(new t_typedef(programs[0], base_types[3], "VAL1"));
-}
-void init_fields() {
- fields.push_back(new t_field(base_types[1], "f1"));
- fields.back()->set_reference(false);
- fields.back()->set_req(t_field::T_OPTIONAL);
- fields.push_back(new t_field(base_types[2], "f2", 9));
- fields.back()->set_reference(true);
- fields.push_back(new t_field(base_types[3], "f3", 11));
- fields.back()->set_req(t_field::T_REQUIRED);
- fields.back()->set_value(const_values[0]);
-}
-void init_structs() {
- structs.push_back(new t_struct(programs[0], "struct1"));
- structs.back()->append(fields[0]);
- structs.back()->append(fields[1]);
- structs.push_back(new t_struct(programs[0], "union1"));
- structs.back()->append(fields[0]);
- structs.back()->append(fields[1]);
- structs.back()->set_union(true);
- structs.push_back(new t_struct(programs[0], "xcept1"));
- structs.back()->set_xception(true);
-}
-void init_functions() {
- structs.push_back(new t_struct(programs[0], "errs1"));
- t_struct* errors = structs.back();
- structs.push_back(new t_struct(programs[0], "args1"));
- t_struct* arglist = structs.back();
- functions.push_back(new t_function(base_types[0], "func1", errors, arglist, false));
- functions.push_back(new t_function(base_types[0], "func2", errors, arglist, true));
-}
-void init_services() {
- services.push_back(new t_service(programs[0]));
- services.back()->set_doc("srv1 doc");
- services.back()->set_name("srv1");
- services.back()->add_function(functions[0]);
- services.back()->add_function(functions[1]);
-
- services.push_back(new t_service(programs[0]));
- services.back()->set_name("srv2");
- services.back()->set_extends(services[0]);
-}
-
-std::vector<t_type*> types;
-void init_types() {
-#define T_COPY_TYPES(type) std::copy(type##s.begin(), type##s.end(), std::back_inserter(types))
- T_COPY_TYPES(base_type);
- T_COPY_TYPES(enum);
- T_COPY_TYPES(typedef);
- T_COPY_TYPES(struct);
- T_COPY_TYPES(list);
- T_COPY_TYPES(set);
- T_COPY_TYPES(map);
-// T_COPY_TYPES(service);
-#undef T_COPY_TYPES
-}
-
-void init() {
- if (!has_data) {
- has_data = true;
-#define T_INIT_TESTDATA(r, d, elem) init_##elem##s();
- BOOST_PP_LIST_FOR_EACH(T_INIT_TESTDATA, _, T_TEST_TYPES)
- init_types();
-#undef T_INIT_TESTDATA
- }
-}
-}
-struct GlobalFixture {
- ~GlobalFixture() { test_data::cleanup(); }
-};
-#if (BOOST_VERSION >= 105900)
-BOOST_GLOBAL_FIXTURE(GlobalFixture);
-#else
-BOOST_GLOBAL_FIXTURE(GlobalFixture)
-#endif
-
-void migrate_global_cache() {
- plugin::TypeRegistry reg;
- plugin_output::get_global_cache(reg);
- plugin::set_global_cache(reg);
- plugin_output::clear_global_cache();
-}
-template <typename T>
-T* round_trip(T* t) {
- typename plugin::ToType<T>::type p;
- plugin::clear_global_cache();
- plugin_output::clear_global_cache();
- plugin_output::convert(t, p);
- migrate_global_cache();
- return plugin::convert(p);
-}
-
-void test_base_type(::t_base_type* sut) {
- plugin::t_base_type p;
- plugin_output::convert(sut, p);
- boost::scoped_ptr< ::t_base_type> sut2(plugin::convert(p));
-
-#define THRIFT_CHECK(r, data, elem) BOOST_PP_EXPAND(BOOST_CHECK_EQUAL(data elem, sut2->elem));
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(7,
- (is_void(),
- is_string(),
- is_bool(),
- is_string_list(),
- is_binary(),
- is_string_enum(),
- is_base_type())))
-}
-
-void test_const_value(t_const_value* sut) {
- boost::scoped_ptr<t_const_value> sut2(round_trip(sut));
-
- BOOST_CHECK_EQUAL(sut->get_type(), sut2->get_type());
- switch (sut->get_type()) {
-#define T_CONST_VALUE_CASE(type, name) \
- case t_const_value::type: \
- BOOST_CHECK_EQUAL(sut->get_##name(), sut2->get_##name()); \
- break
- T_CONST_VALUE_CASE(CV_INTEGER, integer);
- T_CONST_VALUE_CASE(CV_DOUBLE, double);
- T_CONST_VALUE_CASE(CV_STRING, string);
- T_CONST_VALUE_CASE(CV_IDENTIFIER, identifier);
-#undef T_CONST_VALUE_CASE
- case t_const_value::CV_MAP:
- BOOST_CHECK_EQUAL(sut->get_map().size(), sut2->get_map().size());
- {
- std::map<t_const_value::t_const_value_type, t_const_value::t_const_value_type> sut_values;
- for (std::map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator it = sut->get_map().begin();
- it != sut->get_map().end(); it++) {
- sut_values[it->first->get_type()] = it->second->get_type();
- }
- std::map<t_const_value::t_const_value_type, t_const_value::t_const_value_type> sut2_values;
- for (std::map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator it = sut2->get_map().begin();
- it != sut2->get_map().end(); it++) {
- sut2_values[it->first->get_type()] = it->second->get_type();
- }
- BOOST_CHECK_EQUAL(sut_values.begin()->first, sut2_values.begin()->first);
- BOOST_CHECK_EQUAL(sut_values.begin()->second, sut2_values.begin()->second);
- }
- break;
- case t_const_value::CV_LIST:
- BOOST_CHECK_EQUAL(sut->get_list().size(), sut2->get_list().size());
- BOOST_CHECK_EQUAL(sut->get_list().front()->get_type(), sut2->get_list().front()->get_type());
- break;
- default:
- BOOST_ASSERT(false);
- break;
- }
-}
-
-void test_const(t_const* sut) {
- boost::scoped_ptr< ::t_const> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(4,
- (get_type()->get_name(),
- get_name(),
- get_value()->get_type(),
- get_doc())))
-}
-
-void test_enum_value(t_enum_value* sut) {
- boost::scoped_ptr<t_enum_value> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(3, (get_name(), get_value(), get_doc())))
-}
-
-void test_enum(t_enum* sut) {
- boost::scoped_ptr< ::t_enum> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(6,
- (get_name(),
- get_min_value()->get_value(),
- get_max_value()->get_value(),
- get_constant_by_value(11)->get_value(),
- get_constant_by_name("VAL1")->get_value(),
- get_doc())))
-}
-
-void test_list(t_list* sut) {
- boost::scoped_ptr<t_list> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(4,
- (get_elem_type()->get_name(),
- has_cpp_name(),
- get_doc(),
- get_name())))
- if (sut->has_cpp_name())
- BOOST_CHECK_EQUAL(sut->get_cpp_name(), sut2->get_cpp_name());
-}
-void test_set(t_set* sut) {
- boost::scoped_ptr<t_set> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(4,
- (get_elem_type()->get_name(),
- has_cpp_name(),
- get_doc(),
- get_name())))
- if (sut->has_cpp_name())
- BOOST_CHECK_EQUAL(sut->get_cpp_name(), sut2->get_cpp_name());
-}
-void test_map(t_map* sut) {
- boost::scoped_ptr<t_map> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(5,
- (get_key_type()->get_name(),
- get_val_type()->get_name(),
- has_cpp_name(),
- get_doc(),
- get_name())))
- if (sut->has_cpp_name())
- BOOST_CHECK_EQUAL(sut->get_cpp_name(), sut2->get_cpp_name());
-}
-
-void test_typedef(t_typedef* sut) {
- boost::scoped_ptr<t_typedef> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(4,
- (get_doc(),
- get_name(),
- get_symbolic(),
- is_forward_typedef())))
-}
-
-void test_type(t_type* sut) {
- boost::scoped_ptr<t_type> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(15,
- (is_void(),
- is_base_type(),
- is_string(),
- is_bool(),
- is_typedef(),
- is_enum(),
- is_struct(),
- is_xception(),
- is_container(),
- is_list(),
- is_set(),
- is_map(),
- is_service(),
- get_doc(),
- get_name())))
-}
-
-void test_field(t_field* sut) {
- boost::scoped_ptr<t_field> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(5,
- (get_req(),
- get_reference(),
- get_key(),
- get_doc(),
- get_name())))
- if (sut->get_value()) {
- THRIFT_CHECK(, sut->, get_value()->get_type());
- } else {
- BOOST_CHECK(!sut2->get_value());
- }
- if (sut->get_type()) {
- THRIFT_CHECK(, sut->, get_type()->get_name());
- } else {
- BOOST_CHECK(!sut2->get_type());
- }
-}
-void test_struct(t_struct* sut) {
- boost::scoped_ptr<t_struct> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(5,
- (is_union(),
- is_xception(),
- is_struct(),
- get_doc(),
- get_name())))
-}
-
-void test_function(t_function* sut) {
- boost::scoped_ptr<t_function> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(
- THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(4, (get_doc(), get_name(), get_returntype()->get_name(), is_oneway())))
-}
-void test_service(t_service* sut) {
- boost::scoped_ptr<t_service> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK,
- sut->,
- BOOST_PP_TUPLE_TO_LIST(3, (get_doc(), get_name(), get_functions().size())))
- if (sut->get_extends()) {
- THRIFT_CHECK(, sut->, get_extends()->get_name());
- } else {
- BOOST_CHECK(!sut2->get_extends());
- }
-}
-
-void test_program(t_program* sut) {
- boost::scoped_ptr<t_program> sut2(round_trip(sut));
-
- BOOST_PP_LIST_FOR_EACH(THRIFT_CHECK, sut->, BOOST_PP_TUPLE_TO_LIST(2, (get_doc(), get_name())))
-}
-boost::unit_test::test_suite* do_init_unit_test_suite() {
- test_data::init();
- test_suite* ts = BOOST_TEST_SUITE("PluginConversionTest");
-
-#define T_TEST_CASE(r, d, type) \
- ts->add(BOOST_PARAM_TEST_CASE(test_##type, test_data::type##s.begin(), test_data::type##s.end()));
- BOOST_PP_LIST_FOR_EACH(T_TEST_CASE, _, T_TEST_TYPES)
- T_TEST_CASE(_, _, type)
-#undef T_TEST_CASE
- return ts;
-}
-
-#ifdef BOOST_TEST_DYN_LINK
-bool init_unit_test_suite() {
- framework::master_test_suite().add(do_init_unit_test_suite());
- return true;
-}
-int main(int argc, char* argv[]) {
- return ::boost::unit_test::unit_test_main(&init_unit_test_suite, argc, argv);
-}
-#else
-boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
- return do_init_unit_test_suite();
-}
-#endif
diff --git a/compiler/cpp/test/plugin/cpp_plugin.cc b/compiler/cpp/test/plugin/cpp_plugin.cc
deleted file mode 100644
index 6cc19f2a3..000000000
--- a/compiler/cpp/test/plugin/cpp_plugin.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-#include "thrift/plugin/plugin.h"
-#include "thrift/generate/t_generator.h"
-
-namespace apache {
-namespace thrift {
-namespace plugin {
-
-class MyCppGenerator : public GeneratorPlugin {
- virtual int generate(::t_program* program,
- const std::map<std::string, std::string>& parsed_options) {
- t_generator* gen = t_generator_registry::get_generator(program, "cpp", parsed_options, "");
- gen->generate_program();
- delete gen;
- return 0;
- }
-};
-}
-}
-}
-
-int main(int argc, char* argv[]) {
- apache::thrift::plugin::MyCppGenerator p;
- return p.exec(argc, argv);
-}
diff --git a/compiler/cpp/test/plugin_stability_test.sh b/compiler/cpp/test/plugin_stability_test.sh
deleted file mode 100755
index eb7c93d66..000000000
--- a/compiler/cpp/test/plugin_stability_test.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-#
-# 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 intended to be invoked by make.
-#
-# This file runs the compiler twice, using a plugin that just invokes
-# /bin/cat, and compares the output. If GeneratorInput is
-# nondeterminsitic, you'd expect the output to differ from run-to-run.
-# So this tests that in fact, the output is stable from run-to-run.
-set -e
-mkdir -p gen-bincat
-PATH=.:"$PATH" ../thrift -r -gen bincat ../../../test/Include.thrift > gen-bincat/1.ser
-PATH=.:"$PATH" ../thrift -r -gen bincat ../../../test/Include.thrift > gen-bincat/2.ser
-diff --binary gen-bincat/1.ser gen-bincat/2.ser
diff --git a/configure.ac b/configure.ac
index 0f6c6da05..7da52a0bf 100755
--- a/configure.ac
+++ b/configure.ac
@@ -607,20 +607,6 @@ if test "$enable_tests" = "no"; then
fi
AM_CONDITIONAL(WITH_TESTS, [test "$have_tests" = "yes"])
-AC_ARG_ENABLE([plugin],
- AS_HELP_STRING([--enable-plugin], [build compiler plugin support [default=no]]),
- [], enable_plugin=no
-)
-have_plugin=yes
-if test "$have_cpp" = "no" ; then
- have_plugin="no"
-fi
-if test "$enable_plugin" = "no"; then
- have_plugin="no"
-fi
-AC_CONFIG_LINKS([compiler/cpp/test/plugin/t_cpp_generator.cc:compiler/cpp/src/thrift/generate/t_cpp_generator.cc])
-AM_CONDITIONAL(WITH_PLUGIN, [test "$have_plugin" = "yes"])
-
AC_ARG_ENABLE([tutorial],
AS_HELP_STRING([--enable-tutorial], [build tutorial [default=yes]]),
[], enable_tutorial=yes
@@ -803,7 +789,6 @@ AC_CONFIG_FILES([
Makefile
compiler/cpp/Makefile
compiler/cpp/src/Makefile
- compiler/cpp/src/thrift/plugin/Makefile
compiler/cpp/test/Makefile
compiler/cpp/src/thrift/version.h
lib/Makefile
@@ -957,7 +942,6 @@ echo "Building Lua Library ......... : $have_lua"
echo "Building NodeJS Library ...... : $have_nodejs"
echo "Building Perl Library ........ : $have_perl"
echo "Building PHP Library ......... : $have_php"
-echo "Building Plugin Support ...... : $have_plugin"
echo "Building Python Library ...... : $have_python"
echo "Building Py3 Library ......... : $have_py3"
echo "Building Ruby Library ........ : $have_ruby"
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 901c3ef02..f6060c40d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -25,11 +25,8 @@ SUBDIRS += as3
endif
if WITH_CPP
-# cpp dir is picked directly by plugin build
-if !WITH_PLUGIN
SUBDIRS += cpp
endif
-endif
if WITH_C_GLIB
SUBDIRS += c_glib
diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am
index db9d751e4..616effddd 100755
--- a/lib/cpp/Makefile.am
+++ b/lib/cpp/Makefile.am
@@ -25,12 +25,8 @@ moc__%.cpp: %.h
SUBDIRS = .
if WITH_TESTS
-# This file is needed by compiler with plugin, while test/Makefile.am needs compiler
-# So test directory is directly picked by top level Makefile.am for plugin build
-if !WITH_PLUGIN
SUBDIRS += test
endif
-endif
pkgconfigdir = $(libdir)/pkgconfig