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 11:34:27 UTC

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

http://git-wip-us.apache.org/repos/asf/thrift/blob/240120c8/compiler/cpp/src/generate/t_c_glib_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index a97267e..dbebedb 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -38,7 +38,7 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n"; // avoid ostream << std::endl flushes
+static const string endl = "\n";  // avoid ostream << std::endl flushes
 
 /* forward declarations */
 string initial_caps_to_underscores(string name);
@@ -50,14 +50,15 @@ string to_lower_case(string name);
  * C code generator, using glib for C typing.
  */
 class t_c_glib_generator : public t_oop_generator {
-public:
+ public:
+
   /* constructor */
-  t_c_glib_generator(t_program* program,
-                     const map<string, string>& parsed_options,
-                     const string& option_string)
-    : t_oop_generator(program) {
-    (void)parsed_options;
-    (void)option_string;
+  t_c_glib_generator(t_program *program,
+                     const map<string, string> &parsed_options,
+                     const string &option_string) : t_oop_generator(program)
+  {
+    (void) parsed_options;
+    (void) option_string;
     /* set the output directory */
     this->out_dir_base_ = "gen-c_glib";
 
@@ -71,7 +72,7 @@ public:
       this->nspace_lc = "";
     } else {
       /* replace dots with underscores */
-      char* tmp = strdup(this->nspace.c_str());
+      char *tmp = strdup(this->nspace.c_str());
       for (unsigned int i = 0; i < strlen(tmp); i++) {
         if (tmp[i] == '.') {
           tmp[i] = '_';
@@ -100,14 +101,15 @@ public:
   void close_generator();
 
   /* generation functions */
-  void generate_typedef(t_typedef* ttypedef);
-  void generate_enum(t_enum* tenum);
-  void generate_consts(vector<t_const*> consts);
-  void generate_struct(t_struct* tstruct);
-  void generate_service(t_service* tservice);
-  void generate_xception(t_struct* tstruct);
-
-private:
+  void generate_typedef(t_typedef *ttypedef);
+  void generate_enum(t_enum *tenum);
+  void generate_consts(vector<t_const *> consts);
+  void generate_struct(t_struct *tstruct);
+  void generate_service(t_service *tservice);
+  void generate_xception(t_struct *tstruct);
+
+ private:
+
   /* file streams */
   ofstream f_types_;
   ofstream f_types_impl_;
@@ -121,87 +123,50 @@ private:
   string nspace_lc;
 
   /* helper functions */
-  bool is_complex_type(t_type* ttype);
-  string type_name(t_type* ttype, bool in_typedef = false, bool is_const = false);
-  string property_type_name(t_type* ttype, bool in_typedef = false, bool is_const = false);
-  string base_type_name(t_base_type* type);
-  string type_to_enum(t_type* type);
-  string constant_literal(t_type* type, t_const_value* value);
-  string constant_value(string name, t_type* type, t_const_value* value);
-  string function_signature(t_function* tfunction);
-  string argument_list(t_struct* tstruct);
-  string xception_list(t_struct* tstruct);
-  string declare_field(t_field* tfield,
-                       bool init = false,
-                       bool pointer = false,
-                       bool constant = false,
-                       bool reference = false);
-  void declare_local_variable(ofstream& out, t_type* ttype, string& base_name);
+  bool is_complex_type(t_type *ttype);
+  string type_name(t_type* ttype, bool in_typedef=false, bool is_const=false);
+  string property_type_name(t_type* ttype, bool in_typedef=false, bool is_const=false);
+  string base_type_name(t_base_type *type);
+  string type_to_enum(t_type *type);
+  string constant_literal(t_type *type, t_const_value *value);
+  string constant_value(string name, t_type *type, t_const_value *value);
+  string function_signature(t_function *tfunction);
+  string argument_list(t_struct *tstruct);
+  string xception_list(t_struct *tstruct);
+  string declare_field(t_field *tfield, bool init=false, bool pointer=false, bool constant=false, bool reference=false);
+  void declare_local_variable(ofstream &out, t_type *ttype, string &base_name);
 
   /* generation functions */
-  void generate_const_initializer(string name, t_type* type, t_const_value* value);
-  void generate_service_helpers(t_service* tservice);
-  void generate_service_client(t_service* tservice);
-  void generate_service_handler(t_service* tservice);
-  void generate_service_processor(t_service* tservice);
-  void generate_service_server(t_service* tservice);
-  void generate_object(t_struct* tstruct);
-  void generate_struct_writer(ofstream& out,
-                              t_struct* tstruct,
-                              string this_name,
-                              string this_get = "",
-                              bool is_function = true);
-  void generate_struct_reader(ofstream& out,
-                              t_struct* tstruct,
-                              string this_name,
-                              string this_get = "",
-                              bool is_function = true);
-
-  void generate_serialize_field(ofstream& out,
-                                t_field* tfield,
-                                string prefix,
-                                string suffix,
-                                int error_ret);
-  void generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix, int error_ret);
-  void generate_serialize_container(ofstream& out, t_type* ttype, string prefix, int error_ret);
-  void generate_serialize_map_element(ofstream& out,
-                                      t_map* tmap,
-                                      string key,
-                                      string value,
-                                      int error_ret);
-  void generate_serialize_set_element(ofstream& out, t_set* tset, string element, int error_ret);
-  void generate_serialize_list_element(ofstream& out,
-                                       t_list* tlist,
-                                       string list,
-                                       string index,
-                                       int error_ret);
-
-  void generate_deserialize_field(ofstream& out,
-                                  t_field* tfield,
-                                  string prefix,
-                                  string suffix,
-                                  int error_ret,
-                                  bool allocate = true);
-  void generate_deserialize_struct(ofstream& out,
-                                   t_struct* tstruct,
-                                   string prefix,
-                                   int error_ret,
-                                   bool allocate = true);
-  void generate_deserialize_container(ofstream& out, t_type* ttype, string prefix, int error_ret);
-  void generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix, int error_ret);
-  void generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix, int error_ret);
-  void generate_deserialize_list_element(ofstream& out,
-                                         t_list* tlist,
-                                         string prefix,
-                                         string index,
-                                         int error_ret);
-
-  string generate_new_hash_from_type(t_type* key, t_type* value);
-  string generate_new_array_from_type(t_type* ttype);
-
-  string generate_free_func_from_type(t_type* ttype);
-  string generate_hash_func_from_type(t_type* ttype);
-  string generate_cmp_func_from_type(t_type* ttype);
+  void generate_const_initializer(string name, t_type *type, t_const_value *value);
+  void generate_service_helpers(t_service *tservice);
+  void generate_service_client(t_service *tservice);
+  void generate_service_handler(t_service *tservice);
+  void generate_service_processor(t_service *tservice);
+  void generate_service_server(t_service *tservice);
+  void generate_object(t_struct *tstruct);
+  void generate_struct_writer(ofstream &out, t_struct *tstruct, string this_name, string this_get="", bool is_function=true);
+  void generate_struct_reader(ofstream &out, t_struct *tstruct, string this_name, string this_get="", bool is_function=true);
+
+  void generate_serialize_field(ofstream &out, t_field *tfield, string prefix, string suffix, int error_ret);
+  void generate_serialize_struct(ofstream &out, t_struct *tstruct, string prefix, int error_ret);
+  void generate_serialize_container(ofstream &out, t_type *ttype, string prefix, int error_ret);
+  void generate_serialize_map_element(ofstream &out, t_map *tmap, string key, string value, int error_ret);
+  void generate_serialize_set_element(ofstream &out, t_set *tset, string element, int error_ret);
+  void generate_serialize_list_element(ofstream &out, t_list *tlist, string list, string index, int error_ret);
+
+  void generate_deserialize_field(ofstream &out, t_field *tfield, string prefix, string suffix, int error_ret, bool allocate=true);
+  void generate_deserialize_struct(ofstream &out, t_struct *tstruct, string prefix, int error_ret, bool allocate=true);
+  void generate_deserialize_container(ofstream &out, t_type *ttype, string prefix, int error_ret);
+  void generate_deserialize_map_element(ofstream &out, t_map *tmap, string prefix, int error_ret);
+  void generate_deserialize_set_element(ofstream &out, t_set *tset, string prefix, int error_ret);
+  void generate_deserialize_list_element(ofstream &out, t_list *tlist, string prefix, string index, int error_ret);
+
+  string generate_new_hash_from_type(t_type * key, t_type * value);
+  string generate_new_array_from_type(t_type * ttype);
+
+  string generate_free_func_from_type(t_type * ttype);
+  string generate_hash_func_from_type(t_type * ttype);
+  string generate_cmp_func_from_type(t_type * ttype);
 };
 
 /**
@@ -217,9 +182,11 @@ void t_c_glib_generator::init_generator() {
   string program_name_lc = to_lower_case(program_name_u);
 
   /* create output files */
-  string f_types_name = get_out_dir() + this->nspace_lc + program_name_lc + "_types.h";
+  string f_types_name = get_out_dir() + this->nspace_lc
+                        + program_name_lc + "_types.h";
   f_types_.open(f_types_name.c_str());
-  string f_types_impl_name = get_out_dir() + this->nspace_lc + program_name_lc + "_types.c";
+  string f_types_impl_name = get_out_dir() + this->nspace_lc
+                             + program_name_lc + "_types.c";
   f_types_impl_.open(f_types_impl_name.c_str());
 
   /* add thrift boilerplate headers */
@@ -227,53 +194,70 @@ void t_c_glib_generator::init_generator() {
   f_types_impl_ << autogen_comment();
 
   /* include inclusion guard */
-  f_types_ << "#ifndef " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl << "#define "
-           << this->nspace_uc << program_name_uc << "_TYPES_H" << endl << endl;
+  f_types_ <<
+    "#ifndef " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl <<
+    "#define " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl <<
+    endl;
 
   /* include base types */
-  f_types_ << "/* base includes */" << endl << "#include <glib-object.h>" << endl
-           << "#include <thrift/c_glib/thrift_struct.h>" << endl
-           << "#include <thrift/c_glib/protocol/thrift_protocol.h>" << endl;
+  f_types_ <<
+    "/* base includes */" << endl <<
+    "#include <glib-object.h>" << endl <<
+    "#include <thrift/c_glib/thrift_struct.h>" << endl <<
+    "#include <thrift/c_glib/protocol/thrift_protocol.h>" << endl;
 
   /* include other thrift includes */
-  const vector<t_program*>& includes = program_->get_includes();
+  const vector<t_program *> &includes = program_->get_includes();
   for (size_t i = 0; i < includes.size(); ++i) {
-    f_types_ << "/* other thrift includes */" << endl << "#include \"" << this->nspace_lc
-             << initial_caps_to_underscores(includes[i]->get_name()) << "_types.h\"" << endl;
+    f_types_ <<
+      "/* other thrift includes */" << endl <<
+      "#include \"" << this->nspace_lc << initial_caps_to_underscores(includes[i]->get_name()) <<
+          "_types.h\"" << endl;
   }
   f_types_ << endl;
 
   /* include custom headers */
-  const vector<string>& c_includes = program_->get_c_includes();
+  const vector<string> &c_includes = program_->get_c_includes();
   f_types_ << "/* custom thrift includes */" << endl;
   for (size_t i = 0; i < c_includes.size(); ++i) {
     if (c_includes[i][0] == '<') {
-      f_types_ << "#include " << c_includes[i] << endl;
+      f_types_ <<
+        "#include " << c_includes[i] << endl;
     } else {
-      f_types_ << "#include \"" << c_includes[i] << "\"" << endl;
+      f_types_ <<
+        "#include \"" << c_includes[i] << "\"" << endl;
     }
   }
   f_types_ << endl;
 
   /* include math.h (for "INFINITY") in the implementation file, in case we
      encounter a struct with a member of type double */
-  f_types_impl_ << endl << "#include <math.h>" << endl;
+  f_types_impl_ <<
+    endl <<
+    "#include <math.h>" << endl;
 
   // include the types file
-  f_types_impl_ << endl << "#include \"" << this->nspace_lc << program_name_u << "_types.h\""
-                << endl << "#include <thrift/c_glib/thrift.h>" << endl << endl;
-
-  f_types_ << "/* begin types */" << endl << endl;
+  f_types_impl_ <<
+    endl <<
+    "#include \"" << this->nspace_lc << program_name_u <<
+        "_types.h\"" << endl <<
+    "#include <thrift/c_glib/thrift.h>" << endl <<
+    endl;
+
+  f_types_ <<
+    "/* begin types */" << endl << endl;
 }
 
 /**
  *  Finish up generation and close all file streams.
  */
 void t_c_glib_generator::close_generator() {
-  string program_name_uc = to_upper_case(initial_caps_to_underscores(program_name_));
+  string program_name_uc = to_upper_case
+    (initial_caps_to_underscores(program_name_));
 
   /* end the header inclusion guard */
-  f_types_ << "#endif /* " << this->nspace_uc << program_name_uc << "_TYPES_H */" << endl;
+  f_types_ <<
+    "#endif /* " << this->nspace_uc << program_name_uc << "_TYPES_H */" << endl;
 
   /* close output file */
   f_types_.close();
@@ -290,8 +274,10 @@ void t_c_glib_generator::close_generator() {
  * typedef GHashTable * ThriftSomeMap;
  */
 void t_c_glib_generator::generate_typedef(t_typedef* ttypedef) {
-  f_types_ << indent() << "typedef " << type_name(ttypedef->get_type(), true) << " " << this->nspace
-           << ttypedef->get_symbolic() << ";" << endl << endl;
+  f_types_ <<
+    indent() << "typedef " << type_name(ttypedef->get_type(), true) <<
+        " " << this->nspace << ttypedef->get_symbolic() << ";" << endl <<
+    endl;
 }
 
 /**
@@ -310,16 +296,17 @@ void t_c_glib_generator::generate_typedef(t_typedef* ttypedef) {
  * };
  * typedef enum _ThriftMyEnum ThriftMyEnum;
  */
-void t_c_glib_generator::generate_enum(t_enum* tenum) {
+void t_c_glib_generator::generate_enum(t_enum *tenum) {
   string name = tenum->get_name();
   string name_uc = to_upper_case(initial_caps_to_underscores(name));
 
-  f_types_ << indent() << "enum _" << this->nspace << name << " {" << endl;
+  f_types_ <<
+    indent() << "enum _" << this->nspace << name << " {" << endl;
 
   indent_up();
 
-  vector<t_enum_value*> constants = tenum->get_constants();
-  vector<t_enum_value*>::iterator c_iter;
+  vector<t_enum_value *> constants = tenum->get_constants();
+  vector<t_enum_value *>::iterator c_iter;
   bool first = true;
 
   /* output each of the enumeration elements */
@@ -330,28 +317,32 @@ void t_c_glib_generator::generate_enum(t_enum* tenum) {
       f_types_ << "," << endl;
     }
 
-    f_types_ << indent() << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name();
-    f_types_ << " = " << (*c_iter)->get_value();
+    f_types_ <<
+      indent() << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name();
+    f_types_ <<
+      " = " << (*c_iter)->get_value();
   }
 
   indent_down();
-  f_types_ << endl << "};" << endl << "typedef enum _" << this->nspace << name << " "
-           << this->nspace << name << ";" << endl << endl;
+  f_types_ <<
+    endl <<
+    "};" << endl <<
+    "typedef enum _" << this->nspace << name << " " << this->nspace << name << ";" << endl <<
+    endl;
 
   f_types_ << "/* return the name of the constant */" << endl;
   f_types_ << "const char *" << endl;
-  f_types_ << "toString_" << name << "(int value); " << endl << endl;
-  ;
+  f_types_ << "toString_"<<name<<"(int value); "<<endl<<endl;;
   f_types_impl_ << "/* return the name of the constant */" << endl;
   f_types_impl_ << "const char *" << endl;
-  f_types_impl_ << "toString_" << name << "(int value) " << endl;
+  f_types_impl_ << "toString_"<<name<<"(int value) "<<endl;
   f_types_impl_ << "{" << endl;
   f_types_impl_ << "  static __thread char buf[16] = {0};" << endl;
   f_types_impl_ << "  switch(value) {" << endl;
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
-    f_types_impl_ << "  case " << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name() << ":"
-                  << "return \"" << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name()
-                  << "\";" << endl;
+    f_types_impl_ << "  case " << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name()
+        << ":" << "return \"" << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name()
+        << "\";"<<endl;
   }
   f_types_impl_ << "  default: g_snprintf(buf, 16, \"%d\", value); return buf;" << endl;
   f_types_impl_ << "  }" << endl;
@@ -361,22 +352,23 @@ void t_c_glib_generator::generate_enum(t_enum* tenum) {
 /**
  * Generates Thrift constants in C code.
  */
-void t_c_glib_generator::generate_consts(vector<t_const*> consts) {
+void t_c_glib_generator::generate_consts (vector<t_const *> consts) {
   f_types_ << "/* constants */" << endl;
   f_types_impl_ << "/* constants */" << endl;
 
-  vector<t_const*>::iterator c_iter;
+  vector<t_const *>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     string name = (*c_iter)->get_name();
     string name_uc = to_upper_case(name);
     string name_lc = to_lower_case(name);
-    t_type* type = (*c_iter)->get_type();
-    t_const_value* value = (*c_iter)->get_value();
+    t_type *type = (*c_iter)->get_type();
+    t_const_value *value = (*c_iter)->get_value();
 
-    f_types_ << indent() << "#define " << this->nspace_uc << name_uc << " "
-             << constant_value(name_lc, type, value) << endl;
+    f_types_ <<
+      indent() << "#define " << this->nspace_uc << name_uc << " " <<
+          constant_value (name_lc, type, value) << endl;
 
-    generate_const_initializer(name_lc, type, value);
+    generate_const_initializer (name_lc, type, value);
   }
 
   f_types_ << endl;
@@ -404,7 +396,7 @@ void t_c_glib_generator::generate_consts(vector<t_const*> consts) {
  * typedef struct _ThriftBonk ThriftBonk
  * // ... additional GObject boilerplate ...
  */
-void t_c_glib_generator::generate_struct(t_struct* tstruct) {
+void t_c_glib_generator::generate_struct (t_struct *tstruct) {
   f_types_ << "/* struct " << tstruct->get_name() << " */" << endl;
   generate_object(tstruct);
 }
@@ -413,7 +405,7 @@ void t_c_glib_generator::generate_struct(t_struct* tstruct) {
  * Generate C code to represent Thrift services.  Creates a new GObject
  * which can be used to access the service.
  */
-void t_c_glib_generator::generate_service(t_service* tservice) {
+void t_c_glib_generator::generate_service (t_service *tservice) {
   string svcname_u = initial_caps_to_underscores(tservice->get_name());
   string svcname_uc = this->nspace_uc + to_upper_case(svcname_u);
   string filename = this->nspace_lc + to_lower_case(svcname_u);
@@ -426,22 +418,27 @@ void t_c_glib_generator::generate_service(t_service* tservice) {
   string program_name_lc = to_lower_case(program_name_u);
 
   // add header file boilerplate
-  f_header_ << autogen_comment();
+  f_header_ <<
+    autogen_comment();
 
   // add an inclusion guard
-  f_header_ << "#ifndef " << svcname_uc << "_H" << endl << "#define " << svcname_uc << "_H" << endl
-            << endl;
+  f_header_ <<
+    "#ifndef " << svcname_uc << "_H" << endl <<
+    "#define " << svcname_uc << "_H" << endl <<
+    endl;
 
   // add standard includes
-  f_header_ << "#include <thrift/c_glib/processor/thrift_dispatch_processor.h>" << endl << endl;
-  f_header_ << "#include \"" << this->nspace_lc << program_name_lc << "_types.h\"" << endl;
+  f_header_ <<
+    "#include <thrift/c_glib/processor/thrift_dispatch_processor.h>" << endl <<
+    endl;
+  f_header_ <<
+    "#include \"" << this->nspace_lc << program_name_lc << "_types.h\"" << endl;
 
   // if we are inheriting from another service, include its header
-  t_service* extends_service = tservice->get_extends();
+  t_service *extends_service = tservice->get_extends();
   if (extends_service != NULL) {
-    f_header_ << "#include \"" << this->nspace_lc
-              << to_lower_case(initial_caps_to_underscores(extends_service->get_name())) << ".h\""
-              << endl;
+    f_header_ <<
+      "#include \"" << this->nspace_lc << to_lower_case(initial_caps_to_underscores(extends_service->get_name())) << ".h\"" << endl;
   }
   f_header_ << endl;
 
@@ -450,24 +447,29 @@ void t_c_glib_generator::generate_service(t_service* tservice) {
   f_service_.open(f_service_name.c_str());
 
   // add the boilerplace header
-  f_service_ << autogen_comment();
+  f_service_ <<
+    autogen_comment();
 
   // include the headers
-  f_service_ << "#include <string.h>" << endl << "#include <thrift/c_glib/thrift.h>" << endl
-             << "#include <thrift/c_glib/thrift_application_exception.h>" << endl << "#include \""
-             << filename << ".h\"" << endl << endl;
+  f_service_ <<
+    "#include <string.h>" << endl <<
+    "#include <thrift/c_glib/thrift.h>" << endl <<
+    "#include <thrift/c_glib/thrift_application_exception.h>" << endl <<
+    "#include \"" << filename << ".h\"" << endl <<
+    endl;
 
   // generate the service-helper classes
-  generate_service_helpers(tservice);
+  generate_service_helpers (tservice);
 
   // generate the client objects
-  generate_service_client(tservice);
+  generate_service_client (tservice);
 
   // generate the server objects
-  generate_service_server(tservice);
+  generate_service_server (tservice);
 
   // end the header inclusion guard
-  f_header_ << "#endif /* " << svcname_uc << "_H */" << endl;
+  f_header_ <<
+    "#endif /* " << svcname_uc << "_H */" << endl;
 
   // close the files
   f_service_.close();
@@ -477,7 +479,7 @@ void t_c_glib_generator::generate_service(t_service* tservice) {
 /**
  *
  */
-void t_c_glib_generator::generate_xception(t_struct* tstruct) {
+void t_c_glib_generator::generate_xception (t_struct *tstruct) {
   string name = tstruct->get_name();
   string name_u = initial_caps_to_underscores(name);
   string name_lc = to_lower_case(name_u);
@@ -485,18 +487,29 @@ void t_c_glib_generator::generate_xception(t_struct* tstruct) {
 
   generate_object(tstruct);
 
-  f_types_ << "/* exception */" << endl << "typedef enum" << endl << "{" << endl << "  "
-           << this->nspace_uc << name_uc << "_ERROR_CODE," << endl << "} " << this->nspace << name
-           << "Error;" << endl << endl << "GQuark " << this->nspace_lc << name_lc
-           << "_error_quark (void);" << endl << "#define " << this->nspace_uc << name_uc
-           << "_ERROR (" << this->nspace_lc << name_lc << "_error_quark())" << endl << endl << endl;
-
-  f_types_impl_ << "/* define the GError domain for exceptions */" << endl << "#define "
-                << this->nspace_uc << name_uc << "_ERROR_DOMAIN \"" << this->nspace_lc << name_lc
-                << "_error_quark\"" << endl << "GQuark" << endl << this->nspace_lc << name_lc
-                << "_error_quark (void)" << endl << "{" << endl
-                << "  return g_quark_from_static_string (" << this->nspace_uc << name_uc
-                << "_ERROR_DOMAIN);" << endl << "}" << endl << endl;
+  f_types_ << "/* exception */" << endl <<
+    "typedef enum" << endl <<
+    "{" << endl <<
+    "  " << this->nspace_uc << name_uc << "_ERROR_CODE," << endl <<
+    "} " << this->nspace << name << "Error;" << endl <<
+    endl <<
+    "GQuark " << this->nspace_lc << name_lc << "_error_quark (void);" << endl <<
+    "#define " << this->nspace_uc << name_uc << "_ERROR (" <<
+      this->nspace_lc << name_lc << "_error_quark())" << endl <<
+    endl <<
+    endl;
+
+  f_types_impl_ <<
+    "/* define the GError domain for exceptions */" << endl <<
+    "#define " << this->nspace_uc << name_uc << "_ERROR_DOMAIN \"" <<
+        this->nspace_lc << name_lc << "_error_quark\"" << endl <<
+    "GQuark" << endl <<
+    this->nspace_lc << name_lc << "_error_quark (void)" << endl <<
+    "{" << endl <<
+    "  return g_quark_from_static_string (" << this->nspace_uc << name_uc <<
+        "_ERROR_DOMAIN);" << endl <<
+    "}" << endl <<
+    endl;
 }
 
 /********************
@@ -506,19 +519,22 @@ void t_c_glib_generator::generate_xception(t_struct* tstruct) {
 /**
  * Returns true if ttype is not a primitive.
  */
-bool t_c_glib_generator::is_complex_type(t_type* ttype) {
-  ttype = get_true_type(ttype);
+bool t_c_glib_generator::is_complex_type(t_type *ttype) {
+  ttype = get_true_type (ttype);
 
-  return ttype->is_container() || ttype->is_struct() || ttype->is_xception();
+  return ttype->is_container()
+         || ttype->is_struct()
+         || ttype->is_xception();
 }
 
+
 /**
  * Maps a Thrift t_type to a C type.
  */
-string t_c_glib_generator::type_name(t_type* ttype, bool in_typedef, bool is_const) {
-  (void)in_typedef;
+string t_c_glib_generator::type_name (t_type* ttype, bool in_typedef, bool is_const) {
+  (void) in_typedef;
   if (ttype->is_base_type()) {
-    string bname = base_type_name((t_base_type*)ttype);
+    string bname = base_type_name ((t_base_type *) ttype);
 
     if (is_const) {
       return "const " + bname;
@@ -530,7 +546,7 @@ string t_c_glib_generator::type_name(t_type* ttype, bool in_typedef, bool is_con
   if (ttype->is_container()) {
     string cname;
 
-    t_container* tcontainer = (t_container*)ttype;
+    t_container *tcontainer = (t_container *) ttype;
     if (tcontainer->has_cpp_name()) {
       cname = tcontainer->get_cpp_name();
     } else if (ttype->is_map()) {
@@ -544,24 +560,24 @@ string t_c_glib_generator::type_name(t_type* ttype, bool in_typedef, bool is_con
     } else if (ttype->is_list()) {
       // TODO: investigate other implementations besides GPtrArray
       cname = "GPtrArray *";
-      t_type* etype = ((t_list*)ttype)->get_elem_type();
+      t_type *etype = ((t_list *) ttype)->get_elem_type();
       if (etype->is_base_type()) {
-        t_base_type::t_base tbase = ((t_base_type*)etype)->get_base();
+        t_base_type::t_base tbase = ((t_base_type *) etype)->get_base();
         switch (tbase) {
-        case t_base_type::TYPE_VOID:
-          throw "compiler error: cannot determine array type";
-        case t_base_type::TYPE_BOOL:
-        case t_base_type::TYPE_BYTE:
-        case t_base_type::TYPE_I16:
-        case t_base_type::TYPE_I32:
-        case t_base_type::TYPE_I64:
-        case t_base_type::TYPE_DOUBLE:
-          cname = "GArray *";
-          break;
-        case t_base_type::TYPE_STRING:
-          break;
-        default:
-          throw "compiler error: no array info for type";
+          case t_base_type::TYPE_VOID:
+            throw "compiler error: cannot determine array type";
+          case t_base_type::TYPE_BOOL:
+          case t_base_type::TYPE_BYTE:
+          case t_base_type::TYPE_I16:
+          case t_base_type::TYPE_I32:
+          case t_base_type::TYPE_I64:
+          case t_base_type::TYPE_DOUBLE:
+            cname = "GArray *";
+            break;
+          case t_base_type::TYPE_STRING:
+            break;
+          default:
+            throw "compiler error: no array info for type";
         }
       }
     }
@@ -576,7 +592,7 @@ string t_c_glib_generator::type_name(t_type* ttype, bool in_typedef, bool is_con
   // check for a namespace
   string pname = this->nspace + ttype->get_name();
 
-  if (is_complex_type(ttype)) {
+  if (is_complex_type (ttype)) {
     pname += " *";
   }
 
@@ -595,23 +611,25 @@ string t_c_glib_generator::type_name(t_type* ttype, bool in_typedef, bool is_con
  * bits map to the same type, gint, as opposed to their width-specific type
  * (gint8, gint16 or gint32).
  */
-string t_c_glib_generator::property_type_name(t_type* ttype, bool in_typedef, bool is_const) {
+string t_c_glib_generator::property_type_name (t_type* ttype,
+                                               bool in_typedef,
+                                               bool is_const) {
   string result;
 
   if (ttype->is_base_type()) {
-    switch (((t_base_type*)ttype)->get_base()) {
-    case t_base_type::TYPE_BYTE:
-    case t_base_type::TYPE_I16:
-    case t_base_type::TYPE_I32:
-      if (is_const) {
-        result = "const gint";
-      } else {
-        result = "gint";
-      }
-      break;
+    switch (((t_base_type *) ttype)->get_base()) {
+      case t_base_type::TYPE_BYTE:
+      case t_base_type::TYPE_I16:
+      case t_base_type::TYPE_I32:
+        if (is_const) {
+          result = "const gint";
+        } else {
+          result = "gint";
+        }
+        break;
 
-    default:
-      result = type_name(ttype, in_typedef, is_const);
+      default:
+        result = type_name(ttype, in_typedef, is_const);
     }
   } else {
     result = type_name(ttype, in_typedef, is_const);
@@ -623,32 +641,33 @@ string t_c_glib_generator::property_type_name(t_type* ttype, bool in_typedef, bo
 /**
  * Maps a Thrift primitive to a C primitive.
  */
-string t_c_glib_generator::base_type_name(t_base_type* type) {
+string t_c_glib_generator::base_type_name(t_base_type *type) {
   t_base_type::t_base tbase = type->get_base();
 
   switch (tbase) {
-  case t_base_type::TYPE_VOID:
-    return "void";
-  case t_base_type::TYPE_STRING:
-    if (type->is_binary()) {
-      return "GByteArray *";
-    } else {
-      return "gchar *";
-    }
-  case t_base_type::TYPE_BOOL:
-    return "gboolean";
-  case t_base_type::TYPE_BYTE:
-    return "gint8";
-  case t_base_type::TYPE_I16:
-    return "gint16";
-  case t_base_type::TYPE_I32:
-    return "gint32";
-  case t_base_type::TYPE_I64:
-    return "gint64";
-  case t_base_type::TYPE_DOUBLE:
-    return "gdouble";
-  default:
-    throw "compiler error: no C base type name for base type " + t_base_type::t_base_name(tbase);
+    case t_base_type::TYPE_VOID:
+      return "void";
+    case t_base_type::TYPE_STRING:
+      if (type->is_binary()) {
+        return "GByteArray *";
+      } else {
+        return "gchar *";
+      }
+    case t_base_type::TYPE_BOOL:
+      return "gboolean";
+    case t_base_type::TYPE_BYTE:
+      return "gint8";
+    case t_base_type::TYPE_I16:
+      return "gint16";
+    case t_base_type::TYPE_I32:
+      return "gint32";
+    case t_base_type::TYPE_I64:
+      return "gint64";
+    case t_base_type::TYPE_DOUBLE:
+      return "gdouble";
+    default:
+      throw "compiler error: no C base type name for base type "
+            + t_base_type::t_base_name (tbase);
   }
 }
 
@@ -656,29 +675,29 @@ string t_c_glib_generator::base_type_name(t_base_type* type) {
  * Returns a member of the ThriftType C enumeration in thrift_protocol.h
  * for a Thrift type.
  */
-string t_c_glib_generator::type_to_enum(t_type* type) {
-  type = get_true_type(type);
+string t_c_glib_generator::type_to_enum (t_type *type) {
+  type = get_true_type (type);
 
   if (type->is_base_type()) {
-    t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
+    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 "T_STRING";
-    case t_base_type::TYPE_BOOL:
-      return "T_BOOL";
-    case t_base_type::TYPE_BYTE:
-      return "T_BYTE";
-    case t_base_type::TYPE_I16:
-      return "T_I16";
-    case t_base_type::TYPE_I32:
-      return "T_I32";
-    case t_base_type::TYPE_I64:
-      return "T_I64";
-    case t_base_type::TYPE_DOUBLE:
-      return "T_DOUBLE";
+      case t_base_type::TYPE_VOID:
+        throw "NO T_VOID CONSTRUCT";
+      case t_base_type::TYPE_STRING:
+        return "T_STRING";
+      case t_base_type::TYPE_BOOL:
+        return "T_BOOL";
+      case t_base_type::TYPE_BYTE:
+        return "T_BYTE";
+      case t_base_type::TYPE_I16:
+        return "T_I16";
+      case t_base_type::TYPE_I32:
+        return "T_I32";
+      case t_base_type::TYPE_I64:
+        return "T_I64";
+      case t_base_type::TYPE_DOUBLE:
+        return "T_DOUBLE";
     }
   } else if (type->is_enum()) {
     return "T_I32";
@@ -697,63 +716,65 @@ string t_c_glib_generator::type_to_enum(t_type* type) {
   throw "INVALID TYPE IN type_to_enum: " + type->get_name();
 }
 
+
 /**
  * Returns a Thrift constant formatted as a literal for inclusion in C code.
  */
-string t_c_glib_generator::constant_literal(t_type* type, t_const_value* value) {
+string t_c_glib_generator::constant_literal(t_type *type, t_const_value *value) {
   ostringstream render;
 
   if (type->is_base_type()) {
     /* primitives */
-    t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
+    t_base_type::t_base tbase = ((t_base_type *) type)->get_base();
 
     switch (tbase) {
-    case t_base_type::TYPE_STRING:
-      render << "\"" + value->get_string() + "\"";
-      break;
-    case t_base_type::TYPE_BOOL:
-      render << ((value->get_integer() != 0) ? "TRUE" : "FALSE");
-      break;
-    case t_base_type::TYPE_BYTE:
-    case t_base_type::TYPE_I16:
-    case t_base_type::TYPE_I32:
-    case t_base_type::TYPE_I64:
-      render << value->get_integer();
-      break;
-    case t_base_type::TYPE_DOUBLE:
-      render << value->get_double();
-      break;
-    default:
-      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
+      case t_base_type::TYPE_STRING:
+        render << "\"" + value->get_string() + "\"";
+        break;
+      case t_base_type::TYPE_BOOL:
+        render << ((value->get_integer() != 0) ? "TRUE" : "FALSE");
+        break;
+      case t_base_type::TYPE_BYTE:
+      case t_base_type::TYPE_I16:
+      case t_base_type::TYPE_I32:
+      case t_base_type::TYPE_I64:
+        render << value->get_integer();
+        break;
+      case t_base_type::TYPE_DOUBLE:
+        render << value->get_double();
+        break;
+      default:
+        throw "compiler error: no const of base type "
+              + t_base_type::t_base_name (tbase);
     }
   } else {
     t_const_value::t_const_value_type value_type = value->get_type();
 
     switch (value_type) {
-    case t_const_value::CV_IDENTIFIER:
-      render << value->get_integer();
-      break;
-    case t_const_value::CV_LIST:
-      render << "{ ";
-      {
-        t_type* elem_type = ((t_list*)type)->get_elem_type();
-        const vector<t_const_value*>& list = value->get_list();
-        vector<t_const_value*>::const_iterator list_iter;
-
-        if (list.size() > 0) {
-          list_iter = list.begin();
-          render << constant_literal(elem_type, *list_iter);
-
-          while (++list_iter != list.end()) {
-            render << ", " << constant_literal(elem_type, *list_iter);
+      case t_const_value::CV_IDENTIFIER:
+        render << value->get_integer();
+        break;
+      case t_const_value::CV_LIST:
+        render << "{ ";
+        {
+          t_type *elem_type = ((t_list *) type)->get_elem_type();
+          const vector<t_const_value *> &list = value->get_list();
+          vector<t_const_value *>::const_iterator list_iter;
+
+          if (list.size() > 0) {
+            list_iter = list.begin();
+            render << constant_literal(elem_type, *list_iter);
+
+            while (++list_iter != list.end()) {
+              render << ", " << constant_literal(elem_type, *list_iter);
+            }
           }
         }
-      }
-      render << " }";
-      break;
-    case t_const_value::CV_MAP:
-    default:
-      render << "NULL /* not supported */";
+        render << " }";
+        break;
+      case t_const_value::CV_MAP:
+      default:
+        render << "NULL /* not supported */";
     }
   }
 
@@ -763,40 +784,42 @@ string t_c_glib_generator::constant_literal(t_type* type, t_const_value* value)
 /**
  * Returns C code that represents a Thrift constant.
  */
-string t_c_glib_generator::constant_value(string name, t_type* type, t_const_value* value) {
+string t_c_glib_generator::constant_value(string name, t_type *type, t_const_value *value) {
   ostringstream render;
 
   if (type->is_base_type()) {
     /* primitives */
-    t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
+    t_base_type::t_base tbase = ((t_base_type *) type)->get_base();
     switch (tbase) {
-    case t_base_type::TYPE_STRING:
-      render << "g_strdup (\"" + value->get_string() + "\")";
-      break;
-    case t_base_type::TYPE_BOOL:
-      render << ((value->get_integer() != 0) ? 1 : 0);
-      break;
-    case t_base_type::TYPE_BYTE:
-    case t_base_type::TYPE_I16:
-    case t_base_type::TYPE_I32:
-    case t_base_type::TYPE_I64:
-      render << value->get_integer();
-      break;
-    case t_base_type::TYPE_DOUBLE:
-      if (value->get_type() == t_const_value::CV_INTEGER) {
+      case t_base_type::TYPE_STRING:
+        render << "g_strdup (\"" + value->get_string() + "\")";
+        break;
+      case t_base_type::TYPE_BOOL:
+        render << ((value->get_integer() != 0) ? 1 : 0);
+        break;
+      case t_base_type::TYPE_BYTE:
+      case t_base_type::TYPE_I16:
+      case t_base_type::TYPE_I32:
+      case t_base_type::TYPE_I64:
         render << value->get_integer();
-      } else {
-        render << value->get_double();
-      }
-      break;
-    default:
-      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
+        break;
+      case t_base_type::TYPE_DOUBLE:
+        if (value->get_type() == t_const_value::CV_INTEGER) {
+          render << value->get_integer();
+        } else {
+          render << value->get_double();
+        }
+        break;
+      default:
+        throw "compiler error: no const of base type "
+              + t_base_type::t_base_name (tbase);
     }
   } else if (type->is_enum()) {
-    render << "(" << type_name(type) << ")" << value->get_integer();
-  } else if (type->is_struct() || type->is_xception() || type->is_list() || type->is_set()
-             || type->is_map()) {
-    render << "(" << this->nspace_lc << to_lower_case(name) << "_constant())";
+    render << "(" << type_name (type) << ")" << value->get_integer();
+  } else if (type->is_struct() || type->is_xception() || type->is_list()
+             || type->is_set() || type->is_map()) {
+    render << "(" << this->nspace_lc <<
+      to_lower_case(name) << "_constant())";
   } else {
     render << "NULL /* not supported */";
   }
@@ -819,10 +842,13 @@ string t_c_glib_generator::function_signature(t_function* tfunction) {
   bool has_return = !ttype->is_void();
   bool has_args = arglist->get_members().size() == 0;
   bool has_xceptions = xlist->get_members().size() == 0;
-  return "gboolean " + this->nspace_lc + fname + " (" + this->nspace + service_name_ + "If * iface"
-         + (has_return ? ", " + type_name(ttype) + "* _return" : "")
-         + (has_args ? "" : (", " + argument_list(arglist)))
-         + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError ** error)";
+  return
+    "gboolean " + this->nspace_lc + fname + " (" + this->nspace
+    + service_name_ + "If * iface"
+    + (has_return ? ", " + type_name(ttype) + "* _return" : "")
+    + (has_args ? "" : (", " + argument_list (arglist)))
+    + (has_xceptions ? "" : (", " + xception_list (xlist)))
+    + ", GError ** error)";
 }
 
 /**
@@ -831,7 +857,7 @@ string t_c_glib_generator::function_signature(t_function* tfunction) {
  * @param tstruct The struct definition
  * @return Comma sepearated list of all field names in that struct
  */
-string t_c_glib_generator::argument_list(t_struct* tstruct) {
+string t_c_glib_generator::argument_list (t_struct* tstruct) {
   string result = "";
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -843,7 +869,8 @@ string t_c_glib_generator::argument_list(t_struct* tstruct) {
     } else {
       result += ", ";
     }
-    result += type_name((*f_iter)->get_type(), false, true) + " " + (*f_iter)->get_name();
+    result += type_name((*f_iter)->get_type(), false, true) + " " +
+              (*f_iter)->get_name();
   }
   return result;
 }
@@ -854,7 +881,7 @@ string t_c_glib_generator::argument_list(t_struct* tstruct) {
  * @param tstruct The struct definition
  * @return Comma sepearated list of all field names in that struct
  */
-string t_c_glib_generator::xception_list(t_struct* tstruct) {
+string t_c_glib_generator::xception_list (t_struct* tstruct) {
   string result = "";
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -866,15 +893,17 @@ string t_c_glib_generator::xception_list(t_struct* tstruct) {
     } else {
       result += ", ";
     }
-    result += type_name((*f_iter)->get_type(), false, false) + "* " + (*f_iter)->get_name();
+    result += type_name((*f_iter)->get_type(), false, false) + "* " +
+              (*f_iter)->get_name();
   }
   return result;
 }
 
+
 /**
  * Declares a field, including any necessary initialization.
  */
-string t_c_glib_generator::declare_field(t_field* tfield,
+string t_c_glib_generator::declare_field(t_field *tfield,
                                          bool init,
                                          bool pointer,
                                          bool constant,
@@ -895,28 +924,29 @@ string t_c_glib_generator::declare_field(t_field* tfield,
     t_type* type = get_true_type(tfield->get_type());
 
     if (type->is_base_type()) {
-      t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
+      t_base_type::t_base tbase = ((t_base_type *) type)->get_base();
       switch (tbase) {
-      case t_base_type::TYPE_VOID:
-        break;
-      case t_base_type::TYPE_BOOL:
-      case t_base_type::TYPE_BYTE:
-      case t_base_type::TYPE_I16:
-      case t_base_type::TYPE_I32:
-      case t_base_type::TYPE_I64:
-        result += " = 0";
-        break;
-      case t_base_type::TYPE_DOUBLE:
-        result += " = (gdouble) 0";
-        break;
-      case t_base_type::TYPE_STRING:
-        result += " = NULL";
-        break;
-      default:
-        throw "compiler error: no C intializer for base type " + t_base_type::t_base_name(tbase);
+        case t_base_type::TYPE_VOID:
+          break;
+        case t_base_type::TYPE_BOOL:
+        case t_base_type::TYPE_BYTE:
+        case t_base_type::TYPE_I16:
+        case t_base_type::TYPE_I32:
+        case t_base_type::TYPE_I64:
+          result += " = 0";
+          break;
+        case t_base_type::TYPE_DOUBLE:
+          result += " = (gdouble) 0";
+          break;
+        case t_base_type::TYPE_STRING:
+          result += " = NULL";
+          break;
+        default:
+          throw "compiler error: no C intializer for base type "
+                + t_base_type::t_base_name (tbase);
       }
     } else if (type->is_enum()) {
-      result += " = (" + type_name(type) + ") 0";
+      result += " = (" + type_name (type) + ") 0";
     } else if (type->is_struct() || type->is_container()) {
       result += " = NULL";
     }
@@ -932,24 +962,22 @@ string t_c_glib_generator::declare_field(t_field* tfield,
 /**
  * Generates C code that initializes complex constants.
  */
-void t_c_glib_generator::generate_const_initializer(string name,
-                                                    t_type* type,
-                                                    t_const_value* value) {
+void t_c_glib_generator::generate_const_initializer(string name, t_type *type, t_const_value *value) {
   string name_u = initial_caps_to_underscores(name);
   string name_lc = to_lower_case(name_u);
   string type_u = initial_caps_to_underscores(type->get_name());
   string type_uc = to_upper_case(type_u);
 
   if (type->is_struct() || type->is_xception()) {
-    const vector<t_field*>& fields = ((t_struct*)type)->get_members();
-    vector<t_field*>::const_iterator f_iter;
-    const map<t_const_value*, t_const_value*>& val = value->get_map();
-    map<t_const_value*, t_const_value*>::const_iterator v_iter;
+    const vector<t_field *> &fields = ((t_struct *) type)->get_members();
+    vector<t_field *>::const_iterator f_iter;
+    const map<t_const_value *, t_const_value *> &val = value->get_map();
+    map<t_const_value *, t_const_value *>::const_iterator v_iter;
     ostringstream initializers;
 
     // initialize any constants that may be referenced by this initializer
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      t_type* field_type = NULL;
+      t_type *field_type = NULL;
       string field_name = "";
 
       for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -959,25 +987,37 @@ void t_c_glib_generator::generate_const_initializer(string name,
         }
       }
       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();
       }
-      field_name = tmp(field_name);
-
-      generate_const_initializer(name + "_constant_" + field_name, field_type, v_iter->second);
-      initializers << "    constant->" << v_iter->first->get_string() << " = "
-                   << constant_value(name + "_constant_" + field_name, field_type, v_iter->second)
-                   << ";" << endl << "    constant->__isset_" << v_iter->first->get_string()
-                   << " = TRUE;" << endl;
+      field_name = tmp (field_name);
+
+      generate_const_initializer (name + "_constant_" + field_name,
+                                  field_type, v_iter->second);
+      initializers <<
+        "    constant->" << v_iter->first->get_string() << " = " <<
+        constant_value (name + "_constant_" + field_name,
+                        field_type, v_iter->second) << ";" << endl <<
+        "    constant->__isset_" << v_iter->first->get_string() <<
+        " = TRUE;" << endl;
     }
 
     // implement the initializer
-    f_types_impl_ << "static " << this->nspace << type->get_name() << " *" << endl
-                  << this->nspace_lc << name_lc << "_constant (void)" << endl << "{" << endl
-                  << "  static " << this->nspace << type->get_name() << " *constant = NULL;" << endl
-                  << "  if (constant == NULL)" << endl << "  {" << endl
-                  << "    constant = g_object_new (" << this->nspace_uc << "TYPE_" << type_uc
-                  << ", NULL);" << endl << initializers.str() << endl << "  }" << endl
-                  << "  return constant;" << endl << "}" << endl << endl;
+    f_types_impl_ <<
+      "static " << this->nspace << type->get_name() << " *" << endl <<
+      this->nspace_lc << name_lc << "_constant (void)" << endl <<
+      "{" << endl <<
+      "  static " << this->nspace << type->get_name() <<
+          " *constant = NULL;" << endl <<
+      "  if (constant == NULL)" << endl <<
+      "  {" << endl <<
+      "    constant = g_object_new (" << this->nspace_uc << "TYPE_" <<
+          type_uc << ", NULL);" << endl <<
+      initializers.str() << endl <<
+      "  }" << endl <<
+      "  return constant;" << endl <<
+      "}" << endl <<
+      endl;
   } else if (type->is_list()) {
     string list_type = "GPtrArray *";
     // TODO: This initialization should contain a free function for container
@@ -990,99 +1030,126 @@ void t_c_glib_generator::generate_const_initializer(string name,
     vector<t_const_value*>::const_iterator v_iter;
     ostringstream initializers;
 
-    list_initializer = generate_new_array_from_type(etype);
+    list_initializer = generate_new_array_from_type (etype);
     if (etype->is_base_type()) {
-      t_base_type::t_base tbase = ((t_base_type*)etype)->get_base();
+      t_base_type::t_base tbase = ((t_base_type *) etype)->get_base();
       switch (tbase) {
-      case t_base_type::TYPE_VOID:
-        throw "compiler error: cannot determine array type";
-      case t_base_type::TYPE_BOOL:
-      case t_base_type::TYPE_BYTE:
-      case t_base_type::TYPE_I16:
-      case t_base_type::TYPE_I32:
-      case t_base_type::TYPE_I64:
-      case t_base_type::TYPE_DOUBLE:
-        list_type = "GArray *";
-        list_appender = "g_array_append_val";
-        list_variable = true;
-        break;
-      case t_base_type::TYPE_STRING:
-        break;
-      default:
-        throw "compiler error: no array info for type";
+        case t_base_type::TYPE_VOID:
+          throw "compiler error: cannot determine array type";
+        case t_base_type::TYPE_BOOL:
+        case t_base_type::TYPE_BYTE:
+        case t_base_type::TYPE_I16:
+        case t_base_type::TYPE_I32:
+        case t_base_type::TYPE_I64:
+        case t_base_type::TYPE_DOUBLE:
+          list_type = "GArray *";
+          list_appender = "g_array_append_val";
+          list_variable = true;
+          break;
+        case t_base_type::TYPE_STRING:
+          break;
+        default:
+          throw "compiler error: no array info for type";
       }
     }
 
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      string fname = tmp(name);
+      string fname = tmp (name);
 
-      generate_const_initializer(fname, etype, (*v_iter));
+      generate_const_initializer (fname, etype, (*v_iter));
       if (list_variable) {
-        initializers << "    " << type_name(etype) << " " << fname << " = "
-                     << constant_value(fname, (t_type*)etype, (*v_iter)) << ";" << endl << "    "
-                     << list_appender << "(constant, " << fname << ");" << endl;
+        initializers <<
+          "    " << type_name (etype) << " " << fname << " = " <<
+            constant_value (fname, (t_type *) etype, (*v_iter)) << ";" <<
+                endl <<
+          "    " << list_appender << "(constant, " << fname << ");" << endl;
       } else {
-        initializers << "    " << list_appender << "(constant, "
-                     << constant_value(fname, (t_type*)etype, (*v_iter)) << ");" << endl;
+        initializers <<
+          "    " << list_appender << "(constant, " <<
+          constant_value (fname, (t_type *) etype, (*v_iter)) << ");" << endl;
       }
     }
 
-    f_types_impl_ << "static " << list_type << endl << this->nspace_lc << name_lc
-                  << "_constant (void)" << endl << "{" << endl << "  static " << list_type
-                  << " constant = NULL;" << endl << "  if (constant == NULL)" << endl << "  {"
-                  << endl << "    constant = " << list_initializer << endl << initializers.str()
-                  << endl << "  }" << endl << "  return constant;" << endl << "}" << endl << endl;
+    f_types_impl_ <<
+      "static " << list_type << endl <<
+      this->nspace_lc << name_lc << "_constant (void)" << endl <<
+      "{" << endl <<
+      "  static " << list_type << " constant = NULL;" << endl <<
+      "  if (constant == NULL)" << endl <<
+      "  {" << endl <<
+      "    constant = " << list_initializer << endl <<
+      initializers.str() << endl <<
+      "  }" << endl <<
+      "  return constant;" << endl <<
+      "}" << endl <<
+    endl;
   } else if (type->is_set()) {
-    t_type* etype = ((t_set*)type)->get_elem_type();
-    const vector<t_const_value*>& val = value->get_list();
+    t_type *etype = ((t_set *) type)->get_elem_type();
+    const vector<t_const_value *>& val = value->get_list();
     vector<t_const_value*>::const_iterator v_iter;
     ostringstream initializers;
 
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      string fname = tmp(name);
-      generate_const_initializer(fname, etype, (*v_iter));
-      initializers << "    " << type_name(etype) << " " << fname << " = "
-                   << constant_value(fname, (t_type*)etype, (*v_iter)) << ";" << endl
-                   << "    g_hash_table_insert (constant, &" << fname << ", &" << fname << ");"
-                   << endl;
+      string fname = tmp (name);
+      generate_const_initializer (fname, etype, (*v_iter));
+      initializers <<
+        "    " << type_name (etype) << " " << fname << " = " <<
+          constant_value (fname, (t_type *) etype, (*v_iter)) << ";" << endl <<
+        "    g_hash_table_insert (constant, &" << fname << ", &" << fname <<
+        ");" << endl;
     }
 
-    f_types_impl_ << "static GHashTable *" << endl << this->nspace_lc << name_lc
-                  << "_constant (void)" << endl << "{" << endl
-                  << "  static GHashTable *constant = NULL;" << endl << "  if (constant == NULL)"
-                  << endl << "  {" << endl <<
-        // TODO: This initialization should contain a free function for elements
-        "    constant = g_hash_table_new (NULL, NULL);" << endl << initializers.str() << endl
-                  << "  }" << endl << "  return constant;" << endl << "}" << endl << endl;
+    f_types_impl_ <<
+      "static GHashTable *" << endl <<
+      this->nspace_lc << name_lc << "_constant (void)" << endl <<
+      "{" << endl <<
+      "  static GHashTable *constant = NULL;" << endl <<
+      "  if (constant == NULL)" << endl <<
+      "  {" << endl <<
+      // TODO: This initialization should contain a free function for elements
+      "    constant = g_hash_table_new (NULL, NULL);" << endl <<
+      initializers.str() << endl <<
+      "  }" << endl <<
+      "  return constant;" << endl <<
+      "}" << endl <<
+    endl;
   } else if (type->is_map()) {
-    t_type* ktype = ((t_map*)type)->get_key_type();
-    t_type* vtype = ((t_map*)type)->get_val_type();
-    const vector<t_const_value*>& val = value->get_list();
+    t_type *ktype = ((t_map *) type)->get_key_type();
+    t_type *vtype = ((t_map *) type)->get_val_type();
+    const vector<t_const_value *>& val = value->get_list();
     vector<t_const_value*>::const_iterator v_iter;
     ostringstream initializers;
 
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      string fname = tmp(name);
+      string fname = tmp (name);
       string kname = fname + "key";
       string vname = fname + "val";
-      generate_const_initializer(kname, ktype, (*v_iter));
-      generate_const_initializer(vname, vtype, (*v_iter));
-
-      initializers << "    " << type_name(ktype) << " " << kname << " = "
-                   << constant_value(kname, (t_type*)ktype, (*v_iter)) << ";" << endl << "    "
-                   << type_name(vtype) << " " << vname << " = "
-                   << constant_value(vname, (t_type*)vtype, (*v_iter)) << ";" << endl
-                   << "    g_hash_table_insert (constant, &" << fname << ", &" << fname << ");"
-                   << endl;
+      generate_const_initializer (kname, ktype, (*v_iter));
+      generate_const_initializer (vname, vtype, (*v_iter));
+
+      initializers <<
+        "    " << type_name (ktype) << " " << kname << " = " <<
+          constant_value (kname, (t_type *) ktype, (*v_iter)) << ";" << endl <<
+        "    " << type_name (vtype) << " " << vname << " = " <<
+          constant_value (vname, (t_type *) vtype, (*v_iter)) << ";" << endl <<
+        "    g_hash_table_insert (constant, &" << fname << ", &" << fname <<
+        ");" << endl;
     }
 
-    f_types_impl_ << "static GHashTable *" << endl << this->nspace_lc << name_lc
-                  << "_constant (void)" << endl << "{" << endl
-                  << "  static GHashTable *constant = NULL;" << endl << "  if (constant == NULL)"
-                  << endl << "  {" << endl <<
-        // TODO: This initialization should contain a free function for elements
-        "    constant = g_hash_table_new (NULL, NULL);" << endl << initializers.str() << endl
-                  << "  }" << endl << "  return constant;" << endl << "}" << endl << endl;
+    f_types_impl_ <<
+      "static GHashTable *" << endl <<
+      this->nspace_lc << name_lc << "_constant (void)" << endl <<
+      "{" << endl <<
+      "  static GHashTable *constant = NULL;" << endl <<
+      "  if (constant == NULL)" << endl <<
+      "  {" << endl <<
+      // TODO: This initialization should contain a free function for elements
+      "    constant = g_hash_table_new (NULL, NULL);" << endl <<
+      initializers.str() << endl <<
+      "  }" << endl <<
+      "  return constant;" << endl <<
+      "}" << endl <<
+    endl;
   }
 }
 
@@ -1092,18 +1159,22 @@ void t_c_glib_generator::generate_const_initializer(string name,
  *
  * @param tservice The service for which to generate helper classes
  */
-void t_c_glib_generator::generate_service_helpers(t_service* tservice) {
+void t_c_glib_generator::generate_service_helpers(t_service *tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator function_iter;
 
   // Iterate through the service's methods
-  for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
+  for (function_iter = functions.begin();
+       function_iter != functions.end();
+       ++function_iter) {
     string function_name = (*function_iter)->get_name();
-    t_struct* arg_list = (*function_iter)->get_arglist();
+    t_struct *arg_list = (*function_iter)->get_arglist();
     string arg_list_name_orig = arg_list->get_name();
 
     // Generate the arguments class
-    arg_list->set_name(tservice->get_name() + underscores_to_initial_caps(function_name) + "Args");
+    arg_list->set_name(tservice->get_name() +
+                       underscores_to_initial_caps(function_name) +
+                       "Args");
     generate_struct(arg_list);
 
     arg_list->set_name(arg_list_name_orig);
@@ -1111,7 +1182,9 @@ void t_c_glib_generator::generate_service_helpers(t_service* tservice) {
     // Generate the result class
     if (!(*function_iter)->is_oneway()) {
       t_struct result(program_,
-                      tservice->get_name() + underscores_to_initial_caps(function_name) + "Result");
+                      tservice->get_name() +
+                      underscores_to_initial_caps(function_name) +
+                      "Result");
       t_field success((*function_iter)->get_returntype(), "success", 0);
       success.set_req(t_field::T_OPTIONAL);
       if (!(*function_iter)->get_returntype()->is_void()) {
@@ -1121,7 +1194,9 @@ void t_c_glib_generator::generate_service_helpers(t_service* tservice) {
       t_struct* xs = (*function_iter)->get_xceptions();
       const vector<t_field*>& fields = xs->get_members();
       vector<t_field*>::const_iterator field_iter;
-      for (field_iter = fields.begin(); field_iter != fields.end(); ++field_iter) {
+      for (field_iter = fields.begin();
+           field_iter != fields.end();
+           ++field_iter) {
         (*field_iter)->set_req(t_field::T_OPTIONAL);
         result.append(*field_iter);
       }
@@ -1134,7 +1209,7 @@ void t_c_glib_generator::generate_service_helpers(t_service* tservice) {
 /**
  * Generates C code that represents a Thrift service client.
  */
-void t_c_glib_generator::generate_service_client(t_service* tservice) {
+void t_c_glib_generator::generate_service_client(t_service *tservice) {
   /* get some C friendly service names */
   string service_name_lc = to_lower_case(initial_caps_to_underscores(service_name_));
   string service_name_uc = to_upper_case(service_name_lc);
@@ -1148,38 +1223,47 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) {
 
   // The service this service extends, or NULL if it extends no
   // service
-  t_service* extends_service = tservice->get_extends();
+  t_service *extends_service = tservice->get_extends();
   if (extends_service) {
     // The name of the parent service
     parent_service_name = extends_service->get_name();
-    parent_service_name_lc = to_lower_case(initial_caps_to_underscores(parent_service_name));
+    parent_service_name_lc =
+      to_lower_case(initial_caps_to_underscores(parent_service_name));
     parent_service_name_uc = to_upper_case(parent_service_name_lc);
 
     // The names of the client class' parent class and type
     parent_class_name = this->nspace + parent_service_name + "Client";
-    parent_type_name = this->nspace_uc + "TYPE_" + parent_service_name_uc + "_CLIENT";
+    parent_type_name =
+      this->nspace_uc + "TYPE_" + parent_service_name_uc + "_CLIENT";
   }
 
   // The base service (the topmost in the "extends" hierarchy), on
   // whose client class the "input_protocol" and "output_protocol"
   // properties are defined
-  t_service* base_service = tservice;
+  t_service *base_service = tservice;
   while (base_service->get_extends()) {
     base_service = base_service->get_extends();
   }
 
   string base_service_name = base_service->get_name();
-  string base_service_name_lc = to_lower_case(initial_caps_to_underscores(base_service_name));
+  string base_service_name_lc =
+    to_lower_case(initial_caps_to_underscores(base_service_name));
   string base_service_name_uc = to_upper_case(base_service_name_lc);
 
   // Generate the client interface dummy object in the header.
-  f_header_ << "/* " << service_name_ << " service interface */" << endl << "typedef struct _"
-            << this->nspace << service_name_ << "If " << this->nspace << service_name_ << "If; "
-            << " /* dummy object */" << endl << endl;
+  f_header_ <<
+    "/* " << service_name_ << " service interface */" << endl <<
+    "typedef struct _" << this->nspace << service_name_ << "If " <<
+        this->nspace << service_name_ << "If; " <<
+        " /* dummy object */" << endl <<
+    endl;
 
   // Generate the client interface object in the header.
-  f_header_ << "struct _" << this->nspace << service_name_ << "IfInterface" << endl << "{" << endl
-            << "  GTypeInterface parent;" << endl << endl;
+  f_header_ <<
+    "struct _" << this->nspace << service_name_ << "IfInterface" << endl <<
+    "{" << endl <<
+    "  GTypeInterface parent;" << endl <<
+  endl;
 
   /* write out the functions for this interface */
   indent_up();
@@ -1188,135 +1272,163 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) {
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     /* make the function name C friendly */
     string funname = initial_caps_to_underscores((*f_iter)->get_name());
-    t_type* ttype = (*f_iter)->get_returntype();
-    t_struct* arglist = (*f_iter)->get_arglist();
-    t_struct* xlist = (*f_iter)->get_xceptions();
+    t_type *ttype = (*f_iter)->get_returntype();
+    t_struct *arglist = (*f_iter)->get_arglist();
+    t_struct *xlist = (*f_iter)->get_xceptions();
     bool has_return = !ttype->is_void();
     bool has_args = arglist->get_members().size() == 0;
     bool has_xceptions = xlist->get_members().size() == 0;
 
     string params = "(" + this->nspace + service_name_ + "If *iface"
-                    + (has_return ? ", " + type_name(ttype) + "* _return" : "")
-                    + (has_args ? "" : (", " + argument_list(arglist)))
-                    + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)";
+                    + (has_return ? ", " + type_name (ttype) + "* _return" : "")
+                    + (has_args ? "" : (", " + argument_list (arglist)))
+                    + (has_xceptions ? "" : (", " + xception_list (xlist)))
+                    + ", GError **error)";
 
-    indent(f_header_) << "gboolean (*" << funname << ") " << params << ";" << endl;
+    indent(f_header_) << "gboolean (*" << funname << ") " << params << ";" <<
+                          endl;
   }
   indent_down();
 
-  f_header_ << "};" << endl << "typedef struct _" << this->nspace << service_name_ << "IfInterface "
-            << this->nspace << service_name_ << "IfInterface;" << endl << endl;
+  f_header_ <<
+    "};" << endl <<
+    "typedef struct _" << this->nspace << service_name_ << "IfInterface " <<
+        this->nspace << service_name_ << "IfInterface;" << endl <<
+    endl;
 
   // generate all the interface boilerplate
-  f_header_ << "GType " << this->nspace_lc << service_name_lc << "_if_get_type (void);" << endl
-            << "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_IF "
-            << "(" << this->nspace_lc << service_name_lc << "_if_get_type())" << endl << "#define "
-            << this->nspace_uc << service_name_uc << "_IF(obj) "
-            << "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_"
-            << service_name_uc << "_IF, " << this->nspace << service_name_ << "If))" << endl
-            << "#define " << this->nspace_uc << "IS_" << service_name_uc << "_IF(obj) "
-            << "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_"
-            << service_name_uc << "_IF))" << endl << "#define " << this->nspace_uc
-            << service_name_uc << "_IF_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), "
-            << this->nspace_uc << "TYPE_" << service_name_uc << "_IF, " << this->nspace
-            << service_name_ << "IfInterface))" << endl << endl;
+  f_header_ <<
+    "GType " << this->nspace_lc << service_name_lc <<
+        "_if_get_type (void);" << endl <<
+    "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_IF " <<
+        "(" << this->nspace_lc << service_name_lc << "_if_get_type())" <<
+        endl <<
+    "#define " << this->nspace_uc << service_name_uc << "_IF(obj) " <<
+        "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " <<
+        this->nspace_uc << "TYPE_" << service_name_uc << "_IF, " <<
+        this->nspace << service_name_ << "If))" << endl <<
+    "#define " << this->nspace_uc << "IS_" << service_name_uc << "_IF(obj) " <<
+        "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " <<
+        this->nspace_uc << "TYPE_" << service_name_uc << "_IF))" << endl <<
+    "#define " << this->nspace_uc << service_name_uc <<
+        "_IF_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), " <<
+        this->nspace_uc << "TYPE_" << service_name_uc << "_IF, " <<
+        this->nspace << service_name_ << "IfInterface))" << endl <<
+    endl;
 
   // write out all the interface function prototypes
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     /* make the function name C friendly */
     string funname = initial_caps_to_underscores((*f_iter)->get_name());
-    t_type* ttype = (*f_iter)->get_returntype();
-    t_struct* arglist = (*f_iter)->get_arglist();
-    t_struct* xlist = (*f_iter)->get_xceptions();
+    t_type *ttype = (*f_iter)->get_returntype();
+    t_struct *arglist = (*f_iter)->get_arglist();
+    t_struct *xlist = (*f_iter)->get_xceptions();
     bool has_return = !ttype->is_void();
     bool has_args = arglist->get_members().size() == 0;
     bool has_xceptions = xlist->get_members().size() == 0;
 
     string params = "(" + this->nspace + service_name_ + "If *iface"
-                    + (has_return ? ", " + type_name(ttype) + "* _return" : "")
-                    + (has_args ? "" : (", " + argument_list(arglist)))
-                    + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)";
+                    + (has_return ? ", " + type_name (ttype) + "* _return" : "")
+                    + (has_args ? "" : (", " + argument_list (arglist)))
+                    + (has_xceptions ? "" : (", " + xception_list (xlist)))
+                    + ", GError **error)";
 
-    f_header_ << "gboolean " << this->nspace_lc << service_name_lc << "_if_" << funname << " "
-              << params << ";" << endl;
+    f_header_ << "gboolean " << this->nspace_lc << service_name_lc <<
+                 "_if_" << funname << " " << params << ";" << endl;
   }
   f_header_ << endl;
 
   // Generate the client object instance definition in the header.
-  f_header_ << "/* " << service_name_ << " service client */" << endl << "struct _" << this->nspace
-            << service_name_ << "Client" << endl << "{" << endl << "  " << parent_class_name
-            << " parent;" << endl;
+  f_header_ <<
+    "/* " << service_name_ << " service client */" << endl <<
+    "struct _" << this->nspace << service_name_ << "Client" << endl <<
+    "{" << endl <<
+    "  " << parent_class_name << " parent;" << endl;
   if (!extends_service) {
     // Define "input_protocol" and "output_protocol" properties only
     // for base services; child service-client classes will inherit
     // these
-    f_header_ << endl << "  ThriftProtocol *input_protocol;" << endl
-              << "  ThriftProtocol *output_protocol;" << endl;
+    f_header_ <<
+      endl <<
+      "  ThriftProtocol *input_protocol;" << endl <<
+      "  ThriftProtocol *output_protocol;" << endl;
   }
-  f_header_ << "};" << endl << "typedef struct _" << this->nspace << service_name_ << "Client "
-            << this->nspace << service_name_ << "Client;" << endl << endl;
+  f_header_ <<
+    "};" << endl <<
+    "typedef struct _" << this->nspace << service_name_ << "Client " <<
+      this->nspace << service_name_ << "Client;" << endl <<
+    endl;
 
   // Generate the class definition in the header.
-  f_header_ << "struct _" << this->nspace << service_name_ << "ClientClass" << endl << "{" << endl
-            << "  " << parent_class_name << "Class parent;" << endl << "};" << endl
-            << "typedef struct _" << this->nspace << service_name_ << "ClientClass " << this->nspace
-            << service_name_ << "ClientClass;" << endl << endl;
+  f_header_ <<
+    "struct _" << this->nspace << service_name_ << "ClientClass" << endl <<
+    "{" << endl <<
+    "  " << parent_class_name << "Class parent;" << endl <<
+    "};" << endl <<
+    "typedef struct _" << this->nspace << service_name_ << "ClientClass " <<
+      this->nspace << service_name_ << "ClientClass;" << endl <<
+    endl;
 
   // Create all the GObject boilerplate
-  f_header_ << "GType " << this->nspace_lc << service_name_lc << "_client_get_type (void);" << endl
-            << "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT "
-            << "(" << this->nspace_lc << service_name_lc << "_client_get_type())" << endl
-            << "#define " << this->nspace_uc << service_name_uc << "_CLIENT(obj) "
-            << "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_"
-            << service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "Client))" << endl
-            << "#define " << this->nspace_uc << service_name_uc << "_CLIENT_CLASS(c) "
-            << "(G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "TYPE_" << service_name_uc
-            << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))" << endl << "#define "
-            << this->nspace_uc << service_name_uc << "_IS_CLIENT(obj) "
-            << "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_"
-            << service_name_uc << "_CLIENT))" << endl << "#define " << this->nspace_uc
-            << service_name_uc << "_IS_CLIENT_CLASS(c) "
-            << "(G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc << "TYPE_" << service_name_uc
-            << "_CLIENT))" << endl << "#define " << this->nspace_uc << service_name_uc
-            << "_CLIENT_GET_CLASS(obj) "
-            << "(G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_"
-            << service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))"
-            << endl << endl;
+  f_header_ <<
+    "GType " << this->nspace_lc << service_name_lc <<
+        "_client_get_type (void);" << endl <<
+    "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT " <<
+        "(" << this->nspace_lc << service_name_lc << "_client_get_type())" <<
+        endl <<
+    "#define " << this->nspace_uc << service_name_uc << "_CLIENT(obj) " <<
+        "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " <<
+        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
+        this->nspace << service_name_ << "Client))" << endl <<
+    "#define " << this->nspace_uc << service_name_uc << "_CLIENT_CLASS(c) " <<
+        "(G_TYPE_CHECK_CLASS_CAST ((c), " <<
+        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
+        this->nspace << service_name_ << "ClientClass))" << endl <<
+    "#define " << this->nspace_uc << service_name_uc << "_IS_CLIENT(obj) " <<
+        "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " <<
+        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT))" << endl <<
+    "#define " << this->nspace_uc << service_name_uc <<
+        "_IS_CLIENT_CLASS(c) " << "(G_TYPE_CHECK_CLASS_TYPE ((c), " <<
+        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT))" << endl <<
+    "#define " << this->nspace_uc << service_name_uc <<
+        "_CLIENT_GET_CLASS(obj) " << "(G_TYPE_INSTANCE_GET_CLASS ((obj), " <<
+        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
+        this->nspace << service_name_ << "ClientClass))" << endl <<
+    endl;
 
   /* write out the function prototypes */
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     /* make the function name C friendly */
     string funname = to_lower_case(initial_caps_to_underscores((*f_iter)->get_name()));
 
-    t_function service_function((*f_iter)->get_returntype(),
-                                service_name_lc + string("_client_") + funname,
-                                (*f_iter)->get_arglist(),
-                                (*f_iter)->get_xceptions());
-    indent(f_header_) << function_signature(&service_function) << ";" << endl;
+    t_function service_function ((*f_iter)->get_returntype(),
+                                 service_name_lc + string ("_client_")
+                                 + funname,
+                                 (*f_iter)->get_arglist(),
+                                 (*f_iter)->get_xceptions());
+    indent(f_header_) << function_signature (&service_function) << ";" << endl;
 
-    t_function send_function(g_type_void,
-                             service_name_lc + string("_client_send_") + funname,
-                             (*f_iter)->get_arglist());
-    indent(f_header_) << function_signature(&send_function) << ";" << endl;
+    t_function send_function (g_type_void,
+                              service_name_lc + string ("_client_send_")
+                              + funname,
+                              (*f_iter)->get_arglist());
+    indent(f_header_) << function_signature (&send_function) << ";" << endl;
 
     // implement recv if not a oneway service
     if (!(*f_iter)->is_oneway()) {
-      t_struct noargs(program_);
-      t_function recv_function((*f_iter)->get_returntype(),
-                               service_name_lc + string("_client_recv_") + funname,
-                               &noargs,
-                               (*f_iter)->get_xceptions());
-      indent(f_header_) << function_signature(&recv_function) << ";" << endl;
+      t_struct noargs (program_);
+      t_function recv_function ((*f_iter)->get_returntype(),
+                                service_name_lc + string ("_client_recv_")
+                                + funname,
+                                &noargs,
+                                (*f_iter)->get_xceptions());
+      indent(f_header_) << function_signature (&recv_function) << ";" << endl;
     }
   }
 
   /* write out the get/set function prototypes */
-  f_header_ << "void " + service_name_lc + "_client_set_property (GObject *object, guint "
-                                           "property_id, const GValue *value, GParamSpec *pspec);"
-            << endl;
-  f_header_ << "void " + service_name_lc + "_client_get_property (GObject *object, guint "
-                                           "property_id, GValue *value, GParamSpec *pspec);"
-            << endl;
+  f_header_ << "void " + service_name_lc + "_client_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);" << endl;
+  f_header_ << "void " + service_name_lc + "_client_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);" << endl;
 
   f_header_ << endl;
   // end of header code
@@ -1325,104 +1437,164 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) {
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     /* make the function name C friendly */
     string funname = initial_caps_to_underscores((*f_iter)->get_name());
-    t_type* ttype = (*f_iter)->get_returntype();
-    t_struct* arglist = (*f_iter)->get_arglist();
-    t_struct* xlist = (*f_iter)->get_xceptions();
+    t_type *ttype = (*f_iter)->get_returntype();
+    t_struct *arglist = (*f_iter)->get_arglist();
+    t_struct *xlist = (*f_iter)->get_xceptions();
     bool has_return = !ttype->is_void();
     bool has_args = arglist->get_members().size() == 0;
     bool has_xceptions = xlist->get_members().size() == 0;
 
     string params = "(" + this->nspace + service_name_ + "If *iface"
-                    + (has_return ? ", " + type_name(ttype) + "* _return" : "")
-                    + (has_args ? "" : (", " + argument_list(arglist)))
-                    + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)";
+                    + (has_return ? ", " + type_name (ttype) + "* _return" : "")
+                    + (has_args ? "" : (", " + argument_list (arglist)))
+                    + (has_xceptions ? "" : (", " + xception_list (xlist)))
+                    + ", GError **error)";
 
-    string params_without_type = string("iface, ") + (has_return ? "_return, " : "");
+    string params_without_type = string("iface, ")
+                                 + (has_return ? "_return, " : "");
 
-    const vector<t_field*>& fields = arglist->get_members();
-    vector<t_field*>::const_iterator f_iter_field;
+    const vector<t_field *>& fields = arglist->get_members();
+    vector<t_field *>::const_iterator f_iter_field;
     for (f_iter_field = fields.begin(); f_iter_field != fields.end(); ++f_iter_field) {
       params_without_type += (*f_iter_field)->get_name();
       params_without_type += ", ";
     }
 
-    const vector<t_field*>& xceptions = xlist->get_members();
-    vector<t_field*>::const_iterator x_iter;
+    const vector<t_field *>& xceptions = xlist->get_members();
+    vector<t_field *>::const_iterator x_iter;
     for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
       params_without_type += (*x_iter)->get_name();
       params_without_type += ", ";
     }
 
-    f_service_ << "gboolean" << endl << this->nspace_lc << service_name_lc << "_if_" << funname
-               << " " << params << endl << "{" << endl << "  return " << this->nspace_uc
-               << service_name_uc << "_IF_GET_INTERFACE (iface)->" << funname << " ("
-               << params_without_type << "error);" << endl << "}" << endl << endl;
+    f_service_ <<
+      "gboolean" << endl <<
+      this->nspace_lc << service_name_lc << "_if_" << funname << " " <<
+          params << endl <<
+      "{" << endl <<
+      "  return " << this->nspace_uc << service_name_uc <<
+          "_IF_GET_INTERFACE (iface)->" << funname << " (" <<
+          params_without_type << "error);" << endl <<
+      "}" << endl <<
+      endl;
   }
 
   // Generate interface boilerplate
-  f_service_ << "GType" << endl << this->nspace_lc << service_name_lc << "_if_get_type (void)"
-             << endl << "{" << endl << "  static GType type = 0;" << endl << "  if (type == 0)"
-             << endl << "  {" << endl << "    static const GTypeInfo type_info =" << endl << "    {"
-             << endl << "      sizeof (" << this->nspace << service_name_ << "IfInterface)," << endl
-             << "      NULL,  /* base_init */" << endl << "      NULL,  /* base_finalize */" << endl
-             << "      NULL,  /* class_init */" << endl << "      NULL,  /* class_finalize */"
-             << endl << "      NULL,  /* class_data */" << endl
-             << "      0,     /* instance_size */" << endl << "      0,     /* n_preallocs */"
-             << endl << "      NULL,  /* instance_init */" << endl
-             << "      NULL   /* value_table */" << endl << "    };" << endl
-             << "    type = g_type_register_static (G_TYPE_INTERFACE," << endl
-             << "                                   \"" << this->nspace << service_name_ << "If\","
-             << endl << "                                   &type_info, 0);" << endl << "  }"
-             << endl << "  return type;" << endl << "}" << endl << endl;
+  f_service_ <<
+    "GType" << endl <<
+    this->nspace_lc << service_name_lc << "_if_get_type (void)" << endl <<
+    "{" << endl <<
+    "  static GType type = 0;" << endl <<
+    "  if (type == 0)" << endl <<
+    "  {" << endl <<
+    "    static const GTypeInfo type_info =" << endl <<
+    "    {" << endl <<
+    "      sizeof (" << this->nspace << service_name_ << "IfInterface)," <<
+        endl <<
+    "      NULL,  /* base_init */" << endl <<
+    "      NULL,  /* base_finalize */" << endl <<
+    "      NULL,  /* class_init */" << endl <<
+    "      NULL,  /* class_finalize */" << endl <<
+    "      NULL,  /* class_data */" << endl <<
+    "      0,     /* instance_size */" << endl <<
+    "      0,     /* n_preallocs */" << endl <<
+    "      NULL,  /* instance_init */" << endl <<
+    "      NULL   /* value_table */" << endl <<
+    "    };" << endl <<
+    "    type = g_type_register_static (G_TYPE_INTERFACE," << endl <<
+    "                                   \"" << this->nspace << service_name_ <<
+        "If\"," << endl <<
+    "                                   &type_info, 0);" << endl <<
+    "  }" << endl <<
+    "  return type;" << endl <<
+    "}" << endl <<
+    endl;
 
   // Generate client boilerplate
-  f_service_ << "static void " << endl << this->nspace_lc << service_name_lc
-             << "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface);"
-             << endl << endl << "G_DEFINE_TYPE_WITH_CODE (" << this->nspace << service_name_
-             << "Client, " << this->nspace_lc << service_name_lc << "_client," << endl
-             << "                         " << parent_type_name << ", " << endl
-             << "                         G_IMPLEMENT_INTERFACE (" << this->nspace_uc << "TYPE_"
-             << service_name_uc << "_IF," << endl
-             << "                                                " << this->nspace_lc
-             << service_name_lc << "_if_interface_init));" << endl << endl;
+  f_service_ <<
+    "static void " << endl <<
+    this->nspace_lc << service_name_lc <<
+        "_if_interface_init (" << this->nspace << service_name_ <<
+        "IfInterface *iface);" << endl <<
+    endl <<
+    "G_DEFINE_TYPE_WITH_CODE (" << this->nspace << service_name_ <<
+      "Client, " << this->nspace_lc << service_name_lc << "_client," << endl <<
+    "                         " << parent_type_name << ", " << endl <<
+    "                         G_IMPLEMENT_INTERFACE (" <<
+        this->nspace_uc << "TYPE_" << service_name_uc << "_IF," << endl <<
+    "                                                " <<
+        this->nspace_lc << service_name_lc << "_if_interface_init));" << endl <<
+    endl;
 
   // Generate property-related code only for base services---child
   // service-client classes have only properties inherited from their
   // parent class
   if (!extends_service) {
     // Generate client properties
-    f_service_ << "enum _" << this->nspace << service_name_ << "ClientProperties" << endl << "{"
-               << endl << "  PROP_0," << endl << "  PROP_" << this->nspace_uc << service_name_uc
-               << "_CLIENT_INPUT_PROTOCOL," << endl << "  PROP_" << this->nspace_uc
-               << service_name_uc << "_CLIENT_OUTPUT_PROTOCOL" << endl << "};" << endl << endl;
+    f_service_ <<
+      "enum _" << this->nspace << service_name_ << "ClientProperties" << endl <<
+      "{" << endl <<
+      "  PROP_0," << endl <<
+      "  PROP_" << this->nspace_uc << service_name_uc <<
+          "_CLIENT_INPUT_PROTOCOL," <<
+          endl <<
+      "  PROP_" << this->nspace_uc << service_name_uc <<
+          "_CLIENT_OUTPUT_PROTOCOL" <<
+          endl <<
+      "};" << endl <<
+    endl;
 
     // generate property setter
-    f_service_ << "void" << endl << this->nspace_lc << service_name_lc << "_client_set_property ("
-               << "GObject *object, guint property_id, const GValue *value, "
-               << "GParamSpec *pspec)" << endl << "{" << endl << "  " << this->nspace
-               << service_name_ << "Client *client = " << this->nspace_uc << service_name_uc
-               << "_CLIENT (object);" << endl << endl << "  THRIFT_UNUSED_VAR (pspec);" << endl
-               << endl << "  switch (property_id)" << endl << "  {" << endl << "    case PROP_"
-               << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << endl
-               << "      client->input_protocol = g_value_get_object (value);" << endl
-               << "      break;" << endl << "    case PROP_" << this->nspace_uc << service_name_uc
-               << "_CLIENT_OUTPUT_PROTOCOL:" << endl
-               << "      client->output_protocol = g_value_get_object (value);" << endl
-               << "      break;" << endl << "  }" << endl << "}" << endl << endl;
+    f_service_ <<
+      "void" << endl <<
+      this->nspace_lc << service_name_lc << "_client_set_property (" <<
+          "GObject *object, guint property_id, const GValue *value, " <<
+          "GParamSpec *pspec)" << endl <<
+      "{" << endl <<
+      "  " << this->nspace << service_name_ << "Client *client = " <<
+          this->nspace_uc << service_name_uc << "_CLIENT (object);" << endl <<
+      endl <<
+      "  THRIFT_UNUSED_VAR (pspec);" << endl <<
+      endl <<
+      "  switch (property_id)" << endl <<
+      "  {" << endl <<
+      "    case PROP_" << this->nspace_uc << service_name_uc <<
+          "_CLIENT_INPUT_PROTOCOL:" << endl <<
+      "      client->input_protocol = g_value_get_object (value);" << endl <<
+      "      break;" << endl <<
+      "    case PROP_" << this->nspace_uc << service_name_uc <<
+          "_CLIENT_OUTPUT_PROTOCOL:" << endl <<
+      "      client->output_protocol = g_value_get_object (value);" << endl <<
+      "      break;" << endl <<
+      "  }" << endl <<
+      "}" << endl <<
+    endl;
 
     // generate property getter
-    f_service_ << "void" << endl << this->nspace_lc << service_name_lc << "_client_get_property ("
-               << "GObject *object, guint property_id, GValue *value, "
-               << "GParamSpec *pspec)" << endl << "{" << endl << "  " << this->nspace
-               << service_name_ << "Client *client = " << this->nspace_uc << service_name_uc
-               << "_CLIENT (object);" << endl << endl << "  THRIFT_UNUSED_VAR (pspec);" << endl
-               << endl << "  switch (property_id)" << endl << "  {" << endl << "    case PROP_"
-               << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << endl
-               << "      g_value_set_object (value, client->input_protocol);" << endl
-               << "      break;" << endl << "    case PROP_" << this->nspace_uc << service_name_uc
-               << "_CLIENT_OUTPUT_PROTOCOL:" << endl
-               << "      g_value_set_object (value, client->output_protocol);" << endl
-               << "      break;" << endl << "  }" << endl << "}" << endl << endl;
+    f_service_ <<
+      "void" << endl <<
+      this->nspace_lc << service_name_lc << "_client_get_property (" <<
+          "GObject *object, guint property_id, GValue *value, " <<
+          "GParamSpec *pspec)" << endl <<
+      "{" << endl <<
+      "  " << this->nspace << service_name_ << "Client *client = " <<
+          this->nspace_uc << service_name_uc << "_CLIENT (object);" << endl <<
+      endl <<
+      "  THRIFT_UNUSED_VAR (pspec);" << endl <<
+      endl <<
+      "  switch (property_id)" << endl <<
+      "  {" << endl <<
+      "    case PROP_" << this->nspace_uc << service_name_uc <<
+          "_CLIENT_INPUT_PROTOCOL:" << endl <<
+      "      g_value_set_object (value, client->input_protocol);" << endl <<
+      "      break;" << endl <<
+      "    case PROP_" << this->nspace_uc << service_name_uc <<
+          "_CLIENT_OUTPUT_PROTOCOL:" << endl <<
+      "      g_value_set_object (value, client->output_protocol);" << 

<TRUNCATED>