You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2016/04/29 23:30:12 UTC
[1/6] thrift git commit: THRIFT-3797 Generated Delphi processor
shouldn't error out on timed out exceptions Client: Delphi Patch: Kyle
Johnson
Repository: thrift
Updated Branches:
refs/heads/master e363a34e6 -> ea0da97d4
THRIFT-3797 Generated Delphi processor shouldn't error out on timed out exceptions
Client: Delphi
Patch: Kyle Johnson
This closes #994
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/f5972c96
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/f5972c96
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/f5972c96
Branch: refs/heads/master
Commit: f5972c9682744014c9d825c3ccd9200e44449c6e
Parents: e363a34
Author: Kyle Johnson <ky...@powerworld.com>
Authored: Mon Apr 25 23:00:54 2016 -0500
Committer: Jens Geyer <je...@apache.org>
Committed: Fri Apr 29 23:29:23 2016 +0200
----------------------------------------------------------------------
compiler/cpp/src/generate/t_delphi_generator.cc | 10 ++++++++++
1 file changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/f5972c96/compiler/cpp/src/generate/t_delphi_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_delphi_generator.cc b/compiler/cpp/src/generate/t_delphi_generator.cc
index 5578501..fece1da 100644
--- a/compiler/cpp/src/generate/t_delphi_generator.cc
+++ b/compiler/cpp/src/generate/t_delphi_generator.cc
@@ -2291,10 +2291,20 @@ void t_delphi_generator::generate_service_server(t_service* tservice) {
indent_down_impl();
indent_impl(s_service_impl) << "except" << endl;
indent_up_impl();
+ indent_impl(s_service_impl) << "on TTransportExceptionTimedOut do begin" << endl;
+ indent_up_impl();
+ indent_impl(s_service_impl) << "Result := True;" << endl;
+ indent_impl(s_service_impl) << "Exit;" << endl;
+ indent_down_impl();
+ indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "else begin" << endl;
+ indent_up_impl();
indent_impl(s_service_impl) << "Result := False;" << endl;
indent_impl(s_service_impl) << "Exit;" << endl;
indent_down_impl();
indent_impl(s_service_impl) << "end;" << endl;
+ indent_down_impl();
+ indent_impl(s_service_impl) << "end;" << endl;
indent_impl(s_service_impl) << "Result := True;" << endl;
indent_down_impl();
indent_impl(s_service_impl) << "end;" << endl << endl;
[4/6] thrift git commit: THRIFT-3807 Swift compiler does not escape
reserved words Client: Swift Patch: Stig Bakken
Posted by je...@apache.org.
THRIFT-3807 Swift compiler does not escape reserved words
Client: Swift
Patch: Stig Bakken <st...@zedge.net>
This closes #998
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/b749c260
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/b749c260
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/b749c260
Branch: refs/heads/master
Commit: b749c2603ef1935bc1fbba4f9c2935b12b1328e0
Parents: eed6613
Author: Stig Bakken <st...@zedge.net>
Authored: Wed Apr 6 16:36:01 2016 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Fri Apr 29 23:29:27 2016 +0200
----------------------------------------------------------------------
compiler/cpp/src/generate/t_swift_generator.cc | 77 ++++++++++++++++++---
1 file changed, 66 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/b749c260/compiler/cpp/src/generate/t_swift_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_swift_generator.cc b/compiler/cpp/src/generate/t_swift_generator.cc
index a577c3d..e9e8cc9 100644
--- a/compiler/cpp/src/generate/t_swift_generator.cc
+++ b/compiler/cpp/src/generate/t_swift_generator.cc
@@ -21,6 +21,7 @@
#include <fstream>
#include <iostream>
#include <vector>
+#include <set>
#include <stdlib.h>
#include <sys/stat.h>
@@ -32,6 +33,7 @@ using std::map;
using std::ostream;
using std::ofstream;
using std::ostringstream;
+using std::set;
using std::string;
using std::stringstream;
using std::vector;
@@ -177,6 +179,8 @@ public:
string function_name(t_function* tfunction);
string argument_list(t_struct* tstruct, string protocol_name, bool is_internal);
string type_to_enum(t_type* ttype, bool qualified=false);
+ string maybe_escape_identifier(const string& identifier);
+ void populate_reserved_words();
private:
@@ -231,6 +235,8 @@ private:
bool async_clients_;
bool promise_kit_;
bool debug_descriptions_;
+
+ set<string> swift_reserved_words_;
};
/**
@@ -241,6 +247,8 @@ void t_swift_generator::init_generator() {
// Make output directory
MKDIR(get_out_dir().c_str());
+ populate_reserved_words();
+
// we have a .swift declarations file...
string f_decl_name = capitalize(program_name_) + ".swift";
string f_decl_fullname = get_out_dir() + f_decl_name;
@@ -508,7 +516,8 @@ void t_swift_generator::generate_swift_struct_init(ofstream& out,
else {
out << ", ";
}
- out << (*m_iter)->get_name() << ": " << type_name((*m_iter)->get_type(), field_is_optional(*m_iter));
+ out << (*m_iter)->get_name() << ": "
+ << maybe_escape_identifier(type_name((*m_iter)->get_type(), field_is_optional(*m_iter)));
}
++m_iter;
}
@@ -518,7 +527,8 @@ void t_swift_generator::generate_swift_struct_init(ofstream& out,
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if (all || (*m_iter)->get_req() == t_field::T_REQUIRED || (*m_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) {
- out << indent() << "self." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << endl;
+ out << indent() << "self." << maybe_escape_identifier((*m_iter)->get_name()) << " = "
+ << maybe_escape_identifier((*m_iter)->get_name()) << endl;
}
}
@@ -562,7 +572,8 @@ void t_swift_generator::generate_swift_struct_hashable_extension(ofstream& out,
t_field* tfield = *m_iter;
string accessor = field_is_optional(tfield) ? "?." : ".";
string defaultor = field_is_optional(tfield) ? " ?? 0" : "";
- indent(out) << "result = prime &* result &+ (" << tfield->get_name() << accessor << "hashValue" << defaultor << ")" << endl;
+ indent(out) << "result = prime &* result &+ (" << maybe_escape_identifier(tfield->get_name()) << accessor
+ << "hashValue" << defaultor << ")" << endl;
}
indent(out) << "return result" << endl;
@@ -610,7 +621,8 @@ void t_swift_generator::generate_swift_struct_equatable_extension(ofstream& out,
for (m_iter = members.begin(); m_iter != members.end();) {
t_field* tfield = *m_iter;
- indent(out) << "(lhs." << tfield->get_name() << " ?== rhs." << tfield->get_name() << ")";
+ indent(out) << "(lhs." << maybe_escape_identifier(tfield->get_name())
+ << " ?== rhs." << maybe_escape_identifier(tfield->get_name()) << ")";
if (++m_iter != members.end()) {
out << " &&";
}
@@ -718,7 +730,7 @@ void t_swift_generator::generate_swift_struct_reader(ofstream& out,
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool optional = field_is_optional(*f_iter);
- indent(out) << "var " << (*f_iter)->get_name() << " : "
+ indent(out) << "var " << maybe_escape_identifier((*f_iter)->get_name()) << " : "
<< type_name((*f_iter)->get_type(), optional, !optional) << endl;
}
@@ -746,7 +758,8 @@ void t_swift_generator::generate_swift_struct_reader(ofstream& out,
indent(out) << "case (" << (*f_iter)->get_key() << ", " << type_to_enum((*f_iter)->get_type()) << "):" << endl;
indent_up();
- indent(out) << (*f_iter)->get_name() << " = try __proto.readValue() as " << type_name((*f_iter)->get_type()) << endl << endl;
+ indent(out) << maybe_escape_identifier((*f_iter)->get_name()) << " = try __proto.readValue() as "
+ << type_name((*f_iter)->get_type()) << endl << endl;
indent_down();
}
@@ -788,7 +801,7 @@ void t_swift_generator::generate_swift_struct_reader(ofstream& out,
indent(out) << "return " << tstruct->get_name() << "(";
for (f_iter = fields.begin(); f_iter != fields.end();) {
- out << (*f_iter)->get_name() << ": " << (*f_iter)->get_name();
+ out << (*f_iter)->get_name() << ": " << maybe_escape_identifier((*f_iter)->get_name());
if (++f_iter != fields.end()) {
out << ", ";
}
@@ -833,12 +846,13 @@ void t_swift_generator::generate_swift_struct_writer(ofstream& out,
bool optional = field_is_optional(tfield);
if (optional) {
- indent(out) << "if let " << tfield->get_name() << " = __value." << tfield->get_name();
+ indent(out) << "if let " << maybe_escape_identifier(tfield->get_name())
+ << " = __value." << maybe_escape_identifier(tfield->get_name());
block_open(out);
}
indent(out) << "try __proto.writeFieldValue("
- << (optional ? "" : "__value.") << tfield->get_name() << ", "
+ << (optional ? "" : "__value.") << maybe_escape_identifier(tfield->get_name()) << ", "
<< "name: \"" << tfield->get_name() << "\", "
<< "type: " << type_to_enum(tfield->get_type()) << ", "
<< "id: " << tfield->get_key() << ")" << endl;
@@ -934,7 +948,8 @@ void t_swift_generator::generate_swift_struct_printable_extension(ofstream& out,
vector<t_field*>::const_iterator f_iter;
for (f_iter = fields.begin(); f_iter != fields.end();) {
- indent(out) << "desc += \"" << (*f_iter)->get_name() << "=\\(self." << (*f_iter)->get_name() << ")";
+ indent(out) << "desc += \"" << (*f_iter)->get_name()
+ << "=\\(self." << maybe_escape_identifier((*f_iter)->get_name()) << ")";
if (++f_iter != fields.end()) {
out << ", ";
}
@@ -1992,7 +2007,7 @@ string t_swift_generator::declare_property(t_field* tfield, bool is_private) {
ostringstream render;
- render << visibility << " var " << tfield->get_name();
+ render << visibility << " var " << maybe_escape_identifier(tfield->get_name());
if (field_is_optional(tfield)) {
render << " : " << type_name(tfield->get_type(), true);
@@ -2101,6 +2116,46 @@ string t_swift_generator::argument_list(t_struct* tstruct, string protocol_name,
}
/**
+ * https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html
+ *
+ */
+
+void t_swift_generator::populate_reserved_words() {
+ swift_reserved_words_.insert("Self");
+ swift_reserved_words_.insert("associatedtype");
+ swift_reserved_words_.insert("defer");
+ swift_reserved_words_.insert("deinit");
+ swift_reserved_words_.insert("dynamicType");
+ swift_reserved_words_.insert("enum");
+ swift_reserved_words_.insert("extension");
+ swift_reserved_words_.insert("fallthrough");
+ swift_reserved_words_.insert("false");
+ swift_reserved_words_.insert("func");
+ swift_reserved_words_.insert("guard");
+ swift_reserved_words_.insert("init");
+ swift_reserved_words_.insert("inout");
+ swift_reserved_words_.insert("internal");
+ swift_reserved_words_.insert("let");
+ swift_reserved_words_.insert("operator");
+ swift_reserved_words_.insert("protocol");
+ swift_reserved_words_.insert("repeat");
+ swift_reserved_words_.insert("rethrows");
+ swift_reserved_words_.insert("struct");
+ swift_reserved_words_.insert("subscript");
+ swift_reserved_words_.insert("throws");
+ swift_reserved_words_.insert("true");
+ swift_reserved_words_.insert("typealias");
+ swift_reserved_words_.insert("where");
+}
+
+string t_swift_generator::maybe_escape_identifier(const string& identifier) {
+ if (swift_reserved_words_.find(identifier) != swift_reserved_words_.end()) {
+ return "`" + identifier + "`";
+ }
+ return identifier;
+}
+
+/**
* Converts the parse type to a Swift TType enumeration.
*/
string t_swift_generator::type_to_enum(t_type* type, bool qualified) {
[2/6] thrift git commit: THRIFT-3808 Missing `DOUBLE` in thrift type
enumeration Client: Go Patch: Mahendran Kathirvel
Posted by je...@apache.org.
THRIFT-3808 Missing `DOUBLE` in thrift type enumeration
Client: Go
Patch: Mahendran Kathirvel <as...@gmail.com>
This closes #1001
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/7c3eac3e
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/7c3eac3e
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/7c3eac3e
Branch: refs/heads/master
Commit: 7c3eac3ee28facfea3593b4a78488d73eb6a7f4d
Parents: f5972c9
Author: Mahendran Kathirvel <as...@gmail.com>
Authored: Fri Apr 29 16:30:24 2016 +0530
Committer: Jens Geyer <je...@apache.org>
Committed: Fri Apr 29 23:29:24 2016 +0200
----------------------------------------------------------------------
lib/go/thrift/type.go | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/7c3eac3e/lib/go/thrift/type.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/type.go b/lib/go/thrift/type.go
index 7c68c2b..867cd8d 100644
--- a/lib/go/thrift/type.go
+++ b/lib/go/thrift/type.go
@@ -48,6 +48,7 @@ var typeNames = map[int]string{
VOID: "VOID",
BOOL: "BOOL",
BYTE: "BYTE",
+ DOUBLE: "DOUBLE",
I16: "I16",
I32: "I32",
I64: "I64",
[6/6] thrift git commit: THRIFT-3803 - Remove file attribute from
include elements in XML generator Client: XML/XSD Patch: Benjamin Gould
Posted by je...@apache.org.
THRIFT-3803 - Remove file attribute from include elements in XML generator
Client: XML/XSD
Patch: Benjamin Gould <bg...@users.noreply.github.com>
This closes #996
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/ea0da97d
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/ea0da97d
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/ea0da97d
Branch: refs/heads/master
Commit: ea0da97d44d1f9e367303c66cc55e825ed419260
Parents: ad3714a
Author: BCG <bg...@users.noreply.github.com>
Authored: Thu Apr 28 10:54:13 2016 -0400
Committer: Jens Geyer <je...@apache.org>
Committed: Fri Apr 29 23:29:29 2016 +0200
----------------------------------------------------------------------
compiler/cpp/src/generate/t_xml_generator.cc | 2 --
lib/xml/thrift-idl.xsd | 28 +++++++++++------------
2 files changed, 14 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/ea0da97d/compiler/cpp/src/generate/t_xml_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_xml_generator.cc b/compiler/cpp/src/generate/t_xml_generator.cc
index 4a166c8..5465b49 100644
--- a/compiler/cpp/src/generate/t_xml_generator.cc
+++ b/compiler/cpp/src/generate/t_xml_generator.cc
@@ -310,10 +310,8 @@ void t_xml_generator::iterate_program(t_program* program) {
const vector<t_program*> includes = program->get_includes();
vector<t_program*>::const_iterator inc_it;
for (inc_it = includes.begin(); inc_it != includes.end(); ++inc_it) {
- const string include_path = (*inc_it)->get_path();
write_element_start("include");
write_attribute("name", (*inc_it)->get_name());
- write_attribute("file", include_path);
write_element_end();
}
http://git-wip-us.apache.org/repos/asf/thrift/blob/ea0da97d/lib/xml/thrift-idl.xsd
----------------------------------------------------------------------
diff --git a/lib/xml/thrift-idl.xsd b/lib/xml/thrift-idl.xsd
index 7a5248a..09dd695 100644
--- a/lib/xml/thrift-idl.xsd
+++ b/lib/xml/thrift-idl.xsd
@@ -47,14 +47,14 @@
<element name="enum" type="tns:Enum" />
</choice>
</sequence>
- <attribute name="name" type="string" />
- <attribute name="targetNamespace" type="anyURI" />
- <attribute name="doc" type="string" />
+ <attribute name="name" type="string" use="required" />
+ <attribute name="targetNamespace" type="anyURI" use="optional" />
+ <attribute name="doc" type="string" use="optional" />
</complexType>
<complexType name="Include">
- <attribute name="file" type="string" />
- <attribute name="name" type="string" />
+ <attribute name="file" type="string" use="optional" />
+ <attribute name="name" type="string" use="required" />
</complexType>
<complexType name="Namespace">
@@ -62,9 +62,9 @@
<element name="annotation" type="tns:Annotation"
minOccurs="0" maxOccurs="unbounded" />
</sequence>
- <attribute name="name" type="string" />
- <attribute name="value" type="string" />
- <attribute name="doc" type="string" />
+ <attribute name="name" type="string" use="required" />
+ <attribute name="value" type="string" use="required" />
+ <attribute name="doc" type="string" use="optional" />
</complexType>
<group name="AbstractStruct">
@@ -77,8 +77,8 @@
</group>
<attributeGroup name="StructAttributes">
- <attribute name="name" type="string" />
- <attribute name="doc" type="string" />
+ <attribute name="name" type="string" use="required" />
+ <attribute name="doc" type="string" use="optional" />
</attributeGroup>
<complexType name="Exception">
@@ -97,7 +97,7 @@
<attribute name="targetNamespace" type="string" use="required" />
<attribute name="parent-module" type="string" use="optional" />
<attribute name="parent-id" type="string" use="optional" />
- <attribute name="doc" type="string" />
+ <attribute name="doc" type="string" use="optional" />
</complexType>
<complexType name="Method">
@@ -111,8 +111,8 @@
minOccurs="0" maxOccurs="unbounded" />
</sequence>
<attribute name="name" type="string" use="required" />
- <attribute name="oneway" type="boolean" />
- <attribute name="doc" type="string" />
+ <attribute name="oneway" type="boolean" use="optional" />
+ <attribute name="doc" type="string" use="optional" />
</complexType>
<complexType name="Typedef">
@@ -123,7 +123,7 @@
minOccurs="0" maxOccurs="unbounded" />
</sequence>
<attribute name="name" type="string" use="required" />
- <attribute name="doc" type="string" />
+ <attribute name="doc" type="string" use="optional" />
</extension>
</complexContent>
</complexType>
[3/6] thrift git commit: THRIFT-3809 wrong/unused BINARY type code
Client: Go Patch: Jens Geyer
Posted by je...@apache.org.
THRIFT-3809 wrong/unused BINARY type code
Client: Go
Patch: Jens Geyer
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/eed66131
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/eed66131
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/eed66131
Branch: refs/heads/master
Commit: eed661313f4da242d1b3c6e4166b993fd6efba6b
Parents: 7c3eac3
Author: Jens Geyer <je...@apache.org>
Authored: Fri Apr 29 23:10:06 2016 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Fri Apr 29 23:29:26 2016 +0200
----------------------------------------------------------------------
lib/go/thrift/type.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/eed66131/lib/go/thrift/type.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/type.go b/lib/go/thrift/type.go
index 867cd8d..4292ffc 100644
--- a/lib/go/thrift/type.go
+++ b/lib/go/thrift/type.go
@@ -40,7 +40,7 @@ const (
LIST = 15
UTF8 = 16
UTF16 = 17
- BINARY = 18
+ //BINARY = 18 wrong and unusued
)
var typeNames = map[int]string{
[5/6] thrift git commit: THRIFT-3806 Swift generator does not handle
self-referring structs Client: Swift Patch: Stig Bakken
Posted by je...@apache.org.
THRIFT-3806 Swift generator does not handle self-referring structs
Client: Swift
Patch: Stig Bakken <st...@zedge.net>
This closes #997
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/ad3714ac
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/ad3714ac
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/ad3714ac
Branch: refs/heads/master
Commit: ad3714ac3d7b9220d16f3a68503c261b8d22c8ee
Parents: b749c26
Author: Stig Bakken <st...@zedge.net>
Authored: Wed Apr 6 16:35:37 2016 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Fri Apr 29 23:29:28 2016 +0200
----------------------------------------------------------------------
compiler/cpp/src/generate/t_swift_generator.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/ad3714ac/compiler/cpp/src/generate/t_swift_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_swift_generator.cc b/compiler/cpp/src/generate/t_swift_generator.cc
index e9e8cc9..6e48bca 100644
--- a/compiler/cpp/src/generate/t_swift_generator.cc
+++ b/compiler/cpp/src/generate/t_swift_generator.cc
@@ -448,7 +448,7 @@ void t_swift_generator::generate_swift_struct(ofstream& out,
string visibility = is_private ? "private" : "public";
- out << indent() << visibility << " struct " << tstruct->get_name();
+ out << indent() << visibility << " final class " << tstruct->get_name();
if (tstruct->is_xception()) {
out << " : ErrorType";