summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Clark <kclark@apache.org>2009-01-06 01:34:28 +0000
committerKevin Clark <kclark@apache.org>2009-01-06 01:34:28 +0000
commitd6b7182df59ae7cb1849c36b5d9513fce681ce35 (patch)
tree1102c15a46d9ee4d84c0fb5889f4b5a84a3a44f9
parent41baeaba96302e480265542340532842bc5ab0c9 (diff)
downloadthrift-d6b7182df59ae7cb1849c36b5d9513fce681ce35.tar.gz
THRIFT-246. rb: Generate #struct_fields rather than reflect.
Author: Bryan Duxbury git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@731806 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--compiler/cpp/src/generate/t_rb_generator.cc5
-rw-r--r--lib/rb/benchmark/gen-rb/BenchmarkService.rb6
-rw-r--r--lib/rb/lib/thrift/struct.rb2
-rw-r--r--lib/rb/spec/gen-rb/NonblockingService.rb30
-rw-r--r--lib/rb/spec/gen-rb/ThriftSpec_types.rb15
5 files changed, 57 insertions, 1 deletions
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index b2fc5bc7d..e3c3031ff 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -540,7 +540,10 @@ void t_rb_generator::generate_field_defns(std::ofstream& out, t_struct* tstruct)
}
indent_down();
out << endl;
- indent(out) << "}" << endl;
+ indent(out) << "}" << endl << endl;
+
+ indent(out) << "def struct_fields; FIELDS; end" << endl << endl;
+
}
void t_rb_generator::generate_field_data(std::ofstream& out, t_type* field_type,
diff --git a/lib/rb/benchmark/gen-rb/BenchmarkService.rb b/lib/rb/benchmark/gen-rb/BenchmarkService.rb
index 2c3ae4f66..832098b5c 100644
--- a/lib/rb/benchmark/gen-rb/BenchmarkService.rb
+++ b/lib/rb/benchmark/gen-rb/BenchmarkService.rb
@@ -52,6 +52,9 @@ require File.dirname(__FILE__) + '/Benchmark_types'
FIELDS = {
N => {:type => Thrift::Types::BYTE, :name => 'n'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -65,6 +68,9 @@ require File.dirname(__FILE__) + '/Benchmark_types'
FIELDS = {
SUCCESS => {:type => Thrift::Types::I32, :name => 'success'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
diff --git a/lib/rb/lib/thrift/struct.rb b/lib/rb/lib/thrift/struct.rb
index 25eb98191..d790bd432 100644
--- a/lib/rb/lib/thrift/struct.rb
+++ b/lib/rb/lib/thrift/struct.rb
@@ -60,6 +60,8 @@ module Thrift
names_to_ids[name]
end
+ # Obsoleted by THRIFT-246, which generates this method inline
+ # TODO: Should be removed at some point. -- Kevin Clark
def struct_fields
self.class.const_get(:FIELDS)
end
diff --git a/lib/rb/spec/gen-rb/NonblockingService.rb b/lib/rb/spec/gen-rb/NonblockingService.rb
index 8044d8e5b..3b49fce1a 100644
--- a/lib/rb/spec/gen-rb/NonblockingService.rb
+++ b/lib/rb/spec/gen-rb/NonblockingService.rb
@@ -121,6 +121,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
ENGLISH => {:type => Thrift::Types::BOOL, :name => 'english'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -134,6 +137,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
SUCCESS => {:type => Thrift::Types::STRUCT, :name => 'success', :class => SpecNamespace::Hello}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -145,6 +151,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -158,6 +167,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
SUCCESS => {:type => Thrift::Types::BOOL, :name => 'success'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -171,6 +183,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
N => {:type => Thrift::Types::I32, :name => 'n'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -182,6 +197,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -193,6 +211,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -204,6 +225,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -217,6 +241,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
SECONDS => {:type => Thrift::Types::DOUBLE, :name => 'seconds'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -228,6 +255,9 @@ require File.dirname(__FILE__) + '/ThriftSpec_types'
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
diff --git a/lib/rb/spec/gen-rb/ThriftSpec_types.rb b/lib/rb/spec/gen-rb/ThriftSpec_types.rb
index a28c92142..ea73af12e 100644
--- a/lib/rb/spec/gen-rb/ThriftSpec_types.rb
+++ b/lib/rb/spec/gen-rb/ThriftSpec_types.rb
@@ -15,6 +15,9 @@ module SpecNamespace
FIELDS = {
GREETING => {:type => Thrift::Types::STRING, :name => 'greeting', :default => %q"hello world"}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -50,6 +53,9 @@ module SpecNamespace
]), :element => {:type => Thrift::Types::I16}},
OPT_STRING => {:type => Thrift::Types::STRING, :name => 'opt_string', :optional => true}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -63,6 +69,9 @@ module SpecNamespace
FIELDS = {
YESNO => {:type => Thrift::Types::BOOL, :name => 'yesno', :default => true}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -96,6 +105,9 @@ module SpecNamespace
SETS => {:type => Thrift::Types::LIST, :name => 'sets', :element => {:type => Thrift::Types::SET, :element => {:type => Thrift::Types::I16}}},
HELLOS => {:type => Thrift::Types::LIST, :name => 'hellos', :element => {:type => Thrift::Types::STRUCT, :class => SpecNamespace::Hello}}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -111,6 +123,9 @@ module SpecNamespace
MESSAGE => {:type => Thrift::Types::STRING, :name => 'message'},
CODE => {:type => Thrift::Types::I32, :name => 'code', :default => 1}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end