'make style' applied
diff --git a/compiler/cpp/src/generate/t_delphi_generator.cc b/compiler/cpp/src/generate/t_delphi_generator.cc
index b7667b8..65ece6c 100644
--- a/compiler/cpp/src/generate/t_delphi_generator.cc
+++ b/compiler/cpp/src/generate/t_delphi_generator.cc
@@ -2415,8 +2415,8 @@
if (!tfunction->is_oneway()) {
string factory_name = normalize_clsnm((*x_iter)->get_type()->get_name(), "", true)
+ "Factory";
- indent_impl(s_service_impl) << "ret." << prop_name(*x_iter) << " := E." << factory_name
- << ";" << endl;
+ indent_impl(s_service_impl) << "ret." << prop_name(*x_iter) << " := E." << factory_name << ";"
+ << endl;
}
indent_down_impl();
indent_impl(s_service_impl) << "end;" << endl;
@@ -2426,11 +2426,15 @@
indent_up_impl();
indent_impl(s_service_impl) << "if events <> nil then events.UnhandledError(E);" << endl;
if (!tfunction->is_oneway()) {
- indent_impl(s_service_impl) << "appx := TApplicationException.Create( TApplicationException.TExceptionType.InternalError, E.Message);" << endl;
+ indent_impl(s_service_impl) << "appx := TApplicationException.Create( "
+ "TApplicationException.TExceptionType.InternalError, E.Message);"
+ << endl;
indent_impl(s_service_impl) << "try" << endl;
indent_up_impl();
indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << endl;
- indent_impl(s_service_impl) << "msg := Thrift.Protocol.TMessageImpl.Create('" << tfunction->get_name() << "', TMessageType.Exception, seqid);" << endl;
+ indent_impl(s_service_impl) << "msg := Thrift.Protocol.TMessageImpl.Create('"
+ << tfunction->get_name() << "', TMessageType.Exception, seqid);"
+ << endl;
indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << endl;
indent_impl(s_service_impl) << "appx.Write(oprot);" << endl;
indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << endl;
diff --git a/compiler/cpp/src/generate/t_go_generator.cc b/compiler/cpp/src/generate/t_go_generator.cc
index e1f4942..0c8dd00 100644
--- a/compiler/cpp/src/generate/t_go_generator.cc
+++ b/compiler/cpp/src/generate/t_go_generator.cc
@@ -1234,15 +1234,16 @@
<< endl;
indent_up();
out << indent() << "if _, err := iprot.ReadStructBegin(); err != nil {" << endl << indent()
- << " return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)" << endl << indent() << "}" << endl;
+ << " return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)" << endl
+ << indent() << "}" << endl;
// Loop over reading in fields
indent(out) << "for {" << endl;
indent_up();
// Read beginning field marker
out << indent() << "_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()" << endl << indent()
<< "if err != nil {" << endl << indent()
- << " return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)" << endl << indent()
- << "}" << endl;
+ << " return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)"
+ << endl << indent() << "}" << endl;
// Check for field STOP marker and break
out << indent() << "if fieldTypeId == thrift.STOP { break; }" << endl;
@@ -1302,7 +1303,8 @@
<< " return err" << endl << indent() << "}" << endl;
indent_down();
out << indent() << "}" << endl << indent() << "if err := iprot.ReadStructEnd(); err != nil {"
- << endl << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)" << endl
+ << endl << indent()
+ << " return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)" << endl
<< indent() << "}" << endl << indent() << "return nil" << endl;
indent_down();
out << indent() << "}" << endl << endl;
@@ -1338,7 +1340,9 @@
indent(out) << "func (p *" << tstruct_name << ") Write(oprot thrift.TProtocol) error {" << endl;
indent_up();
out << indent() << "if err := oprot.WriteStructBegin(\"" << name << "\"); err != nil {" << endl
- << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }" << endl;
+ << indent()
+ << " return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }"
+ << endl;
string field_name;
string escape_field_name;
@@ -1395,16 +1399,16 @@
out << indent() << "if err := oprot.WriteFieldBegin(\"" << escape_field_name << "\", "
<< type_to_enum((*f_iter)->get_type()) << ", " << field_id << "); err != nil {" << endl
- << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T write field begin error " << field_id << ":"
- << escape_field_name << ": \", p), err) }" << endl;
+ << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T write field begin error "
+ << field_id << ":" << escape_field_name << ": \", p), err) }" << endl;
// Write field contents
generate_serialize_field(out, *f_iter, "p.");
// Write field closer
out << indent() << "if err := oprot.WriteFieldEnd(); err != nil {" << endl << indent()
- << " return thrift.PrependError(fmt.Sprintf(\"%T write field end error " << field_id << ":" << escape_field_name
- << ": \", p), err) }" << endl;
+ << " return thrift.PrependError(fmt.Sprintf(\"%T write field end error " << field_id << ":"
+ << escape_field_name << ": \", p), err) }" << endl;
if (field_required == t_field::T_OPTIONAL) {
indent_down();
@@ -2450,8 +2454,9 @@
out << "ReadI32()";
}
- out << "; err != nil {" << endl << indent() << "return thrift.PrependError(\"error reading field "
- << tfield->get_key() << ": \", err)" << endl;
+ out << "; err != nil {" << endl << indent()
+ << "return thrift.PrependError(\"error reading field " << tfield->get_key() << ": \", err)"
+ << endl;
out << "} else {" << endl;
string wrap;
@@ -2490,8 +2495,8 @@
out << indent() << prefix << eq << (pointer_field ? "&" : "");
generate_go_struct_initializer(out, tstruct);
out << indent() << "if err := " << prefix << ".Read(iprot); err != nil {" << endl << indent()
- << " return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", " << prefix << "), err)" << endl
- << indent() << "}" << endl;
+ << " return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", " << prefix
+ << "), err)" << endl << indent() << "}" << endl;
}
/**
@@ -2514,24 +2519,24 @@
if (ttype->is_map()) {
out << indent() << "_, _, size, err := iprot.ReadMapBegin()" << endl << indent()
<< "if err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error reading map begin: \", err)" << endl << indent() << "}"
- << endl << indent() << "tMap := make(" << type_to_go_type(orig_type) << ", size)" << endl
- << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tMap" << endl;
+ << " return thrift.PrependError(\"error reading map begin: \", err)" << endl << indent()
+ << "}" << endl << indent() << "tMap := make(" << type_to_go_type(orig_type) << ", size)"
+ << endl << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tMap" << endl;
} else if (ttype->is_set()) {
t_set* t = (t_set*)ttype;
out << indent() << "_, size, err := iprot.ReadSetBegin()" << endl << indent()
<< "if err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error reading set begin: \", err)" << endl << indent() << "}"
- << endl << indent() << "tSet := make(map["
+ << " return thrift.PrependError(\"error reading set begin: \", err)" << endl << indent()
+ << "}" << endl << indent() << "tSet := make(map["
<< type_to_go_key_type(t->get_elem_type()->get_true_type()) << "]bool, size)" << endl
<< indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSet" << endl;
} else if (ttype->is_list()) {
out << indent() << "_, size, err := iprot.ReadListBegin()" << endl << indent()
<< "if err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error reading list begin: \", err)" << endl << indent() << "}"
- << endl << indent() << "tSlice := make(" << type_to_go_type(orig_type) << ", 0, size)"
- << endl << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSlice"
- << endl;
+ << " return thrift.PrependError(\"error reading list begin: \", err)" << endl << indent()
+ << "}" << endl << indent() << "tSlice := make(" << type_to_go_type(orig_type)
+ << ", 0, size)" << endl << indent() << prefix << eq << " " << (pointer_field ? "&" : "")
+ << "tSlice" << endl;
} else {
throw "INVALID TYPE IN generate_deserialize_container '" + ttype->get_name() + "' for prefix '"
+ prefix + "'";
@@ -2558,16 +2563,16 @@
// Read container end
if (ttype->is_map()) {
out << indent() << "if err := iprot.ReadMapEnd(); err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error reading map end: \", err)" << endl << indent() << "}"
- << endl;
+ << " return thrift.PrependError(\"error reading map end: \", err)" << endl << indent()
+ << "}" << endl;
} else if (ttype->is_set()) {
out << indent() << "if err := iprot.ReadSetEnd(); err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error reading set end: \", err)" << endl << indent() << "}"
- << endl;
+ << " return thrift.PrependError(\"error reading set end: \", err)" << endl << indent()
+ << "}" << endl;
} else if (ttype->is_list()) {
out << indent() << "if err := iprot.ReadListEnd(); err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error reading list end: \", err)" << endl << indent() << "}"
- << endl;
+ << " return thrift.PrependError(\"error reading list end: \", err)" << endl << indent()
+ << "}" << endl;
}
}
@@ -2715,8 +2720,8 @@
void t_go_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
out << indent() << "if err := " << prefix << ".Write(oprot); err != nil {" << endl << indent()
- << " return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", " << prefix << "), err)" << endl
- << indent() << "}" << endl;
+ << " return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", " << prefix
+ << "), err)" << endl << indent() << "}" << endl;
}
void t_go_generator::generate_serialize_container(ofstream& out,
@@ -2731,20 +2736,20 @@
<< type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
<< "len(" << prefix << ")); err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error writing map begin: \", err)" << endl << indent() << "}"
- << endl;
+ << " return thrift.PrependError(\"error writing map begin: \", err)" << endl << indent()
+ << "}" << endl;
} else if (ttype->is_set()) {
out << indent() << "if err := oprot.WriteSetBegin("
<< type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
<< "len(" << prefix << ")); err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error writing set begin: \", err)" << endl << indent() << "}"
- << endl;
+ << " return thrift.PrependError(\"error writing set begin: \", err)" << endl << indent()
+ << "}" << endl;
} else if (ttype->is_list()) {
out << indent() << "if err := oprot.WriteListBegin("
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", "
<< "len(" << prefix << ")); err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error writing list begin: \", err)" << endl << indent() << "}"
- << endl;
+ << " return thrift.PrependError(\"error writing list begin: \", err)" << endl << indent()
+ << "}" << endl;
} else {
throw "compiler error: Invalid type in generate_serialize_container '" + ttype->get_name()
+ "' for prefix '" + prefix + "'";
@@ -2776,16 +2781,16 @@
if (ttype->is_map()) {
out << indent() << "if err := oprot.WriteMapEnd(); err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error writing map end: \", err)" << endl << indent() << "}"
- << endl;
+ << " return thrift.PrependError(\"error writing map end: \", err)" << endl << indent()
+ << "}" << endl;
} else if (ttype->is_set()) {
out << indent() << "if err := oprot.WriteSetEnd(); err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error writing set end: \", err)" << endl << indent() << "}"
- << endl;
+ << " return thrift.PrependError(\"error writing set end: \", err)" << endl << indent()
+ << "}" << endl;
} else if (ttype->is_list()) {
out << indent() << "if err := oprot.WriteListEnd(); err != nil {" << endl << indent()
- << " return thrift.PrependError(\"error writing list end: \", err)" << endl << indent() << "}"
- << endl;
+ << " return thrift.PrependError(\"error writing list end: \", err)" << endl << indent()
+ << "}" << endl;
}
}
diff --git a/compiler/cpp/src/generate/t_haxe_generator.cc b/compiler/cpp/src/generate/t_haxe_generator.cc
index 26dd83b..520377a 100644
--- a/compiler/cpp/src/generate/t_haxe_generator.cc
+++ b/compiler/cpp/src/generate/t_haxe_generator.cc
@@ -60,7 +60,7 @@
iter = parsed_options.find("buildmacro");
buildmacro_ = (iter != parsed_options.end()) ? (iter->second) : "";
-
+
out_dir_base_ = "gen-haxe";
}
@@ -705,7 +705,7 @@
string clsname = get_cap_name(tstruct->get_name());
generate_rtti_decoration(out);
- generate_macro_decoration(out);
+ generate_macro_decoration(out);
indent(out) << "class " << clsname << " ";
if (is_exception) {
@@ -1582,7 +1582,8 @@
}
generate_haxe_doc(f_service_, tservice);
- //generate_rtti_decoration(f_service_); - not yet, because of https://github.com/HaxeFoundation/haxe/issues/3626
+ // generate_rtti_decoration(f_service_); - not yet, because of
+ // https://github.com/HaxeFoundation/haxe/issues/3626
generate_macro_decoration(f_service_);
f_service_ << indent() << "interface " << get_cap_name(service_name_) << extends_iface << " {"
<< endl << endl;
@@ -2861,8 +2862,8 @@
void t_haxe_generator::generate_macro_decoration(ofstream& out) {
if (!buildmacro_.empty()) {
out << "#if ! macro" << endl;
- out << "@:build( " << buildmacro_ << ")" << endl; // current class/interface
- out << "@:autoBuild( " << buildmacro_ << ")" << endl; // inherited classes/interfaces
+ out << "@:build( " << buildmacro_ << ")" << endl; // current class/interface
+ out << "@:autoBuild( " << buildmacro_ << ")" << endl; // inherited classes/interfaces
out << "#end" << endl;
}
}
@@ -2922,7 +2923,7 @@
THRIFT_REGISTER_GENERATOR(
haxe,
"Haxe",
- " callbacks Use onError()/onSuccess() callbacks for service methods (like AS3)\n" \
- " rtti Enable @:rtti for generated classes and interfaces\n" \
- " buildmacro=my.macros.Class.method(args)\n" \
+ " callbacks Use onError()/onSuccess() callbacks for service methods (like AS3)\n"
+ " rtti Enable @:rtti for generated classes and interfaces\n"
+ " buildmacro=my.macros.Class.method(args)\n"
" Add @:build macro calls to generated classes and interfaces\n")
diff --git a/compiler/cpp/src/generate/t_json_generator.cc b/compiler/cpp/src/generate/t_json_generator.cc
index 777a8b7..3fa5b13 100644
--- a/compiler/cpp/src/generate/t_json_generator.cc
+++ b/compiler/cpp/src/generate/t_json_generator.cc
@@ -58,7 +58,6 @@
std::map<std::string, std::string>::const_iterator iter;
iter = parsed_options.find("merge");
should_merge_includes_ = (iter != parsed_options.end());
-
}
virtual ~t_json_generator() {}
@@ -73,8 +72,8 @@
void generate_typedef(t_typedef* ttypedef);
void generate_enum(t_enum* tenum);
void generate_program();
- void generate_function(t_function * tfunc);
- void generate_field(t_field * field);
+ void generate_function(t_function* tfunc);
+ void generate_field(t_field* field);
void generate_service(t_service* tservice);
void generate_struct(t_struct* tstruct);
@@ -88,7 +87,7 @@
string get_type_name(t_type* ttype);
string get_qualified_name(t_type* ttype);
- void start_object(bool should_indent=true);
+ void start_object(bool should_indent = true);
void start_array();
void end_object();
void end_array();
@@ -107,7 +106,7 @@
void write_integer(long value);
void write_double(double value);
void write_value(t_type* tvalue);
- void write_const_value(t_const_value* value, bool force_string=false);
+ void write_const_value(t_const_value* value, bool force_string = false);
void write_key_and(string key);
void write_key_and_string(string key, string val);
void write_key_and_integer(string key, int val);
@@ -120,7 +119,7 @@
string f_json_name = get_out_dir() + program_->get_name() + ".json";
f_json_.open(f_json_name.c_str());
- //Merge all included programs into this one so we can output one big file.
+ // Merge all included programs into this one so we can output one big file.
if (should_merge_includes_) {
merge_includes(program_);
}
@@ -259,7 +258,6 @@
write_key_and_string("elemTypeId", get_type_name(etype));
write_type_spec_object("elemType", etype);
}
-
}
void t_json_generator::close_generator() {
@@ -324,8 +322,8 @@
// Generate namespaces
write_key_and("namespaces");
start_object(NO_INDENT);
- const map<string,string>& namespaces = program_->get_namespaces();
- map<string,string>::const_iterator ns_it;
+ const map<string, string>& namespaces = program_->get_namespaces();
+ map<string, string>::const_iterator ns_it;
for (ns_it = namespaces.begin(); ns_it != namespaces.end(); ++ns_it) {
write_key_and_string(ns_it->first, ns_it->second);
indicate_comma_needed();
@@ -426,7 +424,6 @@
end_object();
}
-
void t_json_generator::write_string(const string& value) {
f_json_ << quot << escape_json_string(value) << quot;
}
@@ -443,59 +440,59 @@
switch (value->get_type()) {
- case t_const_value::CV_IDENTIFIER:
- case t_const_value::CV_INTEGER:
- if (should_force_string) {
- write_string(std::to_string(value->get_integer()));
- } else {
- write_integer(value->get_integer());
- }
- break;
-
- case t_const_value::CV_DOUBLE:
- if (should_force_string) {
- write_string(std::to_string(value->get_double()));
- } else {
- write_double(value->get_double());
- }
- break;
-
- case t_const_value::CV_STRING:
- write_string(value->get_string());
- break;
-
- case t_const_value::CV_LIST: {
- start_array();
- std::vector<t_const_value*> list = value->get_list();
- std::vector<t_const_value*>::iterator lit;
- for (lit = list.begin(); lit != list.end(); ++lit) {
- write_comma_if_needed();
- write_const_value(*lit);
- indicate_comma_needed();
- }
- end_array();
- break;
+ case t_const_value::CV_IDENTIFIER:
+ case t_const_value::CV_INTEGER:
+ if (should_force_string) {
+ write_string(std::to_string(value->get_integer()));
+ } else {
+ write_integer(value->get_integer());
}
+ break;
- case t_const_value::CV_MAP: {
- start_object(NO_INDENT);
- std::map<t_const_value*, t_const_value*> map = value->get_map();
- std::map<t_const_value*, t_const_value*>::iterator mit;
- for (mit = map.begin(); mit != map.end(); ++mit) {
- write_comma_if_needed();
- // JSON objects only allow string keys
- write_const_value(mit->first, FORCE_STRING);
- f_json_ << ": ";
- write_const_value(mit->second);
- indicate_comma_needed();
- }
- end_object();
- break;
+ case t_const_value::CV_DOUBLE:
+ if (should_force_string) {
+ write_string(std::to_string(value->get_double()));
+ } else {
+ write_double(value->get_double());
}
+ break;
- default:
- f_json_ << "null";
- break;
+ case t_const_value::CV_STRING:
+ write_string(value->get_string());
+ break;
+
+ case t_const_value::CV_LIST: {
+ start_array();
+ std::vector<t_const_value*> list = value->get_list();
+ std::vector<t_const_value*>::iterator lit;
+ for (lit = list.begin(); lit != list.end(); ++lit) {
+ write_comma_if_needed();
+ write_const_value(*lit);
+ indicate_comma_needed();
+ }
+ end_array();
+ break;
+ }
+
+ case t_const_value::CV_MAP: {
+ start_object(NO_INDENT);
+ std::map<t_const_value*, t_const_value*> map = value->get_map();
+ std::map<t_const_value*, t_const_value*>::iterator mit;
+ for (mit = map.begin(); mit != map.end(); ++mit) {
+ write_comma_if_needed();
+ // JSON objects only allow string keys
+ write_const_value(mit->first, FORCE_STRING);
+ f_json_ << ": ";
+ write_const_value(mit->second);
+ indicate_comma_needed();
+ }
+ end_object();
+ break;
+ }
+
+ default:
+ f_json_ << "null";
+ break;
}
}
@@ -643,7 +640,7 @@
end_object();
}
-void t_json_generator::generate_field(t_field * field) {
+void t_json_generator::generate_field(t_field* field) {
start_object();
write_key_and_integer("key", field->get_key());
@@ -657,15 +654,15 @@
write_key_and("required");
switch (field->get_req()) {
- case t_field::T_REQUIRED:
- write_string("required");
- break;
- case t_field::T_OPT_IN_REQ_OUT:
- write_string("req_out");
- break;
- default:
- write_string("optional");
- break;
+ case t_field::T_REQUIRED:
+ write_string("required");
+ break;
+ case t_field::T_OPT_IN_REQ_OUT:
+ write_string("req_out");
+ break;
+ default:
+ write_string("optional");
+ break;
}
if (field->get_value()) {
@@ -709,7 +706,6 @@
return ttype->get_program()->get_name() + "." + ttype->get_name();
}
-
-THRIFT_REGISTER_GENERATOR(json, "JSON",
-" merge: Generate output with included files merged\n"
-)
+THRIFT_REGISTER_GENERATOR(json,
+ "JSON",
+ " merge: Generate output with included files merged\n")
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 0c3de38..2b2d948 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -93,14 +93,14 @@
const std::string& get_include_prefix() const { return include_prefix_; }
// Accessors for program elements
- const std::vector<t_typedef*>& get_typedefs() const { return typedefs_; }
- const std::vector<t_enum*>& get_enums() const { return enums_; }
- const std::vector<t_const*>& get_consts() const { return consts_; }
- const std::vector<t_struct*>& get_structs() const { return structs_; }
- const std::vector<t_struct*>& get_xceptions() const { return xceptions_; }
- const std::vector<t_struct*>& get_objects() const { return objects_; }
- const std::vector<t_service*>& get_services() const { return services_; }
- const std::map<std::string,std::string>& get_namespaces() const { return namespaces_; }
+ const std::vector<t_typedef*>& get_typedefs() const { return typedefs_; }
+ const std::vector<t_enum*>& get_enums() const { return enums_; }
+ const std::vector<t_const*>& get_consts() const { return consts_; }
+ const std::vector<t_struct*>& get_structs() const { return structs_; }
+ const std::vector<t_struct*>& get_xceptions() const { return xceptions_; }
+ const std::vector<t_struct*>& get_objects() const { return objects_; }
+ const std::vector<t_service*>& get_services() const { return services_; }
+ const std::map<std::string, std::string>& get_namespaces() const { return namespaces_; }
// Program elements
void add_typedef(t_typedef* td) { typedefs_.push_back(td); }