You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by hc...@apache.org on 2014/11/18 10:02:57 UTC

[29/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_erl_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_erl_generator.cc b/compiler/cpp/src/generate/t_erl_generator.cc
index 0735ad1..8c8a2c7 100644
--- a/compiler/cpp/src/generate/t_erl_generator.cc
+++ b/compiler/cpp/src/generate/t_erl_generator.cc
@@ -38,22 +38,20 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const std::string endl = "\n";  // avoid ostream << std::endl flushes
+static const std::string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Erlang code generator.
  *
  */
 class t_erl_generator : public t_generator {
- public:
-  t_erl_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+public:
+  t_erl_generator(t_program* program,
+                  const std::map<std::string, std::string>& parsed_options,
+                  const std::string& option_string)
+    : t_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-erl";
 
     legacy_names_ = (parsed_options.find("legacynames") != parsed_options.end());
@@ -70,21 +68,21 @@ class t_erl_generator : public t_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef  (t_typedef*  ttypedef);
-  void generate_enum     (t_enum*     tenum);
-  void generate_const    (t_const*    tconst);
-  void generate_struct   (t_struct*   tstruct);
-  void generate_xception (t_struct*   txception);
-  void generate_service  (t_service*  tservice);
-  void generate_member_type(std::ostream & out, t_type* type);
-  void generate_member_value(std::ostream & out, t_type* type, t_const_value* value);
-
-  std::string render_member_type(t_field * field);
-  std::string render_member_value(t_field * field);
-  std::string render_member_requiredness(t_field * field);
-
-//  std::string render_default_value(t_type* type);
-  std::string render_default_value(t_field * field);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+  void generate_member_type(std::ostream& out, t_type* type);
+  void generate_member_value(std::ostream& out, t_type* type, t_const_value* value);
+
+  std::string render_member_type(t_field* field);
+  std::string render_member_value(t_field* field);
+  std::string render_member_requiredness(t_field* field);
+
+  //  std::string render_default_value(t_type* type);
+  std::string render_default_value(t_field* field);
   std::string render_const_value(t_type* type, t_const_value* value);
   std::string render_type_term(t_type* ttype, bool expand_structs, bool extended_info = false);
 
@@ -94,7 +92,7 @@ class t_erl_generator : public t_generator {
 
   void generate_erl_struct(t_struct* tstruct, bool is_exception);
   void generate_erl_struct_definition(std::ostream& out, t_struct* tstruct);
-  void generate_erl_struct_member(std::ostream& out, t_field * tmember);
+  void generate_erl_struct_member(std::ostream& out, t_field* tmember);
   void generate_erl_struct_info(std::ostream& out, t_struct* tstruct);
   void generate_erl_extended_struct_info(std::ostream& out, t_struct* tstruct);
   void generate_erl_function_helpers(t_function* tfunction);
@@ -103,9 +101,9 @@ class t_erl_generator : public t_generator {
    * Service-level generation functions
    */
 
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_function_info     (t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_function_info(t_service* tservice, t_function* tfunction);
 
   /**
    * Helper rendering functions
@@ -116,14 +114,14 @@ class t_erl_generator : public t_generator {
   std::string render_includes();
   std::string type_name(t_type* ttype);
 
-  std::string function_signature(t_function* tfunction, std::string prefix="");
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
 
   std::string argument_list(t_struct* tstruct);
   std::string type_to_enum(t_type* ttype);
   std::string type_module(t_type* ttype);
 
   std::string make_safe_for_module_name(std::string in) {
-    if(legacy_names_) {
+    if (legacy_names_) {
       return decapitalize(in);
     } else {
       return underscore(in);
@@ -131,7 +129,7 @@ class t_erl_generator : public t_generator {
   }
 
   std::string atomify(std::string in) {
-    if(legacy_names_) {
+    if (legacy_names_) {
       return "'" + decapitalize(in) + "'";
     } else {
       return "'" + in + "'";
@@ -139,7 +137,7 @@ class t_erl_generator : public t_generator {
   }
 
   std::string constify(std::string in) {
-    if(legacy_names_) {
+    if (legacy_names_) {
       return capitalize(in);
     } else {
       return uppercase(in);
@@ -148,9 +146,8 @@ class t_erl_generator : public t_generator {
 
   static std::string comment(string in);
 
- private:
-
-  bool has_default_value(t_field *);
+private:
+  bool has_default_value(t_field*);
 
   /* if true retain pre 0.9.2 naming scheme for functions, atoms and consts */
   bool legacy_names_;
@@ -159,10 +156,10 @@ class t_erl_generator : public t_generator {
    * add function to export list
    */
 
-  void export_function(t_function* tfunction, std::string prefix="");
+  void export_function(t_function* tfunction, std::string prefix = "");
   void export_string(std::string name, int num);
 
-  void export_types_function(t_function* tfunction, std::string prefix="");
+  void export_types_function(t_function* tfunction, std::string prefix = "");
   void export_types_string(std::string name, int num);
 
   /**
@@ -196,10 +193,8 @@ class t_erl_generator : public t_generator {
   std::ostringstream f_service_;
   std::ofstream f_service_file_;
   std::ofstream f_service_hrl_;
-
 };
 
-
 /**
  * UI for file generation by opening up the necessary file output
  * streams.
@@ -223,38 +218,34 @@ void t_erl_generator::init_generator() {
 
   hrl_header(f_types_hrl_file_, make_safe_for_module_name(program_name_) + "_types");
 
-  f_types_file_ <<
-    erl_autogen_comment() << endl <<
-    "-module(" << make_safe_for_module_name(program_name_) << "_types)." << endl <<
-    erl_imports() << endl;
+  f_types_file_ << erl_autogen_comment() << endl << "-module("
+                << make_safe_for_module_name(program_name_) << "_types)." << endl << erl_imports()
+                << endl;
 
-  f_types_file_ <<
-    "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")." << endl <<
-    endl;
+  f_types_file_ << "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")."
+                << endl << endl;
 
   f_types_hrl_file_ << render_includes() << endl;
 
   // consts file
-  string f_consts_name = get_out_dir() + make_safe_for_module_name(program_name_) + "_constants.hrl";
+  string f_consts_name = get_out_dir() + make_safe_for_module_name(program_name_)
+                         + "_constants.hrl";
   f_consts_.open(f_consts_name.c_str());
 
-  f_consts_ <<
-    erl_autogen_comment() << endl <<
-    erl_imports() << endl <<
-    "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")." << endl <<
-    endl;
+  f_consts_ << erl_autogen_comment() << endl << erl_imports() << endl << "-include(\""
+            << make_safe_for_module_name(program_name_) << "_types.hrl\")." << endl << endl;
 }
 
 /**
  * Boilerplate at beginning and end of header files
  */
 void t_erl_generator::hrl_header(ostream& out, string name) {
-  out << "-ifndef(_" << name << "_included)." << endl <<
-    "-define(_" << name << "_included, yeah)." << endl;
+  out << "-ifndef(_" << name << "_included)." << endl << "-define(_" << name << "_included, yeah)."
+      << endl;
 }
 
 void t_erl_generator::hrl_footer(ostream& out, string name) {
-  (void) name;
+  (void)name;
   out << "-endif." << endl;
 }
 
@@ -265,7 +256,8 @@ string t_erl_generator::render_includes() {
   const vector<t_program*>& includes = program_->get_includes();
   string result = "";
   for (size_t i = 0; i < includes.size(); ++i) {
-    result += "-include(\"" + make_safe_for_module_name(includes[i]->get_name()) + "_types.hrl\").\n";
+    result += "-include(\"" + make_safe_for_module_name(includes[i]->get_name())
+              + "_types.hrl\").\n";
   }
   if (includes.size() > 0) {
     result += "\n";
@@ -277,24 +269,19 @@ string t_erl_generator::render_includes() {
  * Autogen'd comment
  */
 string t_erl_generator::erl_autogen_comment() {
-  return
-    std::string("%%\n") +
-    "%% Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
-    "%%\n" +
-    "%% DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-    "%%\n";
+  return std::string("%%\n") + "%% Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+         + "%%\n" + "%% DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n"
+         + "%%\n";
 }
 
 /**
  * Comment out text
  */
 
-string t_erl_generator::comment(string in)
-{
+string t_erl_generator::comment(string in) {
   size_t pos = 0;
   in.insert(pos, "%% ");
-  while ( (pos = in.find_first_of('\n', pos)) != string::npos )
-  {
+  while ((pos = in.find_first_of('\n', pos)) != string::npos) {
     in.insert(++pos, "%% ");
   }
   return in;
@@ -335,7 +322,7 @@ void t_erl_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_erl_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -351,13 +338,9 @@ void t_erl_generator::generate_enum(t_enum* tenum) {
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
     string name = (*c_iter)->get_name();
-    indent(f_types_hrl_file_) <<
-      "-define(" <<
-      constify(make_safe_for_module_name(program_name_)) <<
-      "_" << constify(tenum->get_name()) <<
-      "_" << constify(name) <<
-      ", " << value << ")." <<
-    endl;
+    indent(f_types_hrl_file_) << "-define(" << constify(make_safe_for_module_name(program_name_))
+                              << "_" << constify(tenum->get_name()) << "_" << constify(name) << ", "
+                              << value << ")." << endl;
   }
 
   f_types_hrl_file_ << endl;
@@ -371,12 +354,8 @@ void t_erl_generator::generate_const(t_const* tconst) {
   string name = tconst->get_name();
   t_const_value* value = tconst->get_value();
 
-  f_consts_ <<
-    "-define(" << constify(make_safe_for_module_name(program_name_)) <<
-    "_" << constify(name) <<
-    ", " << render_const_value(type, value) <<
-    ")." << endl <<
-  endl;
+  f_consts_ << "-define(" << constify(make_safe_for_module_name(program_name_)) << "_"
+            << constify(name) << ", " << render_const_value(type, value) << ")." << endl << endl;
 }
 
 /**
@@ -454,10 +433,9 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
     out << "dict:from_list([";
     map<t_const_value*, t_const_value*>::const_iterator i, end = value->get_map().end();
     for (i = value->get_map().begin(); i != end;) {
-      out << "{"
-          << render_const_value(ktype, i->first)  << ","
+      out << "{" << render_const_value(ktype, i->first) << ","
           << render_const_value(vtype, i->second) << "}";
-      if ( ++i != end ) {
+      if (++i != end) {
         out << ",";
       }
     }
@@ -466,9 +444,9 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
     t_type* etype = ((t_set*)type)->get_elem_type();
     out << "sets:from_list([";
     vector<t_const_value*>::const_iterator i, end = value->get_list().end();
-    for( i = value->get_list().begin(); i != end; ) {
-      out << render_const_value(etype, *i) ;
-      if ( ++i != end ) {
+    for (i = value->get_list().begin(); i != end;) {
+      out << render_const_value(etype, *i);
+      if (++i != end) {
         out << ",";
       }
     }
@@ -483,7 +461,7 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
     vector<t_const_value*>::const_iterator v_iter;
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
       if (first) {
-        first=false;
+        first = false;
       } else {
         out << ",";
       }
@@ -496,9 +474,8 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
   return out.str();
 }
 
-
 string t_erl_generator::render_default_value(t_field* field) {
-  t_type *type = field->get_type();
+  t_type* type = field->get_type();
   if (type->is_struct() || type->is_xception()) {
     return "#" + atomify(type->get_name()) + "{}";
   } else if (type->is_map()) {
@@ -512,8 +489,8 @@ string t_erl_generator::render_default_value(t_field* field) {
   }
 }
 
-string t_erl_generator::render_member_type(t_field * field) {
-  t_type * type = get_true_type(field->get_type());
+string t_erl_generator::render_member_type(t_field* field) {
+  t_type* type = get_true_type(field->get_type());
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
@@ -546,12 +523,15 @@ string t_erl_generator::render_member_type(t_field * field) {
   }
 }
 
-string t_erl_generator::render_member_requiredness(t_field * field) {
-    switch(field->get_req()) {
-        case t_field::T_REQUIRED:       return "required";
-        case t_field::T_OPTIONAL:       return "optional";
-        default:                        return "undefined";
-    }
+string t_erl_generator::render_member_requiredness(t_field* field) {
+  switch (field->get_req()) {
+  case t_field::T_REQUIRED:
+    return "required";
+  case t_field::T_OPTIONAL:
+    return "optional";
+  default:
+    return "undefined";
+  }
 }
 
 /**
@@ -575,7 +555,7 @@ void t_erl_generator::generate_xception(t_struct* txception) {
  * Generates a struct
  */
 void t_erl_generator::generate_erl_struct(t_struct* tstruct, bool is_exception) {
-  (void) is_exception;
+  (void)is_exception;
   generate_erl_struct_definition(f_types_hrl_file_, tstruct);
   generate_erl_struct_info(f_info_, tstruct);
   generate_erl_extended_struct_info(f_info_ext_, tstruct);
@@ -586,8 +566,7 @@ void t_erl_generator::generate_erl_struct(t_struct* tstruct, bool is_exception)
  *
  * @param tstruct The struct definition
  */
-void t_erl_generator::generate_erl_struct_definition(ostream& out, t_struct* tstruct)
-{
+void t_erl_generator::generate_erl_struct_definition(ostream& out, t_struct* tstruct) {
   indent(out) << "%% struct " << type_name(tstruct) << endl << endl;
 
   std::stringstream buf;
@@ -597,36 +576,33 @@ void t_erl_generator::generate_erl_struct_definition(ostream& out, t_struct* tst
   const vector<t_field*>& members = tstruct->get_members();
   for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end();) {
     generate_erl_struct_member(buf, *m_iter);
-    if ( ++m_iter != members.end() ) {
+    if (++m_iter != members.end()) {
       buf << "," << endl << field_indent;
     }
   }
   buf << "}).";
 
   out << buf.str() << endl;
-  out <<
-    "-type " + type_name(tstruct) << "() :: #" + type_name(tstruct) + "{}."
-      << endl << endl;
+  out << "-type " + type_name(tstruct) << "() :: #" + type_name(tstruct) + "{}." << endl << endl;
 }
 
 /**
  * Generates the record field definition
  */
 
-void t_erl_generator::generate_erl_struct_member(ostream & out, t_field * tmember)
-{
+void t_erl_generator::generate_erl_struct_member(ostream& out, t_field* tmember) {
   out << atomify(tmember->get_name());
   if (has_default_value(tmember))
-    out << " = "  << render_member_value(tmember);
+    out << " = " << render_member_value(tmember);
   out << " :: " << render_member_type(tmember);
 }
 
-bool t_erl_generator::has_default_value(t_field * field) {
-  t_type *type = field->get_type();
+bool t_erl_generator::has_default_value(t_field* field) {
+  t_type* type = field->get_type();
   if (!field->get_value()) {
-    if ( field->get_req() == t_field::T_REQUIRED) {
-      if (type->is_struct() || type->is_xception() || type->is_map() ||
-          type->is_set() || type->is_list()) {
+    if (field->get_req() == t_field::T_REQUIRED) {
+      if (type->is_struct() || type->is_xception() || type->is_map() || type->is_set()
+          || type->is_list()) {
         return true;
       } else {
         return false;
@@ -639,7 +615,7 @@ bool t_erl_generator::has_default_value(t_field * field) {
   }
 }
 
-string t_erl_generator::render_member_value(t_field * field) {
+string t_erl_generator::render_member_value(t_field* field) {
   if (!field->get_value()) {
     return render_default_value(field);
   } else {
@@ -647,8 +623,6 @@ string t_erl_generator::render_member_value(t_field * field) {
   }
 }
 
-
-
 /**
  * Generates the read method for a struct
  */
@@ -689,13 +663,13 @@ void t_erl_generator::generate_service(t_service* tservice) {
   hrl_header(f_service_hrl_, service_name_);
 
   if (tservice->get_extends() != NULL) {
-    f_service_hrl_ << "-include(\"" <<
-      make_safe_for_module_name(tservice->get_extends()->get_name()) << "_thrift.hrl\"). % inherit " << endl;
+    f_service_hrl_ << "-include(\""
+                   << make_safe_for_module_name(tservice->get_extends()->get_name())
+                   << "_thrift.hrl\"). % inherit " << endl;
   }
 
-  f_service_hrl_ <<
-    "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")." << endl <<
-    endl;
+  f_service_hrl_ << "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")."
+                 << endl << endl;
 
   // Generate the three main parts of the service (well, two for now in PHP)
   generate_service_helpers(tservice); // cpiro: New Erlang Order
@@ -704,13 +678,11 @@ void t_erl_generator::generate_service(t_service* tservice) {
 
   // indent_down();
 
-  f_service_file_ <<
-    erl_autogen_comment() << endl <<
-    "-module(" << service_name_ << "_thrift)." << endl <<
-    "-behaviour(thrift_service)." << endl << endl <<
-    erl_imports() << endl;
+  f_service_file_ << erl_autogen_comment() << endl << "-module(" << service_name_ << "_thrift)."
+                  << endl << "-behaviour(thrift_service)." << endl << endl << erl_imports() << endl;
 
-  f_service_file_ << "-include(\"" << make_safe_for_module_name(tservice->get_name()) << "_thrift.hrl\")." << endl << endl;
+  f_service_file_ << "-include(\"" << make_safe_for_module_name(tservice->get_name())
+                  << "_thrift.hrl\")." << endl << endl;
 
   f_service_file_ << "-export([" << export_lines_.str() << "])." << endl << endl;
 
@@ -740,7 +712,7 @@ void t_erl_generator::generate_service_helpers(t_service* tservice) {
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     generate_erl_function_helpers(*f_iter);
   }
-  f_service_    << "struct_info(_) -> erlang:error(function_clause)." << endl;
+  f_service_ << "struct_info(_) -> erlang:error(function_clause)." << endl;
 }
 
 /**
@@ -749,7 +721,7 @@ void t_erl_generator::generate_service_helpers(t_service* tservice) {
  * @param tfunction The function
  */
 void t_erl_generator::generate_erl_function_helpers(t_function* tfunction) {
-  (void) tfunction;
+  (void)tfunction;
 }
 
 /**
@@ -765,23 +737,21 @@ void t_erl_generator::generate_service_interface(t_service* tservice) {
   vector<t_function*>::iterator f_iter;
   f_service_ << "%%% interface" << endl;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      indent() << "% " << function_signature(*f_iter) << endl;
+    f_service_ << indent() << "% " << function_signature(*f_iter) << endl;
 
     generate_function_info(tservice, *f_iter);
   }
 
   // Inheritance - pass unknown functions to base class
   if (tservice->get_extends() != NULL) {
-      indent(f_service_) << "function_info(Function, InfoType) ->" << endl;
-      indent_up();
-      indent(f_service_) << make_safe_for_module_name(tservice->get_extends()->get_name())
-                         << "_thrift:function_info(Function, InfoType)." << endl;
-      indent_down();
+    indent(f_service_) << "function_info(Function, InfoType) ->" << endl;
+    indent_up();
+    indent(f_service_) << make_safe_for_module_name(tservice->get_extends()->get_name())
+                       << "_thrift:function_info(Function, InfoType)." << endl;
+    indent_down();
   } else {
-      // return function_clause error for non-existent functions
-      indent(f_service_) << "function_info(_Func, _Info) -> erlang:error(function_clause)."
-                         << endl;
+    // return function_clause error for non-existent functions
+    indent(f_service_) << "function_info(_Func, _Info) -> erlang:error(function_clause)." << endl;
   }
 
   indent(f_service_) << endl;
@@ -791,17 +761,15 @@ void t_erl_generator::generate_service_interface(t_service* tservice) {
  * Generates a function_info(FunctionName, params_type) and
  * function_info(FunctionName, reply_type)
  */
-void t_erl_generator::generate_function_info(t_service* tservice,
-                                                t_function* tfunction) {
-  (void) tservice;
+void t_erl_generator::generate_function_info(t_service* tservice, t_function* tfunction) {
+  (void)tservice;
   string name_atom = atomify(tfunction->get_name());
 
   t_struct* xs = tfunction->get_xceptions();
   t_struct* arg_struct = tfunction->get_arglist();
 
   // function_info(Function, params_type):
-  indent(f_service_) <<
-    "function_info(" << name_atom << ", params_type) ->" << endl;
+  indent(f_service_) << "function_info(" << name_atom << ", params_type) ->" << endl;
   indent_up();
 
   indent(f_service_) << render_type_term(arg_struct, true) << ";" << endl;
@@ -809,22 +777,20 @@ void t_erl_generator::generate_function_info(t_service* tservice,
   indent_down();
 
   // function_info(Function, reply_type):
-  indent(f_service_) <<
-    "function_info(" << name_atom << ", reply_type) ->" << endl;
+  indent(f_service_) << "function_info(" << name_atom << ", reply_type) ->" << endl;
   indent_up();
 
   if (!tfunction->get_returntype()->is_void())
-    indent(f_service_) <<
-        render_type_term(tfunction->get_returntype(), false) << ";" << endl;
+    indent(f_service_) << render_type_term(tfunction->get_returntype(), false) << ";" << endl;
   else if (tfunction->is_oneway())
     indent(f_service_) << "oneway_void;" << endl;
   else
-    indent(f_service_) << "{struct, []}" << ";" << endl;
+    indent(f_service_) << "{struct, []}"
+                       << ";" << endl;
   indent_down();
 
   // function_info(Function, exceptions):
-  indent(f_service_) <<
-    "function_info(" << name_atom << ", exceptions) ->" << endl;
+  indent(f_service_) << "function_info(" << name_atom << ", exceptions) ->" << endl;
   indent_up();
   indent(f_service_) << render_type_term(xs, true) << ";" << endl;
   indent_down();
@@ -836,11 +802,9 @@ void t_erl_generator::generate_function_info(t_service* tservice,
  * @param tfunction Function definition
  * @return String of rendered function definition
  */
-string t_erl_generator::function_signature(t_function* tfunction,
-                                           string prefix) {
-  return
-    prefix + tfunction->get_name() +
-    "(This" +  capitalize(argument_list(tfunction->get_arglist())) + ")";
+string t_erl_generator::function_signature(t_function* tfunction, string prefix) {
+  return prefix + tfunction->get_name() + "(This"
+         + capitalize(argument_list(tfunction->get_arglist())) + ")";
 }
 
 /**
@@ -855,13 +819,11 @@ void t_erl_generator::export_string(string name, int num) {
   export_lines_ << name << "/" << num;
 }
 
-void t_erl_generator::export_types_function(t_function* tfunction,
-                                               string prefix) {
+void t_erl_generator::export_types_function(t_function* tfunction, string prefix) {
 
   export_types_string(prefix + tfunction->get_name(),
                       1 // This
-                      + ((tfunction->get_arglist())->get_members()).size()
-                      );
+                      + ((tfunction->get_arglist())->get_members()).size());
 }
 
 void t_erl_generator::export_types_string(string name, int num) {
@@ -873,16 +835,13 @@ void t_erl_generator::export_types_string(string name, int num) {
   export_types_lines_ << name << "/" << num;
 }
 
-void t_erl_generator::export_function(t_function* tfunction,
-                                      string prefix) {
+void t_erl_generator::export_function(t_function* tfunction, string prefix) {
 
   export_string(prefix + tfunction->get_name(),
                 1 // This
-                + ((tfunction->get_arglist())->get_members()).size()
-                );
+                + ((tfunction->get_arglist())->get_members()).size());
 }
 
-
 /**
  * Renders a field list
  */
@@ -956,12 +915,13 @@ string t_erl_generator::type_to_enum(t_type* type) {
   throw "INVALID TYPE IN type_to_enum: " + type->get_name();
 }
 
-
 /**
  * Generate an Erlang term which represents a thrift type
  */
-std::string t_erl_generator::render_type_term(t_type* type, bool expand_structs, bool extended_info) {
-    type = get_true_type(type);
+std::string t_erl_generator::render_type_term(t_type* type,
+                                              bool expand_structs,
+                                              bool extended_info) {
+  type = get_true_type(type);
 
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
@@ -994,30 +954,24 @@ std::string t_erl_generator::render_type_term(t_type* type, bool expand_structs,
 
       t_struct::members_type const& fields = static_cast<t_struct*>(type)->get_members();
       t_struct::members_type::const_iterator i, end = fields.end();
-      for( i = fields.begin(); i != end; )
-      {
+      for (i = fields.begin(); i != end;) {
         t_struct::members_type::value_type member = *i;
-        int32_t key  = member->get_key();
-        string  type = render_type_term(member->get_type(), false, false); // recursive call
+        int32_t key = member->get_key();
+        string type = render_type_term(member->get_type(), false, false); // recursive call
 
-        if ( !extended_info ) {
+        if (!extended_info) {
           // Convert to format: {struct, [{Fid, Type}|...]}
-          buf << "{" << key << ", "  << type << "}";
+          buf << "{" << key << ", " << type << "}";
         } else {
           // Convert to format: {struct, [{Fid, Req, Type, Name, Def}|...]}
-          string  name         = member->get_name();
-          string  value        = render_member_value(member);
-          string  requiredness = render_member_requiredness(member);
-          buf <<
-            "{" << key <<
-            ", "  << requiredness <<
-            ", "  << type <<
-            ", " << atomify(name) <<
-            ", "  << value <<
-          "}";
+          string name = member->get_name();
+          string value = render_member_value(member);
+          string requiredness = render_member_requiredness(member);
+          buf << "{" << key << ", " << requiredness << ", " << type << ", " << atomify(name) << ", "
+              << value << "}";
         }
 
-        if ( ++i != end ) {
+        if (++i != end) {
           buf << "," << endl << field_indent;
         }
       }
@@ -1029,19 +983,19 @@ std::string t_erl_generator::render_type_term(t_type* type, bool expand_structs,
     }
   } else if (type->is_map()) {
     // {map, KeyType, ValType}
-    t_type *key_type = ((t_map*)type)->get_key_type();
-    t_type *val_type = ((t_map*)type)->get_val_type();
+    t_type* key_type = ((t_map*)type)->get_key_type();
+    t_type* val_type = ((t_map*)type)->get_val_type();
 
-    return "{map, " + render_type_term(key_type, false) + ", " +
-      render_type_term(val_type, false) + "}";
+    return "{map, " + render_type_term(key_type, false) + ", " + render_type_term(val_type, false)
+           + "}";
 
   } else if (type->is_set()) {
-    t_type *elem_type = ((t_set*)type)->get_elem_type();
+    t_type* elem_type = ((t_set*)type)->get_elem_type();
 
     return "{set, " + render_type_term(elem_type, false) + "}";
 
   } else if (type->is_list()) {
-    t_type *elem_type = ((t_list*)type)->get_elem_type();
+    t_type* elem_type = ((t_list*)type)->get_elem_type();
 
     return "{list, " + render_type_term(elem_type, false) + "}";
   }
@@ -1053,7 +1007,7 @@ std::string t_erl_generator::type_module(t_type* ttype) {
   return make_safe_for_module_name(ttype->get_program()->get_name()) + "_types";
 }
 
-THRIFT_REGISTER_GENERATOR(erl, "Erlang",
-"    legacynames: Output files retain naming conventions of Thrift 0.9.1 and earlier.\n"
-)
-
+THRIFT_REGISTER_GENERATOR(
+    erl,
+    "Erlang",
+    "    legacynames: Output files retain naming conventions of Thrift 0.9.1 and earlier.\n")

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_generator.cc b/compiler/cpp/src/generate/t_generator.cc
index f04c65a..e7760d7 100644
--- a/compiler/cpp/src/generate/t_generator.cc
+++ b/compiler/cpp/src/generate/t_generator.cc
@@ -76,7 +76,7 @@ void t_generator::generate_program() {
   close_generator();
 }
 
-string t_generator::escape_string(const string &in) const {
+string t_generator::escape_string(const string& in) const {
   string result = "";
   for (string::const_iterator it = in.begin(); it < in.end(); it++) {
     std::map<char, std::string>::const_iterator res = escape_.find(*it);
@@ -101,23 +101,24 @@ void t_generator::generate_docstring_comment(ostream& out,
                                              const string& line_prefix,
                                              const string& contents,
                                              const string& comment_end) {
-  if (comment_start != "") indent(out) << comment_start;
+  if (comment_start != "")
+    indent(out) << comment_start;
   stringstream docs(contents, ios_base::in);
-  while ( ! (docs.eof() || docs.fail())) {
+  while (!(docs.eof() || docs.fail())) {
     char line[1024];
     docs.getline(line, 1024);
 
     // Just prnt a newline when the line & prefix are empty.
     if (strlen(line) == 0 && line_prefix == "" && !docs.eof()) {
-        out << std::endl;
-    } else if (strlen(line) > 0 || !docs.eof()) {  // skip the empty last line
+      out << std::endl;
+    } else if (strlen(line) > 0 || !docs.eof()) { // skip the empty last line
       indent(out) << line_prefix << line << std::endl;
     }
   }
-  if (comment_end != "") indent(out) << comment_end;
+  if (comment_end != "")
+    indent(out) << comment_end;
 }
 
-
 void t_generator_registry::register_generator(t_generator_factory* factory) {
   gen_map_t& the_map = get_generator_map();
   if (the_map.find(factory->get_short_name()) != the_map.end()) {
@@ -126,18 +127,17 @@ void t_generator_registry::register_generator(t_generator_factory* factory) {
   the_map[factory->get_short_name()] = factory;
 }
 
-t_generator* t_generator_registry::get_generator(t_program* program,
-                                                 const string& options) {
+t_generator* t_generator_registry::get_generator(t_program* program, const string& options) {
   string::size_type colon = options.find(':');
   string language = options.substr(0, colon);
 
   map<string, string> parsed_options;
   if (colon != string::npos) {
-    string::size_type pos = colon+1;
+    string::size_type pos = colon + 1;
     while (pos != string::npos && pos < options.size()) {
       string::size_type next_pos = options.find(',', pos);
-      string option = options.substr(pos, next_pos-pos);
-      pos = ((next_pos == string::npos) ? next_pos : next_pos+1);
+      string option = options.substr(pos, next_pos - pos);
+      pos = ((next_pos == string::npos) ? next_pos : next_pos + 1);
 
       string::size_type separator = option.find('=');
       string key, value;
@@ -146,7 +146,7 @@ t_generator* t_generator_registry::get_generator(t_program* program,
         value = "";
       } else {
         key = option.substr(0, separator);
-        value = option.substr(separator+1);
+        value = option.substr(separator + 1);
       }
 
       parsed_options[key] = value;
@@ -169,13 +169,9 @@ t_generator_registry::gen_map_t& t_generator_registry::get_generator_map() {
   return *the_map;
 }
 
-t_generator_factory::t_generator_factory(
-    const std::string& short_name,
-    const std::string& long_name,
-    const std::string& documentation)
-  : short_name_(short_name)
-  , long_name_(long_name)
-  , documentation_(documentation)
-{
+t_generator_factory::t_generator_factory(const std::string& short_name,
+                                         const std::string& long_name,
+                                         const std::string& documentation)
+  : short_name_(short_name), long_name_(long_name), documentation_(documentation) {
   t_generator_registry::register_generator(this);
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_generator.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_generator.h b/compiler/cpp/src/generate/t_generator.h
index 04d88d9..99d878a 100644
--- a/compiler/cpp/src/generate/t_generator.h
+++ b/compiler/cpp/src/generate/t_generator.h
@@ -35,7 +35,7 @@
  *
  */
 class t_generator {
- public:
+public:
   t_generator(t_program* program) {
     tmp_ = 0;
     indent_ = 0;
@@ -44,7 +44,7 @@ class t_generator {
     escape_['\n'] = "\\n";
     escape_['\r'] = "\\r";
     escape_['\t'] = "\\t";
-    escape_['"']  = "\\\"";
+    escape_['"'] = "\\\"";
     escape_['\\'] = "\\\\";
   }
 
@@ -74,21 +74,20 @@ class t_generator {
    * will be called for the above example.
    */
   static bool is_valid_namespace(const std::string& sub_namespace) {
-    (void) sub_namespace;
+    (void)sub_namespace;
     return false;
   }
 
   /**
    * Escape string to use one in generated sources.
    */
-  virtual std::string escape_string(const std::string &in) const;
+  virtual std::string escape_string(const std::string& in) const;
 
   std::string get_escaped_string(t_const_value* constval) {
     return escape_string(constval->get_string());
   }
 
- protected:
-
+protected:
   /**
    * Optional methods that may be imlemented by subclasses to take necessary
    * steps at the beginning or end of code generation.
@@ -103,15 +102,13 @@ class t_generator {
    * Pure virtual methods implemented by the generator subclasses.
    */
 
-  virtual void generate_typedef  (t_typedef*  ttypedef)  = 0;
-  virtual void generate_enum     (t_enum*     tenum)     = 0;
-  virtual void generate_const    (t_const*    tconst) {
-    (void) tconst;
-  }
-  virtual void generate_struct   (t_struct*   tstruct)   = 0;
-  virtual void generate_service  (t_service*  tservice)  = 0;
-  virtual void generate_forward_declaration (t_struct*) {}
-  virtual void generate_xception (t_struct*   txception) {
+  virtual void generate_typedef(t_typedef* ttypedef) = 0;
+  virtual void generate_enum(t_enum* tenum) = 0;
+  virtual void generate_const(t_const* tconst) { (void)tconst; }
+  virtual void generate_struct(t_struct* tstruct) = 0;
+  virtual void generate_service(t_service* tservice) = 0;
+  virtual void generate_forward_declaration(t_struct*) {}
+  virtual void generate_xception(t_struct* txception) {
     // By default exceptions are the same as structs
     generate_struct(txception);
   }
@@ -119,16 +116,12 @@ class t_generator {
   /**
    * Method to get the program name, may be overridden
    */
-  virtual std::string get_program_name(t_program* tprogram) {
-    return tprogram->get_name();
-  }
+  virtual std::string get_program_name(t_program* tprogram) { return tprogram->get_name(); }
 
   /**
    * Method to get the service name, may be overridden
    */
-  virtual std::string get_service_name(t_service* tservice) {
-    return tservice->get_name();
-  }
+  virtual std::string get_service_name(t_service* tservice) { return tservice->get_name(); }
 
   /**
    * Get the current output directory
@@ -155,13 +148,9 @@ class t_generator {
    * Indentation level modifiers
    */
 
-  void indent_up(){
-    ++indent_;
-  }
+  void indent_up() { ++indent_; }
 
-  void indent_down() {
-    --indent_;
-  }
+  void indent_down() { --indent_; }
 
   /**
    * Indentation print function
@@ -178,9 +167,7 @@ class t_generator {
   /**
    * Indentation utility wrapper
    */
-  std::ostream& indent(std::ostream &os) {
-    return os << indent();
-  }
+  std::ostream& indent(std::ostream& os) { return os << indent(); }
 
   /**
    * Capitalization helpers
@@ -239,7 +226,7 @@ class t_generator {
         continue;
       }
       if (underscore) {
-        out << (char) toupper(in[i]);
+        out << (char)toupper(in[i]);
         underscore = false;
         continue;
       }
@@ -249,15 +236,13 @@ class t_generator {
     return out.str();
   }
 
- public:
+public:
   /**
    * Get the true type behind a series of typedefs.
    */
-  static t_type* get_true_type(t_type* type) {
-    return type->get_true_type();
-  }
+  static t_type* get_true_type(t_type* type) { return type->get_true_type(); }
 
- protected:
+protected:
   /**
    * The program being generated
    */
@@ -285,7 +270,7 @@ class t_generator {
    */
   std::map<char, std::string> escape_;
 
- private:
+private:
   /**
    * Current code indentation level
    */

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_generator_registry.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_generator_registry.h b/compiler/cpp/src/generate/t_generator_registry.h
index 0010e94..a852385 100644
--- a/compiler/cpp/src/generate/t_generator_registry.h
+++ b/compiler/cpp/src/generate/t_generator_registry.h
@@ -30,7 +30,7 @@ class t_generator;
  *  - Providing documentation for the generators it produces.
  */
 class t_generator_factory {
- public:
+public:
   t_generator_factory(const std::string& short_name,
                       const std::string& long_name,
                       const std::string& documentation);
@@ -43,8 +43,7 @@ class t_generator_factory {
       // Note: parsed_options will not exist beyond the call to get_generator.
       const std::map<std::string, std::string>& parsed_options,
       // Note: option_string might not exist beyond the call to get_generator.
-      const std::string& option_string)
-    = 0;
+      const std::string& option_string) = 0;
 
   virtual bool is_valid_namespace(const std::string& sub_namespace) = 0;
 
@@ -52,7 +51,7 @@ class t_generator_factory {
   std::string get_long_name() { return long_name_; }
   std::string get_documentation() { return documentation_; }
 
- private:
+private:
   std::string short_name_;
   std::string long_name_;
   std::string documentation_;
@@ -60,17 +59,15 @@ class t_generator_factory {
 
 template <typename generator>
 class t_generator_factory_impl : public t_generator_factory {
- public:
+public:
   t_generator_factory_impl(const std::string& short_name,
                            const std::string& long_name,
                            const std::string& documentation)
-    : t_generator_factory(short_name, long_name, documentation)
-  {}
+    : t_generator_factory(short_name, long_name, documentation) {}
 
-  virtual t_generator* get_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string) {
+  virtual t_generator* get_generator(t_program* program,
+                                     const std::map<std::string, std::string>& parsed_options,
+                                     const std::string& option_string) {
     return new generator(program, parsed_options, option_string);
   }
 
@@ -80,30 +77,26 @@ class t_generator_factory_impl : public t_generator_factory {
 };
 
 class t_generator_registry {
- public:
+public:
   static void register_generator(t_generator_factory* factory);
 
-  static t_generator* get_generator(t_program* program,
-                                    const std::string& options);
+  static t_generator* get_generator(t_program* program, const std::string& options);
 
   typedef std::map<std::string, t_generator_factory*> gen_map_t;
   static gen_map_t& get_generator_map();
 
- private:
+private:
   t_generator_registry();
   t_generator_registry(const t_generator_registry&);
 };
 
-#define THRIFT_REGISTER_GENERATOR(language, long_name, doc)        \
-  class t_##language##_generator_factory_impl                      \
-    : public t_generator_factory_impl<t_##language##_generator>    \
-  {                                                                \
-   public:                                                         \
-    t_##language##_generator_factory_impl()                        \
-      : t_generator_factory_impl<t_##language##_generator>(        \
-          #language, long_name, doc)                               \
-    {}                                                             \
-  };                                                               \
+#define THRIFT_REGISTER_GENERATOR(language, long_name, doc)                                        \
+  class t_##language##_generator_factory_impl                                                      \
+      : public t_generator_factory_impl<t_##language##_generator> {                                \
+  public:                                                                                          \
+    t_##language##_generator_factory_impl()                                                        \
+      : t_generator_factory_impl<t_##language##_generator>(#language, long_name, doc) {}           \
+  };                                                                                               \
   static t_##language##_generator_factory_impl _registerer;
 
 #endif