summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2022-06-05 11:12:49 +0200
committerJens Geyer <jensg@apache.org>2022-06-06 01:44:16 +0200
commit0b1eb6bcabebe02d61be614eab0eb6c4d2d972c3 (patch)
tree74b2844ae9be2817d629d6cb3b694807ee466cd5
parentaad75837f4e12a9b37fd38bee51b96df595997d8 (diff)
downloadthrift-0b1eb6bcabebe02d61be614eab0eb6c4d2d972c3.tar.gz
THRIFT-5588 Remove slist/senum from IDL
Patch: Jens Geyer This closes #2615
-rw-r--r--compiler/cpp/src/thrift/common.cc3
-rw-r--r--compiler/cpp/src/thrift/common.h1
-rw-r--r--compiler/cpp/src/thrift/generate/t_perl_generator.cc6
-rw-r--r--compiler/cpp/src/thrift/generate/t_php_generator.cc4
-rw-r--r--compiler/cpp/src/thrift/generate/t_xsd_generator.cc17
-rw-r--r--compiler/cpp/src/thrift/parse/t_base_type.h17
-rw-r--r--compiler/cpp/src/thrift/thriftl.ll12
-rw-r--r--compiler/cpp/src/thrift/thrifty.yy51
-rw-r--r--test/AnnotationTest.thrift8
-rw-r--r--test/SmallTest.thrift10
10 files changed, 22 insertions, 107 deletions
diff --git a/compiler/cpp/src/thrift/common.cc b/compiler/cpp/src/thrift/common.cc
index fb1832daf..6dcd85500 100644
--- a/compiler/cpp/src/thrift/common.cc
+++ b/compiler/cpp/src/thrift/common.cc
@@ -23,7 +23,6 @@
t_type* g_type_void;
t_type* g_type_string;
t_type* g_type_binary;
-t_type* g_type_slist;
t_type* g_type_bool;
t_type* g_type_i8;
t_type* g_type_i16;
@@ -36,8 +35,6 @@ void initGlobals() {
g_type_string = new t_base_type("string", t_base_type::TYPE_STRING);
g_type_binary = new t_base_type("string", t_base_type::TYPE_STRING);
((t_base_type*)g_type_binary)->set_binary(true);
- g_type_slist = new t_base_type("string", t_base_type::TYPE_STRING);
- ((t_base_type*)g_type_slist)->set_string_list(true);
g_type_bool = new t_base_type("bool", t_base_type::TYPE_BOOL);
g_type_i8 = new t_base_type("i8", t_base_type::TYPE_I8);
g_type_i16 = new t_base_type("i16", t_base_type::TYPE_I16);
diff --git a/compiler/cpp/src/thrift/common.h b/compiler/cpp/src/thrift/common.h
index 694884636..06392cda7 100644
--- a/compiler/cpp/src/thrift/common.h
+++ b/compiler/cpp/src/thrift/common.h
@@ -29,7 +29,6 @@
extern t_type* g_type_void;
extern t_type* g_type_string;
extern t_type* g_type_binary;
-extern t_type* g_type_slist;
extern t_type* g_type_bool;
extern t_type* g_type_i8;
extern t_type* g_type_i16;
diff --git a/compiler/cpp/src/thrift/generate/t_perl_generator.cc b/compiler/cpp/src/thrift/generate/t_perl_generator.cc
index 2e687dd5e..68bd57f0f 100644
--- a/compiler/cpp/src/thrift/generate/t_perl_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_perl_generator.cc
@@ -998,15 +998,17 @@ void t_perl_generator::generate_service_rest(t_service* tservice) {
const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
vector<t_field*>::const_iterator a_iter;
for (a_iter = args.begin(); a_iter != args.end(); ++a_iter) {
- t_type* atype = get_true_type((*a_iter)->get_type());
+ //t_type* atype = get_true_type((*a_iter)->get_type());
string req = "$request->{'" + (*a_iter)->get_name() + "'}";
f_service_ << indent() << "my $" << (*a_iter)->get_name() << " = (" << req << ") ? " << req
<< " : undef;" << endl;
- if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
+ /* slist no longer supported
+ if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
f_service_ << indent() << "my @" << (*a_iter)->get_name() << " = split(/,/, $"
<< (*a_iter)->get_name() << ");" << endl << indent() << "$"
<< (*a_iter)->get_name() << " = \\@" << (*a_iter)->get_name() << endl;
}
+ */
}
f_service_ << indent() << "return $self->{impl}->" << (*f_iter)->get_name() << "("
<< argument_list((*f_iter)->get_arglist()) << ");" << endl;
diff --git a/compiler/cpp/src/thrift/generate/t_php_generator.cc b/compiler/cpp/src/thrift/generate/t_php_generator.cc
index 96d5fbe67..39968a658 100644
--- a/compiler/cpp/src/thrift/generate/t_php_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_php_generator.cc
@@ -1785,10 +1785,12 @@ void t_php_generator::generate_service_rest(t_service* tservice) {
f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = isset(" << req << ") ? "
<< cast << req << " : null;" << endl;
}
+ /* slist no longer supported
if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = explode(',', $"
<< (*a_iter)->get_name() << ");" << endl;
- } else if (atype->is_map() || atype->is_list()) {
+ } else */
+ if (atype->is_map() || atype->is_list()) {
f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = json_decode($"
<< (*a_iter)->get_name() << ", true);" << endl;
} else if (atype->is_set()) {
diff --git a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
index d7fb6cf2a..a10f05959 100644
--- a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
@@ -132,21 +132,8 @@ void t_xsd_generator::close_generator() {
void t_xsd_generator::generate_typedef(t_typedef* ttypedef) {
indent(s_xsd_types_) << "<xsd:simpleType name=\"" << ttypedef->get_name() << "\">" << endl;
indent_up();
- if (ttypedef->get_type()->is_string() && ((t_base_type*)ttypedef->get_type())->is_string_enum()) {
- indent(s_xsd_types_) << "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\">"
- << endl;
- indent_up();
- const vector<string>& values = ((t_base_type*)ttypedef->get_type())->get_string_enum_vals();
- vector<string>::const_iterator v_iter;
- for (v_iter = values.begin(); v_iter != values.end(); ++v_iter) {
- indent(s_xsd_types_) << "<xsd:enumeration value=\"" << (*v_iter) << "\" />" << endl;
- }
- indent_down();
- indent(s_xsd_types_) << "</xsd:restriction>" << endl;
- } else {
- indent(s_xsd_types_) << "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\" />"
- << endl;
- }
+ indent(s_xsd_types_) << "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\" />"
+ << endl;
indent_down();
indent(s_xsd_types_) << "</xsd:simpleType>" << endl << endl;
}
diff --git a/compiler/cpp/src/thrift/parse/t_base_type.h b/compiler/cpp/src/thrift/parse/t_base_type.h
index ca2b0f6ef..5676f0492 100644
--- a/compiler/cpp/src/thrift/parse/t_base_type.h
+++ b/compiler/cpp/src/thrift/parse/t_base_type.h
@@ -45,7 +45,7 @@ public:
};
t_base_type(std::string name, t_base base)
- : t_type(name), base_(base), string_list_(false), binary_(false), string_enum_(false) {}
+ : t_type(name), base_(base), binary_(false) {}
t_base get_base() const { return base_; }
@@ -55,22 +55,10 @@ public:
bool is_bool() const override { return base_ == TYPE_BOOL; }
- void set_string_list(bool val) { string_list_ = val; }
-
- bool is_string_list() const { return string_list_ && (base_ == TYPE_STRING); }
-
void set_binary(bool val) { binary_ = val; }
bool is_binary() const override { return binary_ && (base_ == TYPE_STRING); }
- void set_string_enum(bool val) { string_enum_ = val; }
-
- bool is_string_enum() const { return string_enum_ && base_ == TYPE_STRING; }
-
- void add_string_enum_val(std::string val) { string_enum_vals_.push_back(val); }
-
- const std::vector<std::string>& get_string_enum_vals() const { return string_enum_vals_; }
-
bool is_base_type() const override { return true; }
static std::string t_base_name(t_base tbase) {
@@ -108,10 +96,7 @@ public:
private:
t_base base_;
- bool string_list_;
bool binary_;
- bool string_enum_;
- std::vector<std::string> string_enum_vals_;
};
#endif
diff --git a/compiler/cpp/src/thrift/thriftl.ll b/compiler/cpp/src/thrift/thriftl.ll
index 377351649..810a983e0 100644
--- a/compiler/cpp/src/thrift/thriftl.ll
+++ b/compiler/cpp/src/thrift/thriftl.ll
@@ -86,6 +86,12 @@ void unexpected_token(char* text) {
exit(1);
}
+void error_no_longer_supported(char* text, char* replace_with) {
+ yyerror("\"%s\" is no longer supported, use \"%s\" instead. Line %d\n", text, replace_with, yylineno);
+ exit(1);
+}
+
+
%}
/**
@@ -234,12 +240,10 @@ literal_begin (['\"])
"string" { return tok_string; }
"binary" { return tok_binary; }
"slist" {
- pwarning(0, "\"slist\" is deprecated and will be removed in a future compiler version. This type should be replaced with \"string\".\n");
- return tok_slist;
+ error_no_longer_supported("slist","string");
}
"senum" {
- pwarning(0, "\"senum\" is deprecated and will be removed in a future compiler version. This type should be replaced with \"string\".\n");
- return tok_senum;
+ error_no_longer_supported("senum","string");
}
"map" { return tok_map; }
"list" { return tok_list; }
diff --git a/compiler/cpp/src/thrift/thrifty.yy b/compiler/cpp/src/thrift/thrifty.yy
index dc6838a54..a062a0e40 100644
--- a/compiler/cpp/src/thrift/thrifty.yy
+++ b/compiler/cpp/src/thrift/thrifty.yy
@@ -134,8 +134,6 @@ const int struct_is_union = 1;
%token tok_bool
%token tok_string
%token tok_binary
-%token tok_slist
-%token tok_senum
%token tok_i8
%token tok_i16
%token tok_i32
@@ -205,10 +203,6 @@ const int struct_is_union = 1;
%type<tenumv> EnumDef
%type<tenumv> EnumValue
-%type<ttypedef> Senum
-%type<tbase> SenumDefList
-%type<id> SenumDef
-
%type<tconst> Const
%type<tconstv> ConstValue
%type<tconstv> ConstList
@@ -404,13 +398,6 @@ TypeDefinition:
g_program->add_enum($1);
}
}
-| Senum
- {
- pdebug("TypeDefinition -> Senum");
- if (g_parse_mode == PROGRAM) {
- g_program->add_typedef($1);
- }
- }
| Struct
{
pdebug("TypeDefinition -> Struct");
@@ -530,39 +517,6 @@ EnumValue:
$$ = new t_enum_value($1, y_enum_val);
}
-Senum:
- tok_senum tok_identifier '{' SenumDefList '}' TypeAnnotations
- {
- pdebug("Senum -> tok_senum tok_identifier { SenumDefList }");
- validate_simple_identifier( $2);
- $$ = new t_typedef(g_program, $4, $2);
- if ($6 != nullptr) {
- $$->annotations_ = $6->annotations_;
- delete $6;
- }
- }
-
-SenumDefList:
- SenumDefList SenumDef
- {
- pdebug("SenumDefList -> SenumDefList SenumDef");
- $$ = $1;
- $$->add_string_enum_val($2);
- }
-|
- {
- pdebug("SenumDefList -> ");
- $$ = new t_base_type("string", t_base_type::TYPE_STRING);
- $$->set_string_enum(true);
- }
-
-SenumDef:
- tok_literal CommaOrSemicolonOptional
- {
- pdebug("SenumDef -> tok_literal");
- $$ = $1;
- }
-
Const:
tok_const FieldType tok_identifier '=' ConstValue CommaOrSemicolonOptional
{
@@ -1048,11 +1002,6 @@ SimpleBaseType:
pdebug("BaseType -> tok_binary");
$$ = g_type_binary;
}
-| tok_slist
- {
- pdebug("BaseType -> tok_slist");
- $$ = g_type_slist;
- }
| tok_bool
{
pdebug("BaseType -> tok_bool");
diff --git a/test/AnnotationTest.thrift b/test/AnnotationTest.thrift
index 925832255..8818e74c5 100644
--- a/test/AnnotationTest.thrift
+++ b/test/AnnotationTest.thrift
@@ -49,14 +49,6 @@ enum weekdays {
SATURDAY ( weekend = "yes" )
} (foo.bar="baz")
-/* Note that annotations on senum values are not supported. */
-senum seasons {
- "Spring",
- "Summer",
- "Fall",
- "Winter"
-} ( foo = "bar" )
-
struct ostr_default {
1: i32 bar;
}
diff --git a/test/SmallTest.thrift b/test/SmallTest.thrift
index d0821c7ff..955cdc9a7 100644
--- a/test/SmallTest.thrift
+++ b/test/SmallTest.thrift
@@ -24,12 +24,6 @@ struct Goodbyez {
1: i32 val = 325;
}
-senum Thinger {
- "ASDFKJ",
- "r32)*F#@",
- "ASDFLJASDF"
-}
-
struct BoolPasser {
1: bool value = 1
}
@@ -52,6 +46,10 @@ exception Goodbye {
3: map<i32, map<i32,i32>> complexer,
}
+struct Thinger {
+ 1: i32 dummy
+}
+
service SmallService {
Thinger testThinger(1:Thinger bootz),
Hello testMe(1:i32 hello=64, 2: Hello wonk) throws (1: Goodbye g),