You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2015/08/03 22:30:35 UTC

[2/5] thrift git commit: THRIFT-3288 c_glib: Compiler: Silence unused-parameter warnings

THRIFT-3288 c_glib: Compiler: Silence unused-parameter warnings

This change modifies the generated class and interface initializers
so they don't generate "unused parameter" warnings when compiled.


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/7bc907a9
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/7bc907a9
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/7bc907a9

Branch: refs/heads/master
Commit: 7bc907a95931985792e11713eb38244259f1b926
Parents: c83a2b5
Author: Simon South <ss...@simonsouth.com>
Authored: Sat Aug 1 14:53:22 2015 +0000
Committer: Roger Meier <ro...@apache.org>
Committed: Mon Aug 3 22:10:23 2015 +0200

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_c_glib_generator.cc | 49 +++++++++++++-------
 1 file changed, 33 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/7bc907a9/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 807148d..7bf30e3 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -1648,15 +1648,22 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) {
   // create the interface initializer
   f_service_ << "static void" << endl << this->nspace_lc << service_name_lc
              << "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface)"
-             << endl << "{" << endl;
-  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());
+             << endl;
+  scope_up(f_service_);
+  if (functions.size() > 0) {
+    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());
 
-    f_service_ << "  iface->" << funname << " = " << this->nspace_lc << service_name_lc
-               << "_client_" << funname << ";" << endl;
+      f_service_ << "  iface->" << funname << " = " << this->nspace_lc << service_name_lc
+                 << "_client_" << funname << ";" << endl;
+    }
   }
-  f_service_ << "}" << endl << endl;
+  else {
+    f_service_ << indent() << "THRIFT_UNUSED_VAR (iface);" << endl;
+  }
+  scope_down(f_service_);
+  f_service_ << endl;
 
   // create the client instance initializer
   f_service_ << "static void" << endl << this->nspace_lc << service_name_lc << "_client_init ("
@@ -1879,11 +1886,16 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) {
              << "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface)"
              << endl;
   scope_up(f_service_);
-  for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
-    string method_name = initial_caps_to_underscores((*function_iter)->get_name());
+  if (functions.size() > 0) {
+    for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
+      string method_name = initial_caps_to_underscores((*function_iter)->get_name());
 
-    f_service_ << indent() << "iface->" << method_name << " = " << class_name_lc << "_"
-               << method_name << ";" << endl;
+      f_service_ << indent() << "iface->" << method_name << " = " << class_name_lc << "_"
+                 << method_name << ";" << endl;
+    }
+  }
+  else {
+    f_service_ << "THRIFT_UNUSED_VAR (iface);" << endl;
   }
   scope_down(f_service_);
   f_service_ << endl;
@@ -1900,12 +1912,17 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) {
   f_service_ << "static void" << endl << class_name_lc << "_class_init (" << class_name
              << "Class *cls)" << endl;
   scope_up(f_service_);
-  for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
-    string function_name = (*function_iter)->get_name();
-    string method_name = initial_caps_to_underscores(function_name);
+  if (functions.size() > 0) {
+    for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
+      string function_name = (*function_iter)->get_name();
+      string method_name = initial_caps_to_underscores(function_name);
 
-    // All methods are pure virtual and must be implemented by subclasses
-    f_service_ << indent() << "cls->" << method_name << " = NULL;" << endl;
+      // All methods are pure virtual and must be implemented by subclasses
+      f_service_ << indent() << "cls->" << method_name << " = NULL;" << endl;
+    }
+  }
+  else {
+    f_service_ << indent() << "THRIFT_UNUSED_VAR (cls);" << endl;
   }
   scope_down(f_service_);
   f_service_ << endl;