Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/thrift
diff --git a/.gitignore b/.gitignore
index 8c4ba8e..b9c63dc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,7 +23,7 @@
/Makefile
/Makefile.in
-/.vagrant/
+/contrib/.vagrant/
/aclocal/libtool.m4
/aclocal/ltoptions.m4
/aclocal/ltsugar.m4
diff --git a/Makefile.am b/Makefile.am
index f7758af..c8d85ae 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,7 +40,6 @@
doap.rdf \
sonar-project.properties \
tutorial \
- Vagrantfile \
LICENSE \
CHANGES \
NOTICE
diff --git a/compiler/cpp/src/generate/t_as3_generator.cc b/compiler/cpp/src/generate/t_as3_generator.cc
index 9f72eac..5abeba4 100644
--- a/compiler/cpp/src/generate/t_as3_generator.cc
+++ b/compiler/cpp/src/generate/t_as3_generator.cc
@@ -431,7 +431,7 @@
return;
}
- string f_consts_name = package_dir_+"/Constants.as";
+ string f_consts_name = package_dir_+ "/" + program_name_ + "Constants.as";
ofstream f_consts;
f_consts.open(f_consts_name.c_str());
@@ -447,7 +447,7 @@
indent(f_consts) <<
- "public class Constants {" << endl <<
+ "public class " << program_name_ << "Constants {" << endl <<
endl;
indent_up();
vector<t_const*>::iterator c_iter;
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc
index 26f1bdf..016e3f8 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -21,6 +21,8 @@
* details.
*/
+#include <cassert>
+
#include <string>
#include <fstream>
#include <iostream>
@@ -160,6 +162,8 @@
std::string type_to_enum(t_type* ttype);
std::string prop_name(t_field* tfield);
std::string get_enum_class_name(t_type* type);
+
+ std::string make_valid_csharp_identifier( std::string const & fromName);
bool field_has_default(t_field* tfield) {
return tfield->get_value() != NULL;
@@ -302,7 +306,7 @@
start_csharp_namespace(f_consts);
indent(f_consts) <<
- "public static class " << program_name_ << "Constants" << endl;
+ "public static class " << make_valid_csharp_identifier(program_name_) << "Constants" << endl;
scope_up(f_consts);
vector<t_const*>::iterator c_iter;
@@ -372,7 +376,7 @@
}
void t_csharp_generator::print_const_constructor(std::ofstream& out, std::vector<t_const*> consts) {
- indent(out) << "static " << program_name_ << "Constants()" << endl;
+ indent(out) << "static " << make_valid_csharp_identifier(program_name_).c_str() << "Constants()" << endl;
scope_up(out);
vector<t_const*>::iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -2246,6 +2250,35 @@
out << endl;
}
+std::string t_csharp_generator::make_valid_csharp_identifier( std::string const & fromName) {
+ std::string str = fromName;
+ if( str.empty()) {
+ return str;
+ }
+
+ // tests rely on this
+ assert( ('A' < 'Z') && ('a' < 'z') && ('0' < '9'));
+
+ // if the first letter is a number, we add an additional underscore in front of it
+ char c = str.at(0);
+ if( ('0' <= c) && (c <= '9')) {
+ str = "_" + str;
+ }
+
+ // following chars: letter, number or underscore
+ for( size_t i = 0; i < str.size(); ++i) {
+ c = str.at(i);
+ if( (('A' > c) || (c > 'Z')) &&
+ (('a' > c) || (c > 'z')) &&
+ (('0' > c) || (c > '9')) &&
+ ('_' != c) ) {
+ str.replace( i, 1, "_");
+ }
+ }
+
+ return str;
+}
+
std::string t_csharp_generator::prop_name(t_field* tfield) {
string name (tfield->get_name());
name[0] = toupper(name[0]);
diff --git a/compiler/cpp/src/generate/t_delphi_generator.cc b/compiler/cpp/src/generate/t_delphi_generator.cc
index 0fc9c06..8476f80 100644
--- a/compiler/cpp/src/generate/t_delphi_generator.cc
+++ b/compiler/cpp/src/generate/t_delphi_generator.cc
@@ -60,6 +60,8 @@
iter = parsed_options.find("ansistr_binary");
ansistr_binary_ = (iter != parsed_options.end());
+ iter = parsed_options.find("register_types");
+ register_types_ = (iter != parsed_options.end());
out_dir_base_ = "gen-delphi";
escape_.clear();
@@ -108,6 +110,9 @@
void generate_delphi_struct(t_struct* tstruct, bool is_exception);
void generate_delphi_struct_impl( ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result = false, bool is_x_factory = false);
+ void print_delphi_struct_type_factory_func( ostream& out, t_struct* tstruct);
+ void generate_delphi_struct_type_factory( ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result = false, bool is_x_factory = false);
+ void generate_delphi_struct_type_factory_registration( ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result = false, bool is_x_factory = false);
void generate_delphi_struct_definition(std::ostream& out, t_struct* tstruct, bool is_xception=false, bool in_class=false, bool is_result=false, bool is_x_factory = false);
void generate_delphi_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_delphi_struct_result_writer(std::ostream& out, t_struct* tstruct);
@@ -188,6 +193,8 @@
std::ostringstream s_const_impl;
std::ostringstream s_struct_impl;
std::ostringstream s_service_impl;
+ std::ostringstream s_type_factory_registration;
+ std::ostringstream s_type_factory_funcs;
bool has_enum;
bool has_const;
std::string namespace_dir_;
@@ -207,6 +214,7 @@
bool is_void( t_type* type );
int indent_impl_;
bool ansistr_binary_;
+ bool register_types_;
void indent_up_impl(){
++indent_impl_;
};
@@ -428,6 +436,11 @@
add_delphi_uses_list("Thrift.Protocol");
add_delphi_uses_list("Thrift.Transport");
+ if (register_types_)
+ {
+ add_delphi_uses_list("Thrift.TypeRegistry");
+ }
+
init_known_types_list();
string unitname, nsname;
@@ -509,20 +522,39 @@
f_all << s_struct_impl.str();
f_all << s_service_impl.str();
f_all << s_const_impl.str();
-
- if ( has_const ) {
- f_all << "{$IF CompilerVersion < 21.0}" << endl;
- f_all << "initialization" << endl;
- f_all << "begin" << endl;
- f_all << " TConstants_Initialize;" << endl;
- f_all << "end;" << endl << endl;
-
- f_all << "finalization" << endl;
- f_all << "begin" << endl;
- f_all << " TConstants_Finalize;" << endl;
- f_all << "end;" << endl;
- f_all << "{$IFEND}" << endl << endl;
+
+
+ if (register_types_)
+ {
+ f_all << endl;
+ f_all << "// Type factory methods and registration" << endl;
+ f_all << s_type_factory_funcs.str();
+ f_all << "procedure RegisterTypeFactories;" << endl;
+ f_all << "begin" << endl;
+ f_all << s_type_factory_registration.str();
+ f_all << "end;" << endl;
}
+ f_all << endl;
+
+ f_all << "initialization" << endl;
+ if ( has_const ) {
+ f_all << "{$IF CompilerVersion < 21.0}" << endl;
+ f_all << " TConstants_Initialize;" << endl;
+ f_all << "{$IFEND}" << endl;
+ }
+ if (register_types_) {
+ f_all << " RegisterTypeFactories;" << endl;
+ }
+ f_all << endl;
+
+ f_all << "finalization" << endl;
+ if ( has_const ) {
+ f_all << "{$IF CompilerVersion < 21.0}" << endl;
+ f_all << " TConstants_Finalize;" << endl;
+ f_all << "{$IFEND}" << endl;
+ }
+ f_all << endl << endl;
+
f_all << "end." << endl;
f_all.close();
@@ -924,6 +956,10 @@
add_defined_type( tstruct);
generate_delphi_struct_impl(s_struct_impl, "", tstruct, is_exception);
+ if (register_types_) {
+ generate_delphi_struct_type_factory(s_type_factory_funcs, "", tstruct, is_exception);
+ generate_delphi_struct_type_factory_registration(s_type_factory_registration, "", tstruct, is_exception);
+ }
}
void t_delphi_generator::generate_delphi_struct_impl( ostream& out, string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result, bool is_x_factory) {
@@ -1064,6 +1100,54 @@
}
}
+void t_delphi_generator::print_delphi_struct_type_factory_func( ostream& out, t_struct* tstruct) {
+ string struct_intf_name = type_name(tstruct);
+ out << "Create_";
+ out << struct_intf_name;
+ out << "_Impl";
+}
+
+
+void t_delphi_generator::generate_delphi_struct_type_factory( ostream& out, string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result, bool is_x_factory) {
+
+ if (is_exception)
+ return;
+ if (is_result)
+ return;
+ if (is_x_factory)
+ return;
+
+ string struct_intf_name = type_name(tstruct);
+ string cls_nm = type_name(tstruct,true,false);
+
+ out << "function ";
+ print_delphi_struct_type_factory_func(out, tstruct);
+ out << ": ";
+ out << struct_intf_name;
+ out << ";" << endl;
+ out << "begin" << endl;
+ indent_up();
+ indent(out) << "Result := " << cls_nm << ".Create;" << endl;
+ indent_down();
+ out << "end;" << endl << endl;
+}
+
+void t_delphi_generator::generate_delphi_struct_type_factory_registration( ostream& out, string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result, bool is_x_factory) {
+ if (is_exception)
+ return;
+ if (is_result)
+ return;
+ if (is_x_factory)
+ return;
+
+ string struct_intf_name = type_name(tstruct);
+
+ indent(out) << " TypeRegistry.RegisterTypeFactory<" << struct_intf_name << ">(";
+ print_delphi_struct_type_factory_func(out, tstruct);
+ out << ");";
+ out << endl;
+}
+
void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struct* tstruct, bool is_exception, bool in_class, bool is_result, bool is_x_factory) {
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
string struct_intf_name;
@@ -3038,6 +3122,7 @@
return false;
}
-THRIFT_REGISTER_GENERATOR(delphi, "delphi",
-" ansistr_binary: Use AnsiString as binary properties.\n")
+THRIFT_REGISTER_GENERATOR(delphi, "delphi",
+" ansistr_binary: Use AnsiString as binary properties.\n"
+" register_types: Register structs and there implementations in a global type registry\n");
diff --git a/compiler/cpp/src/generate/t_javame_generator.cc b/compiler/cpp/src/generate/t_javame_generator.cc
index aa847ac..a2a31a5 100644
--- a/compiler/cpp/src/generate/t_javame_generator.cc
+++ b/compiler/cpp/src/generate/t_javame_generator.cc
@@ -414,7 +414,7 @@
return;
}
- string f_consts_name = package_dir_+"/Constants.java";
+ string f_consts_name = package_dir_+ "/" + program_name_ + "Constants.java";
ofstream f_consts;
f_consts.open(f_consts_name.c_str());
@@ -425,7 +425,7 @@
java_type_imports();
f_consts <<
- "public class Constants {" << endl <<
+ "public class " << program_name_ << "Constants {" << endl <<
endl;
indent_up();
vector<t_const*>::iterator c_iter;
diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll
index fda6b33..958bb40 100644
--- a/compiler/cpp/src/thriftl.ll
+++ b/compiler/cpp/src/thriftl.ll
@@ -143,7 +143,10 @@
"double" { return tok_double; }
"string" { return tok_string; }
"binary" { return tok_binary; }
-"slist" { return tok_slist; }
+"slist" {
+ pwarning(0, "\"slist\" is deprecated and will be removed in a future compiler version. This type should be replaced with \"string\".\n");
+ return tok_slist;
+}
"senum" { return tok_senum; }
"map" { return tok_map; }
"list" { return tok_list; }
diff --git a/configure.ac b/configure.ac
index 372f2d1..757922e 100755
--- a/configure.ac
+++ b/configure.ac
@@ -574,6 +574,15 @@
AM_CONDITIONAL([WITH_BOOSTTHREADS], [test "x[$]ENABLE_BOOSTTHREADS" = "x1"])
AC_CONFIG_HEADERS(config.h:config.hin)
+# gruard against pre defined config.h
+AH_TOP([
+#ifndef CONFIG_H
+#define CONFIG_H
+])
+AH_BOTTOM([
+#endif
+])
+
AC_CONFIG_FILES([
Makefile
diff --git a/Vagrantfile b/contrib/Vagrantfile
similarity index 63%
rename from Vagrantfile
rename to contrib/Vagrantfile
index b63dae9..dd2e2ee 100644
--- a/Vagrantfile
+++ b/contrib/Vagrantfile
@@ -1,9 +1,25 @@
-# © The Apache Software Foundation
-# http://www.apache.org/licenses/LICENSE-2.0
-
# -*- mode: ruby -*-
# vi: set ft=ruby :
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
$script = <<SCRIPT
echo I am provisioning for Apache Thrift ...
sudo apt-get update -qq -y
@@ -19,7 +35,7 @@
#sudo apt-get install -qq ghc6 cabal-install libghc6-binary-dev libghc6-network-dev libghc6-http-dev
sudo apt-get install -qq mingw32 mingw32-binutils mingw32-runtime
echo I am building Apache Thrift ...
-cd /vagrant
+cd /thrift
sh bootstrap.sh
sh configure
make
@@ -36,6 +52,8 @@
# config.vm.box = "precise32"
# config.vm.box_url = "http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-i386-disk1.box"
+ config.vm.synced_folder "../", "/thrift"
+
# call the script
config.vm.provision :shell, :inline => $script
end
diff --git a/contrib/fb303/java/build.xml b/contrib/fb303/java/build.xml
index bb80e64..8f2fa51 100755
--- a/contrib/fb303/java/build.xml
+++ b/contrib/fb303/java/build.xml
@@ -153,6 +153,8 @@
<developer id="molinaro" name="Anthony Molinaro"/>
<developer id="roger" name="Roger Meier"/>
<developer id="jfarrell" name="Jake Farrell"/>
+ <developer id="jensg" name="Jens Geyer"/>
+ <developer id="carl" name="Carl Yeksigian"/>
<!-- Thrift dependencies list -->
<dependency groupId="org.apache.thrift" artifactId="libthrift" version="${version}"/>
diff --git a/lib/as3/build.xml b/lib/as3/build.xml
index 62a9fe8..604da42 100755
--- a/lib/as3/build.xml
+++ b/lib/as3/build.xml
@@ -141,6 +141,8 @@
<developer id="molinaro" name="Anthony Molinaro"/>
<developer id="roger" name="Roger Meier"/>
<developer id="jfarrell" name="Jake Farrell"/>
+ <developer id="jensg" name="Jens Geyer"/>
+ <developer id="carl" name="Carl Yeksigian"/>
</artifact:pom>
<!-- Generate the pom file -->
diff --git a/lib/cpp/src/thrift/Thrift.cpp b/lib/cpp/src/thrift/Thrift.cpp
index bcbdb1a..6c7f8ae 100644
--- a/lib/cpp/src/thrift/Thrift.cpp
+++ b/lib/cpp/src/thrift/Thrift.cpp
@@ -34,6 +34,19 @@
char stack_buf[STACK_BUF_SIZE];
va_list ap;
+#ifdef _MSC_VER
+ va_start(ap, message);
+ int need = _vscprintf(message, ap);
+ va_end(ap);
+
+ if (need < STACK_BUF_SIZE) {
+ va_start(ap, message);
+ vsnprintf_s(stack_buf, STACK_BUF_SIZE, _TRUNCATE, message, ap);
+ va_end(ap);
+ f_(stack_buf);
+ return;
+ }
+#else
va_start(ap, message);
int need = vsnprintf(stack_buf, STACK_BUF_SIZE, message, ap);
va_end(ap);
@@ -42,9 +55,15 @@
f_(stack_buf);
return;
}
+#endif
char *heap_buf = (char*)malloc((need+1) * sizeof(char));
if (heap_buf == NULL) {
+#ifdef _MSC_VER
+ va_start(ap, message);
+ vsnprintf_s(stack_buf, STACK_BUF_SIZE, _TRUNCATE, message, ap);
+ va_end(ap);
+#endif
// Malloc failed. We might as well print the stack buffer.
f_(stack_buf);
return;
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
index c4d1f08..23ee1a9 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
@@ -35,10 +35,10 @@
: public TVirtualProtocol< TCompactProtocolT<Transport_> > {
protected:
- static const int8_t PROTOCOL_ID = (int8_t)0x82;
+ static const int8_t PROTOCOL_ID = 0x82u;
static const int8_t VERSION_N = 1;
static const int8_t VERSION_MASK = 0x1f; // 0001 1111
- static const int8_t TYPE_MASK = (int8_t)0xE0; // 1110 0000
+ static const int8_t TYPE_MASK = 0xE0u; // 1110 0000
static const int32_t TYPE_SHIFT_AMOUNT = 5;
Transport_* trans_;
@@ -161,12 +161,12 @@
const TType fieldType,
const int16_t fieldId,
int8_t typeOverride);
- uint32_t writeCollectionBegin(int8_t elemType, int32_t size);
+ uint32_t writeCollectionBegin(const TType elemType, int32_t size);
uint32_t writeVarint32(uint32_t n);
uint32_t writeVarint64(uint64_t n);
uint64_t i64ToZigzag(const int64_t l);
uint32_t i32ToZigzag(const int32_t n);
- inline int8_t getCompactType(int8_t ttype);
+ inline int8_t getCompactType(const TType ttype);
public:
uint32_t readMessageBegin(std::string& name,
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
index 79f1b6b..62d6485 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
@@ -198,16 +198,20 @@
if (booleanField_.name != NULL) {
// we haven't written the field header yet
- wsize += writeFieldBeginInternal(booleanField_.name,
- booleanField_.fieldType,
- booleanField_.fieldId,
- value ? detail::compact::CT_BOOLEAN_TRUE :
- detail::compact::CT_BOOLEAN_FALSE);
+ wsize
+ += writeFieldBeginInternal(booleanField_.name,
+ booleanField_.fieldType,
+ booleanField_.fieldId,
+ static_cast<int8_t>(value
+ ? detail::compact::CT_BOOLEAN_TRUE
+ : detail::compact::CT_BOOLEAN_FALSE));
booleanField_.name = NULL;
} else {
// we're not part of a field, so just write the value
- wsize += writeByte(value ? detail::compact::CT_BOOLEAN_TRUE :
- detail::compact::CT_BOOLEAN_FALSE);
+ wsize
+ += writeByte(static_cast<int8_t>(value
+ ? detail::compact::CT_BOOLEAN_TRUE
+ : detail::compact::CT_BOOLEAN_FALSE));
}
return wsize;
}
@@ -296,7 +300,8 @@
// check if we can use delta encoding for the field id
if (fieldId > lastFieldId_ && fieldId - lastFieldId_ <= 15) {
// write them together
- wsize += writeByte((fieldId - lastFieldId_) << 4 | typeToWrite);
+ wsize += writeByte(static_cast<int8_t>((fieldId - lastFieldId_)
+ << 4 | typeToWrite));
} else {
// write them separate
wsize += writeByte(typeToWrite);
@@ -312,11 +317,12 @@
* the wire differ only by the type indicator.
*/
template <class Transport_>
-uint32_t TCompactProtocolT<Transport_>::writeCollectionBegin(int8_t elemType,
+uint32_t TCompactProtocolT<Transport_>::writeCollectionBegin(const TType elemType,
int32_t size) {
uint32_t wsize = 0;
if (size <= 14) {
- wsize += writeByte(size << 4 | getCompactType(elemType));
+ wsize += writeByte(static_cast<int8_t>(size
+ << 4 | getCompactType(elemType)));
} else {
wsize += writeByte(0xf0 | getCompactType(elemType));
wsize += writeVarint32(size);
@@ -388,7 +394,7 @@
* Given a TType value, find the appropriate detail::compact::Types value
*/
template <class Transport_>
-int8_t TCompactProtocolT<Transport_>::getCompactType(int8_t ttype) {
+int8_t TCompactProtocolT<Transport_>::getCompactType(const TType ttype) {
return detail::compact::TTypeToCType[ttype];
}
@@ -641,12 +647,13 @@
BOOST_STATIC_ASSERT(sizeof(double) == sizeof(uint64_t));
BOOST_STATIC_ASSERT(std::numeric_limits<double>::is_iec559);
- uint64_t bits;
- uint8_t b[8];
- trans_->readAll(b, 8);
- bits = *(uint64_t*)b;
- bits = letohll(bits);
- dub = bitwise_cast<double>(bits);
+ union {
+ uint64_t bits;
+ uint8_t b[8];
+ } u;
+ trans_->readAll(u.b, 8);
+ u.bits = letohll(u.bits);
+ dub = bitwise_cast<double>(u.bits);
return 8;
}
@@ -761,7 +768,7 @@
*/
template <class Transport_>
int32_t TCompactProtocolT<Transport_>::zigzagToI32(uint32_t n) {
- return (n >> 1) ^ -(n & 1);
+ return (n >> 1) ^ -static_cast<int32_t>(n & 1);
}
/**
@@ -769,7 +776,7 @@
*/
template <class Transport_>
int64_t TCompactProtocolT<Transport_>::zigzagToI64(uint64_t n) {
- return (n >> 1) ^ -(n & 1);
+ return (n >> 1) ^ -static_cast<int32_t>(n & 1);
}
template <class Transport_>
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
index 641f714..69f0e55 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
@@ -64,6 +64,7 @@
#ifdef _MSC_VER
#define PRIu32 "I32u"
+#define PRIu64 "I64u"
#endif
namespace apache { namespace thrift { namespace server {
@@ -478,9 +479,10 @@
// Don't allow giant frame sizes. This prevents bad clients from
// causing us to try and allocate a giant buffer.
GlobalOutput.printf("TNonblockingServer: frame size too large "
- "(%"PRIu32" > %zu) from client %s. remote side not "
- "using TFramedTransport?",
- readWant_, server_->getMaxFrameSize(),
+ "(%"PRIu32" > %"PRIu64") from client %s. "
+ "Remote side not using TFramedTransport?",
+ readWant_,
+ (uint64_t)server_->getMaxFrameSize(),
tSocket_->getSocketInfo().c_str());
close();
return;
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp
index 20313ac..1000367 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp
@@ -78,7 +78,7 @@
TServerSocket::TServerSocket(int port) :
port_(port),
serverSocket_(-1),
- acceptBacklog_(1024),
+ acceptBacklog_(DEFAULT_BACKLOG),
sendTimeout_(0),
recvTimeout_(0),
accTimeout_(-1),
@@ -92,7 +92,7 @@
TServerSocket::TServerSocket(int port, int sendTimeout, int recvTimeout) :
port_(port),
serverSocket_(-1),
- acceptBacklog_(1024),
+ acceptBacklog_(DEFAULT_BACKLOG),
sendTimeout_(sendTimeout),
recvTimeout_(recvTimeout),
accTimeout_(-1),
@@ -107,7 +107,7 @@
port_(0),
path_(path),
serverSocket_(-1),
- acceptBacklog_(1024),
+ acceptBacklog_(DEFAULT_BACKLOG),
sendTimeout_(0),
recvTimeout_(0),
accTimeout_(-1),
@@ -134,6 +134,10 @@
accTimeout_ = accTimeout;
}
+void TServerSocket::setAcceptBacklog(int accBacklog) {
+ acceptBacklog_ = accBacklog;
+}
+
void TServerSocket::setRetryLimit(int retryLimit) {
retryLimit_ = retryLimit;
}
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.h b/lib/cpp/src/thrift/transport/TServerSocket.h
index 2ee7593..e562a19 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.h
+++ b/lib/cpp/src/thrift/transport/TServerSocket.h
@@ -37,6 +37,8 @@
*/
class TServerSocket : public TServerTransport {
public:
+ const static int DEFAULT_BACKLOG = 1024;
+
TServerSocket(int port);
TServerSocket(int port, int sendTimeout, int recvTimeout);
TServerSocket(std::string path);
@@ -47,6 +49,7 @@
void setRecvTimeout(int recvTimeout);
void setAcceptTimeout(int accTimeout);
+ void setAcceptBacklog(int accBacklog);
void setRetryLimit(int retryLimit);
void setRetryDelay(int retryDelay);
diff --git a/lib/delphi/src/Thrift.TypeRegistry.pas b/lib/delphi/src/Thrift.TypeRegistry.pas
new file mode 100644
index 0000000..1b863d2
--- /dev/null
+++ b/lib/delphi/src/Thrift.TypeRegistry.pas
@@ -0,0 +1,84 @@
+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+unit Thrift.TypeRegistry;
+
+interface
+
+uses
+ Generics.Collections;
+
+type
+ TFactoryMethod<T> = function:T;
+
+ TypeRegistry = class
+ private
+ class var FTypeInfoToFactoryLookup : TDictionary<Pointer, Pointer>;
+ public
+ class constructor Create;
+ class destructor Destroy;
+ class procedure RegisterTypeFactory<F>(const aFactoryMethod: TFactoryMethod<F>);
+ class function Construct<F>: F;
+ end;
+
+implementation
+
+uses
+ TypInfo;
+
+{ TypeRegistration }
+
+class constructor TypeRegistry.Create;
+begin
+ FTypeInfoToFactoryLookup := TDictionary<Pointer, Pointer>.Create;
+end;
+
+class destructor TypeRegistry.Destroy;
+begin
+ FTypeInfoToFactoryLookup.Free;
+end;
+
+class procedure TypeRegistry.RegisterTypeFactory<F>(const aFactoryMethod: TFactoryMethod<F>);
+var
+ TypeInfo : Pointer;
+begin
+ TypeInfo := System.TypeInfo(F);
+
+ if (TypeInfo <> nil) and (PTypeInfo(TypeInfo).Kind = tkInterface)
+ then FTypeInfoToFactoryLookup.AddOrSetValue(TypeInfo, @aFactoryMethod);
+end;
+
+class function TypeRegistry.Construct<F>: F;
+var
+ TypeInfo : PTypeInfo;
+ Factory : Pointer;
+begin
+ Result := default(F);
+
+ TypeInfo := System.TypeInfo(F);
+
+ if Assigned(TypeInfo) and (TypeInfo.Kind = tkInterface)
+ then begin
+ if FTypeInfoToFactoryLookup.TryGetValue(TypeInfo, Factory)
+ then Result := TFactoryMethod<F>(Factory)();
+ end;
+end;
+
+
+end.
diff --git a/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl b/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl
index 8d25eae..6ccd260 100644
--- a/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl
+++ b/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl
@@ -58,7 +58,7 @@
echo.
echo Generating code, please wait ...
cd "%TARGET%"
-for %%a in (*.thrift) do "%BIN%\thrift.exe" -v --gen delphi:ansistr_binary "%%a" >> "%LOGFILE%"
+for %%a in (*.thrift) do "%BIN%\thrift.exe" -v --gen delphi:ansistr_binary,register_types "%%a" 2>> "%LOGFILE%"
REM * for %%a in (*.thrift) do "%BIN%\thrift.exe" -v --gen cpp "%%a" >> NUL:
cmd /c start notepad "%LOGFILE%"
cd ..
diff --git a/lib/delphi/test/typeregistry/TestTypeRegistry.dpr b/lib/delphi/test/typeregistry/TestTypeRegistry.dpr
new file mode 100644
index 0000000..64d5771
--- /dev/null
+++ b/lib/delphi/test/typeregistry/TestTypeRegistry.dpr
@@ -0,0 +1,89 @@
+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+program TestTypeRegistry;
+
+{$APPTYPE CONSOLE}
+
+uses
+ Classes, Windows, SysUtils, Generics.Collections, TypInfo,
+ Thrift in '..\..\src\Thrift.pas',
+ Thrift.Transport in '..\..\src\Thrift.Transport.pas',
+ Thrift.Protocol in '..\..\src\Thrift.Protocol.pas',
+ Thrift.Protocol.JSON in '..\..\src\Thrift.Protocol.JSON.pas',
+ Thrift.Collections in '..\..\src\Thrift.Collections.pas',
+ Thrift.Server in '..\..\src\Thrift.Server.pas',
+ Thrift.Console in '..\..\src\Thrift.Console.pas',
+ Thrift.Utils in '..\..\src\Thrift.Utils.pas',
+ Thrift.Serializer in '..\..\src\Thrift.Serializer.pas',
+ Thrift.Stream in '..\..\src\Thrift.Stream.pas',
+ Thrift.TypeRegistry in '..\..\src\Thrift.TypeRegistry.pas',
+ DebugProtoTest;
+
+type
+ Tester<T : IInterface> = class
+ public
+ class procedure Test;
+ end;
+
+class procedure Tester<T>.Test;
+var instance : T;
+ name : string;
+begin
+ instance := TypeRegistry.Construct<T>;
+ name := GetTypeName(TypeInfo(T));
+ if instance <> nil
+ then Writeln( name, ' = ok')
+ else begin
+ Writeln( name, ' = failed');
+ raise Exception.Create( 'Test with '+name+' failed!');
+ end;
+end;
+
+begin
+ Writeln('Testing ...');
+ Tester<IDoubles>.Test;
+ Tester<IOneOfEach>.Test;
+ Tester<IBonk>.Test;
+ Tester<INesting>.Test;
+ Tester<IHolyMoley>.Test;
+ Tester<IBackwards>.Test;
+ Tester<IEmpty>.Test;
+ Tester<IWrapper>.Test;
+ Tester<IRandomStuff>.Test;
+ Tester<IBase64>.Test;
+ Tester<ICompactProtoTestStruct>.Test;
+ Tester<ISingleMapTestStruct>.Test;
+ Tester<IBlowUp>.Test;
+ Tester<IReverseOrderStruct>.Test;
+ Tester<IStructWithSomeEnum>.Test;
+ Tester<ITestUnion>.Test;
+ Tester<ITestUnionMinusStringField>.Test;
+ Tester<IComparableUnion>.Test;
+ Tester<IStructWithAUnion>.Test;
+ Tester<IPrimitiveThenStruct>.Test;
+ Tester<IStructWithASomemap>.Test;
+ Tester<IBigFieldIdStruct>.Test;
+ Tester<IBreaksRubyCompactProtocol>.Test;
+ Tester<ITupleProtocolTestStruct>.Test;
+ Writeln('Completed.');
+
+
+end.
+
diff --git a/lib/java/build.xml b/lib/java/build.xml
index 64995fe..c2bfd9c 100755
--- a/lib/java/build.xml
+++ b/lib/java/build.xml
@@ -129,9 +129,6 @@
<include name="org/apache/thrift/**/*.class"/>
<include name="META-INF/*.txt"/>
</fileset>
- <fileset dir="src">
- <include name="**/*.java"/>
- </fileset>
</jar>
</target>
@@ -316,6 +313,8 @@
<developer id="molinaro" name="Anthony Molinaro"/>
<developer id="roger" name="Roger Meier"/>
<developer id="jfarrell" name="Jake Farrell"/>
+ <developer id="jensg" name="Jens Geyer"/>
+ <developer id="carl" name="Carl Yeksigian"/>
<!-- Thrift dependencies list -->
<dependency groupId="org.slf4j" artifactId="slf4j-api" version="${slf4j.version}"/>