Add comma-separated list of type "slist" to thrift

Summary: Useful for API arguments

Reviewed By: tbr-dave


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664931 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc
index 1f77575..092244e 100644
--- a/compiler/cpp/src/generate/t_php_generator.cc
+++ b/compiler/cpp/src/generate/t_php_generator.cc
@@ -836,7 +836,8 @@
       }
       f_service_ <<
         indent() << "$" << (*a_iter)->get_name() << " = $request['" << (*a_iter)->get_name() << "'];" << endl;
-      if (atype->is_list()) {
+      if (atype->is_string() &&
+          ((t_base_type*)atype)->is_string_list()) {
         f_service_ << 
           indent() << "$" << (*a_iter)->get_name() << " = explode(',', $" << (*a_iter)->get_name() << ");" << endl;
       }      
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index c6e81e3..a8e0726 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -811,7 +811,7 @@
       "    sys.exit(1)" << endl <<
       "  pp.pprint(client." << (*f_iter)->get_name() << "(";
     for (int i = 0; i < num_args; ++i) {
-      if (args[i]->get_type() == g_type_string) {
+      if (args[i]->get_type()->is_string()) {
         f_remote << "args[" << i << "],";
       } else {
         f_remote << "eval(args[" << i << "]),";
diff --git a/compiler/cpp/src/globals.h b/compiler/cpp/src/globals.h
index 51502c7..dd1067f 100644
--- a/compiler/cpp/src/globals.h
+++ b/compiler/cpp/src/globals.h
@@ -47,6 +47,7 @@
 
 extern t_type* g_type_void;
 extern t_type* g_type_string;
+extern t_type* g_type_slist;
 extern t_type* g_type_bool;
 extern t_type* g_type_byte;
 extern t_type* g_type_i16;
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
index 065c95f..2fbf913 100644
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -41,6 +41,7 @@
 
 t_type* g_type_void;
 t_type* g_type_string;
+t_type* g_type_slist;
 t_type* g_type_bool;
 t_type* g_type_byte;
 t_type* g_type_i16;
@@ -621,6 +622,8 @@
   // Initialize global types
   g_type_void   = new t_base_type("void",   t_base_type::TYPE_VOID);
   g_type_string = new t_base_type("string", t_base_type::TYPE_STRING);
+  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_byte   = new t_base_type("byte",   t_base_type::TYPE_BYTE);
   g_type_i16    = new t_base_type("i16",    t_base_type::TYPE_I16);
diff --git a/compiler/cpp/src/parse/t_base_type.h b/compiler/cpp/src/parse/t_base_type.h
index 837caa5..b0d41d6 100644
--- a/compiler/cpp/src/parse/t_base_type.h
+++ b/compiler/cpp/src/parse/t_base_type.h
@@ -27,7 +27,8 @@
 
   t_base_type(std::string name, t_base base) :
     t_type(name),
-    base_(base) {}
+    base_(base),
+    string_list_(false) {}
     
   t_base get_base() const {
     return base_;
@@ -37,12 +38,25 @@
     return base_ == TYPE_VOID;
   }
 
+  bool is_string() const {
+    return base_ == TYPE_STRING;
+  }
+  
+  void set_string_list(bool val) {
+    string_list_ = val;
+  }
+
+  bool is_string_list() const {
+    return base_ == TYPE_STRING && string_list_;
+  }
+
   bool is_base_type() const {
     return true;
   }
     
  private:
   t_base base_;
+  bool string_list_;
 };
 
 #endif
diff --git a/compiler/cpp/src/parse/t_type.h b/compiler/cpp/src/parse/t_type.h
index 9589f02..da062b5 100644
--- a/compiler/cpp/src/parse/t_type.h
+++ b/compiler/cpp/src/parse/t_type.h
@@ -28,6 +28,7 @@
 
   virtual bool is_void()      const { return false; }
   virtual bool is_base_type() const { return false; }
+  virtual bool is_string()    const { return false; }
   virtual bool is_typedef()   const { return false; }
   virtual bool is_enum()      const { return false; }
   virtual bool is_struct()    const { return false; }
diff --git a/compiler/cpp/src/thrift.l b/compiler/cpp/src/thrift.l
index 4f2d542..b7008c6 100644
--- a/compiler/cpp/src/thrift.l
+++ b/compiler/cpp/src/thrift.l
@@ -70,6 +70,7 @@
 "i64"           { return tok_i64;           }
 "double"        { return tok_double;        }
 "string"        { return tok_string;        }
+"slist"         { return tok_slist;         }
 "map"           { return tok_map;           }
 "list"          { return tok_list;          }
 "set"           { return tok_set;           }
diff --git a/compiler/cpp/src/thrift.y b/compiler/cpp/src/thrift.y
index cfb3e44..fe56dad 100644
--- a/compiler/cpp/src/thrift.y
+++ b/compiler/cpp/src/thrift.y
@@ -75,6 +75,7 @@
 %token tok_bool
 %token tok_byte
 %token tok_string
+%token tok_slist
 %token tok_i16
 %token tok_i32
 %token tok_i64
@@ -637,6 +638,11 @@
       pdebug("BaseType -> tok_string");
       $$ = g_type_string;
     }
+| tok_slist
+    {
+      pdebug("BaseType -> tok_slist");
+      $$ = g_type_slist;
+    }
 | tok_bool
     {
       pdebug("BaseType -> tok_bool");