Fix C++ Thrift test code to work with new gen'd code interface

Reviewed By: tbr-aditya


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664938 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index db00347..d7191ca 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -110,7 +110,8 @@
      * STRING TEST
      */
     printf("testString(\"Test\")");
-    string s = testClient.testString("Test");
+    string s;
+    testClient.testString(s, "Test");
     printf(" = \"%s\"\n", s.c_str());
    
     /**
@@ -150,7 +151,8 @@
     out.byte_thing = 1;
     out.i32_thing = -3;
     out.i64_thing = -5;
-    Xtruct in = testClient.testStruct(out);
+    Xtruct in;
+    testClient.testStruct(in, out);
     printf(" = {\"%s\", %d, %d, %ld}\n",
            in.string_thing.c_str(),
            (int)in.byte_thing,
@@ -165,7 +167,8 @@
     out2.byte_thing = 1;
     out2.struct_thing = out;
     out2.i32_thing = 5;
-    Xtruct2 in2 = testClient.testNest(out2);
+    Xtruct2 in2;
+    testClient.testNest(in2, out2);
     in = in2.struct_thing;
     printf(" = {%d, {\"%s\", %d, %d, %ld}, %d}\n",
            in2.byte_thing,
@@ -194,7 +197,8 @@
       printf("%d => %d", m_iter->first, m_iter->second);
     }
     printf("})");
-    map<int32_t,int32_t> mapin = testClient.testMap(mapout);
+    map<int32_t,int32_t> mapin;
+    testClient.testMap(mapin, mapout);
     printf(" = {");
     first = true;
     for (m_iter = mapin.begin(); m_iter != mapin.end(); ++m_iter) {
@@ -226,7 +230,8 @@
       printf("%d", *s_iter);
     }
     printf("})");
-    set<int32_t> setin = testClient.testSet(setout);
+    set<int32_t> setin;
+    testClient.testSet(setin, setout);
     printf(" = {");
     first = true;
     for (s_iter = setin.begin(); s_iter != setin.end(); ++s_iter) {
@@ -258,7 +263,8 @@
       printf("%d", *l_iter);
     }
     printf("})");
-    vector<int32_t> listin = testClient.testList(listout);
+    vector<int32_t> listin;
+    testClient.testList(listin, listout);
     printf(" = {");
     first = true;
     for (l_iter = listin.begin(); l_iter != listin.end(); ++l_iter) {
@@ -305,7 +311,8 @@
      * NESTED MAP TEST
      */
     printf("testMapMap(1)");
