mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-06 18:35:19 +00:00
Fixed a few typos - test client and server samples now working with new code generation
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664753 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
91f674823a
commit
e6889de36f
@ -230,7 +230,7 @@ CPP_INTERFACE_FUNCTION_DECLARATION = Template(""" virtual ${functionDeclarati
|
||||
CPP_INTERFACE_DECLARATION = Template("""
|
||||
class ${service}If {
|
||||
public:
|
||||
~${service}If() {}
|
||||
virtual ~${service}If() {}
|
||||
${functionDeclarations}};
|
||||
""")
|
||||
|
||||
@ -322,8 +322,6 @@ void ${service}ServerIf::process_${function}(uint32_t seqid, """+CPP_TRANSPORTP+
|
||||
CPP_SERVER_PROCESS_DEFINITION = Template("""
|
||||
bool ${service}ServerIf::process("""+CPP_TRANSPORTP+""" itrans, """+CPP_TRANSPORTP+""" otrans) {
|
||||
|
||||
uint32_t xfer = 0;
|
||||
|
||||
std::string name;
|
||||
|
||||
"""+CPP_PROTOCOL_MESSAGE_TYPE+""" messageType;
|
||||
@ -337,6 +335,8 @@ ${callProcessSwitch}
|
||||
} else {
|
||||
throw """+CPP_EXCEPTION+"""(\"Unexpected message type\");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
""")
|
||||
|
||||
@ -785,7 +785,7 @@ uint32_t read_${suffix}("""+CPP_PROTOCOLP+""" iprot, """+CPP_TRANSPORTP+""" itra
|
||||
|
||||
xfer += iprot->readU32(itrans, count);
|
||||
|
||||
for(int ix = 0; ix < count; ix++) {
|
||||
for(uint32_t ix = 0; ix < count; ix++) {
|
||||
${keyReaderCall};
|
||||
${valueReaderCall};
|
||||
value.insert(std::make_pair(key, elem));
|
||||
@ -819,7 +819,7 @@ uint32_t read_${suffix}("""+CPP_PROTOCOLP+""" iprot, """+CPP_TRANSPORTP+""" itra
|
||||
|
||||
xfer+= iprot->readU32(itrans, count);
|
||||
|
||||
for(int ix = 0; ix < count; ix++) {
|
||||
for(uint32_t ix = 0; ix < count; ix++) {
|
||||
${valueReaderCall};
|
||||
value.${insert}(elem);
|
||||
}
|
||||
|
@ -5,7 +5,11 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#if defined(HAVE_CLOCK_GETTIME)
|
||||
#include <time.h>
|
||||
#else // defined(HAVE_CLOCK_GETTIME)
|
||||
#include <sys/time.h>
|
||||
#endif // defined(HAVE_CLOCK_GETTIME)
|
||||
|
||||
namespace facebook { namespace thrift { namespace concurrency {
|
||||
|
||||
|
@ -110,6 +110,20 @@ uint32_t TBinaryProtocol::writeI16(shared_ptr<TTransport> out,
|
||||
return 2;
|
||||
}
|
||||
|
||||
uint32_t TBinaryProtocol::writeU32(shared_ptr<TTransport> out,
|
||||
const uint32_t u32) const {
|
||||
uint32_t net = (uint32_t)htonl(u32);
|
||||
out->write((uint8_t*)&net, 4);
|
||||
return 4;
|
||||
}
|
||||
|
||||
uint32_t TBinaryProtocol::writeI32(shared_ptr<TTransport> out,
|
||||
const int32_t i32) const {
|
||||
int32_t net = (int32_t)htonl(i32);
|
||||
out->write((uint8_t*)&net, 4);
|
||||
return 4;
|
||||
}
|
||||
|
||||
uint32_t TBinaryProtocol::writeU64(shared_ptr<TTransport> out,
|
||||
const uint64_t u64) const {
|
||||
uint64_t net = (uint64_t)htonll(u64);
|
||||
@ -135,10 +149,10 @@ uint32_t TBinaryProtocol::writeString(shared_ptr<TTransport> out,
|
||||
* Reading functions
|
||||
*/
|
||||
|
||||
uint32_t TBinaryProtocol::readMessasgeBegin(shared_ptr<TTransport> in,
|
||||
std::string& name,
|
||||
TMessageType& messageType,
|
||||
uint32_t& seqid) const {
|
||||
uint32_t TBinaryProtocol::readMessageBegin(shared_ptr<TTransport> in,
|
||||
std::string& name,
|
||||
TMessageType& messageType,
|
||||
uint32_t& seqid) const {
|
||||
|
||||
uint32_t result = 0;
|
||||
uint8_t type;
|
||||
|
@ -97,10 +97,10 @@ using namespace boost;
|
||||
*/
|
||||
|
||||
|
||||
uint32_t readMessasgeBegin(shared_ptr<TTransport> in,
|
||||
std::string& name,
|
||||
TMessageType& messageType,
|
||||
uint32_t& seqid) const;
|
||||
uint32_t readMessageBegin(shared_ptr<TTransport> in,
|
||||
std::string& name,
|
||||
TMessageType& messageType,
|
||||
uint32_t& seqid) const;
|
||||
|
||||
uint32_t readMessageEnd(shared_ptr<TTransport> in) const;
|
||||
|
||||
|
@ -28,7 +28,7 @@ struct Xtruct2
|
||||
struct Insanity
|
||||
{
|
||||
map<Numberz, UserId> userMap = 0,
|
||||
list<Xtruct> xtructList = 1
|
||||
list<Xtruct> xtructs = 1
|
||||
}
|
||||
|
||||
struct Empty {}
|
||||
|
@ -8,15 +8,24 @@
|
||||
ifndef thrift_home
|
||||
thrift_home=../../build
|
||||
endif #thrift_home
|
||||
|
||||
target: all
|
||||
|
||||
ifndef boost_home
|
||||
boost_home=../../../../../thirdparty/boost_1_33_1
|
||||
endif #thrift_home
|
||||
target: all
|
||||
|
||||
include_paths = $(thrift_home)/include/thrift \
|
||||
$(boost_home)
|
||||
|
||||
include_flags = $(patsubst %,-I%, $(include_paths))
|
||||
|
||||
# Tools
|
||||
THRIFT = thrift
|
||||
THRIFT = python ../../compiler/src/thrift.py ~/ws/thrift/dev/test/ThriftTest.thrift --cpp
|
||||
CC = g++
|
||||
LD = g++
|
||||
|
||||
include_flags = $(patsubst %,-I$(thrift_home)/include/%, thrift boost-1_33_1)
|
||||
|
||||
# Compiler flags
|
||||
LIBS = ../../lib/cpp/src/server/TSimpleServer.cc \
|
||||
../../lib/cpp/src/protocol/TBinaryProtocol.cc \
|
||||
@ -24,8 +33,8 @@ LIBS = ../../lib/cpp/src/server/TSimpleServer.cc \
|
||||
../../lib/cpp/src/transport/TChunkedTransport.cc \
|
||||
../../lib/cpp/src/transport/TServerSocket.cc \
|
||||
../../lib/cpp/src/transport/TSocket.cc
|
||||
DCFL = -Wall -O3 -g -Igen-cpp $(include_flags) $(LIBS)
|
||||
CFL = -Wall -O3 -Igen-cpp $(include_flags) -L$(thrift_home)/lib -lthrift
|
||||
DCFL = -Wall -O3 -g -I../cpp-gen $(include_flags) $(LIBS)
|
||||
CFL = -Wall -O3 -I../cpp-gen $(include_flags) -L$(thrift_home)/lib -lthrift
|
||||
|
||||
all: server client
|
||||
|
||||
@ -35,16 +44,16 @@ stubs: ../ThriftTest.thrift
|
||||
$(THRIFT) -cpp ../ThriftTest.thrift
|
||||
|
||||
server-debug: stubs
|
||||
g++ -o TestServer $(DCFL) src/TestServer.cc gen-cpp/ThriftTest.cc
|
||||
g++ -o TestServer $(DCFL) src/TestServer.cc ../cpp-gen/ThriftTest.cc
|
||||
|
||||
client-debug: stubs
|
||||
g++ -o TestClient $(DCFL) src/TestClient.cc gen-cpp/ThriftTest.cc
|
||||
g++ -o TestClient $(DCFL) src/TestClient.cc ../cpp-gen/ThriftTest.cc
|
||||
|
||||
server: stubs
|
||||
g++ -o TestServer $(CFL) src/TestServer.cc gen-cpp/ThriftTest.cc
|
||||
g++ -o TestServer $(CFL) src/TestServer.cc ../cpp-gen/ThriftTest.cc
|
||||
|
||||
client: stubs
|
||||
g++ -o TestClient $(CFL) src/TestClient.cc gen-cpp/ThriftTest.cc
|
||||
g++ -o TestClient $(CFL) src/TestClient.cc ../cpp-gen/ThriftTest.cc
|
||||
|
||||
clean:
|
||||
rm -fr TestServer TestClient gen-cpp
|
||||
rm -fr TestServer TestClient ../cpp-gen
|
||||
|
@ -215,6 +215,18 @@ class TestServer : public ThriftTestServerIf {
|
||||
|
||||
return insane;
|
||||
}
|
||||
|
||||
Xtruct testMulti(uint8_t arg0, int32_t arg1, uint64_t arg2, std::map<int16_t, std::string> arg3, Numberz arg4, 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;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
Loading…
Reference in New Issue
Block a user