public
Description: Cross language RPC
Homepage: http://developers.facebook.com/thrift/
Clone URL: git://github.com/kevinclark/thrift.git
Search Repo:
rb: Support encoding arrays as sets in TBinaryProtocolAccelerated
kevinclark (author)
Wed Apr 30 16:01:30 -0700 2008
commit  1f48098f8d03a6ee090a614bca02ec408d155678
tree    1bfa7d7eeb589dec19e8f6e4a56f5a01284bcc7e
parent  dbfe4000510bd38105a4be05b24912f4f330343f
...
360
361
362
363
 
 
 
 
 
 
 
 
 
364
365
366
...
360
361
362
 
363
364
365
366
367
368
369
370
371
372
373
374
0
@@ -360,7 +360,15 @@
0
     }
0
 
0
     case T_SET: {
0
- VALUE items = rb_funcall(value, keys_id, 0);
0
+ VALUE items;
0
+
0
+ if (TYPE(value) == T_ARRAY) {
0
+ items = value;
0
+ } else {
0
+ Check_Type(value, T_HASH);
0
+ items = rb_funcall(value, keys_id, 0);
0
+ }
0
+
0
       sz = RARRAY(items)->len;
0
       
0
       write_set_begin(buf, spec->data.element->type, sz);
...
117
118
119
 
 
 
 
 
120
121
122
...
117
118
119
120
121
122
123
124
125
126
127
0
@@ -117,6 +117,11 @@
0
     obj = Fixtures::Structs::OneSet.new(:set => {"a" => true, "b" => true, "c" => true})
0
     assert_encodes_struct obj
0
     assert_decodes_struct obj
0
+
0
+ # We also support arrays as compatability bug from TBinaryProtocol....
0
+ obj = Fixtures::Structs::OneSet.new(:set => ["a", "b", "c"])
0
+ assert_encodes_struct obj
0
+ assert_decodes_struct obj, Fixtures::Structs::OneSet.new(:set => {"a" => true, "b" => true, "c" => true})
0
   end
0
   
0
   def test_encodes_maps_of_maps

Comments

    No one has commented yet.