-    map<int32_t, map<int32_t, int32_t> > mm = testClient.testMapMap(1);
+    map<int32_t, map<int32_t, int32_t> > mm;
+    testClient.testMapMap(mm, 1);
     printf(" = {");
     map<int32_t, map<int32_t, int32_t> >::const_iterator mi;
     for (mi = mm.begin(); mi != mm.end(); ++mi) {
@@ -330,7 +337,8 @@
     truck.i64_thing = 8;
     insane.xtructs.push_back(truck);
     printf("testInsanity()");
-    map<UserId, map<Numberz,Insanity> > whoa = testClient.testInsanity(insane);
+    map<UserId, map<Numberz,Insanity> > whoa;
+    testClient.testInsanity(whoa, insane);
     printf(" = {");
     map<UserId, map<Numberz,Insanity> >::const_iterator i_iter;
     for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) {
@@ -389,7 +397,8 @@
     
     try {
       printf("testClient.testMultiException(\"Xception\", \"test 1\") =>");
-      Xtruct result = testClient.testMultiException("Xception", "test 1");
+      Xtruct result;
+      testClient.testMultiException(result, "Xception", "test 1");
       printf("  result\nFAILURE\n");
     } catch(Xception& e) {
       printf("  {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
@@ -397,7 +406,8 @@
 
     try {
       printf("testClient.testMultiException(\"Xception2\", \"test 2\") =>");
-      Xtruct result = testClient.testMultiException("Xception2", "test 2");
+      Xtruct result;
+      testClient.testMultiException(result, "Xception2", "test 2");
       printf("  result\nFAILURE\n");
       
     } catch(Xception2& e) {
@@ -406,7 +416,8 @@
     
     try {
       printf("testClient.testMultiException(\"success\", \"test 3\") =>");
-      Xtruct result = testClient.testMultiException("success", "test 3");
+      Xtruct result;
+      testClient.testMultiException(result, "success", "test 3");
       printf("  {{\"%s\"}}\n", result.string_thing.c_str());
     } catch(...) {
       printf("  exception\nFAILURE\n");
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 28a40fd..bd6a2cf 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -29,43 +29,43 @@
     printf("testVoid()\n");
   }
 
-  string testString(string thing) {
+  void testString(string& out, const string &thing) {
     printf("testString(\"%s\")\n", thing.c_str());
-    return thing;
+    out = thing;
   }
 
-  int8_t testByte(int8_t thing) {
+  int8_t testByte(const int8_t thing) {
     printf("testByte(%d)\n", (int)thing);
     return thing;
   }
 
-  int32_t testI32(int32_t thing) {
+  int32_t testI32(const int32_t thing) {
     printf("testI32(%d)\n", thing);
     return thing;
   }
 
-  int64_t testI64(int64_t thing) {
+  int64_t testI64(const int64_t thing) {
     printf("testI64(%ld)\n", thing);
     return thing;
   }
 
-  double testDouble(double thing) {
+  double testDouble(const double thing) {
     printf("testDouble(%lf)\n", thing);
     return thing;
   }
 
-  Xtruct testStruct(Xtruct thing) {
+  void testStruct(Xtruct& out, const Xtruct &thing) {
     printf("testStruct({\"%s\", %d, %d, %ld})\n", thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing);
-    return thing;
+    out = thing;
   }
 
-  Xtruct2 testNest(Xtruct2 nest) {
-    Xtruct thing = nest.struct_thing;
+  void testNest(Xtruct2& out, const Xtruct2& nest) {
+    const Xtruct &thing = nest.struct_thing;
     printf("testNest({%d, {\"%s\", %d, %d, %ld}, %d})\n", (int)nest.byte_thing, thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing, nest.i32_thing);
-    return nest;
+    out = nest;
   }
 
-  map<int32_t, int32_t> testMap(map<int32_t, int32_t> thing) {
+  void testMap(map<int32_t, int32_t> &out, const map<int32_t, int32_t> &thing) {
     printf("testMap({");
     map<int32_t, int32_t>::const_iterator m_iter;
     bool first = true;
@@ -78,10 +78,10 @@
       printf("%d => %d", m_iter->first, m_iter->second);
     }
     printf("})\n");
-    return thing;
+    out = thing;
   }
 
-  set<int32_t> testSet(set<int32_t> thing) {
+  void testSet(set<int32_t> &out, const set<int32_t> &thing) {
     printf("testSet({");
     set<int32_t>::const_iterator s_iter;
     bool first = true;
@@ -94,10 +94,10 @@
       printf("%d", *s_iter);
     }
     printf("})\n");
-    return thing;
+    out = thing;
   }
 
-  vector<int32_t> testList(vector<int32_t> thing) {
+  void testList(vector<int32_t> &out, const vector<int32_t> &thing) {
     printf("testList({");
     vector<int32_t>::const_iterator l_iter;
     bool first = true;
@@ -110,22 +110,21 @@
       printf("%d", *l_iter);
     }
     printf("})\n");
-    return thing;
+    out = thing;
   }
 
-  Numberz testEnum(Numberz thing) {
+  Numberz testEnum(const Numberz thing) {
     printf("testEnum(%d)\n", thing);
     return thing;
   }
 
-  UserId testTypedef(UserId thing) {
+  UserId testTypedef(const UserId thing) {
     printf("testTypedef(%ld)\n", thing);
     return thing;
   }
 
-  map<int32_t, map<int32_t,int32_t> > testMapMap(int32_t hello) {
+  void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) {
     printf("testMapMap(%d)\n", hello);
-    map<int32_t, map<int32_t,int32_t> > mapmap;
 
     map<int32_t,int32_t> pos;
     map<int32_t,int32_t> neg;
@@ -137,10 +136,9 @@
     mapmap.insert(make_pair(4, pos));
     mapmap.insert(make_pair(-4, neg));
 
-    return mapmap;
   }
 
-  map<UserId, map<Numberz,Insanity> > testInsanity(Insanity argument) {
+  void testInsanity(map<UserId, map<Numberz,Insanity> > &insane, const Insanity &argument) {
     printf("testInsanity()\n");
     
     Xtruct hello;
@@ -171,7 +169,6 @@
 
     second_map.insert(make_pair(SIX, looney));
 
-    map<UserId, map<Numberz,Insanity> > insane;
     insane.insert(make_pair(1, first_map));
     insane.insert(make_pair(2, second_map));
 
@@ -207,22 +204,19 @@
     }
     printf("}\n");
 
-    return insane;
+    
   }
 
-  Xtruct testMulti(int8_t arg0, int32_t arg1, int64_t arg2, std::map<int16_t, std::string>  arg3, Numberz arg4, UserId arg5) {
+  void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string>  &arg3, const Numberz arg4, const UserId arg5) {
     printf("testMulti()\n");
     
-    Xtruct hello;
     hello.string_thing = "Hello2";
     hello.byte_thing = arg0;
     hello.i32_thing = arg1;
     hello.i64_thing = (int64_t)arg2;
-
-    return hello;
   }
 
-  void testException(std::string arg) throw(Xception) {
+  void testException(const std::string &arg) throw(Xception) {
     printf("testException(%s)\n", arg.c_str());
     if (arg.compare("Xception") == 0) {
       Xception e;
@@ -236,7 +230,7 @@
     }
   }
   
-  Xtruct testMultiException(std::string arg0, std::string arg1) throw(Xception, Xception2) {
+  void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) {
 
     printf("testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str());
 
@@ -251,9 +245,8 @@
       e.struct_thing.string_thing = "This is an Xception2";
       throw e;
     } else {
-      Xtruct result;
       result.string_thing = arg1;
-      return  result;
+      return;
     }
   }
 };