You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2014/11/05 16:54:27 UTC
[2/2] git commit: compiler: remove trailing whitespaces
compiler: remove trailing whitespaces
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/4f4b15ba
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/4f4b15ba
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/4f4b15ba
Branch: refs/heads/master
Commit: 4f4b15ba2b89aa553f982cd36b1cd70fd82a156e
Parents: e81367b
Author: Roger Meier <ro...@apache.org>
Authored: Wed Nov 5 16:51:04 2014 +0100
Committer: Roger Meier <ro...@apache.org>
Committed: Wed Nov 5 16:53:41 2014 +0100
----------------------------------------------------------------------
compiler/cpp/src/generate/t_as3_generator.cc | 174 +++++++++---------
compiler/cpp/src/generate/t_c_glib_generator.cc | 92 +++++-----
compiler/cpp/src/generate/t_cocoa_generator.cc | 92 +++++-----
compiler/cpp/src/generate/t_csharp_generator.cc | 124 ++++++-------
compiler/cpp/src/generate/t_d_generator.cc | 2 +-
compiler/cpp/src/generate/t_delphi_generator.cc | 182 +++++++++----------
compiler/cpp/src/generate/t_go_generator.cc | 24 +--
compiler/cpp/src/generate/t_gv_generator.cc | 2 +-
compiler/cpp/src/generate/t_hs_generator.cc | 8 +-
compiler/cpp/src/generate/t_html_generator.cc | 74 ++++----
compiler/cpp/src/generate/t_java_generator.cc | 136 +++++++-------
compiler/cpp/src/generate/t_javame_generator.cc | 62 +++----
compiler/cpp/src/generate/t_js_generator.cc | 8 +-
compiler/cpp/src/generate/t_perl_generator.cc | 2 +-
compiler/cpp/src/generate/t_rb_generator.cc | 30 +--
compiler/cpp/src/main.cc | 20 +-
compiler/cpp/src/md5.h | 2 +-
compiler/cpp/src/parse/t_program.h | 6 +-
compiler/cpp/src/parse/t_scope.h | 1 -
compiler/cpp/src/parse/t_struct.h | 10 +-
compiler/cpp/src/parse/t_typedef.h | 2 +-
compiler/cpp/src/thrifty.yy | 32 ++--
22 files changed, 542 insertions(+), 543 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/4f4b15ba/compiler/cpp/src/generate/t_as3_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_as3_generator.cc b/compiler/cpp/src/generate/t_as3_generator.cc
index e84ab0d..aacc77d 100644
--- a/compiler/cpp/src/generate/t_as3_generator.cc
+++ b/compiler/cpp/src/generate/t_as3_generator.cc
@@ -53,10 +53,10 @@ class t_as3_generator : public t_oop_generator {
{
(void) option_string;
std::map<std::string, std::string>::const_iterator iter;
-
+
iter = parsed_options.find("bindable");
bindable_ = (iter != parsed_options.end());
-
+
out_dir_base_ = "gen-as3";
}
@@ -110,13 +110,13 @@ class t_as3_generator : public t_oop_generator {
std::string generate_isset_check(std::string field);
void generate_isset_set(ofstream& out, t_field* field);
//removed std::string isset_field_id(t_field* field);
-
+
void generate_service_interface (t_service* tservice);
void generate_service_helpers (t_service* tservice);
void generate_service_client (t_service* tservice);
void generate_service_server (t_service* tservice);
void generate_process_function (t_service* tservice, t_function* tfunction);
-
+
/**
* Serialization constructs
*/
@@ -183,8 +183,8 @@ class t_as3_generator : public t_oop_generator {
std::string as3_package();
std::string as3_type_imports();
std::string as3_thrift_imports();
- std::string as3_thrift_gen_imports(t_struct* tstruct, string& imports);
- std::string as3_thrift_gen_imports(t_service* tservice);
+ std::string as3_thrift_gen_imports(t_struct* tstruct, string& imports);
+ std::string as3_thrift_gen_imports(t_service* tservice);
std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false);
std::string base_type_name(t_base_type* tbase, bool in_container=false);
std::string declare_field(t_field* tfield, bool init=false);
@@ -214,8 +214,8 @@ class t_as3_generator : public t_oop_generator {
std::string package_name_;
std::ofstream f_service_;
std::string package_dir_;
-
- bool bindable_;
+
+ bool bindable_;
};
@@ -306,7 +306,7 @@ string t_as3_generator::as3_thrift_gen_imports(t_struct* tstruct, string& import
}
}
}
- return imports;
+ return imports;
}
@@ -332,11 +332,11 @@ string t_as3_generator::as3_thrift_gen_imports(t_service* tservice) {
}
}
- as3_thrift_gen_imports((*f_iter)->get_arglist(), imports);
- as3_thrift_gen_imports((*f_iter)->get_xceptions(), imports);
+ as3_thrift_gen_imports((*f_iter)->get_arglist(), imports);
+ as3_thrift_gen_imports((*f_iter)->get_xceptions(), imports);
}
-
+
return imports;
}
@@ -372,13 +372,13 @@ void t_as3_generator::generate_enum(t_enum* tenum) {
f_enum <<
autogen_comment() <<
as3_package() << endl;
-
+
scope_up(f_enum);
// Add as3 imports
f_enum << string() +
"import org.apache.thrift.Set;" << endl <<
"import flash.utils.Dictionary;" << endl;
-
+
indent(f_enum) <<
"public class " << tenum->get_name() << " ";
scope_up(f_enum);
@@ -391,10 +391,10 @@ void t_as3_generator::generate_enum(t_enum* tenum) {
"public static const " << (*c_iter)->get_name() <<
":int = " << value << ";" << endl;
}
-
+
// Create a static Set with all valid values for this enum
f_enum << endl;
-
+
indent(f_enum) << "public static const VALID_VALUES:Set = new Set(";
indent_up();
bool firstValue = true;
@@ -413,13 +413,13 @@ void t_as3_generator::generate_enum(t_enum* tenum) {
indent(f_enum) << "VALUES_TO_NAMES[" << (*c_iter)->get_name() << "] = \"" << (*c_iter)->get_name() << "\";" << endl;
}
f_enum << endl;
-
+
scope_down(f_enum);
scope_down(f_enum); // end class
-
+
scope_down(f_enum); // end package
-
+
f_enum.close();
}
@@ -438,14 +438,14 @@ void t_as3_generator::generate_consts(std::vector<t_const*> consts) {
// Print header
f_consts <<
autogen_comment() << as3_package();
-
+
scope_up(f_consts);
f_consts << endl;
-
+
f_consts << as3_type_imports();
-
-
+
+
indent(f_consts) <<
"public class " << program_name_ << "Constants {" << endl <<
endl;
@@ -467,7 +467,7 @@ void t_as3_generator::generate_consts(std::vector<t_const*> consts) {
void t_as3_generator::print_const_value(std::ofstream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval) {
type = get_true_type(type);
-
+
indent(out);
if (!defval) {
out <<
@@ -587,7 +587,7 @@ string t_as3_generator::render_const_value(ofstream& out, string name, t_type* t
(void) name;
type = get_true_type(type);
std::ostringstream render;
-
+
if (type->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
switch (tbase) {
@@ -626,7 +626,7 @@ string t_as3_generator::render_const_value(ofstream& out, string name, t_type* t
print_const_value(out, t, type, value, true);
render << t;
}
-
+
return render.str();
}
@@ -666,27 +666,27 @@ void t_as3_generator::generate_as3_struct(t_struct* tstruct,
f_struct <<
autogen_comment() <<
as3_package();
-
+
scope_up(f_struct);
f_struct << endl;
-
+
string imports;
f_struct <<
as3_type_imports() <<
- as3_thrift_imports() <<
+ as3_thrift_imports() <<
as3_thrift_gen_imports(tstruct, imports) << endl;
-
+
if (bindable_ && ! is_exception) {
f_struct << "import flash.events.Event;" << endl <<
"import flash.events.EventDispatcher;" << endl <<
"import mx.events.PropertyChangeEvent;" << endl;
}
-
+
generate_as3_struct_definition(f_struct,
tstruct,
is_exception);
-
+
scope_down(f_struct); // end of package
f_struct.close();
}
@@ -747,9 +747,9 @@ void t_as3_generator::generate_as3_struct_definition(ofstream &out,
indent(out) << "public static const " << upcase_string((*m_iter)->get_name()) << ":int = " << (*m_iter)->get_key() << ";" << endl;
}
-
+
out << endl;
-
+
// Inner Isset class
if (members.size() > 0) {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -759,11 +759,11 @@ void t_as3_generator::generate_as3_struct_definition(ofstream &out,
}
}
}
-
+
out << endl;
-
+
generate_as3_meta_data_map(out, tstruct);
-
+
// Static initializer to populate global class to struct metadata map
indent(out) << "{" << endl;
indent_up();
@@ -783,7 +783,7 @@ void t_as3_generator::generate_as3_struct_definition(ofstream &out,
}
indent_down();
indent(out) << "}" << endl << endl;
-
+
generate_as3_bean_boilerplate(out, tstruct, bindable);
generate_generic_field_getters_setters(out, tstruct);
generate_generic_isset_method(out, tstruct);
@@ -880,7 +880,7 @@ void t_as3_generator::generate_as3_struct_reader(ofstream& out,
out <<
indent() << "iprot.readStructEnd();" << endl << endl;
-
+
// in non-beans style, check for required fields of primitive type
// (which can be checked here but not in the general validate method)
out << endl << indent() << "// check for required fields of primitive type, which can't be checked in the validate method" << endl;
@@ -907,11 +907,11 @@ void t_as3_generator::generate_as3_struct_reader(ofstream& out,
void t_as3_generator::generate_as3_validator(ofstream& out,
t_struct* tstruct){
indent(out) << "public function validate():void {" << endl;
- indent_up();
-
+ indent_up();
+
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
-
+
out << indent() << "// check for required fields" << endl;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
@@ -924,7 +924,7 @@ void t_as3_generator::generate_as3_validator(ofstream& out,
}
}
}
-
+
// check that fields of type enum have valid values
out << indent() << "// check that fields of type enum have valid values" << endl;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -937,9 +937,9 @@ void t_as3_generator::generate_as3_validator(ofstream& out,
indent(out) << "throw new TProtocolError(TProtocolError.UNKNOWN, \"The field '" << field->get_name() << "' has been assigned the invalid value \" + " << field->get_name() << ");" << endl;
indent_down();
indent(out) << "}" << endl;
- }
- }
-
+ }
+ }
+
indent_down();
indent(out) << "}" << endl << endl;
}
@@ -1031,7 +1031,7 @@ void t_as3_generator::generate_as3_struct_result_writer(ofstream& out,
out << "(this." << generate_isset_check(*f_iter) << ") {" << endl;
indent_up();
-
+
indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
// Write field contents
@@ -1178,7 +1178,7 @@ void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
t_type* type = get_true_type(field->get_type());
std::string field_name = field->get_name();
std::string cap_name = get_cap_name(field_name);
-
+
// Simple getter
generate_as3_doc(out, field);
indent(out) << "public function get " << field_name << "():" <<
@@ -1187,7 +1187,7 @@ void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
indent(out) << "return this._" << field_name << ";" << endl;
indent_down();
indent(out) << "}" << endl << endl;
-
+
// Simple setter
generate_as3_doc(out, field);
std::string propName = tmp("thriftPropertyChange");
@@ -1200,21 +1200,21 @@ void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
indent(out) << "this._" << field_name << " = " << field_name << ";" <<
endl;
generate_isset_set(out, field);
-
+
if (bindable) {
// We have to use a custom event rather than the default, because if you use the default,
// the setter only gets called if the value has changed - this means calling foo.setIntValue(0)
// will not cause foo.isIntValueSet() to return true since the value of foo._intValue wasn't changed
// so the setter was never called.
indent(out) << "dispatchEvent(new Event(\"" << propName << "\"));" << endl;
-
+
// However, if you just use a custom event, then collections won't be able to detect when elements
// in the collections have changed since they listed for PropertyChangeEvents. So, we dispatch both.
indent(out) << "dispatchEvent(new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE));" << endl;
}
indent_down();
indent(out) << "}" << endl << endl;
-
+
// Unsetter
indent(out) << "public function unset" << cap_name << "():void {" << endl;
indent_up();
@@ -1225,7 +1225,7 @@ void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
}
indent_down();
indent(out) << "}" << endl << endl;
-
+
// isSet method
indent(out) << "// Returns true if field " << field_name << " is set (has been assigned a value) and false otherwise" << endl;
indent(out) << "public function is" << get_cap_name("set") << cap_name << "():Boolean {" << endl;
@@ -1278,7 +1278,7 @@ void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
indent(out) << "} else {" << endl;
indent_up();
}
-
+
if (field->get_type()->is_base_type() && ((t_base_type*)(field->get_type()))->is_binary()) {
indent(out) << " ret += \"BINARY\";" << endl;
} else if(field->get_type()->is_enum()) {
@@ -1294,7 +1294,7 @@ void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
} else {
indent(out) << "ret += this." << (*f_iter)->get_name() << ";" << endl;
}
-
+
if (can_be_null) {
indent_down();
indent(out) << "}" << endl;
@@ -1347,7 +1347,7 @@ void t_as3_generator::generate_as3_meta_data_map(ofstream& out,
out << "TFieldRequirementType.DEFAULT, ";
}
- // Create value meta data
+ // Create value meta data
generate_field_value_meta_data(out, field->get_type());
out << ");" << endl;
}
@@ -1355,7 +1355,7 @@ void t_as3_generator::generate_as3_meta_data_map(ofstream& out,
}
}
-/**
+/**
* Returns a string with the as3 representation of the given thrift type
* (e.g. for the type struct it returns "TType.STRUCT")
*/
@@ -1398,12 +1398,12 @@ void t_as3_generator::generate_field_value_meta_data(std::ofstream& out, t_type*
} else if (type->is_container()){
if (type->is_list()){
indent(out) << "new ListMetaData(TType.LIST, ";
- t_type* elem_type = ((t_list*)type)->get_elem_type();
- generate_field_value_meta_data(out, elem_type);
+ t_type* elem_type = ((t_list*)type)->get_elem_type();
+ generate_field_value_meta_data(out, elem_type);
} else if (type->is_set()){
indent(out) << "new SetMetaData(TType.SET, ";
- t_type* elem_type = ((t_list*)type)->get_elem_type();
- generate_field_value_meta_data(out, elem_type);
+ t_type* elem_type = ((t_list*)type)->get_elem_type();
+ generate_field_value_meta_data(out, elem_type);
} else{ // map
indent(out) << "new MapMetaData(TType.MAP, ";
t_type* key_type = ((t_map*)type)->get_key_type();
@@ -1436,9 +1436,9 @@ void t_as3_generator::generate_service(t_service* tservice) {
f_service_ <<
autogen_comment() << as3_package();
-
+
scope_up(f_service_);
-
+
f_service_ << endl <<
as3_type_imports() <<
as3_thrift_imports() <<
@@ -1458,16 +1458,16 @@ void t_as3_generator::generate_service(t_service* tservice) {
scope_down(f_service_);
f_service_.close();
-
+
// Now make the implementation/client file
f_service_name = package_dir_+"/"+service_name_+"Impl.as";
f_service_.open(f_service_name.c_str());
-
+
f_service_ <<
autogen_comment() << as3_package();
-
+
scope_up(f_service_);
-
+
f_service_ << endl <<
as3_type_imports() <<
as3_thrift_imports() <<
@@ -1486,46 +1486,46 @@ void t_as3_generator::generate_service(t_service* tservice) {
generate_service_client(tservice);
scope_down(f_service_);
-
+
f_service_ << as3_type_imports();
f_service_ << as3_thrift_imports();
f_service_ << as3_thrift_gen_imports(tservice);
if(!package_name_.empty()) {
f_service_ << "import " << package_name_ << ".*;" << endl;
}
-
+
generate_service_helpers(tservice);
-
+
f_service_.close();
-
+
// Now make the processor/server file
f_service_name = package_dir_+"/"+service_name_+"Processor.as";
f_service_.open(f_service_name.c_str());
-
+
f_service_ <<
autogen_comment() << as3_package();
-
+
scope_up(f_service_);
-
+
f_service_ << endl <<
as3_type_imports() <<
as3_thrift_imports() <<
as3_thrift_gen_imports(tservice) << endl;
-
+
generate_service_server(tservice);
scope_down(f_service_);
-
+
f_service_ << as3_type_imports();
f_service_ << as3_thrift_imports();
f_service_ << as3_thrift_gen_imports(tservice) <<endl;
if(!package_name_.empty()) {
f_service_ << "import " << package_name_ << ".*;" << endl;
}
-
+
generate_service_helpers(tservice);
-
+
f_service_.close();
-
+
}
/**
@@ -1670,7 +1670,7 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
// Get the struct of function call params
t_struct* arg_struct = (*f_iter)->get_arglist();
-
+
string argsname = (*f_iter)->get_name() + "_args";
vector<t_field*>::const_iterator fld_iter;
const vector<t_field*>& fields = arg_struct->get_members();
@@ -1690,7 +1690,7 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
f_service_ <<
indent() << "args.write(oprot_);" << endl <<
indent() << "oprot_.writeMessageEnd();" << endl;
-
+
if ((*f_iter)->is_oneway()) {
f_service_ << indent() << "oprot_.getTransport().flush();" << endl;
}
@@ -1742,7 +1742,7 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
indent() << "if (onSuccess != null) onSuccess();" << endl <<
indent() << "return;" << endl;
} else {
-
+
f_service_ <<
indent() << "if (onError != null) onError(new TApplicationError(TApplicationError.MISSING_RESULT, \"" << (*f_iter)->get_name() << " failed: unknown result\"));" << endl;
}
@@ -1750,8 +1750,8 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
f_service_ << indent() << "} catch (e:TError) {" << endl <<
indent() << " if (onError != null) onError(e);" << endl <<
indent() << "}" << endl;
-
-
+
+
indent_down();
indent(f_service_) <<
"});" << endl;
@@ -1948,7 +1948,7 @@ void t_as3_generator::generate_process_function(t_service* tservice,
first = false;
} else {
f_service_ << ", ";
- }
+ }
f_service_ << "args." << (*f_iter)->get_name();
}
f_service_ << ");" << endl;
@@ -2344,7 +2344,7 @@ void t_as3_generator::generate_serialize_container(ofstream& out,
indent(out) << "for (var " << iter << ":* in " << prefix << ") {" << endl;
indent(out) << " " << counter << +"++;" << endl;
indent(out) << "}" << endl;
-
+
indent(out) <<
"oprot.writeMapBegin(new TMap(" <<
type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
@@ -2567,7 +2567,7 @@ string t_as3_generator::function_signature(t_function* tfunction,
arguments += "onError:Function, onSuccess:Function";
}
- std::string result = "function " +
+ std::string result = "function " +
prefix + tfunction->get_name() + "(" + arguments + "):void";
return result;
}
http://git-wip-us.apache.org/repos/asf/thrift/blob/4f4b15ba/compiler/cpp/src/generate/t_c_glib_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index e143171..dbebedb 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -162,7 +162,7 @@ class t_c_glib_generator : public t_oop_generator {
void generate_deserialize_list_element(ofstream &out, t_list *tlist, string prefix, string index, int error_ret);
string generate_new_hash_from_type(t_type * key, t_type * value);
- string generate_new_array_from_type(t_type * ttype);
+ string generate_new_array_from_type(t_type * ttype);
string generate_free_func_from_type(t_type * ttype);
string generate_hash_func_from_type(t_type * ttype);
@@ -194,7 +194,7 @@ void t_c_glib_generator::init_generator() {
f_types_impl_ << autogen_comment();
/* include inclusion guard */
- f_types_ <<
+ f_types_ <<
"#ifndef " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl <<
"#define " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl <<
endl;
@@ -239,7 +239,7 @@ void t_c_glib_generator::init_generator() {
// include the types file
f_types_impl_ <<
endl <<
- "#include \"" << this->nspace_lc << program_name_u <<
+ "#include \"" << this->nspace_lc << program_name_u <<
"_types.h\"" << endl <<
"#include <thrift/c_glib/thrift.h>" << endl <<
endl;
@@ -252,7 +252,7 @@ void t_c_glib_generator::init_generator() {
* Finish up generation and close all file streams.
*/
void t_c_glib_generator::close_generator() {
- string program_name_uc = to_upper_case
+ string program_name_uc = to_upper_case
(initial_caps_to_underscores(program_name_));
/* end the header inclusion guard */
@@ -266,11 +266,11 @@ void t_c_glib_generator::close_generator() {
/**
* Generates a Thrift typedef in C code. For example:
- *
- * Thrift:
+ *
+ * Thrift:
* typedef map<i32,i32> SomeMap
- *
- * C:
+ *
+ * C:
* typedef GHashTable * ThriftSomeMap;
*/
void t_c_glib_generator::generate_typedef(t_typedef* ttypedef) {
@@ -278,7 +278,7 @@ void t_c_glib_generator::generate_typedef(t_typedef* ttypedef) {
indent() << "typedef " << type_name(ttypedef->get_type(), true) <<
" " << this->nspace << ttypedef->get_symbolic() << ";" << endl <<
endl;
-}
+}
/**
* Generates a C enumeration. For example:
@@ -846,7 +846,7 @@ string t_c_glib_generator::function_signature(t_function* tfunction) {
"gboolean " + this->nspace_lc + fname + " (" + this->nspace
+ service_name_ + "If * iface"
+ (has_return ? ", " + type_name(ttype) + "* _return" : "")
- + (has_args ? "" : (", " + argument_list (arglist)))
+ + (has_args ? "" : (", " + argument_list (arglist)))
+ (has_xceptions ? "" : (", " + xception_list (xlist)))
+ ", GError ** error)";
}
@@ -1112,7 +1112,7 @@ void t_c_glib_generator::generate_const_initializer(string name, t_type *type, t
" }" << endl <<
" return constant;" << endl <<
"}" << endl <<
- endl;
+ endl;
} else if (type->is_map()) {
t_type *ktype = ((t_map *) type)->get_key_type();
t_type *vtype = ((t_map *) type)->get_val_type();
@@ -1284,7 +1284,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
+ (has_args ? "" : (", " + argument_list (arglist)))
+ (has_xceptions ? "" : (", " + xception_list (xlist)))
+ ", GError **error)";
-
+
indent(f_header_) << "gboolean (*" << funname << ") " << params << ";" <<
endl;
}
@@ -1371,29 +1371,29 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
// Create all the GObject boilerplate
f_header_ <<
- "GType " << this->nspace_lc << service_name_lc <<
+ "GType " << this->nspace_lc << service_name_lc <<
"_client_get_type (void);" << endl <<
"#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT " <<
"(" << this->nspace_lc << service_name_lc << "_client_get_type())" <<
endl <<
"#define " << this->nspace_uc << service_name_uc << "_CLIENT(obj) " <<
- "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " <<
- this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
+ "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " <<
+ this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
this->nspace << service_name_ << "Client))" << endl <<
- "#define " << this->nspace_uc << service_name_uc << "_CLIENT_CLASS(c) " <<
- "(G_TYPE_CHECK_CLASS_CAST ((c), " <<
- this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
+ "#define " << this->nspace_uc << service_name_uc << "_CLIENT_CLASS(c) " <<
+ "(G_TYPE_CHECK_CLASS_CAST ((c), " <<
+ this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
this->nspace << service_name_ << "ClientClass))" << endl <<
"#define " << this->nspace_uc << service_name_uc << "_IS_CLIENT(obj) " <<
- "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " <<
- this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT))" << endl <<
+ "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " <<
+ this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT))" << endl <<
"#define " << this->nspace_uc << service_name_uc <<
- "_IS_CLIENT_CLASS(c) " << "(G_TYPE_CHECK_CLASS_TYPE ((c), " <<
+ "_IS_CLIENT_CLASS(c) " << "(G_TYPE_CHECK_CLASS_TYPE ((c), " <<
this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT))" << endl <<
"#define " << this->nspace_uc << service_name_uc <<
- "_CLIENT_GET_CLASS(obj) " << "(G_TYPE_INSTANCE_GET_CLASS ((obj), " <<
+ "_CLIENT_GET_CLASS(obj) " << "(G_TYPE_INSTANCE_GET_CLASS ((obj), " <<
this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
- this->nspace << service_name_ << "ClientClass))" << endl <<
+ this->nspace << service_name_ << "ClientClass))" << endl <<
endl;
/* write out the function prototypes */
@@ -1418,7 +1418,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
if (!(*f_iter)->is_oneway()) {
t_struct noargs (program_);
t_function recv_function ((*f_iter)->get_returntype(),
- service_name_lc + string ("_client_recv_")
+ service_name_lc + string ("_client_recv_")
+ funname,
&noargs,
(*f_iter)->get_xceptions());
@@ -1456,7 +1456,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
const vector<t_field *>& fields = arglist->get_members();
vector<t_field *>::const_iterator f_iter_field;
for (f_iter_field = fields.begin(); f_iter_field != fields.end(); ++f_iter_field) {
- params_without_type += (*f_iter_field)->get_name();
+ params_without_type += (*f_iter_field)->get_name();
params_without_type += ", ";
}
@@ -1471,7 +1471,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
"gboolean" << endl <<
this->nspace_lc << service_name_lc << "_if_" << funname << " " <<
params << endl <<
- "{" << endl <<
+ "{" << endl <<
" return " << this->nspace_uc << service_name_uc <<
"_IF_GET_INTERFACE (iface)->" << funname << " (" <<
params_without_type << "error);" << endl <<
@@ -1621,7 +1621,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
// Serialize the request
f_service_ <<
indent() << "gint32 cseqid = 0;" << endl <<
- indent() << "ThriftProtocol * protocol = " <<
+ indent() << "ThriftProtocol * protocol = " <<
this->nspace_uc << base_service_name_uc <<
"_CLIENT (iface)->output_protocol;" << endl <<
endl <<
@@ -1648,7 +1648,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
indent() <<
" return FALSE;" << endl <<
endl <<
- indent() <<
+ indent() <<
"return TRUE;" << endl;
scope_down(f_service_);
@@ -1670,11 +1670,11 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
indent() << "gint32 rseqid;" << endl <<
indent() << "gchar * fname = NULL;" << endl <<
indent() << "ThriftMessageType mtype;" << endl <<
- indent() << "ThriftProtocol * protocol = " <<
+ indent() << "ThriftProtocol * protocol = " <<
this->nspace_uc << base_service_name_uc <<
"_CLIENT (iface)->input_protocol;" << endl <<
endl <<
- indent() << "if (thrift_protocol_read_message_begin " <<
+ indent() << "if (thrift_protocol_read_message_begin " <<
"(protocol, &fname, &mtype, &rseqid, error) < 0)" <<
endl <<
indent() << "{" << endl <<
@@ -1696,7 +1696,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
indent() << " if (fname) g_free (fname);" << endl <<
indent() << " thrift_protocol_skip (protocol, T_STRUCT, NULL);" << endl <<
indent() << " thrift_protocol_read_message_end (protocol, NULL);" << endl <<
- indent() << " thrift_transport_read_end (protocol->transport, NULL);" << endl <<
+ indent() << " thrift_transport_read_end (protocol->transport, NULL);" << endl <<
indent() << " g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR, THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_MESSAGE_TYPE, \"invalid message type %d, expected T_REPLY\", mtype);" << endl <<
indent() << " return FALSE;" << endl <<
indent() << "} else if (strncmp (fname, \"" << name << "\", " << name.length() << ") != 0) {" << endl <<
@@ -1707,7 +1707,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
indent() << " if (fname) g_free (fname);" << endl <<
indent() << " return FALSE;" << endl <<
indent() << "}" << endl <<
- indent() << "if (fname) g_free (fname);" << endl <<
+ indent() << "if (fname) g_free (fname);" << endl <<
endl;
t_struct* xs = (*f_iter)->get_xceptions();
@@ -1715,7 +1715,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
vector<t_field*>::const_iterator x_iter;
{
- t_struct result(program_, tservice->get_name() + "_" +
+ t_struct result(program_, tservice->get_name() + "_" +
(*f_iter)->get_name() + "_result");
t_field success((*f_iter)->get_returntype(), "*_return", 0);
if (!(*f_iter)->get_returntype()->is_void()) {
@@ -1743,7 +1743,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
// copy over any throw exceptions and return failure
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); x_iter++) {
- f_service_ <<
+ f_service_ <<
indent() << "if (*" << (*x_iter)->get_name() << " != NULL)" << endl <<
indent() << "{" << endl <<
indent() << " g_set_error (error, " << this->nspace_uc <<
@@ -1753,7 +1753,7 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
this->nspace_uc <<
to_upper_case(initial_caps_to_underscores(
(*x_iter)->get_type()->get_name())) <<
- "_ERROR_CODE, \"" << (*x_iter)->get_type()->get_name() <<
+ "_ERROR_CODE, \"" << (*x_iter)->get_type()->get_name() <<
"\");" << endl <<
indent() << " return FALSE;" << endl <<
indent() << "}" << endl;
@@ -3061,7 +3061,7 @@ void t_c_glib_generator::generate_object(t_struct *tstruct) {
// close the structure definition and create a typedef
f_types_ <<
"};" << endl <<
- "typedef struct _" << this->nspace << name << " " <<
+ "typedef struct _" << this->nspace << name << " " <<
this->nspace << name << ";" << endl <<
endl;
@@ -3111,7 +3111,7 @@ void t_c_glib_generator::generate_object(t_struct *tstruct) {
}
// generate struct I/O methods
- string this_get = this->nspace + name + " * this_object = "
+ string this_get = this->nspace + name + " * this_object = "
+ this->nspace_uc + name_uc + "(object);";
generate_struct_reader (f_types_impl_, tstruct, "this_object->", this_get);
generate_struct_writer (f_types_impl_, tstruct, "this_object->", this_get);
@@ -3501,7 +3501,7 @@ void t_c_glib_generator::generate_object(t_struct *tstruct) {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type ((*m_iter)->get_type());
- if (t->is_container()) {
+ if (t->is_container()) {
string name = (*m_iter)->get_name();
if (t->is_map() || t->is_set()) {
f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << endl;
@@ -3524,7 +3524,7 @@ void t_c_glib_generator::generate_object(t_struct *tstruct) {
case t_base_type::TYPE_BOOL:
case t_base_type::TYPE_BYTE:
case t_base_type::TYPE_I16:
- case t_base_type::TYPE_I32:
+ case t_base_type::TYPE_I32:
case t_base_type::TYPE_I64:
case t_base_type::TYPE_DOUBLE:
destructor_function = "g_array_unref";
@@ -3584,7 +3584,7 @@ void t_c_glib_generator::generate_object(t_struct *tstruct) {
class_name_lc << "_class_init (" << class_name << "Class * cls)" << endl;
scope_up(f_types_impl_);
- f_types_impl_ <<
+ f_types_impl_ <<
indent() << "GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << endl <<
indent() << "ThriftStructClass *struct_class = " <<
"THRIFT_STRUCT_CLASS (cls);" << endl <<
@@ -3869,7 +3869,7 @@ void t_c_glib_generator::generate_struct_writer (ofstream &out,
if ((*f_iter)->get_req() == t_field::T_OPTIONAL) {
indent(out) << "if (this_object->__isset_" << (*f_iter)->get_name() << " == TRUE) {" << endl;
indent_up();
- }
+ }
out <<
indent() << "if ((ret = thrift_protocol_write_field_begin (protocol, " <<
@@ -4221,7 +4221,7 @@ void t_c_glib_generator::generate_serialize_container(ofstream &out,
tval_ptr = tval->is_string() || !tval->is_base_type() ? "" : "*";
out <<
- indent() << "g_hash_table_foreach ((GHashTable *) " << prefix <<
+ indent() << "g_hash_table_foreach ((GHashTable *) " << prefix <<
", thrift_hash_table_get_keys, &key_list);" << endl <<
indent() << tkey_name << tkey_ptr <<
" keys[g_list_length (key_list)];" << endl <<
@@ -4356,7 +4356,7 @@ void t_c_glib_generator::generate_serialize_list_element(ofstream &out,
+ index + ")";
if (ttype->is_base_type()) {
- t_base_type::t_base tbase = ((t_base_type *) ttype)->get_base();
+ t_base_type::t_base tbase = ((t_base_type *) ttype)->get_base();
switch (tbase) {
case t_base_type::TYPE_VOID:
throw "compiler error: cannot determine array type";
@@ -4585,7 +4585,7 @@ void t_c_glib_generator::generate_deserialize_container (ofstream &out, t_type *
generate_deserialize_map_element (out, (t_map *) ttype, prefix, error_ret);
scope_down(out);
out << endl;
-
+
// read map end
out <<
indent() << "/* read the map end marker */" << endl <<
@@ -4637,7 +4637,7 @@ void t_c_glib_generator::generate_deserialize_container (ofstream &out, t_type *
scope_down(out);
out <<
- indent() << "if ((ret = thrift_protocol_read_list_end (protocol, error)) < 0)" << endl <<
+ indent() << "if ((ret = thrift_protocol_read_list_end (protocol, error)) < 0)" << endl <<
indent() << " return " << error_ret << ";" << endl <<
indent() << "xfer += ret;" << endl <<
endl;
@@ -4980,7 +4980,7 @@ string initial_caps_to_underscores(string name) {
ret += tolower (tmp[pos]);
pos++;
for (unsigned int i = pos; i < name.length(); i++) {
- char lc = tolower (tmp[i]);
+ char lc = tolower (tmp[i]);
if (lc != tmp[i]) {
ret += '_';
}
http://git-wip-us.apache.org/repos/asf/thrift/blob/4f4b15ba/compiler/cpp/src/generate/t_cocoa_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_cocoa_generator.cc b/compiler/cpp/src/generate/t_cocoa_generator.cc
index f765f7d..cbed831 100644
--- a/compiler/cpp/src/generate/t_cocoa_generator.cc
+++ b/compiler/cpp/src/generate/t_cocoa_generator.cc
@@ -52,13 +52,13 @@ class t_cocoa_generator : public t_oop_generator {
{
(void) option_string;
std::map<std::string, std::string>::const_iterator iter;
-
+
iter = parsed_options.find("log_unexpected");
- log_unexpected_ = (iter != parsed_options.end());
-
+ log_unexpected_ = (iter != parsed_options.end());
+
iter = parsed_options.find("validate_required");
- validate_required_ = (iter != parsed_options.end());
-
+ validate_required_ = (iter != parsed_options.end());
+
out_dir_base_ = "gen-cocoa";
}
@@ -408,7 +408,7 @@ void t_cocoa_generator::generate_consts(std::vector<t_const*> consts) {
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
if ((*c_iter)->get_type()->is_container() ||
(*c_iter)->get_type()->is_struct()) {
- print_const_value(f_impl_,
+ print_const_value(f_impl_,
cocoa_prefix_+(*c_iter)->get_name(),
(*c_iter)->get_type(),
(*c_iter)->get_value(),
@@ -582,7 +582,7 @@ void t_cocoa_generator::generate_cocoa_struct_field_accessor_declarations(ofstre
*/
void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ofstream &out,
t_struct* tstruct,
- bool is_exception)
+ bool is_exception)
{
indent(out) << "- (id) initWithCoder: (NSCoder *) decoder" << endl;
scope_up(out);
@@ -601,45 +601,45 @@ void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ofstream &o
out << indent() << "if ([decoder containsValueForKey: @\""<< (*m_iter)->get_name() <<"\"])" << endl;
scope_up(out);
out << indent() << "__" << (*m_iter)->get_name() << " = ";
- if (type_can_be_null(t))
+ if (type_can_be_null(t))
{
out << "[[decoder decodeObjectForKey: @\"" << (*m_iter)->get_name() << "\"] retain_stub];" << endl;
}
- else if (t->is_enum())
+ else if (t->is_enum())
{
- out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+ out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
}
- else
+ else
{
t_base_type::t_base tbase = ((t_base_type *) t)->get_base();
switch (tbase)
{
case t_base_type::TYPE_BOOL:
- out << "[decoder decodeBoolForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+ out << "[decoder decodeBoolForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
break;
case t_base_type::TYPE_BYTE:
- out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+ out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
break;
case t_base_type::TYPE_I16:
- out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+ out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
break;
case t_base_type::TYPE_I32:
- out << "[decoder decodeInt32ForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+ out << "[decoder decodeInt32ForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
break;
case t_base_type::TYPE_I64:
- out << "[decoder decodeInt64ForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+ out << "[decoder decodeInt64ForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
break;
case t_base_type::TYPE_DOUBLE:
- out << "[decoder decodeDoubleForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+ out << "[decoder decodeDoubleForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
break;
- default:
+ default:
throw "compiler error: don't know how to decode thrift type: " + t_base_type::t_base_name(tbase);
}
}
out << indent() << "__" << (*m_iter)->get_name() << "_isset = YES;" << endl;
scope_down(out);
}
-
+
out << indent() << "return self;" << endl;
scope_down(out);
out << endl;
@@ -652,7 +652,7 @@ void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ofstream &o
*/
void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream &out,
t_struct* tstruct,
- bool is_exception)
+ bool is_exception)
{
indent(out) << "- (void) encodeWithCoder: (NSCoder *) encoder" << endl;
scope_up(out);
@@ -660,24 +660,24 @@ void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream
// NSExceptions conform to NSCoding, so we can call super
out << indent() << "[super encodeWithCoder: encoder];" << endl;
}
-
+
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
-
+
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
out << indent() << "if (__"<< (*m_iter)->get_name() <<"_isset)" << endl;
scope_up(out);
//out << indent() << "__" << (*m_iter)->get_name() << " = ";
- if (type_can_be_null(t))
+ if (type_can_be_null(t))
{
out << indent() << "[encoder encodeObject: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
}
- else if (t->is_enum())
+ else if (t->is_enum())
{
out << indent() << "[encoder encodeInt: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
}
- else
+ else
{
t_base_type::t_base tbase = ((t_base_type *) t)->get_base();
switch (tbase)
@@ -700,13 +700,13 @@ void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream
case t_base_type::TYPE_DOUBLE:
out << indent() << "[encoder encodeDouble: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
break;
- default:
+ default:
throw "compiler error: don't know how to encode thrift type: " + t_base_type::t_base_name(tbase);
}
}
scope_down(out);
}
-
+
scope_down(out);
out << endl;
}
@@ -786,11 +786,11 @@ void t_cocoa_generator::generate_cocoa_struct_implementation(ofstream &out,
scope_down(out);
out << endl;
}
-
+
// initWithCoder for NSCoding
generate_cocoa_struct_init_with_coder_method(out, tstruct, is_exception);
// encodeWithCoder for NSCoding
- generate_cocoa_struct_encode_with_coder_method(out, tstruct, is_exception);
+ generate_cocoa_struct_encode_with_coder_method(out, tstruct, is_exception);
// dealloc
if (!members.empty()) {
@@ -1077,7 +1077,7 @@ void t_cocoa_generator::generate_cocoa_struct_validator(ofstream& out,
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
-
+
out << indent() << "// check for required fields" << endl;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field* field = (*f_iter);
@@ -1228,7 +1228,7 @@ void t_cocoa_generator::generate_cocoa_service_helpers(t_service* tservice) {
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* ts = (*f_iter)->get_arglist();
generate_cocoa_struct_interface(f_impl_, ts, false);
- generate_cocoa_struct_implementation(f_impl_, ts, false, false);
+ generate_cocoa_struct_implementation(f_impl_, ts, false, false);
generate_function_helpers(*f_iter);
}
}
@@ -1274,7 +1274,7 @@ void t_cocoa_generator::generate_function_helpers(t_function* tfunction) {
// generate the result struct
generate_cocoa_struct_interface(f_impl_, &result, false);
- generate_cocoa_struct_implementation(f_impl_, &result, false, true);
+ generate_cocoa_struct_implementation(f_impl_, &result, false, true);
}
@@ -1334,12 +1334,12 @@ void t_cocoa_generator::generate_cocoa_service_client_interface(ofstream& out,
void t_cocoa_generator::generate_cocoa_service_server_interface(ofstream& out,
t_service* tservice) {
out << "@interface " << cocoa_prefix_ << tservice->get_name() << "Processor : NSObject <TProcessor> ";
-
+
scope_up(out);
out << indent() << "id <" << cocoa_prefix_ << tservice->get_name() <<"> mService;" << endl;
out << indent() << "NSDictionary * mMethodMap;" << endl;
scope_down(out);
-
+
out << "- (id) initWith" << tservice->get_name() << ": (id <" << cocoa_prefix_ << tservice->get_name() << ">) service;" << endl;
out << "- (id<"<<cocoa_prefix_ << tservice->get_name() << ">) service;" << endl;
@@ -1557,7 +1557,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
t_service* tservice) {
out << "@implementation " << cocoa_prefix_ << tservice->get_name() << "Processor" << endl;
indent_up();
-
+
// initializer
out << endl;
out << "- (id) initWith" << tservice->get_name() << ": (id <" << cocoa_prefix_ << tservice->get_name() << ">) service" << endl;
@@ -1568,7 +1568,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
out << indent() << "}" << endl;
out << indent() << "mService = [service retain_stub];" << endl;
out << indent() << "mMethodMap = [[NSMutableDictionary dictionary] retain_stub];" << endl;
-
+
// generate method map for routing incoming calls
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::const_iterator f_iter;
@@ -1585,7 +1585,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
}
out << indent() << "return self;" << endl;
scope_down(out);
-
+
// implementation of the 'service' method which returns the service associated with this
// processor
out << endl;
@@ -1593,7 +1593,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
out << indent() << "{" << endl;
out << indent() << " return [[mService retain_stub] autorelease_stub];" << endl;
out << indent() << "}" << endl;
-
+
// implementation of the TProcess method, which dispatches the incoming call using the method map
out << endl;
out << indent() << "- (BOOL) processOnInputProtocol: (id <TProtocol>) inProtocol" << endl;
@@ -1628,7 +1628,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
out << indent() << " [i invoke];" << endl;
out << indent() << " return YES;" << endl;
out << indent() << "}" << endl;
-
+
// generate a process_XXXX method for each service function, which reads args, calls the service, and writes results
functions = tservice->get_functions();
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1640,7 +1640,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
out << indent() << argstype << " * args = [[" << argstype << " alloc] init];" << endl;
out << indent() << "[args read: inProtocol];" << endl;
out << indent() << "[inProtocol readMessageEnd];" << endl;
-
+
// prepare the result if not oneway
if (!(*f_iter)->is_oneway()) {
string resulttype = cocoa_prefix_ + function_result_helper_struct_type(*f_iter);
@@ -1672,7 +1672,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
out << "]";
}
out << ";" << endl;
-
+
// write out the result if not oneway
if (!(*f_iter)->is_oneway()) {
out << indent() << "[outProtocol writeMessageBeginWithName: @\"" << funname << "\"" << endl;
@@ -1684,10 +1684,10 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
out << indent() << "[result release_stub];" << endl;
}
out << indent() << "[args release_stub];" << endl;
-
+
scope_down(out);
}
-
+
// dealloc
out << endl;
out << "- (void) dealloc" << endl;
@@ -2380,7 +2380,7 @@ string t_cocoa_generator::render_const_value(ofstream& out, t_type* type, t_cons
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
switch (tbase) {
case t_base_type::TYPE_STRING:
- // We must handle binary constant but the syntax of IDL defines
+ // We must handle binary constant but the syntax of IDL defines
// nothing about binary constant.
// if ((t_base_type*)type)->is_binary())
// // binary code
@@ -2469,7 +2469,7 @@ string t_cocoa_generator::render_const_value(string name,
render << "[[" << type_name(type, true) << " alloc] init";
bool first = true;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- // FIXME The generated code does not match with initWithXXX
+ // FIXME The generated code does not match with initWithXXX
// initializer and causes compile error.
// Try: test/DebugProtoTest.thrift and test/SmallTest.thrift
t_type* field_type = NULL;
@@ -2579,7 +2579,7 @@ string t_cocoa_generator::declare_property(t_field* tfield) {
if (type_can_be_null(tfield->get_type()))
render << "retain, ";
-
+
render << "getter=" << decapitalize(tfield->get_name()) <<
", setter=set" << capitalize(tfield->get_name()) + ":) " <<
type_name(tfield->get_type()) << " " << tfield->get_name() << ";";
http://git-wip-us.apache.org/repos/asf/thrift/blob/4f4b15ba/compiler/cpp/src/generate/t_csharp_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc
index 1d66cef..0b9ae2a 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -80,7 +80,7 @@ class t_csharp_generator : public t_oop_generator
if (serialize_) {
wcf_namespace_ = iter->second; // since there can be only one namespace
}
-
+
iter = parsed_options.find("wcf");
wcf_ = (iter != parsed_options.end());
if (wcf_) {
@@ -163,7 +163,7 @@ class t_csharp_generator : public t_oop_generator
std::string type_to_enum(t_type* ttype);
std::string prop_name(t_field* tfield, bool suppress_mapping = false);
std::string get_enum_class_name(t_type* type);
-
+
bool field_has_default(t_field* tfield) {
return tfield->get_value() != NULL;
}
@@ -232,7 +232,7 @@ void t_csharp_generator::init_generator() {
namespace_dir_ = subdir;
init_keywords();
member_mapping_scope = NULL;
-
+
pverbose("C# options:\n");
pverbose("- async ...... %s\n", (async_ ? "ON" : "off"));
pverbose("- async_ctp .. %s\n", (async_ctp_ ? "ON" : "off"));
@@ -258,7 +258,7 @@ std::string t_csharp_generator::normalize_name( std::string name) {
void t_csharp_generator::init_keywords() {
csharp_keywords.clear();
-
+
// C# keywords
csharp_keywords["abstract"] = 1;
csharp_keywords["as"]= 1;
@@ -652,13 +652,13 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
prepare_member_name_mapping( tstruct);
indent(out) << "#if !SILVERLIGHT" << endl;
- indent(out) << "[Serializable]" << endl;
+ indent(out) << "[Serializable]" << endl;
indent(out) << "#endif" << endl;
if ((serialize_||wcf_) &&!is_exception) {
indent(out) << "[DataContract(Namespace=\"" << wcf_namespace_ << "\")]" << endl; // do not make exception classes directly WCF serializable, we provide a seperate "fault" for that
}
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
-
+
indent(out) << "public " << (is_final ? "sealed " : "") << "partial class " << normalize_name(tstruct->get_name()) << " : ";
if (is_exception) {
@@ -730,7 +730,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
if (!is_required && (!nullable_ || has_default)) {
if(serialize_||wcf_) {
indent(out) << "[DataMember]" << endl;
- }
+ }
indent(out) << "public bool " << normalize_name((*m_iter)->get_name()) << ";" << endl;
}
}
@@ -740,7 +740,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
if(generate_isset && (serialize_||wcf_)) {
indent(out) << "#region XmlSerializer support" << endl << endl;
-
+
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
bool is_required = field_is_required((*m_iter));
bool has_default = field_has_default((*m_iter));
@@ -760,7 +760,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
indent(out) << "#endregion XmlSerializer support" << endl << endl;
}
}
-
+
// We always want a default, no argument constructor for Reading
indent(out) << "public " << normalize_name(tstruct->get_name()) << "() {" << endl;
indent_up();
@@ -782,7 +782,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
}
indent_down();
indent(out) << "}" << endl << endl;
-
+
if (has_required_fields) {
indent(out) << "public " << tstruct->get_name() << "(";
bool first = true;
@@ -808,7 +808,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
indent_down();
indent(out) << "}" << endl << endl;
}
-
+
generate_csharp_struct_reader(out, tstruct);
if (is_result) {
generate_csharp_struct_result_writer(out, tstruct);
@@ -917,7 +917,7 @@ void t_csharp_generator::generate_csharp_struct_reader(ofstream& out, t_struct*
if (is_required) {
indent(out) << "isset_" << (*f_iter)->get_name() << " = true;" << endl;
}
-
+
indent_down();
out <<
indent() << "} else { " << endl <<
@@ -1040,7 +1040,7 @@ void t_csharp_generator::generate_csharp_struct_result_writer(ofstream& out, t_s
} else {
out << " else if ";
}
-
+
if (nullable_) {
out << "(this." << prop_name((*f_iter)) << " != null) {" << endl;
} else {
@@ -1142,8 +1142,8 @@ void t_csharp_generator::generate_csharp_struct_tostring(ofstream& out, t_struct
indent(out) <<
"__sb.Append(\", " << prop_name((*f_iter)) << ": \");" << endl;
}
-
-
+
+
t_type* ttype = (*f_iter)->get_type();
if (ttype->is_xception() || ttype->is_struct()) {
indent(out) <<
@@ -1152,7 +1152,7 @@ void t_csharp_generator::generate_csharp_struct_tostring(ofstream& out, t_struct
indent(out) <<
"__sb.Append(" << prop_name((*f_iter)) << ");" << endl;
}
-
+
if (!is_required) {
indent_down();
indent(out) << "}" << endl;
@@ -1256,7 +1256,7 @@ void t_csharp_generator::generate_csharp_union_class(std::ofstream& out, t_struc
indent(out) << "field.Type = " << type_to_enum(tfield->get_type()) << ";" << endl;
indent(out) << "field.ID = " << tfield->get_key() << ";" << endl;
indent(out) << "oprot.WriteFieldBegin(field);" << endl;
-
+
generate_serialize_field(out, tfield, "_data", true, true);
indent(out) << "oprot.WriteFieldEnd();" << endl;
@@ -1273,16 +1273,16 @@ void t_csharp_generator::generate_csharp_union_class(std::ofstream& out, t_struc
void t_csharp_generator::generate_csharp_struct_equals(ofstream& out, t_struct* tstruct) {
indent(out) << "public override bool Equals(object that) {" << endl;
indent_up();
-
+
indent(out) << "var other = that as " << type_name(tstruct) << ";" << endl;
indent(out) << "if (other == null) return false;" << endl;
indent(out) << "if (ReferenceEquals(this, other)) return true;" << endl;
-
+
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
-
+
bool first = true;
-
+
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (first) {
first = false;
@@ -1293,8 +1293,8 @@ void t_csharp_generator::generate_csharp_struct_equals(ofstream& out, t_struct*
indent(out) << "&& ";
}
if (!field_is_required((*f_iter)) && !(nullable_ && !field_has_default((*f_iter)))) {
- out << "((__isset." << normalize_name((*f_iter)->get_name())
- << " == other.__isset." << normalize_name((*f_iter)->get_name())
+ out << "((__isset." << normalize_name((*f_iter)->get_name())
+ << " == other.__isset." << normalize_name((*f_iter)->get_name())
<< ") && ((!__isset." << normalize_name((*f_iter)->get_name()) << ") || (";
}
t_type* ttype = (*f_iter)->get_type();
@@ -1314,7 +1314,7 @@ void t_csharp_generator::generate_csharp_struct_equals(ofstream& out, t_struct*
out << ";" << endl;
indent_down();
}
-
+
indent_down();
indent(out) << "}" << endl << endl;
}
@@ -1322,14 +1322,14 @@ void t_csharp_generator::generate_csharp_struct_equals(ofstream& out, t_struct*
void t_csharp_generator::generate_csharp_struct_hashcode(ofstream& out, t_struct* tstruct) {
indent(out) << "public override int GetHashCode() {" << endl;
indent_up();
-
+
indent(out) << "int hashcode = 0;" << endl;
indent(out) << "unchecked {" << endl;
indent_up();
-
+
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
-
+
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_type* ttype = (*f_iter)->get_type();
indent(out) << "hashcode = (hashcode * 397) ^ ";
@@ -1351,11 +1351,11 @@ void t_csharp_generator::generate_csharp_struct_hashcode(ofstream& out, t_struct
}
out << ");" << endl;
}
-
+
indent_down();
indent(out) << "}" << endl;
indent(out) << "return hashcode;" << endl;
-
+
indent_down();
indent(out) << "}" << endl << endl;
}
@@ -1432,7 +1432,7 @@ void t_csharp_generator::generate_service_interface(t_service* tservice) {
indent(f_service_) <<
function_signature_async_begin(*f_iter, "Begin_") << ";" << endl;
indent(f_service_) <<
- function_signature_async_end(*f_iter, "End_") << ";" << endl;
+ function_signature_async_end(*f_iter, "End_") << ";" << endl;
if(async_||async_ctp_) {
indent(f_service_) <<
function_signature_async(*f_iter) << ";" << endl;
@@ -1511,7 +1511,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
indent(f_service_) << "get { return oprot_; }" << endl;
scope_down(f_service_);
f_service_ << endl << endl;
-
+
indent(f_service_) << "#region \" IDisposable Support \"" << endl;
indent(f_service_) << "private bool _IsDisposed;" << endl << endl;
indent(f_service_) << "// IDisposable" << endl;
@@ -1548,7 +1548,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
string funname = (*f_iter)->get_name();
indent(f_service_) << endl;
-
+
if (!async_) {
indent(f_service_) << "#if SILVERLIGHT" << endl;
}
@@ -1560,7 +1560,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
"return " << "send_" << funname << "(callback, state";
t_struct* arg_struct = (*f_iter)->get_arglist();
- prepare_member_name_mapping( arg_struct);
+ prepare_member_name_mapping( arg_struct);
const vector<t_field*>& fields = arg_struct->get_members();
vector<t_field*>::const_iterator fld_iter;
@@ -1571,7 +1571,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
f_service_ << ");" << endl;
scope_down(f_service_);
f_service_ << endl;
-
+
// End
indent(f_service_) <<
"public " << function_signature_async_end(*f_iter, "End_") << endl;
@@ -1595,7 +1595,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
indent(f_service_) <<
"public async " << function_signature_async(*f_iter, "") << endl;
scope_up(f_service_);
-
+
if (!(*f_iter)->get_returntype()->is_void()) {
indent(f_service_) <<
type_name( (*f_iter)->get_returntype()) << " retval;" << endl;
@@ -1615,7 +1615,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
f_service_ <<
"return ";
}
- f_service_ <<
+ f_service_ <<
funname << "(";
first = true;
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
@@ -1628,16 +1628,16 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
}
f_service_ << ");" << endl;
indent_down();
- indent(f_service_) <<
+ indent(f_service_) <<
"});" << endl;
if (!(*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) <<
+ indent(f_service_) <<
"return retval;" << endl;
}
scope_down(f_service_);
f_service_ << endl;
}
-
+
if (!async_) {
indent(f_service_) << "#endif" << endl << endl;
}
@@ -1731,7 +1731,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
f_service_ <<
indent() << "args.Write(oprot_);" << endl <<
indent() << "oprot_.WriteMessageEnd();" << endl;;
-
+
if (!async_) {
indent(f_service_) << "#if SILVERLIGHT" << endl;
}
@@ -1742,7 +1742,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
indent(f_service_) << "#endif" << endl;
}
- cleanup_member_name_mapping( arg_struct);
+ cleanup_member_name_mapping( arg_struct);
scope_down(f_service_);
f_service_ << endl;
@@ -1757,7 +1757,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
indent(f_service_) <<
"public " << function_signature(&recv_function) << endl;
scope_up(f_service_);
- prepare_member_name_mapping( (*f_iter)->get_xceptions());
+ prepare_member_name_mapping( (*f_iter)->get_xceptions());
f_service_ <<
indent() << "TMessage msg = iprot_.ReadMessageBegin();" << endl <<
@@ -1821,7 +1821,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
indent() << "throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, \"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
}
- cleanup_member_name_mapping( (*f_iter)->get_xceptions());
+ cleanup_member_name_mapping( (*f_iter)->get_xceptions());
scope_down(f_service_);
f_service_ << endl;
}
@@ -1998,7 +1998,7 @@ void t_csharp_generator::generate_process_function(t_service* tservice, t_functi
f_service_ <<
"iface_." << normalize_name(tfunction->get_name()) << "(";
bool first = true;
- prepare_member_name_mapping(arg_struct);
+ prepare_member_name_mapping(arg_struct);
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (first) {
first = false;
@@ -2010,13 +2010,13 @@ void t_csharp_generator::generate_process_function(t_service* tservice, t_functi
f_service_ << ".Value";
}
}
- cleanup_member_name_mapping(arg_struct);
+ cleanup_member_name_mapping(arg_struct);
f_service_ << ");" << endl;
if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
f_service_ << indent() << "}";
- prepare_member_name_mapping( xs);
+ prepare_member_name_mapping( xs);
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " " << (*x_iter)->get_name() << ") {" << endl;
if (!tfunction->is_oneway()) {
@@ -2029,7 +2029,7 @@ void t_csharp_generator::generate_process_function(t_service* tservice, t_functi
f_service_ << "}";
}
}
- cleanup_member_name_mapping( xs);
+ cleanup_member_name_mapping( xs);
f_service_ << endl;
}
@@ -2083,7 +2083,7 @@ void t_csharp_generator::generate_csharp_union_reader(std::ofstream& out, t_stru
indent(out) << type_name((*f_iter)->get_type()) << " temp;" << endl;
generate_deserialize_field(out, (*f_iter), "temp", true);
indent(out) << "retval = new " << (*f_iter)->get_name() << "(temp);" << endl;
-
+
indent_down();
out <<
indent() << "} else { " << endl <<
@@ -2308,7 +2308,7 @@ void t_csharp_generator::generate_deserialize_list_element(ofstream& out, t_list
}
string name = prefix + (is_propertyless ? "" : prop_name(tfield));
-
+
if (type->is_void()) {
throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " + name;
}
@@ -2320,7 +2320,7 @@ void t_csharp_generator::generate_deserialize_list_element(ofstream& out, t_list
} else if (type->is_base_type() || type->is_enum()) {
indent(out) <<
"oprot.";
-
+
string nullable_name = nullable_ && !is_element && !field_is_required(tfield)
? name + ".Value"
: name;
@@ -2518,7 +2518,7 @@ std::string t_csharp_generator::make_valid_csharp_identifier( std::string const
// 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')) {
@@ -2527,10 +2527,10 @@ std::string t_csharp_generator::make_valid_csharp_identifier( std::string const
// 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.at(i);
+ if( (('A' > c) || (c > 'Z')) &&
+ (('a' > c) || (c > 'z')) &&
+ (('0' > c) || (c > '9')) &&
('_' != c) ) {
str.replace( i, 1, "_");
}
@@ -2576,14 +2576,14 @@ void t_csharp_generator::prepare_member_name_mapping( void* scope, const vector<
member_mapping_scope = scope;
member_name_mapping.clear();
-
+
std::set<std::string> used_member_names;
vector<t_field*>::const_iterator iter;
-
- // current C# generator policy:
+
+ // current C# generator policy:
// - prop names are always rendered with an Uppercase first letter
// - struct names are used as given
-
+
for (iter = members.begin(); iter != members.end(); ++iter) {
string oldname = (*iter)->get_name();
string newname = prop_name(*iter, true);
@@ -2591,7 +2591,7 @@ void t_csharp_generator::prepare_member_name_mapping( void* scope, const vector<
// name conflicts with struct (CS0542 error)
if( structname.compare( newname) == 0) {
pverbose("struct %s: member %s conflicts with struct (preventing CS0542)\n", structname.c_str(), newname.c_str());
- newname += '_';
+ newname += '_';
}
// new name conflicts with another member
@@ -2601,7 +2601,7 @@ void t_csharp_generator::prepare_member_name_mapping( void* scope, const vector<
continue;
}
- // add always, this helps us to detect edge cases like
+ // add always, this helps us to detect edge cases like
// different spellings ("foo" and "Foo") within the same struct
pverbose("struct %s: member mapping %s => %s\n", structname.c_str(), oldname.c_str(), newname.c_str());
member_name_mapping[oldname] = newname;
@@ -2699,7 +2699,7 @@ string t_csharp_generator::declare_field(t_field* tfield, bool init, std::string
throw "NO T_VOID CONSTRUCT";
case t_base_type::TYPE_STRING:
result += " = null";
- break;
+ break;
case t_base_type::TYPE_BOOL:
result += " = false";
break;
http://git-wip-us.apache.org/repos/asf/thrift/blob/4f4b15ba/compiler/cpp/src/generate/t_d_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_d_generator.cc b/compiler/cpp/src/generate/t_d_generator.cc
index c23aa1f..622fb29 100644
--- a/compiler/cpp/src/generate/t_d_generator.cc
+++ b/compiler/cpp/src/generate/t_d_generator.cc
@@ -743,7 +743,7 @@ class t_d_generator : public t_oop_generator {
ss << "Compiler error: Invalid requirement level " << req;
throw ss.str();
}
-
+
}
}