You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2013/01/17 22:47:45 UTC

git commit: THRIFT-1832 C# async generator assumes all methods have arguments Patch: Kevin Radloff

Updated Branches:
  refs/heads/master d53642463 -> a1e36f6ee


THRIFT-1832 C# async generator assumes all methods have arguments
Patch: Kevin Radloff


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

Branch: refs/heads/master
Commit: a1e36f6ee59e0502c1a5f759e4d43c2dbc4c6542
Parents: d536424
Author: Jens Geyer <je...@apache.org>
Authored: Thu Jan 17 22:46:57 2013 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Thu Jan 17 22:46:57 2013 +0100

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_csharp_generator.cc |   63 +++++++++---------
 1 files changed, 31 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/a1e36f6e/compiler/cpp/src/generate/t_csharp_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc
index 6dc8605..7a7a278 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -1178,43 +1178,40 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
     indent(f_service_) <<
       "public " << function_signature(*f_iter) << endl;
     scope_up(f_service_);
-    indent(f_service_) << "#if !SILVERLIGHT" << endl;
-    indent(f_service_) <<
-      "send_" << funname << "(";
 
-    first = true;
-    for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      if (first) {
-        first = false;
-      } else {
-        f_service_ << ", ";
+    if (!async_) {
+      indent(f_service_) << "#if !SILVERLIGHT" << endl;
+      indent(f_service_) <<
+        "send_" << funname << "(";
+
+      first = true;
+      for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
+        if (first) {
+          first = false;
+        } else {
+          f_service_ << ", ";
+        }
+        f_service_ << (*fld_iter)->get_name();
       }
-      f_service_ << (*fld_iter)->get_name();
-    }
-    f_service_ << ");" << endl;
+      f_service_ << ");" << endl;
 
-    if (!(*f_iter)->is_oneway()) {
-      f_service_ << indent();
-      if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ << "return ";
+      if (!(*f_iter)->is_oneway()) {
+        f_service_ << indent();
+        if (!(*f_iter)->get_returntype()->is_void()) {
+          f_service_ << "return ";
+        }
+        f_service_ <<
+          "recv_" << funname << "();" << endl;
       }
-      f_service_ <<
-        "recv_" << funname << "();" << endl;
-    }
-    f_service_ << endl;
+      f_service_ << endl;
 
-    indent(f_service_) << "#else" << endl;
+      indent(f_service_) << "#else" << endl;
+    }
 
     // Silverlight synchronous invoke
-    indent(f_service_) << "var asyncResult = Begin_" << funname << "(null, null, ";
-    first = true;
+    indent(f_service_) << "var asyncResult = Begin_" << funname << "(null, null";
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      if (first) {
-        first = false;
-      } else {
-        f_service_ << ", ";
-      }
-      f_service_ << (*fld_iter)->get_name();
+      f_service_ << ", " << (*fld_iter)->get_name();
     }
     f_service_ << ");" << endl;
 
@@ -1228,8 +1225,9 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
     }
     f_service_ << endl;
 
-
-    indent(f_service_) << "#endif" << endl;
+    if (!async_) {
+      indent(f_service_) << "#endif" << endl;
+    }
     scope_down(f_service_);
 
     // Send
@@ -2073,7 +2071,8 @@ string t_csharp_generator::function_signature(t_function* tfunction, string pref
 }
 
 string t_csharp_generator::function_signature_async_begin(t_function* tfunction, string prefix) {
-  return "IAsyncResult " + prefix + tfunction->get_name() + "(AsyncCallback callback, object state, " + argument_list(tfunction->get_arglist()) + ")";
+  string comma = (tfunction->get_arglist()->get_members().size() > 0 ? ", " : "");
+  return "IAsyncResult " + prefix + tfunction->get_name() + "(AsyncCallback callback, object state" + comma + argument_list(tfunction->get_arglist()) + ")";
 }
 
 string t_csharp_generator::function_signature_async_end(t_function* tfunction, string prefix) {