From 4d8a9cd5693e9d6d14d4196d325be2e6917043a5 Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Mon, 30 Aug 2010 17:09:58 +0000 Subject: [PATCH] THRIFT-877. compiler: smalltalk namespace doesn't work This patch adds a special case to map 'smalltalk' to 'st' when checking for valid namespace declarations. Patch: Bruce Lowekamp git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@990866 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/generate/t_st_generator.cc | 3 ++- compiler/cpp/src/parse/t_program.h | 5 +++++ test/ThriftTest.thrift | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/cpp/src/generate/t_st_generator.cc b/compiler/cpp/src/generate/t_st_generator.cc index 42c8f933..11d23941 100644 --- a/compiler/cpp/src/generate/t_st_generator.cc +++ b/compiler/cpp/src/generate/t_st_generator.cc @@ -121,6 +121,7 @@ class t_st_generator : public t_oop_generator { void st_accessors(std::ofstream &out, std::string cls, std::string name, std::string type); std::string class_name(); + static bool is_valid_namespace(const std::string& sub_namespace); std::string client_class_name(); std::string prefix(std::string name); std::string declare_field(t_field* tfield); @@ -181,7 +182,7 @@ string t_st_generator::class_name() { return capitalize(program_name_); } -static bool is_valid_namespace(const std::string& sub_namespace) { +bool t_st_generator::is_valid_namespace(const std::string& sub_namespace) { return sub_namespace == "prefix" || sub_namespace == "category"; } diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h index ddf7cd19..4f8f1514 100644 --- a/compiler/cpp/src/parse/t_program.h +++ b/compiler/cpp/src/parse/t_program.h @@ -164,6 +164,11 @@ class t_program : public t_doc { std::string base_language = language.substr(0, sub_index); std::string sub_namespace; + if(base_language == "smalltalk") { + pwarning(1, "Namespace 'smalltalk' is deprecated. Use 'st' instead"); + base_language = "st"; + } + t_generator_registry::gen_map_t my_copy = t_generator_registry::get_generator_map(); t_generator_registry::gen_map_t::iterator it; diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index 919b68f1..4ade6aa7 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -27,6 +27,7 @@ namespace rb Thrift.Test namespace perl ThriftTest namespace csharp Thrift.Test namespace js ThriftTest +namespace st ThriftTest /** * Docstring! -- 2.17.1