CPP_INTERFACE_DECLARATION = Template("""
class ${service}If {
public:
- ~${service}If() {}
+ virtual ~${service}If() {}
${functionDeclarations}};
""")
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;
} else {
throw """+CPP_EXCEPTION+"""(\"Unexpected message type\");
}
+
+ return true;
}
""")
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));
xfer+= iprot->readU32(itrans, count);
- for(int ix = 0; ix < count; ix++) {
+ for(uint32_t ix = 0; ix < count; ix++) {
${valueReaderCall};
value.${insert}(elem);
}
#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 {
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);
* 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;
*/
- 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;
struct Insanity
{
map<Numberz, UserId> userMap = 0,
- list<Xtruct> xtructList = 1
+ list<Xtruct> xtructs = 1
}
struct Empty {}
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 \
../../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
$(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
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) {