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

thrift git commit: THRIFT-2961: Service inheritance does not work with namespaced Ruby code Client: rb Patch: Jan Brauer

Repository: thrift
Updated Branches:
  refs/heads/master 4e16718e9 -> 8f2596ad5


THRIFT-2961: Service inheritance does not work with namespaced Ruby code
Client: rb
Patch: Jan Brauer

This closes #364

commit 111c4e77a78c1a82f526923f13534bb0027ef33f
Author: Jan Brauer <ja...@jimdo.com>
Date: 2015-01-29T22:01:26Z
Make 'extends' work with 'rb:namespaced'.
commit 34cab3d7c77bd5e8325ac4f30f1091429c35905e
Author: Jan Brauer <ja...@jimdo.com>
Date: 2015-01-29T22:25:03Z
Add test for namespaced service extension


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

Branch: refs/heads/master
Commit: 8f2596ad546451c50e48425e37eddc9195c5807e
Parents: 4e16718
Author: jfarrell <jf...@apache.org>
Authored: Thu Jan 29 23:42:05 2015 -0500
Committer: jfarrell <jf...@apache.org>
Committed: Thu Jan 29 23:42:05 2015 -0500

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_rb_generator.cc |  9 ++++++--
 lib/rb/Rakefile                             |  2 ++
 lib/rb/spec/BaseService.thrift              | 27 ++++++++++++++++++++++++
 lib/rb/spec/ExtendedService.thrift          | 25 ++++++++++++++++++++++
 lib/rb/spec/namespaced_spec.rb              |  5 +++++
 5 files changed, 66 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/8f2596ad/compiler/cpp/src/generate/t_rb_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index ec7f802..9dac54a 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -753,8 +753,13 @@ void t_rb_generator::generate_service(t_service* tservice) {
   f_service_ << rb_autogen_comment() << endl << render_require_thrift();
 
   if (tservice->get_extends() != NULL) {
-    f_service_ << "require '" << require_prefix_ << underscore(tservice->get_extends()->get_name())
-               << "'" << endl;
+    if (namespaced_) {
+      f_service_ << "require '" << rb_namespace_to_path_prefix(tservice->get_extends()->get_program()->get_namespace("rb")) << underscore(tservice->get_extends()->get_name())
+	         << "'" << endl;
+    } else {
+      f_service_ << "require '" << require_prefix_ << underscore(tservice->get_extends()->get_name())
+	         << "'" << endl;
+    }
   }
 
   f_service_ << "require '" << require_prefix_ << underscore(program_name_) << "_types'" << endl

http://git-wip-us.apache.org/repos/asf/thrift/blob/8f2596ad/lib/rb/Rakefile
----------------------------------------------------------------------
diff --git a/lib/rb/Rakefile b/lib/rb/Rakefile
index 8f1c4fe..9dc8324 100644
--- a/lib/rb/Rakefile
+++ b/lib/rb/Rakefile
@@ -48,6 +48,8 @@ namespace :'gen-rb' do
   task :'namespaced_spec' do
     dir = File.dirname(__FILE__) + '/spec'
     sh THRIFT, '--gen', 'rb:namespaced', '-recurse', '-o', dir, "#{dir}/ThriftNamespacedSpec.thrift"
+    sh THRIFT, '--gen', 'rb:namespaced', '-recurse', '-o', dir, "#{dir}/BaseService.thrift"
+    sh THRIFT, '--gen', 'rb:namespaced', '-recurse', '-o', dir, "#{dir}/ExtendedService.thrift"
   end
 
   task :'flat_spec' do

http://git-wip-us.apache.org/repos/asf/thrift/blob/8f2596ad/lib/rb/spec/BaseService.thrift
----------------------------------------------------------------------
diff --git a/lib/rb/spec/BaseService.thrift b/lib/rb/spec/BaseService.thrift
new file mode 100644
index 0000000..5c7d32a
--- /dev/null
+++ b/lib/rb/spec/BaseService.thrift
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+namespace rb Base
+
+struct Hello {
+  1: string greeting = "hello world"
+}
+
+service BaseService {
+  Hello greeting(1:bool english)
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/8f2596ad/lib/rb/spec/ExtendedService.thrift
----------------------------------------------------------------------
diff --git a/lib/rb/spec/ExtendedService.thrift b/lib/rb/spec/ExtendedService.thrift
new file mode 100644
index 0000000..1a6b705
--- /dev/null
+++ b/lib/rb/spec/ExtendedService.thrift
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+namespace rb Extended
+
+include "BaseService.thrift"
+
+service ExtendedService extends BaseService.BaseService {
+  void ping()
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/8f2596ad/lib/rb/spec/namespaced_spec.rb
----------------------------------------------------------------------
diff --git a/lib/rb/spec/namespaced_spec.rb b/lib/rb/spec/namespaced_spec.rb
index 8d4f88b..31379d9 100644
--- a/lib/rb/spec/namespaced_spec.rb
+++ b/lib/rb/spec/namespaced_spec.rb
@@ -59,4 +59,9 @@ describe 'namespaced generation' do
   it "required an included file" do
     defined?(OtherNamespace::SomeEnum).should be_true
   end
+
+  it "extended a service" do
+    require "extended/extended_service"
+  end
+
 end