From: Bryan Duxbury Date: Mon, 27 Sep 2010 17:26:02 +0000 (+0000) Subject: THRIFT-920. cpp: C++ Test and Tutorial does not compile anymore due to the change... X-Git-Tag: 0.5.0~18 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=833ae492902c08ab13ebc4efa73adef0a4936dff;p=common%2Fthrift.git THRIFT-920. cpp: C++ Test and Tutorial does not compile anymore due to the change within Enum handling Patch: Roger Meier and Christian Lavoie git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1001826 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/cpp/Thrift-test.mk b/test/cpp/Thrift-test.mk index fb3e38bc..97f0decf 100644 --- a/test/cpp/Thrift-test.mk +++ b/test/cpp/Thrift-test.mk @@ -59,16 +59,16 @@ stubs: ../ThriftTest.thrift $(THRIFT) --gen cpp ../ThriftTest.thrift server-debug: stubs - g++ -o TestServer $(DCFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp + g++ -o TestServer $(DCFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp client-debug: stubs - g++ -o TestClient $(DCFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp + g++ -o TestClient $(DCFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp server: stubs - g++ -o TestServer $(CFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp + g++ -o TestServer $(CFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp client: stubs - g++ -o TestClient $(CFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp + g++ -o TestClient $(CFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp small: $(THRIFT) --gen cpp ../SmallTest.thrift diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index 5ddfa060..4764a4c3 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -297,23 +297,23 @@ int main(int argc, char** argv) { * ENUM TEST */ printf("testEnum(ONE)"); - Numberz ret = testClient.testEnum(ONE); + Numberz::type ret = testClient.testEnum(Numberz::ONE); printf(" = %d\n", ret); printf("testEnum(TWO)"); - ret = testClient.testEnum(TWO); + ret = testClient.testEnum(Numberz::TWO); printf(" = %d\n", ret); printf("testEnum(THREE)"); - ret = testClient.testEnum(THREE); + ret = testClient.testEnum(Numberz::THREE); printf(" = %d\n", ret); printf("testEnum(FIVE)"); - ret = testClient.testEnum(FIVE); + ret = testClient.testEnum(Numberz::FIVE); printf(" = %d\n", ret); printf("testEnum(EIGHT)"); - ret = testClient.testEnum(EIGHT); + ret = testClient.testEnum(Numberz::EIGHT); printf(" = %d\n", ret); /** @@ -345,7 +345,7 @@ int main(int argc, char** argv) { * INSANITY TEST */ Insanity insane; - insane.userMap.insert(make_pair(FIVE, 5000)); + insane.userMap.insert(make_pair(Numberz::FIVE, 5000)); Xtruct truck; truck.string_thing = "Truck"; truck.byte_thing = 8; @@ -353,19 +353,19 @@ int main(int argc, char** argv) { truck.i64_thing = 8; insane.xtructs.push_back(truck); printf("testInsanity()"); - map > whoa; + map > whoa; testClient.testInsanity(whoa, insane); printf(" = {"); - map >::const_iterator i_iter; + map >::const_iterator i_iter; for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) { printf("%"PRId64" => {", i_iter->first); - map::const_iterator i2_iter; + map::const_iterator i2_iter; for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) { printf("%d => {", i2_iter->first); - map userMap = i2_iter->second.userMap; - map::const_iterator um; + map userMap = i2_iter->second.userMap; + map::const_iterator um; printf("{"); for (um = userMap.begin(); um != userMap.end(); ++um) { printf("%d => %"PRId64", ", um->first, um->second); diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 83454dca..d6063ac3 100644 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -138,7 +138,7 @@ class TestHandler : public ThriftTestIf { out = thing; } - Numberz testEnum(const Numberz thing) { + Numberz::type testEnum(const Numberz::type thing) { printf("testEnum(%d)\n", thing); return thing; } @@ -163,7 +163,7 @@ class TestHandler : public ThriftTestIf { } - void testInsanity(map > &insane, const Insanity &argument) { + void testInsanity(map > &insane, const Insanity &argument) { printf("testInsanity()\n"); Xtruct hello; @@ -179,36 +179,36 @@ class TestHandler : public ThriftTestIf { goodbye.i64_thing = 4; Insanity crazy; - crazy.userMap.insert(make_pair(EIGHT, 8)); + crazy.userMap.insert(make_pair(Numberz::EIGHT, 8)); crazy.xtructs.push_back(goodbye); Insanity looney; - crazy.userMap.insert(make_pair(FIVE, 5)); + crazy.userMap.insert(make_pair(Numberz::FIVE, 5)); crazy.xtructs.push_back(hello); - map first_map; - map second_map; + map first_map; + map second_map; - first_map.insert(make_pair(TWO, crazy)); - first_map.insert(make_pair(THREE, crazy)); + first_map.insert(make_pair(Numberz::TWO, crazy)); + first_map.insert(make_pair(Numberz::THREE, crazy)); - second_map.insert(make_pair(SIX, looney)); + second_map.insert(make_pair(Numberz::SIX, looney)); insane.insert(make_pair(1, first_map)); insane.insert(make_pair(2, second_map)); printf("return"); printf(" = {"); - map >::const_iterator i_iter; + map >::const_iterator i_iter; for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) { printf("%"PRId64" => {", i_iter->first); - map::const_iterator i2_iter; + map::const_iterator i2_iter; for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) { printf("%d => {", i2_iter->first); - map userMap = i2_iter->second.userMap; - map::const_iterator um; + map userMap = i2_iter->second.userMap; + map::const_iterator um; printf("{"); for (um = userMap.begin(); um != userMap.end(); ++um) { printf("%d => %"PRId64", ", um->first, um->second); @@ -232,7 +232,7 @@ class TestHandler : public ThriftTestIf { } - void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map &arg3, const Numberz arg4, const UserId arg5) { + void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map &arg3, const Numberz::type arg4, const UserId arg5) { printf("testMulti()\n"); hello.string_thing = "Hello2"; @@ -353,7 +353,7 @@ int main(int argc, char **argv) { if (!args["workers"].empty()) { workerCount = atoi(args["workers"].c_str()); } - } catch (exception& e) { + } catch (std::exception& e) { cerr << e.what() << endl; cerr << usage; } diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp index a3f17fee..4dac90c4 100644 --- a/tutorial/cpp/CppClient.cpp +++ b/tutorial/cpp/CppClient.cpp @@ -53,7 +53,7 @@ int main(int argc, char** argv) { printf("1+1=%d\n", sum); Work work; - work.op = DIVIDE; + work.op = Operation::DIVIDE; work.num1 = 1; work.num2 = 0; @@ -64,7 +64,7 @@ int main(int argc, char** argv) { printf("InvalidOperation: %s\n", io.why.c_str()); } - work.op = SUBTRACT; + work.op = Operation::SUBTRACT; work.num1 = 15; work.num2 = 10; int32_t diff = client.calculate(1, work); diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp index 23c2b833..860381ee 100644 --- a/tutorial/cpp/CppServer.cpp +++ b/tutorial/cpp/CppServer.cpp @@ -61,16 +61,16 @@ class CalculatorHandler : public CalculatorIf { int32_t val; switch (work.op) { - case ADD: + case Operation::ADD: val = work.num1 + work.num2; break; - case SUBTRACT: + case Operation::SUBTRACT: val = work.num1 - work.num2; break; - case MULTIPLY: + case Operation::MULTIPLY: val = work.num1 * work.num2; break; - case DIVIDE: + case Operation::DIVIDE: if (work.num2 == 0) { InvalidOperation io; io.what = work.op;