public
Description: Cross language RPC
Homepage: http://developers.facebook.com/thrift/
Clone URL: git://github.com/kevinclark/thrift.git
rb: Fix bug when passing a false bool to a ThriftStruct constructor
kevinclark (author)
Wed Apr 09 14:06:10 -0700 2008
commit  571765a26ac53c12fae4c2119d8e9f5b56bf27b9
tree    1bba30b998c86523fe0708b42dd6f0fced9dd5d8
parent  1b4e887e6e20cdca9f0615305c1818f8886cdc8a
...
178
179
180
181
 
 
 
 
 
 
 
182
183
184
...
178
179
180
 
181
182
183
184
185
186
187
188
189
190
0
@@ -178,7 +178,13 @@ end
0
 module ThriftStruct
0
   def initialize(d={})
0
     each_field do |fid, type, name, default|
0
- instance_variable_set("@#{name}", d[name.to_s] || d[name.intern] || default)
0
+ if !d[name.to_s].nil?
0
+ instance_variable_set("@#{name}", d[name.to_s])
0
+ elsif !d[name.to_sym].nil?
0
+ instance_variable_set("@#{name}", d[name.to_sym])
0
+ else
0
+ instance_variable_set("@#{name}", default)
0
+ end
0
     end
0
   end
0
 
...
11
12
13
 
 
 
 
14
15
16
...
11
12
13
14
15
16
17
18
19
20
0
@@ -11,6 +11,10 @@ senum Thinger {
0
   "ASDFLJASDF"
0
 }
0
 
0
+struct BoolPasser {
0
+ 1: bool value = 1
0
+}
0
+
0
 struct Hello {
0
   1: i32 simple = 53,
0
   2: map<i32,i32> complex = {23:532, 6243:632, 2355:532},
...
17
18
19
 
 
 
20
21
22
...
17
18
19
20
21
22
23
24
25
0
@@ -17,6 +17,9 @@ class TestStructGeneration < Test::Unit::TestCase
0
 
0
     assert_kind_of(Hash, hello.complex)
0
     assert_equal(hello.complex, { 6243 => 632, 2355 => 532, 23 => 532})
0
+
0
+ bool_passer = TestNamespace::BoolPasser.new(:value => false)
0
+ assert_equal false, bool_passer.value
0
   end
0
 
0
   def test_goodbyez

Comments

    No one has commented yet.