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:48 UTC

[20/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_json_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_json_generator.cc b/compiler/cpp/src/generate/t_json_generator.cc
index 290ffaa..dee1de2 100644
--- a/compiler/cpp/src/generate/t_json_generator.cc
+++ b/compiler/cpp/src/generate/t_json_generator.cc
@@ -45,14 +45,12 @@ static const string quot = "\"";
 
 class t_json_generator : public t_generator {
 public:
-  t_json_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;
+  t_json_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-json";
   }
 
@@ -69,8 +67,8 @@ public:
   void generate_enum(t_enum* tenum);
   void generate_program();
   void generate_consts(vector<t_const*>);
-  void generate_function(t_function * tfunc);
-  void generate_field(t_field * field);
+  void generate_function(t_function* tfunc);
+  void generate_field(t_field* field);
 
   void generate_service(t_service* tservice);
   void generate_struct(t_struct* tstruct);
@@ -100,7 +98,7 @@ void t_json_generator::init_generator() {
   string f_json_name = get_out_dir() + program_->get_name() + ".json";
   f_json_.open(f_json_name.c_str());
 
-  //Merge all included programs into this one so we can output one big file.
+  // Merge all included programs into this one so we can output one big file.
   merge_includes(program_);
 }
 
@@ -108,60 +106,81 @@ string t_json_generator::escapeJsonString(const string& input) {
   std::ostringstream ss;
   for (std::string::const_iterator iter = input.begin(); iter != input.end(); iter++) {
     switch (*iter) {
-    case '\\': ss << "\\\\"; break;
-    case '"': ss << "\\\""; break;
-    case '/': ss << "\\/"; break;
-    case '\b': ss << "\\b"; break;
-    case '\f': ss << "\\f"; break;
-    case '\n': ss << "\\n"; break;
-    case '\r': ss << "\\r"; break;
-    case '\t': ss << "\\t"; break;
-    default: ss << *iter; break;
+    case '\\':
+      ss << "\\\\";
+      break;
+    case '"':
+      ss << "\\\"";
+      break;
+    case '/':
+      ss << "\\/";
+      break;
+    case '\b':
+      ss << "\\b";
+      break;
+    case '\f':
+      ss << "\\f";
+      break;
+    case '\n':
+      ss << "\\n";
+      break;
+    case '\r':
+      ss << "\\r";
+      break;
+    case '\t':
+      ss << "\\t";
+      break;
+    default:
+      ss << *iter;
+      break;
     }
   }
   return ss.str();
 }
 
-void t_json_generator::start_object(){
+void t_json_generator::start_object() {
   f_json_ << "{";
   _commaNeeded.push(false);
 }
 
-void t_json_generator::start_array(){
+void t_json_generator::start_array() {
   f_json_ << "[";
   _commaNeeded.push(false);
 }
 
-void t_json_generator::write_comma_if_needed(){
-  if (_commaNeeded.top()) f_json_ << ",";
+void t_json_generator::write_comma_if_needed() {
+  if (_commaNeeded.top())
+    f_json_ << ",";
 }
 
-void t_json_generator::indicate_comma_needed(){
+void t_json_generator::indicate_comma_needed() {
   _commaNeeded.pop();
   _commaNeeded.push(true);
 }
 
-void t_json_generator::write_key(string key, string val){
+void t_json_generator::write_key(string key, string val) {
   write_comma_if_needed();
   f_json_ << quot << key << quot << ":" << quot << escapeJsonString(val) << quot;
   indicate_comma_needed();
 }
 
-void t_json_generator::write_key_int(string key, int val){
+void t_json_generator::write_key_int(string key, int val) {
   write_comma_if_needed();
   f_json_ << quot << key << quot << ":" << quot << val << quot;
   indicate_comma_needed();
 }
 
-void t_json_generator::end_object(bool newLine){
+void t_json_generator::end_object(bool newLine) {
   f_json_ << "}";
-  if (newLine) f_json_ << endl;
+  if (newLine)
+    f_json_ << endl;
   _commaNeeded.pop();
 }
 
-void t_json_generator::end_array(bool newLine){
+void t_json_generator::end_array(bool newLine) {
   f_json_ << "]";
-  if (newLine) f_json_ << endl;
+  if (newLine)
+    f_json_ << endl;
   _commaNeeded.pop();
 }
 
@@ -169,35 +188,35 @@ void t_json_generator::close_generator() {
   f_json_.close();
 }
 
-void t_json_generator::merge_includes(t_program * program) {
+void t_json_generator::merge_includes(t_program* program) {
   vector<t_program*> includes = program->get_includes();
   vector<t_program*>::iterator inc_iter;
-  for (inc_iter = includes.begin(); inc_iter != includes.end(); ++inc_iter){
+  for (inc_iter = includes.begin(); inc_iter != includes.end(); ++inc_iter) {
     t_program* include = *inc_iter;
-    //recurse in case we get crazy
+    // recurse in case we get crazy
     merge_includes(include);
-    //merge enums
+    // merge enums
     vector<t_enum*> enums = include->get_enums();
     vector<t_enum*>::iterator en_iter;
     for (en_iter = enums.begin(); en_iter != enums.end(); ++en_iter) {
       program->add_enum(*en_iter);
     }
-    //merge typedefs
+    // merge typedefs
     vector<t_typedef*> typedefs = include->get_typedefs();
     vector<t_typedef*>::iterator td_iter;
     for (td_iter = typedefs.begin(); td_iter != typedefs.end(); ++td_iter) {
       program->add_typedef(*td_iter);
     }
-    //merge structs
+    // merge structs
     vector<t_struct*> objects = include->get_objects();
     vector<t_struct*>::iterator o_iter;
     for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) {
       program->add_struct(*o_iter);
     }
-    //merge constants
+    // merge constants
     vector<t_const*> consts = include->get_consts();
     vector<t_const*>::iterator c_iter;
-    for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter){
+    for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
       program->add_const(*c_iter);
     }
 
@@ -216,7 +235,8 @@ void t_json_generator::generate_program() {
   start_object();
 
   write_key("name", program_->get_name());
-  if (program_->has_doc()) write_key("doc", program_->get_doc());
+  if (program_->has_doc())
+    write_key("doc", program_->get_doc());
 
   // Generate enums
   vector<t_enum*> enums = program_->get_enums();
@@ -254,8 +274,7 @@ void t_json_generator::generate_program() {
     write_comma_if_needed();
     if ((*o_iter)->is_xception()) {
       generate_xception(*o_iter);
-    }
-    else {
+    } else {
       generate_struct(*o_iter);
     }
     indicate_comma_needed();
@@ -284,15 +303,16 @@ void t_json_generator::generate_program() {
   close_generator();
 }
 
-void t_json_generator::generate_typedef(t_typedef* ttypedef){
+void t_json_generator::generate_typedef(t_typedef* ttypedef) {
   start_object();
   write_key("name", ttypedef->get_name());
   write_key("type", get_type_name(ttypedef->get_true_type()));
-  if (ttypedef->has_doc()) write_key("doc", ttypedef->get_doc());
+  if (ttypedef->has_doc())
+    write_key("doc", ttypedef->get_doc());
   end_object(true);
 }
 
-void t_json_generator::generate_consts(vector<t_const*> consts){
+void t_json_generator::generate_consts(vector<t_const*> consts) {
   vector<t_const*>::iterator c_iter;
   f_json_ << ",\"constants\":";
   start_array();
@@ -304,7 +324,8 @@ void t_json_generator::generate_consts(vector<t_const*> consts){
     t_const* con = (*c_iter);
     write_key("name", con->get_name());
     write_key("type", get_type_name(con->get_type()));
-    if (con->has_doc()) write_key("doc", con->get_doc());
+    if (con->has_doc())
+      write_key("doc", con->get_doc());
     write_key("value", get_const_value(con->get_value()));
     end_object(true);
   }
@@ -314,7 +335,8 @@ void t_json_generator::generate_consts(vector<t_const*> consts){
 void t_json_generator::generate_enum(t_enum* tenum) {
   start_object();
   write_key("name", tenum->get_name());
-  if (tenum->has_doc()) write_key("doc", tenum->get_doc());
+  if (tenum->has_doc())
+    write_key("doc", tenum->get_doc());
   f_json_ << ",\"members\":";
   start_array();
   vector<t_enum_value*> values = tenum->get_constants();
@@ -325,7 +347,8 @@ void t_json_generator::generate_enum(t_enum* tenum) {
     start_object();
     write_key("name", val->get_name());
     write_key_int("value", val->get_value());
-    if (val->has_doc()) write_key("doc", val->get_doc());
+    if (val->has_doc())
+      write_key("doc", val->get_doc());
     end_object(false);
     indicate_comma_needed();
   }
@@ -333,11 +356,13 @@ void t_json_generator::generate_enum(t_enum* tenum) {
   end_object(true);
 }
 
-void t_json_generator::generate_struct(t_struct* tstruct){
+void t_json_generator::generate_struct(t_struct* tstruct) {
   start_object();
   write_key("name", tstruct->get_name());
-  if (tstruct->has_doc()) write_key("doc", tstruct->get_doc());
-  if (tstruct->is_xception()) write_key("isException", "true");
+  if (tstruct->has_doc())
+    write_key("doc", tstruct->get_doc());
+  if (tstruct->is_xception())
+    write_key("isException", "true");
   vector<t_field*> members = tstruct->get_members();
   vector<t_field*>::iterator mem_iter = members.begin();
   f_json_ << ",\"fields\":";
@@ -349,11 +374,13 @@ void t_json_generator::generate_struct(t_struct* tstruct){
   end_object(true);
 }
 
-void t_json_generator::generate_service(t_service* tservice){
+void t_json_generator::generate_service(t_service* tservice) {
   start_object();
   write_key("name", tservice->get_name());
-  if (tservice->get_extends()) write_key("extendsType", tservice->get_extends()->get_name());
-  if (tservice->has_doc()) write_key("doc", tservice->get_doc());
+  if (tservice->get_extends())
+    write_key("extendsType", tservice->get_extends()->get_name());
+  if (tservice->has_doc())
+    write_key("doc", tservice->get_doc());
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator fn_iter = functions.begin();
   f_json_ << ",\"functions\":";
@@ -368,12 +395,14 @@ void t_json_generator::generate_service(t_service* tservice){
   end_object(true);
 }
 
-void t_json_generator::generate_function(t_function* tfunc){
+void t_json_generator::generate_function(t_function* tfunc) {
   start_object();
   write_key("name", tfunc->get_name());
   write_key("returnType", get_type_name(tfunc->get_returntype()));
-  if (tfunc->is_oneway()) write_key("oneWay", "true");
-  if (tfunc->has_doc()) write_key("doc", tfunc->get_doc());
+  if (tfunc->is_oneway())
+    write_key("oneWay", "true");
+  if (tfunc->has_doc())
+    write_key("doc", tfunc->get_doc());
   vector<t_field*> members = tfunc->get_arglist()->get_members();
   vector<t_field*>::iterator mem_iter = members.begin();
   f_json_ << ",\"arguments\":";
@@ -394,20 +423,21 @@ void t_json_generator::generate_function(t_function* tfunc){
   end_object(false);
 }
 
-void t_json_generator::generate_field(t_field * field){
+void t_json_generator::generate_field(t_field* field) {
   write_comma_if_needed();
   start_object();
   write_key_int("index", field->get_key());
   write_key("name", field->get_name());
   write_key("type", get_type_name(field->get_type()));
-  if (field->has_doc()) write_key("doc", field->get_doc());
+  if (field->has_doc())
+    write_key("doc", field->get_doc());
   switch (field->get_req()) {
-        case t_field::T_REQUIRED:
-            write_key("required", "true");
-            break;
-        default:
-            write_key("required", "false");
-            break;
+  case t_field::T_REQUIRED:
+    write_key("required", "true");
+    break;
+  default:
+    write_key("required", "false");
+    break;
   }
   if (field->get_value())
     write_key("default", get_const_value(field->get_value()));
@@ -415,7 +445,7 @@ void t_json_generator::generate_field(t_field * field){
   end_object(false);
   indicate_comma_needed();
 }
-string t_json_generator::get_const_value(t_const_value* tvalue){
+string t_json_generator::get_const_value(t_const_value* tvalue) {
 
   switch (tvalue->get_type()) {
   case t_const_value::CV_INTEGER:
@@ -424,14 +454,15 @@ string t_json_generator::get_const_value(t_const_value* tvalue){
     return tvalue->get_string();
   case t_const_value::CV_STRING:
     return tvalue->get_string();
-  case t_const_value::CV_LIST:
-  {
+  case t_const_value::CV_LIST: {
     string list = "[";
-    vector<t_const_value*> list_elems = tvalue->get_list();;
+    vector<t_const_value*> list_elems = tvalue->get_list();
+    ;
     vector<t_const_value*>::iterator list_iter;
     bool first = true;
     for (list_iter = list_elems.begin(); list_iter != list_elems.end(); list_iter++) {
-      if (!first)list += ",";
+      if (!first)
+        list += ",";
       first = false;
       list += get_const_value(*list_iter);
     }
@@ -445,7 +476,8 @@ string t_json_generator::get_const_value(t_const_value* tvalue){
     string map = "[";
     bool first = true;
     for (map_iter = map_elems.begin(); map_iter != map_elems.end(); map_iter++) {
-      if (!first) map += ",";
+      if (!first)
+        map += ",";
       first = false;
       map += get_const_value(map_iter->first) + ":";
       map += get_const_value(map_iter->second);
@@ -454,20 +486,17 @@ string t_json_generator::get_const_value(t_const_value* tvalue){
   }
   return "UNKNOWN";
 }
-string t_json_generator::get_type_name(t_type* ttype){
+string t_json_generator::get_type_name(t_type* ttype) {
   if (ttype->is_container()) {
     if (ttype->is_list()) {
       return "list<" + get_type_name(((t_list*)ttype)->get_elem_type()) + ">";
-    }
-    else if (ttype->is_set()) {
+    } else if (ttype->is_set()) {
       return "set<" + get_type_name(((t_set*)ttype)->get_elem_type()) + ">";
+    } else if (ttype->is_map()) {
+      return "map<" + get_type_name(((t_map*)ttype)->get_key_type()) + +","
+             + get_type_name(((t_map*)ttype)->get_val_type()) + ">";
     }
-    else if (ttype->is_map()) {
-      return "map<" + get_type_name(((t_map*)ttype)->get_key_type()) +
-        +"," + get_type_name(((t_map*)ttype)->get_val_type()) + ">";
-    }
-  }
-  else if (ttype->is_base_type()) {
+  } else if (ttype->is_base_type()) {
     return (((t_base_type*)ttype)->is_binary() ? "binary" : ttype->get_name());
   }
   return ttype->get_name();

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_lua_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_lua_generator.cc b/compiler/cpp/src/generate/t_lua_generator.cc
index 7303c21..5703ecb 100644
--- a/compiler/cpp/src/generate/t_lua_generator.cc
+++ b/compiler/cpp/src/generate/t_lua_generator.cc
@@ -26,21 +26,19 @@ using std::string;
 using std::vector;
 using std::map;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * LUA code generator.
  *
  */
 class t_lua_generator : public t_oop_generator {
- public:
-  t_lua_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) option_string;
+public:
+  t_lua_generator(t_program* program,
+                  const std::map<std::string, std::string>& parsed_options,
+                  const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("omit_requires");
@@ -58,17 +56,16 @@ class t_lua_generator : public t_oop_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_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);
 
   std::string render_const_value(t_type* type, t_const_value* value);
 
- private:
-
+private:
   /**
    * True iff we should generate lua require statements.
    */
@@ -77,81 +74,71 @@ class t_lua_generator : public t_oop_generator {
   /**
    * Struct-level generation functions
    */
-  void generate_lua_struct_definition(
-    std::ofstream& out, t_struct* tstruct, bool is_xception=false);
+  void generate_lua_struct_definition(std::ofstream& out,
+                                      t_struct* tstruct,
+                                      bool is_xception = false);
   void generate_lua_struct_reader(std::ofstream& out, t_struct* tstruct);
   void generate_lua_struct_writer(std::ofstream& out, t_struct* tstruct);
 
   /**
    * Service-level generation functions
    */
-  void generate_service_client    (std::ofstream& out, t_service* tservice);
-  void generate_service_interface (std::ofstream& out, t_service* tservice);
-  void generate_service_processor (std::ofstream& out, t_service* tservice);
-  void generate_process_function  (std::ofstream& out, t_service* tservice,
-                                   t_function* tfunction);
-  void generate_service_helpers   (ofstream &out, t_service* tservice);
-  void generate_function_helpers  (ofstream &out, t_function* tfunction);
+  void generate_service_client(std::ofstream& out, t_service* tservice);
+  void generate_service_interface(std::ofstream& out, t_service* tservice);
+  void generate_service_processor(std::ofstream& out, t_service* tservice);
+  void generate_process_function(std::ofstream& out, t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(ofstream& out, t_service* tservice);
+  void generate_function_helpers(ofstream& out, t_function* tfunction);
 
   /**
    * Deserialization (Read)
    */
-  void generate_deserialize_field(
-    std::ofstream &out, t_field *tfield, std::string prefix="");
+  void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_deserialize_struct(
-    std::ofstream &out, t_struct *tstruct, std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container(
-    std::ofstream &out, t_type *ttype, std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element(
-    std::ofstream &out, t_set *tset, std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element(
-    std::ofstream &out, t_map *tmap, std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element(
-    std::ofstream &out, t_list *tlist, std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
   /**
    * Serialization (Write)
    */
-  void generate_serialize_field(
-    std::ofstream &out, t_field *tfield, std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct(
-    std::ofstream &out, t_struct *tstruct, std::string prefix="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container(
-    std::ofstream &out, t_type *ttype, std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element(
-    std::ofstream &out, t_map *tmap, std::string kiter, std::string viter);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string kiter,
+                                      std::string viter);
 
-  void generate_serialize_set_element(
-    std::ofstream &out, t_set *tmap, std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element(
-    std::ofstream &out, t_list *tlist, std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
   /**
    * Helper rendering functions
    */
   std::string lua_includes();
-  std::string function_signature(t_function* tfunction, std::string prefix="");
-  std::string argument_list(t_struct* tstruct, std::string prefix="");
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
+  std::string argument_list(t_struct* tstruct, std::string prefix = "");
   std::string type_to_enum(t_type* ttype);
   static std::string get_namespace(const t_program* program);
 
   std::string autogen_comment() {
-    return
-      std::string("--\n") +
-      "-- Autogenerated by Thrift\n" +
-      "--\n" +
-      "-- DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-      "-- @""generated\n" +
-      "--\n";
+    return std::string("--\n") + "-- Autogenerated by Thrift\n" + "--\n"
+           + "-- DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" + "-- @"
+                                                                                       "generated\n"
+           + "--\n";
   }
 
   /**
@@ -162,7 +149,6 @@ class t_lua_generator : public t_oop_generator {
   std::ofstream f_service_;
 };
 
-
 /**
  * Init and close methods
  */
@@ -196,10 +182,8 @@ void t_lua_generator::close_generator() {
  * Generate a typedef (essentially a constant)
  */
 void t_lua_generator::generate_typedef(t_typedef* ttypedef) {
-  f_types_
-    << endl << endl << indent()
-    << ttypedef->get_symbolic() << " = "
-    << ttypedef->get_type()->get_name();
+  f_types_ << endl << endl << indent() << ttypedef->get_symbolic() << " = "
+           << ttypedef->get_type()->get_name();
 }
 
 /**
@@ -238,8 +222,7 @@ void t_lua_generator::generate_const(t_const* tconst) {
 /**
  * Prints the value of a constant with the given type.
  */
-string t_lua_generator::render_const_value(
-  t_type* type, t_const_value* value) {
+string t_lua_generator::render_const_value(t_type* type, t_const_value* value) {
   std::ostringstream out;
 
   type = get_true_type(type);
@@ -268,8 +251,7 @@ string t_lua_generator::render_const_value(
       }
       break;
     default:
-      throw "compiler error: no const of base type "
-        + t_base_type::t_base_name(tbase);
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
     }
   } else if (type->is_enum()) {
     out << value->get_integer();
@@ -289,8 +271,7 @@ string t_lua_generator::render_const_value(
         }
       }
       if (field_type == NULL) {
-        throw "type error: " + type->get_name() + " has no field "
-          + v_iter->first->get_string();
+        throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
       }
 
       indent(out);
@@ -315,9 +296,8 @@ string t_lua_generator::render_const_value(
     const map<t_const_value*, t_const_value*>& val = value->get_map();
     map<t_const_value*, t_const_value*>::const_iterator v_iter;
     for (v_iter = val.begin(); v_iter != val.end();) {
-      indent(out)
-        << "[" << render_const_value(ktype, v_iter->first) << "] = "
-        << render_const_value(vtype, v_iter->second);
+      indent(out) << "[" << render_const_value(ktype, v_iter->first)
+                  << "] = " << render_const_value(vtype, v_iter->second);
       ++v_iter;
       if (v_iter != val.end()) {
         out << ",";
@@ -371,16 +351,15 @@ void t_lua_generator::generate_xception(t_struct* txception) {
 /**
  * Generate a thrift struct or exception (lua table)
  */
-void t_lua_generator::generate_lua_struct_definition(ofstream &out,
-                                                     t_struct *tstruct,
+void t_lua_generator::generate_lua_struct_definition(ofstream& out,
+                                                     t_struct* tstruct,
                                                      bool is_exception) {
   vector<t_field*>::const_iterator m_iter;
   const vector<t_field*>& members = tstruct->get_members();
 
   indent(out) << endl << endl << tstruct->get_name();
   if (is_exception) {
-    out << " = TException:new{" << endl <<
-      indent() << "  __type = '" << tstruct->get_name() << "'";
+    out << " = TException:new{" << endl << indent() << "  __type = '" << tstruct->get_name() << "'";
     if (members.size() > 0) {
       out << ",";
     }
@@ -408,56 +387,51 @@ void t_lua_generator::generate_lua_struct_definition(ofstream &out,
 /**
  * Generate a struct/exception reader
  */
-void t_lua_generator::generate_lua_struct_reader(ofstream& out,
-                                                  t_struct* tstruct) {
+void t_lua_generator::generate_lua_struct_reader(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // function
-  indent(out) << endl << endl
-    << "function " << tstruct->get_name() << ":read(iprot)" << endl;
+  indent(out) << endl << endl << "function " << tstruct->get_name() << ":read(iprot)" << endl;
   indent_up();
 
   indent(out) << "iprot:readStructBegin()" << endl;
 
   // while: Read in fields
   indent(out) << "while true do" << endl;
-    indent_up();
+  indent_up();
 
-    // if: Check what to read
-    indent(out) << "local fname, ftype, fid = iprot:readFieldBegin()" << endl;
-    indent(out) << "if ftype == TType.STOP then" << endl;
-      indent_up();
-      indent(out) << "break" << endl;
+  // if: Check what to read
+  indent(out) << "local fname, ftype, fid = iprot:readFieldBegin()" << endl;
+  indent(out) << "if ftype == TType.STOP then" << endl;
+  indent_up();
+  indent(out) << "break" << endl;
 
-      for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        indent_down();
-        indent(out)
-          << "elseif fid == " << (*f_iter)->get_key() << " then" << endl;
-          indent_up();
-          indent(out)
-            << "if ftype == " << type_to_enum((*f_iter)->get_type())
-            << " then" << endl;
-            indent_up();
-
-            // Read field contents
-            generate_deserialize_field(out, *f_iter, "self.");
-
-            indent_down();
-          indent(out) << "else" << endl;
-          indent(out) << "  iprot:skip(ftype)" << endl;
-          indent(out) << "end" << endl;
-      }
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent_down();
+    indent(out) << "elseif fid == " << (*f_iter)->get_key() << " then" << endl;
+    indent_up();
+    indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << " then" << endl;
+    indent_up();
+
+    // Read field contents
+    generate_deserialize_field(out, *f_iter, "self.");
 
-    // end if
     indent_down();
     indent(out) << "else" << endl;
     indent(out) << "  iprot:skip(ftype)" << endl;
     indent(out) << "end" << endl;
-    indent(out) << "iprot:readFieldEnd()" << endl;
+  }
+
+  // end if
+  indent_down();
+  indent(out) << "else" << endl;
+  indent(out) << "  iprot:skip(ftype)" << endl;
+  indent(out) << "end" << endl;
+  indent(out) << "iprot:readFieldEnd()" << endl;
 
   // end while
-    indent_down();
+  indent_down();
   indent(out) << "end" << endl;
   indent(out) << "iprot:readStructEnd()" << endl;
 
@@ -470,36 +444,31 @@ void t_lua_generator::generate_lua_struct_reader(ofstream& out,
 /**
  * Generate a struct/exception writer
  */
-void t_lua_generator::generate_lua_struct_writer(ofstream& out,
-                                                  t_struct* tstruct) {
+void t_lua_generator::generate_lua_struct_writer(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // function
-  indent(out) << endl << endl
-    << "function " << tstruct->get_name() << ":write(oprot)" << endl;
+  indent(out) << endl << endl << "function " << tstruct->get_name() << ":write(oprot)" << endl;
   indent_up();
 
-    indent(out)
-      << "oprot:writeStructBegin('" << tstruct->get_name() << "')" << endl;
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      indent(out) << "if self." << (*f_iter)->get_name() << " then" << endl;
-      indent_up();
-        indent(out)
-          << "oprot:writeFieldBegin('" << (*f_iter)->get_name() << "', "
-          << type_to_enum((*f_iter)->get_type()) << ", "
-          << (*f_iter)->get_key() << ")" << endl;
+  indent(out) << "oprot:writeStructBegin('" << tstruct->get_name() << "')" << endl;
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent(out) << "if self." << (*f_iter)->get_name() << " then" << endl;
+    indent_up();
+    indent(out) << "oprot:writeFieldBegin('" << (*f_iter)->get_name() << "', "
+                << type_to_enum((*f_iter)->get_type()) << ", " << (*f_iter)->get_key() << ")"
+                << endl;
 
-        // Write field contents
-        generate_serialize_field(out, *f_iter, "self.");
+    // Write field contents
+    generate_serialize_field(out, *f_iter, "self.");
 
-        indent(out)
-          << "oprot:writeFieldEnd()" << endl;
-      indent_down();
-      indent(out) << "end" << endl;
-    }
-    indent(out) << "oprot:writeFieldStop()" << endl;
-    indent(out) << "oprot:writeStructEnd()" << endl;
+    indent(out) << "oprot:writeFieldEnd()" << endl;
+    indent_down();
+    indent(out) << "end" << endl;
+  }
+  indent(out) << "oprot:writeFieldStop()" << endl;
+  indent(out) << "oprot:writeStructEnd()" << endl;
 
   // end function
   indent_down();
@@ -525,9 +494,8 @@ void t_lua_generator::generate_service(t_service* tservice) {
     f_service_ << endl << "require '" << cur_ns << "ttypes'" << endl;
 
     if (tservice->get_extends() != NULL) {
-      f_service_
-        << "require '" << get_namespace(tservice->get_extends()->get_program())
-        << tservice->get_extends()->get_name() << "'" << endl;
+      f_service_ << "require '" << get_namespace(tservice->get_extends()->get_program())
+                 << tservice->get_extends()->get_name() << "'" << endl;
     }
   }
 
@@ -542,8 +510,7 @@ void t_lua_generator::generate_service(t_service* tservice) {
   f_service_.close();
 }
 
-void t_lua_generator::generate_service_interface(ofstream &out,
-                                                 t_service* tservice) {
+void t_lua_generator::generate_service_interface(ofstream& out, t_service* tservice) {
   string classname = tservice->get_name() + "Iface";
   t_service* extends_s = tservice->get_extends();
 
@@ -554,13 +521,10 @@ void t_lua_generator::generate_service_interface(ofstream &out,
   } else {
     out << "__TObject:new{" << endl;
   }
-  out
-    << "  __type = '" << classname << "'" << endl
-    << "}" << endl << endl;
+  out << "  __type = '" << classname << "'" << endl << "}" << endl << endl;
 }
 
-void t_lua_generator::generate_service_client(ofstream &out,
-                                              t_service* tservice) {
+void t_lua_generator::generate_service_client(ofstream& out, t_service* tservice) {
   string classname = tservice->get_name() + "Client";
   t_service* extends_s = tservice->get_extends();
 
@@ -571,10 +535,7 @@ void t_lua_generator::generate_service_client(ofstream &out,
   } else {
     out << "__TClient";
   }
-  out
-    <<", {" << endl
-    << "  __type = '" << classname << "'" << endl
-    << "})" << endl;
+  out << ", {" << endl << "  __type = '" << classname << "'" << endl << "})" << endl;
 
   // Send/Recv functions
   vector<t_function*> functions = tservice->get_functions();
@@ -585,141 +546,113 @@ void t_lua_generator::generate_service_client(ofstream &out,
 
     // Wrapper function
     indent(out) << endl << "function " << classname << ":" << sig << endl;
-      indent_up();
+    indent_up();
 
-      indent(out) << "self:send_" << sig << endl << indent();
-      if (!(*f_iter)->is_oneway()) {
-        if (!(*f_iter)->get_returntype()->is_void()) {
-          out << "return ";
-        }
-        out << "self:recv_" << sig << endl;
+    indent(out) << "self:send_" << sig << endl << indent();
+    if (!(*f_iter)->is_oneway()) {
+      if (!(*f_iter)->get_returntype()->is_void()) {
+        out << "return ";
       }
+      out << "self:recv_" << sig << endl;
+    }
 
-      indent_down();
+    indent_down();
     indent(out) << "end" << endl;
 
     // Send function
     indent(out) << endl << "function " << classname << ":send_" << sig << endl;
-      indent_up();
+    indent_up();
 
-      indent(out) << "self.oprot:writeMessageBegin('" << funcname << "', "
-                  << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
-                  << ", self._seqid)" << endl;
-      indent(out) << "local args = " << funcname << "_args:new{}" << endl;
-
-      // Set the args
-      const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
-      vector<t_field*>::const_iterator fld_iter;
-      for (fld_iter = args.begin(); fld_iter != args.end(); ++fld_iter) {
-        std::string argname = (*fld_iter)->get_name();
-        indent(out) << "args." << argname << " = " << argname << endl;
-      }
+    indent(out) << "self.oprot:writeMessageBegin('" << funcname << "', "
+                << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
+                << ", self._seqid)" << endl;
+    indent(out) << "local args = " << funcname << "_args:new{}" << endl;
+
+    // Set the args
+    const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
+    vector<t_field*>::const_iterator fld_iter;
+    for (fld_iter = args.begin(); fld_iter != args.end(); ++fld_iter) {
+      std::string argname = (*fld_iter)->get_name();
+      indent(out) << "args." << argname << " = " << argname << endl;
+    }
 
-      indent(out) << "args:write(self.oprot)" << endl;
-      indent(out) << "self.oprot:writeMessageEnd()" << endl;
-      indent(out) << "self.oprot.trans:flush()" << endl;
+    indent(out) << "args:write(self.oprot)" << endl;
+    indent(out) << "self.oprot:writeMessageEnd()" << endl;
+    indent(out) << "self.oprot.trans:flush()" << endl;
 
-      indent_down();
+    indent_down();
     indent(out) << "end" << endl;
 
     // Recv function
     if (!(*f_iter)->is_oneway()) {
-      indent(out)
-        << endl << "function " << classname << ":recv_" << sig << endl;
-        indent_up();
-
-        out <<
-          indent() << "local fname, mtype, rseqid = self.iprot:"
-                   << "readMessageBegin()"<< endl <<
-          indent() << "if mtype == TMessageType.EXCEPTION then" << endl <<
-          indent() << "  local x = TApplicationException:new{}" << endl <<
-          indent() << "  x:read(self.iprot)" << endl <<
-          indent() << "  self.iprot:readMessageEnd()" << endl <<
-          indent() << "  error(x)" << endl <<
-          indent() << "end" << endl <<
-          indent() << "local result = " << funcname << "_result:new{}"
-                   << endl <<
-          indent() << "result:read(self.iprot)" << endl <<
-          indent() << "self.iprot:readMessageEnd()" << endl;
-
-        // Return the result if it's not a void function
-        if (!(*f_iter)->get_returntype()->is_void()) {
-          out <<
-            indent() << "if result.success then" << endl <<
-            indent() << "  return result.success" << endl;
-
-          // Throw custom exceptions
-          const std::vector<t_field*>& xf =
-            (*f_iter)->get_xceptions()->get_members();
-          vector<t_field*>::const_iterator x_iter;
-          for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
-            out <<
-              indent() << "elseif result." << (*x_iter)->get_name() << " then"
-                       << endl <<
-              indent() << "  error(result." << (*x_iter)->get_name() << ")"
-                       << endl;
-          }
-
-          out <<
-            indent() << "end" << endl <<
-            indent() << "error(TApplicationException:new{errorCode = "
-                     << "TApplicationException.MISSING_RESULT})" << endl;
+      indent(out) << endl << "function " << classname << ":recv_" << sig << endl;
+      indent_up();
+
+      out << indent() << "local fname, mtype, rseqid = self.iprot:"
+          << "readMessageBegin()" << endl << indent() << "if mtype == TMessageType.EXCEPTION then"
+          << endl << indent() << "  local x = TApplicationException:new{}" << endl << indent()
+          << "  x:read(self.iprot)" << endl << indent() << "  self.iprot:readMessageEnd()" << endl
+          << indent() << "  error(x)" << endl << indent() << "end" << endl << indent()
+          << "local result = " << funcname << "_result:new{}" << endl << indent()
+          << "result:read(self.iprot)" << endl << indent() << "self.iprot:readMessageEnd()" << endl;
+
+      // Return the result if it's not a void function
+      if (!(*f_iter)->get_returntype()->is_void()) {
+        out << indent() << "if result.success then" << endl << indent() << "  return result.success"
+            << endl;
+
+        // Throw custom exceptions
+        const std::vector<t_field*>& xf = (*f_iter)->get_xceptions()->get_members();
+        vector<t_field*>::const_iterator x_iter;
+        for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
+          out << indent() << "elseif result." << (*x_iter)->get_name() << " then" << endl
+              << indent() << "  error(result." << (*x_iter)->get_name() << ")" << endl;
         }
 
-        indent_down();
+        out << indent() << "end" << endl << indent()
+            << "error(TApplicationException:new{errorCode = "
+            << "TApplicationException.MISSING_RESULT})" << endl;
+      }
+
+      indent_down();
       indent(out) << "end" << endl;
     }
   }
 }
 
-void t_lua_generator::generate_service_processor(ofstream &out,
-                                                 t_service* tservice) {
+void t_lua_generator::generate_service_processor(ofstream& out, t_service* tservice) {
   string classname = tservice->get_name() + "Processor";
   t_service* extends_s = tservice->get_extends();
 
   // Define processor table
-  out << endl
-    << classname << " = __TObject.new(";
+  out << endl << classname << " = __TObject.new(";
   if (extends_s != NULL) {
     out << extends_s << "Processor" << endl;
   } else {
     out << "__TProcessor" << endl;
   }
-  out
-    << ", {" << endl
-    << " __type = '" << classname << "'" << endl
-    << "})" << endl;
+  out << ", {" << endl << " __type = '" << classname << "'" << endl << "})" << endl;
 
   // Process function
-  indent(out) << endl << "function " << classname
-    << ":process(iprot, oprot, server_ctx)" << endl;
-    indent_up();
+  indent(out) << endl << "function " << classname << ":process(iprot, oprot, server_ctx)" << endl;
+  indent_up();
 
-    indent(out)
-      << "local name, mtype, seqid = iprot:readMessageBegin()" << endl;
-    indent(out)
-      << "local func_name = 'process_' .. name" << endl;
-    indent(out)
-      << "if not self[func_name] or ttype(self[func_name]) ~= 'function' then";
-    indent_up();
-      out << endl <<
-        indent() << "iprot:skip(TType.STRUCT)" << endl <<
-        indent() << "iprot:readMessageEnd()" << endl <<
-        indent() << "x = TApplicationException:new{" << endl <<
-        indent() << "  errorCode = TApplicationException.UNKNOWN_METHOD" << endl
-     << indent() << "}" << endl <<
-        indent() << "oprot:writeMessageBegin(name, TMessageType.EXCEPTION, "
-                 << "seqid)" << endl <<
-        indent() << "x:write(oprot)" << endl <<
-        indent() << "oprot:writeMessageEnd()" << endl <<
-        indent() << "oprot.trans:flush()" << endl;
-    indent_down();
-    indent(out) << "else" << endl <<
-       indent() << "  self[func_name](self, seqid, iprot, oprot, server_ctx)"
-                << endl
-    << indent() << "end" << endl;
+  indent(out) << "local name, mtype, seqid = iprot:readMessageBegin()" << endl;
+  indent(out) << "local func_name = 'process_' .. name" << endl;
+  indent(out) << "if not self[func_name] or ttype(self[func_name]) ~= 'function' then";
+  indent_up();
+  out << endl << indent() << "iprot:skip(TType.STRUCT)" << endl << indent()
+      << "iprot:readMessageEnd()" << endl << indent() << "x = TApplicationException:new{" << endl
+      << indent() << "  errorCode = TApplicationException.UNKNOWN_METHOD" << endl << indent() << "}"
+      << endl << indent() << "oprot:writeMessageBegin(name, TMessageType.EXCEPTION, "
+      << "seqid)" << endl << indent() << "x:write(oprot)" << endl << indent()
+      << "oprot:writeMessageEnd()" << endl << indent() << "oprot.trans:flush()" << endl;
+  indent_down();
+  indent(out) << "else" << endl << indent()
+              << "  self[func_name](self, seqid, iprot, oprot, server_ctx)" << endl << indent()
+              << "end" << endl;
 
-    indent_down();
+  indent_down();
   indent(out) << "end" << endl;
 
   // Generate the process subfunctions
@@ -730,7 +663,7 @@ void t_lua_generator::generate_service_processor(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_process_function(ofstream &out,
+void t_lua_generator::generate_process_function(ofstream& out,
                                                 t_service* tservice,
                                                 t_function* tfunction) {
   string classname = tservice->get_name() + "Processor";
@@ -739,62 +672,49 @@ void t_lua_generator::generate_process_function(ofstream &out,
   string fn_name = tfunction->get_name();
 
   indent(out) << endl << "function " << classname << ":process_" << fn_name
-    << "(seqid, iprot, oprot, server_ctx)" << endl;
-    indent_up();
+              << "(seqid, iprot, oprot, server_ctx)" << endl;
+  indent_up();
 
-    // Read the request
-    out <<
-      indent() << "local args = " << argsname << ":new{}" << endl <<
-      indent() << "local reply_type = TMessageType.REPLY" << endl <<
-      indent() << "args:read(iprot)" << endl <<
-      indent() << "iprot:readMessageEnd()" << endl <<
-      indent() << "local result = " << resultname << ":new{}" << endl <<
-      indent() << "local status, res = pcall(self.handler." << fn_name
-               << ", self.handler";
-
-    // Print arguments
-    t_struct *args = tfunction->get_arglist();
-    if (args->get_members().size() > 0) {
-      out << ", " << argument_list(args, "args.");
-    }
+  // Read the request
+  out << indent() << "local args = " << argsname << ":new{}" << endl << indent()
+      << "local reply_type = TMessageType.REPLY" << endl << indent() << "args:read(iprot)" << endl
+      << indent() << "iprot:readMessageEnd()" << endl << indent() << "local result = " << resultname
+      << ":new{}" << endl << indent() << "local status, res = pcall(self.handler." << fn_name
+      << ", self.handler";
+
+  // Print arguments
+  t_struct* args = tfunction->get_arglist();
+  if (args->get_members().size() > 0) {
+    out << ", " << argument_list(args, "args.");
+  }
 
-    // Check for errors
-    out << ")" << endl <<
-      indent() << "if not status then" << endl <<
-      indent() << "  reply_type = TMessageType.EXCEPTION" << endl <<
-      indent() << "  result = TApplicationException:new{message = res}"
-               << endl;
-
-    // Handle custom exceptions
-    const std::vector<t_field*>& xf = tfunction->get_xceptions()->get_members();
-    if (xf.size() > 0) {
-      vector<t_field*>::const_iterator x_iter;
-      for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
-        out <<
-          indent() << "elseif ttype(res) == '"
-                   << (*x_iter)->get_type()->get_name() << "' then" << endl <<
-          indent() << "  result." << (*x_iter)->get_name() << " = res" << endl;
-      }
+  // Check for errors
+  out << ")" << endl << indent() << "if not status then" << endl << indent()
+      << "  reply_type = TMessageType.EXCEPTION" << endl << indent()
+      << "  result = TApplicationException:new{message = res}" << endl;
+
+  // Handle custom exceptions
+  const std::vector<t_field*>& xf = tfunction->get_xceptions()->get_members();
+  if (xf.size() > 0) {
+    vector<t_field*>::const_iterator x_iter;
+    for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
+      out << indent() << "elseif ttype(res) == '" << (*x_iter)->get_type()->get_name() << "' then"
+          << endl << indent() << "  result." << (*x_iter)->get_name() << " = res" << endl;
     }
+  }
 
-    // Set the result and write the reply
-    out <<
-      indent() << "else" << endl <<
-      indent() << "  result.success = res" << endl <<
-      indent() << "end" << endl <<
-      indent() << "oprot:writeMessageBegin('" << fn_name << "', reply_type, "
-               << "seqid)" << endl <<
-      indent() << "result:write(oprot)" << endl <<
-      indent() << "oprot:writeMessageEnd()" << endl <<
-      indent() << "oprot.trans:flush()" << endl;
+  // Set the result and write the reply
+  out << indent() << "else" << endl << indent() << "  result.success = res" << endl << indent()
+      << "end" << endl << indent() << "oprot:writeMessageBegin('" << fn_name << "', reply_type, "
+      << "seqid)" << endl << indent() << "result:write(oprot)" << endl << indent()
+      << "oprot:writeMessageEnd()" << endl << indent() << "oprot.trans:flush()" << endl;
 
-    indent_down();
+  indent_down();
   indent(out) << "end" << endl;
 }
 
 // Service helpers
-void t_lua_generator::generate_service_helpers(ofstream &out,
-                                               t_service* tservice) {
+void t_lua_generator::generate_service_helpers(ofstream& out, t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
 
@@ -806,8 +726,7 @@ void t_lua_generator::generate_service_helpers(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_function_helpers(ofstream &out,
-                                                t_function *tfunction) {
+void t_lua_generator::generate_function_helpers(ofstream& out, t_function* tfunction) {
   if (!tfunction->is_oneway()) {
     t_struct result(program_, tfunction->get_name() + "_result");
     t_field success(tfunction->get_returntype(), "success", 0);
@@ -828,14 +747,11 @@ void t_lua_generator::generate_function_helpers(ofstream &out,
 /**
  * Deserialize (Read)
  */
-void t_lua_generator::generate_deserialize_field(ofstream &out,
-                                                 t_field* tfield,
-                                                 string prefix) {
+void t_lua_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
   t_type* type = get_true_type(tfield->get_type());
 
   if (type->is_void()) {
-    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " +
-      prefix + tfield->get_name();
+    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
   }
 
   string name = prefix + tfield->get_name();
@@ -845,15 +761,13 @@ void t_lua_generator::generate_deserialize_field(ofstream &out,
   } else if (type->is_container()) {
     generate_deserialize_container(out, type, name);
   } else if (type->is_base_type() || type->is_enum()) {
-    indent(out) <<
-      name << " = iprot:";
+    indent(out) << name << " = iprot:";
 
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw "compiler error: cannot serialize void field in a struct: " +
-          name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         out << "readString()";
@@ -877,8 +791,7 @@ void t_lua_generator::generate_deserialize_field(ofstream &out,
         out << "readDouble()";
         break;
       default:
-        throw "compiler error: no PHP name for base type " +
-          t_base_type::t_base_name(tbase);
+        throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase);
       }
     } else if (type->is_enum()) {
       out << "readI32()";
@@ -887,21 +800,17 @@ void t_lua_generator::generate_deserialize_field(ofstream &out,
 
   } else {
     printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
-           tfield->get_name().c_str(), type->get_name().c_str());
+           tfield->get_name().c_str(),
+           type->get_name().c_str());
   }
 }
 
-void t_lua_generator::generate_deserialize_struct(ofstream &out,
-                                                  t_struct* tstruct,
-                                                  string prefix) {
-  indent(out)
-    << prefix << " = " << tstruct->get_name() << ":new{}" << endl
-    << indent() << prefix << ":read(iprot)" << endl;
+void t_lua_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  indent(out) << prefix << " = " << tstruct->get_name() << ":new{}" << endl << indent() << prefix
+              << ":read(iprot)" << endl;
 }
 
-void t_lua_generator::generate_deserialize_container(ofstream &out,
-                                                     t_type* ttype,
-                                                     string prefix) {
+void t_lua_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string prefix) {
   string size = tmp("_size");
   string ktype = tmp("_ktype");
   string vtype = tmp("_vtype");
@@ -915,29 +824,27 @@ void t_lua_generator::generate_deserialize_container(ofstream &out,
   // Declare variables, read header
   indent(out) << prefix << " = {}" << endl;
   if (ttype->is_map()) {
-    indent(out) << "local " << ktype << ", " << vtype << ", " << size
-                << " = iprot:readMapBegin() " << endl;
+    indent(out) << "local " << ktype << ", " << vtype << ", " << size << " = iprot:readMapBegin() "
+                << endl;
   } else if (ttype->is_set()) {
-    indent(out) << "local " << etype << ", " << size
-                << " = iprot:readSetBegin()" << endl;
+    indent(out) << "local " << etype << ", " << size << " = iprot:readSetBegin()" << endl;
   } else if (ttype->is_list()) {
-    indent(out) << "local " << etype << ", " << size
-                << " = iprot:readListBegin()" << endl;
+    indent(out) << "local " << etype << ", " << size << " = iprot:readListBegin()" << endl;
   }
 
   // Deserialize
   indent(out) << "for _i=1," << size << " do" << endl;
-    indent_up();
+  indent_up();
 
-    if (ttype->is_map()) {
-      generate_deserialize_map_element(out, (t_map*)ttype, prefix);
-    } else if (ttype->is_set()) {
-      generate_deserialize_set_element(out, (t_set*)ttype, prefix);
-    } else if (ttype->is_list()) {
-      generate_deserialize_list_element(out, (t_list*)ttype, prefix);
-    }
+  if (ttype->is_map()) {
+    generate_deserialize_map_element(out, (t_map*)ttype, prefix);
+  } else if (ttype->is_set()) {
+    generate_deserialize_set_element(out, (t_set*)ttype, prefix);
+  } else if (ttype->is_list()) {
+    generate_deserialize_list_element(out, (t_list*)ttype, prefix);
+  }
 
-    indent_down();
+  indent_down();
   indent(out) << "end" << endl;
 
   // Read container end
@@ -950,9 +857,7 @@ void t_lua_generator::generate_deserialize_container(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_deserialize_map_element(ofstream &out,
-                                                       t_map* tmap,
-                                                       string prefix) {
+void t_lua_generator::generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix) {
   // A map is represented by a table indexable by any lua type
   string key = tmp("_key");
   string val = tmp("_val");
@@ -965,20 +870,17 @@ void t_lua_generator::generate_deserialize_map_element(ofstream &out,
   indent(out) << prefix << "[" << key << "] = " << val << endl;
 }
 
-void t_lua_generator::generate_deserialize_set_element(ofstream &out,
-                                                       t_set* tset,
-                                                       string prefix) {
+void t_lua_generator::generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix) {
   // A set is represented by a table indexed by the value
   string elem = tmp("_elem");
   t_field felem(tset->get_elem_type(), elem);
 
   generate_deserialize_field(out, &felem);
 
-  indent(out) <<
-    prefix << "[" << elem << "] = " << elem << endl;
+  indent(out) << prefix << "[" << elem << "] = " << elem << endl;
 }
 
-void t_lua_generator::generate_deserialize_list_element(ofstream &out,
+void t_lua_generator::generate_deserialize_list_element(ofstream& out,
                                                         t_list* tlist,
                                                         string prefix) {
   // A list is represented by a table indexed by integer values
@@ -994,9 +896,7 @@ void t_lua_generator::generate_deserialize_list_element(ofstream &out,
 /**
  * Serialize (Write)
  */
-void t_lua_generator::generate_serialize_field(ofstream &out,
-                                               t_field* tfield,
-                                               string prefix) {
+void t_lua_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
   t_type* type = get_true_type(tfield->get_type());
   string name = prefix + tfield->get_name();
 
@@ -1016,8 +916,7 @@ void t_lua_generator::generate_serialize_field(ofstream &out,
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw
-          "compiler error: cannot serialize void field in a struct: " + name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         out << "writeString(" << name << ")";
@@ -1041,8 +940,7 @@ void t_lua_generator::generate_serialize_field(ofstream &out,
         out << "writeDouble(" << name << ")";
         break;
       default:
-        throw "compiler error: no PHP name for base type " +
-          t_base_type::t_base_name(tbase);
+        throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase);
       }
     } else if (type->is_enum()) {
       out << "writeI32(" << name << ")";
@@ -1055,61 +953,48 @@ void t_lua_generator::generate_serialize_field(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_serialize_struct(ofstream &out,
-                                                t_struct* tstruct,
-                                                string prefix) {
-  (void) tstruct;
+void t_lua_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  (void)tstruct;
   indent(out) << prefix << ":write(oprot)" << endl;
 }
 
-void t_lua_generator::generate_serialize_container(ofstream &out,
-                                                   t_type* ttype,
-                                                   string prefix) {
+void t_lua_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
   // Begin writing
   if (ttype->is_map()) {
-    indent(out) <<
-      "oprot:writeMapBegin(" <<
-      type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
-      type_to_enum(((t_map*)ttype)->get_val_type()) << ", " <<
-      "string.len(" << prefix << "))" << endl;
+    indent(out) << "oprot:writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
+                << type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
+                << "string.len(" << prefix << "))" << endl;
   } else if (ttype->is_set()) {
-    indent(out) <<
-      "oprot:writeSetBegin(" <<
-      type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " <<
-      "string.len(" << prefix << "))" << endl;
+    indent(out) << "oprot:writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
+                << "string.len(" << prefix << "))" << endl;
   } else if (ttype->is_list()) {
-    indent(out) <<
-      "oprot:writeListBegin(" <<
-      type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " <<
-      "string.len(" << prefix << "))" << endl;
+    indent(out) << "oprot:writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
+                << ", "
+                << "string.len(" << prefix << "))" << endl;
   }
 
   // Serialize
   if (ttype->is_map()) {
     string kiter = tmp("kiter");
     string viter = tmp("viter");
-    indent(out)
-      << "for " << kiter << "," << viter << " in pairs(" << prefix << ") do"
-      << endl;
-      indent_up();
-      generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
-      indent_down();
+    indent(out) << "for " << kiter << "," << viter << " in pairs(" << prefix << ") do" << endl;
+    indent_up();
+    generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
+    indent_down();
     indent(out) << "end" << endl;
   } else if (ttype->is_set()) {
     string iter = tmp("iter");
-    indent(out) <<
-      "for " << iter << ",_ in pairs(" << prefix << ") do" << endl;
-      indent_up();
-      generate_serialize_set_element(out, (t_set*)ttype, iter);
-      indent_down();
+    indent(out) << "for " << iter << ",_ in pairs(" << prefix << ") do" << endl;
+    indent_up();
+    generate_serialize_set_element(out, (t_set*)ttype, iter);
+    indent_down();
     indent(out) << "end" << endl;
   } else if (ttype->is_list()) {
     string iter = tmp("iter");
-    indent(out) <<
-      "for _," << iter << " in ipairs(" << prefix << ") do" << endl;
-      indent_up();
-      generate_serialize_list_element(out, (t_list*)ttype, iter);
-      indent_down();
+    indent(out) << "for _," << iter << " in ipairs(" << prefix << ") do" << endl;
+    indent_up();
+    generate_serialize_list_element(out, (t_list*)ttype, iter);
+    indent_down();
     indent(out) << "end" << endl;
   }
 
@@ -1123,7 +1008,7 @@ void t_lua_generator::generate_serialize_container(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_serialize_map_element(ofstream &out,
+void t_lua_generator::generate_serialize_map_element(ofstream& out,
                                                      t_map* tmap,
                                                      string kiter,
                                                      string viter) {
@@ -1134,16 +1019,12 @@ void t_lua_generator::generate_serialize_map_element(ofstream &out,
   generate_serialize_field(out, &vfield, "");
 }
 
-void t_lua_generator::generate_serialize_set_element(ofstream &out,
-                                                     t_set* tset,
-                                                     string iter) {
+void t_lua_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
   t_field efield(tset->get_elem_type(), iter);
   generate_serialize_field(out, &efield, "");
 }
 
-void t_lua_generator::generate_serialize_list_element(ofstream &out,
-                                                      t_list* tlist,
-                                                      string iter) {
+void t_lua_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
   t_field efield(tlist->get_elem_type(), iter);
   generate_serialize_field(out, &efield, "");
 }
@@ -1167,11 +1048,9 @@ string t_lua_generator::get_namespace(const t_program* program) {
   return real_module + "_";
 }
 
-string t_lua_generator::function_signature(t_function* tfunction,
-                                           string prefix) {
-  (void) prefix;
-  std::string ret = tfunction->get_name() + "(" +
-    argument_list(tfunction->get_arglist()) + ")";
+string t_lua_generator::function_signature(t_function* tfunction, string prefix) {
+  (void)prefix;
+  std::string ret = tfunction->get_name() + "(" + argument_list(tfunction->get_arglist()) + ")";
   return ret;
 }
 
@@ -1195,22 +1074,22 @@ string t_lua_generator::type_to_enum(t_type* type) {
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-      case t_base_type::TYPE_VOID:
-        throw "NO T_VOID CONSTRUCT";
-      case t_base_type::TYPE_STRING:
-        return "TType.STRING";
-      case t_base_type::TYPE_BOOL:
-        return "TType.BOOL";
-      case t_base_type::TYPE_BYTE:
-        return "TType.BYTE";
-      case t_base_type::TYPE_I16:
-        return "TType.I16";
-      case t_base_type::TYPE_I32:
-        return "TType.I32";
-      case t_base_type::TYPE_I64:
-        return "TType.I64";
-      case t_base_type::TYPE_DOUBLE:
-        return "TType.DOUBLE";
+    case t_base_type::TYPE_VOID:
+      throw "NO T_VOID CONSTRUCT";
+    case t_base_type::TYPE_STRING:
+      return "TType.STRING";
+    case t_base_type::TYPE_BOOL:
+      return "TType.BOOL";
+    case t_base_type::TYPE_BYTE:
+      return "TType.BYTE";
+    case t_base_type::TYPE_I16:
+      return "TType.I16";
+    case t_base_type::TYPE_I32:
+      return "TType.I32";
+    case t_base_type::TYPE_I64:
+      return "TType.I64";
+    case t_base_type::TYPE_DOUBLE:
+      return "TType.DOUBLE";
     }
   } else if (type->is_enum()) {
     return "TType.I32";