Author: kclark
Date: Mon Jan 5 17:34:28 2009
New Revision: 731806
URL: http://svn.apache.org/viewvc?rev=731806&view=rev
Log:
THRIFT-246. rb: Generate #struct_fields rather than reflect.
Author: Bryan Duxbury
Modified:
incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
incubator/thrift/trunk/lib/rb/benchmark/gen-rb/BenchmarkService.rb
incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
incubator/thrift/trunk/lib/rb/spec/gen-rb/NonblockingService.rb
incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb
Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc?rev=731806&r1=731805&r2=731806&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
(original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc Mon Jan
5 17:34:28 2009
@@ -540,7 +540,10 @@
}
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,
Modified: incubator/thrift/trunk/lib/rb/benchmark/gen-rb/BenchmarkService.rb
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/benchmark/gen-rb/BenchmarkService.rb?rev=731806&r1=731805&r2=731806&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/benchmark/gen-rb/BenchmarkService.rb
(original)
+++ incubator/thrift/trunk/lib/rb/benchmark/gen-rb/BenchmarkService.rb Mon Jan
5 17:34:28 2009
@@ -52,6 +52,9 @@
FIELDS = {
N => {:type => Thrift::Types::BYTE, :name => 'n'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -65,6 +68,9 @@
FIELDS = {
SUCCESS => {:type => Thrift::Types::I32, :name => 'success'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
Modified: incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb?rev=731806&r1=731805&r2=731806&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb Mon Jan 5 17:34:28 2009
@@ -60,6 +60,8 @@
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
Modified: incubator/thrift/trunk/lib/rb/spec/gen-rb/NonblockingService.rb
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/gen-rb/NonblockingService.rb?rev=731806&r1=731805&r2=731806&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/gen-rb/NonblockingService.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/gen-rb/NonblockingService.rb Mon Jan 5
17:34:28 2009
@@ -121,6 +121,9 @@
FIELDS = {
ENGLISH => {:type => Thrift::Types::BOOL, :name => 'english'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -134,6 +137,9 @@
FIELDS = {
SUCCESS => {:type => Thrift::Types::STRUCT, :name => 'success',
:class => SpecNamespace::Hello}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -145,6 +151,9 @@
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -158,6 +167,9 @@
FIELDS = {
SUCCESS => {:type => Thrift::Types::BOOL, :name => 'success'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -171,6 +183,9 @@
FIELDS = {
N => {:type => Thrift::Types::I32, :name => 'n'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -182,6 +197,9 @@
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -193,6 +211,9 @@
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -204,6 +225,9 @@
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -217,6 +241,9 @@
FIELDS = {
SECONDS => {:type => Thrift::Types::DOUBLE, :name => 'seconds'}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -228,6 +255,9 @@
FIELDS = {
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
Modified: incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb?rev=731806&r1=731805&r2=731806&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb Mon Jan 5
17:34:28 2009
@@ -15,6 +15,9 @@
FIELDS = {
GREETING => {:type => Thrift::Types::STRING, :name => 'greeting',
:default => %q"hello world"}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -50,6 +53,9 @@
]), :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 @@
FIELDS = {
YESNO => {:type => Thrift::Types::BOOL, :name => 'yesno', :default =>
true}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end
@@ -96,6 +105,9 @@
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 @@
MESSAGE => {:type => Thrift::Types::STRING, :name => 'message'},
CODE => {:type => Thrift::Types::I32, :name => 'code', :default => 1}
}
+
+ def struct_fields; FIELDS; end
+
def validate
end