You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by me...@apache.org on 2016/05/26 02:26:38 UTC
thrift git commit: THRIFT-3842 Dart generates incorrect code for a
const struct Client: Dart Patch: Mark Erickson
Repository: thrift
Updated Branches:
refs/heads/master 839b9320a -> 1fa95f53b
THRIFT-3842 Dart generates incorrect code for a const struct
Client: Dart
Patch: Mark Erickson <me...@apache.org>
This closes #1019
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/1fa95f53
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/1fa95f53
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/1fa95f53
Branch: refs/heads/master
Commit: 1fa95f53bbac168fe4e25ca6b02ebebd2d0affca
Parents: 839b932
Author: Mark Erickson <me...@apache.org>
Authored: Wed May 25 21:23:51 2016 -0500
Committer: Mark Erickson <me...@apache.org>
Committed: Wed May 25 21:23:51 2016 -0500
----------------------------------------------------------------------
compiler/cpp/src/generate/t_dart_generator.cc | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/1fa95f53/compiler/cpp/src/generate/t_dart_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_dart_generator.cc b/compiler/cpp/src/generate/t_dart_generator.cc
index 2931447..bec2e47 100644
--- a/compiler/cpp/src/generate/t_dart_generator.cc
+++ b/compiler/cpp/src/generate/t_dart_generator.cc
@@ -544,6 +544,7 @@ void t_dart_generator::generate_consts(std::vector<t_const*> consts) {
// Print header
f_consts << autogen_comment() << dart_library(file_name) << endl;
+ f_consts << dart_thrift_imports() << endl;
export_class_to_library(file_name, class_name);
indent(f_consts) << "class " << class_name;
@@ -594,8 +595,8 @@ void t_dart_generator::print_const_value(std::ofstream& out,
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
- out << type_name(type) << " " << name << " = new " << type_name(type) << "();"
- << endl;
+ out << type_name(type) << " " << name << " = new " << type_name(type) << "()";
+ indent_up();
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -607,10 +608,11 @@ void t_dart_generator::print_const_value(std::ofstream& out,
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string val = render_const_value(out, name, field_type, v_iter->second);
- indent(out) << name << ".";
- out << v_iter->first->get_string() << " = " << val << ";" << endl;
+ out << endl;
+ indent(out) << ".." << v_iter->first->get_string() << " = " << val;
}
- out << endl;
+ indent_down();
+ out << ";" << endl;
} else if (type->is_map()) {
if (!defval) {
out << type_name(type) << " ";