thrift 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/benchmark/gen-rb/benchmark_constants.rb +1 -1
- data/benchmark/gen-rb/benchmark_service.rb +1 -1
- data/benchmark/gen-rb/benchmark_types.rb +1 -1
- data/ext/strlcpy.c +41 -0
- data/ext/strlcpy.h +30 -0
- data/ext/struct.c +6 -32
- data/lib/thrift/struct_union.rb +1 -1
- data/spec/base_protocol_spec.rb +1 -1
- data/spec/base_transport_spec.rb +1 -1
- data/spec/binary_protocol_accelerated_spec.rb +2 -2
- data/spec/binary_protocol_spec.rb +2 -2
- data/spec/binary_protocol_spec_shared.rb +1 -1
- data/spec/client_spec.rb +1 -1
- data/spec/compact_protocol_spec.rb +12 -1
- data/spec/exception_spec.rb +1 -1
- data/spec/gen-rb/nonblocking_service.rb +1 -1
- data/spec/gen-rb/thrift_spec_constants.rb +1 -1
- data/spec/gen-rb/thrift_spec_types.rb +1 -1
- data/spec/http_client_spec.rb +1 -1
- data/spec/mongrel_http_server_spec.rb +1 -1
- data/spec/nonblocking_server_spec.rb +1 -1
- data/spec/processor_spec.rb +1 -1
- data/spec/serializer_spec.rb +1 -1
- data/spec/server_socket_spec.rb +2 -2
- data/spec/server_spec.rb +1 -2
- data/spec/socket_spec.rb +2 -2
- data/spec/socket_spec_shared.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/struct_spec.rb +1 -1
- data/spec/types_spec.rb +1 -1
- data/spec/union_spec.rb +1 -1
- data/spec/unix_socket_spec.rb +2 -2
- data/{debug_proto_test → test/debug_proto}/gen-rb/debug_proto_test_constants.rb +1 -1
- data/{debug_proto_test → test/debug_proto}/gen-rb/debug_proto_test_types.rb +56 -1
- data/{debug_proto_test → test/debug_proto}/gen-rb/empty_service.rb +1 -1
- data/{debug_proto_test → test/debug_proto}/gen-rb/inherited.rb +1 -1
- data/{debug_proto_test → test/debug_proto}/gen-rb/reverse_order_service.rb +1 -1
- data/{debug_proto_test → test/debug_proto}/gen-rb/service_for_exception_with_a_map.rb +1 -1
- data/{debug_proto_test → test/debug_proto}/gen-rb/srv.rb +1 -1
- metadata +143 -70
- data/InstalledFiles +0 -1
- data/Makefile +0 -512
- data/Makefile.am +0 -49
- data/Makefile.in +0 -512
- data/Manifest +0 -103
- data/Rakefile +0 -102
- data/script/proto_benchmark.rb +0 -121
- data/script/read_struct.rb +0 -43
- data/script/write_struct.rb +0 -30
- data/setup.rb +0 -1585
- data/thrift.gemspec +0 -30
- data/tmp/thrift-0.7.0.gem +0 -0
data/ext/strlcpy.c
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
/**
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
4
|
+
* distributed with this work for additional information
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
7
|
+
* "License"); you may not use this file except in compliance
|
8
|
+
* with the License. You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
13
|
+
* software distributed under the License is distributed on an
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
* KIND, either express or implied. See the License for the
|
16
|
+
* specific language governing permissions and limitations
|
17
|
+
* under the License.
|
18
|
+
*/
|
19
|
+
|
20
|
+
#include "strlcpy.h"
|
21
|
+
|
22
|
+
#ifndef HAVE_STRLCPY
|
23
|
+
#define HAVE_STRLCPY
|
24
|
+
size_t
|
25
|
+
strlcpy (char *dst, const char *src, size_t dst_sz)
|
26
|
+
{
|
27
|
+
size_t n;
|
28
|
+
|
29
|
+
for (n = 0; n < dst_sz; n++) {
|
30
|
+
if ((*dst++ = *src++) == '\0')
|
31
|
+
break;
|
32
|
+
}
|
33
|
+
|
34
|
+
if (n < dst_sz)
|
35
|
+
return n;
|
36
|
+
if (n > 0)
|
37
|
+
*(dst - 1) = '\0';
|
38
|
+
return n + strlen (src);
|
39
|
+
}
|
40
|
+
#endif
|
41
|
+
|
data/ext/strlcpy.h
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
4
|
+
* distributed with this work for additional information
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
7
|
+
* "License"); you may not use this file except in compliance
|
8
|
+
* with the License. You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
13
|
+
* software distributed under the License is distributed on an
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
* KIND, either express or implied. See the License for the
|
16
|
+
* specific language governing permissions and limitations
|
17
|
+
* under the License.
|
18
|
+
*/
|
19
|
+
|
20
|
+
|
21
|
+
#include <sys/types.h>
|
22
|
+
#include <string.h>
|
23
|
+
|
24
|
+
#ifndef HAVE_STRLCPY
|
25
|
+
size_t
|
26
|
+
strlcpy (char *dst, const char *src, size_t dst_sz);
|
27
|
+
#else
|
28
|
+
extern size_t strlcpy(char *, const char *, size_t);
|
29
|
+
#endif
|
30
|
+
|
data/ext/struct.c
CHANGED
@@ -20,33 +20,7 @@
|
|
20
20
|
#include "struct.h"
|
21
21
|
#include "constants.h"
|
22
22
|
#include "macros.h"
|
23
|
-
|
24
|
-
#ifndef HAVE_STRLCPY
|
25
|
-
|
26
|
-
static
|
27
|
-
size_t
|
28
|
-
strlcpy (char *dst, const char *src, size_t dst_sz)
|
29
|
-
{
|
30
|
-
size_t n;
|
31
|
-
|
32
|
-
for (n = 0; n < dst_sz; n++) {
|
33
|
-
if ((*dst++ = *src++) == '\0')
|
34
|
-
break;
|
35
|
-
}
|
36
|
-
|
37
|
-
if (n < dst_sz)
|
38
|
-
return n;
|
39
|
-
if (n > 0)
|
40
|
-
*(dst - 1) = '\0';
|
41
|
-
return n + strlen (src);
|
42
|
-
}
|
43
|
-
#else
|
44
|
-
/*
|
45
|
-
Ruby 1.9.x includes the OpenBSD implementation of strlcpy.
|
46
|
-
See missing/strlcpy.c in Ruby 1.9 source
|
47
|
-
*/
|
48
|
-
extern size_t strlcpy(char *, const char *, size_t);
|
49
|
-
#endif
|
23
|
+
#include "strlcpy.h"
|
50
24
|
|
51
25
|
VALUE thrift_union_class;
|
52
26
|
|
@@ -231,10 +205,10 @@ static VALUE rb_thrift_struct_write(VALUE self, VALUE protocol);
|
|
231
205
|
static void write_anything(int ttype, VALUE value, VALUE protocol, VALUE field_info);
|
232
206
|
|
233
207
|
VALUE get_field_value(VALUE obj, VALUE field_name) {
|
234
|
-
char name_buf[RSTRING_LEN(field_name) +
|
208
|
+
char name_buf[RSTRING_LEN(field_name) + 2];
|
235
209
|
|
236
210
|
name_buf[0] = '@';
|
237
|
-
strlcpy(&name_buf[1], RSTRING_PTR(field_name),
|
211
|
+
strlcpy(&name_buf[1], RSTRING_PTR(field_name), RSTRING_LEN(field_name) + 1);
|
238
212
|
|
239
213
|
VALUE value = rb_ivar_get(obj, rb_intern(name_buf));
|
240
214
|
|
@@ -417,10 +391,10 @@ static void skip_map_contents(VALUE protocol, VALUE key_type_value, VALUE value_
|
|
417
391
|
static void skip_list_or_set_contents(VALUE protocol, VALUE element_type_value, int size);
|
418
392
|
|
419
393
|
static void set_field_value(VALUE obj, VALUE field_name, VALUE value) {
|
420
|
-
char name_buf[RSTRING_LEN(field_name) +
|
394
|
+
char name_buf[RSTRING_LEN(field_name) + 2];
|
421
395
|
|
422
396
|
name_buf[0] = '@';
|
423
|
-
strlcpy(&name_buf[1], RSTRING_PTR(field_name),
|
397
|
+
strlcpy(&name_buf[1], RSTRING_PTR(field_name), RSTRING_LEN(field_name)+1);
|
424
398
|
|
425
399
|
rb_ivar_set(obj, rb_intern(name_buf), value);
|
426
400
|
}
|
@@ -484,7 +458,7 @@ static VALUE read_anything(VALUE protocol, int ttype, VALUE field_info) {
|
|
484
458
|
if (!NIL_P(key_info) && !NIL_P(value_info)) {
|
485
459
|
int specified_key_type = FIX2INT(rb_hash_aref(key_info, type_sym));
|
486
460
|
int specified_value_type = FIX2INT(rb_hash_aref(value_info, type_sym));
|
487
|
-
if (specified_key_type == key_ttype && specified_value_type == value_ttype) {
|
461
|
+
if (num_entries == 0 || (specified_key_type == key_ttype && specified_value_type == value_ttype)) {
|
488
462
|
result = rb_hash_new();
|
489
463
|
|
490
464
|
for (i = 0; i < num_entries; ++i) {
|
data/lib/thrift/struct_union.rb
CHANGED
@@ -56,7 +56,7 @@ module Thrift
|
|
56
56
|
when Types::MAP
|
57
57
|
key_type, val_type, size = iprot.read_map_begin
|
58
58
|
# Skip the map contents if the declared key or value types don't match the expected ones.
|
59
|
-
if (key_type != field[:key][:type] || val_type != field[:value][:type])
|
59
|
+
if (size != 0 && (key_type != field[:key][:type] || val_type != field[:value][:type]))
|
60
60
|
size.times do
|
61
61
|
iprot.skip(key_type)
|
62
62
|
iprot.skip(val_type)
|
data/spec/base_protocol_spec.rb
CHANGED
data/spec/base_transport_spec.rb
CHANGED
@@ -17,8 +17,8 @@
|
|
17
17
|
# under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require File.dirname(__FILE__)
|
21
|
-
require File.dirname(__FILE__)
|
20
|
+
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
21
|
+
require File.expand_path("#{File.dirname(__FILE__)}/binary_protocol_spec_shared")
|
22
22
|
|
23
23
|
if defined? Thrift::BinaryProtocolAccelerated
|
24
24
|
|
@@ -17,8 +17,8 @@
|
|
17
17
|
# under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require File.dirname(__FILE__)
|
21
|
-
require File.dirname(__FILE__)
|
20
|
+
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
21
|
+
require File.expand_path("#{File.dirname(__FILE__)}/binary_protocol_spec_shared")
|
22
22
|
|
23
23
|
class ThriftBinaryProtocolSpec < Spec::ExampleGroup
|
24
24
|
include Thrift
|
data/spec/client_spec.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require File.dirname(__FILE__)
|
20
|
+
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
21
21
|
|
22
22
|
describe Thrift::CompactProtocol do
|
23
23
|
TESTS = {
|
@@ -115,6 +115,17 @@ describe Thrift::CompactProtocol do
|
|
115
115
|
brcp2.should == brcp
|
116
116
|
end
|
117
117
|
|
118
|
+
it "should deserialize an empty map to an empty hash" do
|
119
|
+
struct = SingleMapTestStruct.new(:i32_map => {})
|
120
|
+
ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
|
121
|
+
bytes = ser.serialize(struct)
|
122
|
+
|
123
|
+
deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
|
124
|
+
struct2 = SingleMapTestStruct.new
|
125
|
+
deser.deserialize(struct2, bytes)
|
126
|
+
struct.should == struct2
|
127
|
+
end
|
128
|
+
|
118
129
|
class JankyHandler
|
119
130
|
def Janky(i32arg)
|
120
131
|
i32arg * 2
|
data/spec/exception_spec.rb
CHANGED
data/spec/http_client_spec.rb
CHANGED
data/spec/processor_spec.rb
CHANGED
data/spec/serializer_spec.rb
CHANGED
data/spec/server_socket_spec.rb
CHANGED
@@ -17,8 +17,8 @@
|
|
17
17
|
# under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require File.dirname(__FILE__)
|
21
|
-
require File.dirname(__FILE__)
|
20
|
+
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
21
|
+
require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
|
22
22
|
|
23
23
|
class ThriftServerSocketSpec < Spec::ExampleGroup
|
24
24
|
include Thrift
|
data/spec/server_spec.rb
CHANGED
@@ -16,8 +16,7 @@
|
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
18
|
#
|
19
|
-
|
20
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
19
|
+
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
21
20
|
|
22
21
|
class ThriftServerSpec < Spec::ExampleGroup
|
23
22
|
include Thrift
|
data/spec/socket_spec.rb
CHANGED
@@ -17,8 +17,8 @@
|
|
17
17
|
# under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require File.dirname(__FILE__)
|
21
|
-
require File.dirname(__FILE__)
|
20
|
+
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
21
|
+
require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
|
22
22
|
|
23
23
|
class ThriftSocketSpec < Spec::ExampleGroup
|
24
24
|
include Thrift
|
data/spec/socket_spec_shared.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -42,7 +42,7 @@ Spec::Runner.configure do |configuration|
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
$:.unshift File.join(File.dirname(__FILE__), *%w[..
|
45
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. test debug_proto gen-rb])
|
46
46
|
require "srv"
|
47
47
|
require "debug_proto_test_constants"
|
48
48
|
|
data/spec/struct_spec.rb
CHANGED
data/spec/types_spec.rb
CHANGED
data/spec/union_spec.rb
CHANGED
data/spec/unix_socket_spec.rb
CHANGED
@@ -17,8 +17,8 @@
|
|
17
17
|
# under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require File.dirname(__FILE__)
|
21
|
-
require File.dirname(__FILE__)
|
20
|
+
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
21
|
+
require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
|
22
22
|
|
23
23
|
class ThriftUNIXSocketSpec < Spec::ExampleGroup
|
24
24
|
include Thrift
|