thrift 0.0.751142 → 0.0.810255.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/CHANGELOG +3 -1
  2. data/Manifest +47 -44
  3. data/README +19 -6
  4. data/Rakefile +1 -1
  5. data/benchmark/Benchmark.thrift +19 -0
  6. data/benchmark/benchmark.rb +20 -3
  7. data/benchmark/client.rb +20 -2
  8. data/benchmark/server.rb +22 -4
  9. data/benchmark/thin_server.rb +22 -4
  10. data/ext/binary_protocol_accelerated.c +32 -21
  11. data/ext/binary_protocol_accelerated.h +19 -0
  12. data/ext/compact_protocol.c +665 -0
  13. data/ext/compact_protocol.h +20 -0
  14. data/ext/constants.h +19 -1
  15. data/ext/extconf.rb +19 -0
  16. data/ext/macros.h +41 -0
  17. data/ext/memory_buffer.c +29 -5
  18. data/ext/memory_buffer.h +19 -0
  19. data/ext/protocol.c +20 -1
  20. data/ext/protocol.h +19 -0
  21. data/ext/struct.c +115 -83
  22. data/ext/struct.h +19 -0
  23. data/ext/thrift_native.c +23 -2
  24. data/lib/thrift/client.rb +19 -1
  25. data/lib/thrift/core_ext/fixnum.rb +29 -0
  26. data/lib/thrift/core_ext.rb +23 -0
  27. data/lib/thrift/exceptions.rb +19 -2
  28. data/lib/thrift/processor.rb +19 -1
  29. data/lib/thrift/protocol/base_protocol.rb +290 -0
  30. data/lib/thrift/protocol/{binaryprotocol.rb → binary_protocol.rb} +27 -15
  31. data/lib/thrift/protocol/binary_protocol_accelerated.rb +35 -0
  32. data/lib/thrift/protocol/compact_protocol.rb +422 -0
  33. data/lib/thrift/serializer/deserializer.rb +33 -0
  34. data/lib/thrift/serializer/serializer.rb +34 -0
  35. data/lib/thrift/server/base_server.rb +31 -0
  36. data/lib/thrift/server/{httpserver.rb → mongrel_http_server.rb} +19 -5
  37. data/lib/thrift/server/{nonblockingserver.rb → nonblocking_server.rb} +42 -24
  38. data/lib/thrift/server/simple_server.rb +43 -0
  39. data/lib/thrift/server/thread_pool_server.rb +75 -0
  40. data/lib/thrift/server/threaded_server.rb +47 -0
  41. data/lib/thrift/struct.rb +73 -47
  42. data/lib/thrift/thrift_native.rb +24 -0
  43. data/lib/thrift/transport/base_server_transport.rb +37 -0
  44. data/lib/thrift/transport/base_transport.rb +70 -0
  45. data/lib/thrift/transport/buffered_transport.rb +77 -0
  46. data/lib/thrift/transport/framed_transport.rb +90 -0
  47. data/lib/thrift/transport/http_client_transport.rb +45 -0
  48. data/lib/thrift/transport/io_stream_transport.rb +39 -0
  49. data/lib/thrift/transport/memory_buffer_transport.rb +96 -0
  50. data/lib/thrift/transport/server_socket.rb +63 -0
  51. data/lib/thrift/transport/socket.rb +22 -53
  52. data/lib/thrift/transport/unix_server_socket.rb +60 -0
  53. data/lib/thrift/transport/unix_socket.rb +40 -0
  54. data/lib/thrift/types.rb +20 -2
  55. data/lib/thrift.rb +50 -19
  56. data/script/proto_benchmark.rb +121 -0
  57. data/script/read_struct.rb +43 -0
  58. data/script/write_struct.rb +30 -0
  59. data/spec/ThriftSpec.thrift +40 -2
  60. data/spec/{protocol_spec.rb → base_protocol_spec.rb} +25 -7
  61. data/spec/{transport_spec.rb → base_transport_spec.rb} +44 -52
  62. data/spec/binary_protocol_accelerated_spec.rb +41 -0
  63. data/spec/{binaryprotocol_spec.rb → binary_protocol_spec.rb} +20 -2
  64. data/spec/{binaryprotocol_spec_shared.rb → binary_protocol_spec_shared.rb} +117 -16
  65. data/spec/client_spec.rb +23 -4
  66. data/spec/compact_protocol_spec.rb +117 -0
  67. data/spec/exception_spec.rb +19 -0
  68. data/spec/http_client_spec.rb +49 -0
  69. data/spec/{httpserver_spec.rb → mongrel_http_server_spec.rb} +26 -7
  70. data/spec/{nonblockingserver_spec.rb → nonblocking_server_spec.rb} +25 -5
  71. data/spec/processor_spec.rb +19 -0
  72. data/spec/serializer_spec.rb +27 -10
  73. data/spec/server_socket_spec.rb +80 -0
  74. data/spec/server_spec.rb +35 -16
  75. data/spec/socket_spec.rb +19 -55
  76. data/spec/socket_spec_shared.rb +19 -0
  77. data/spec/spec_helper.rb +34 -9
  78. data/spec/struct_spec.rb +26 -18
  79. data/spec/types_spec.rb +19 -1
  80. data/spec/{unixsocket_spec.rb → unix_socket_spec.rb} +19 -1
  81. data/thrift.gemspec +6 -6
  82. data.tar.gz.sig +0 -0
  83. metadata +80 -70
  84. metadata.gz.sig +0 -0
  85. data/COPYING +0 -14
  86. data/LICENSE +0 -14
  87. data/Makefile.am +0 -15
  88. data/benchmark/gen-rb/BenchmarkService.rb +0 -81
  89. data/benchmark/gen-rb/Benchmark_constants.rb +0 -11
  90. data/benchmark/gen-rb/Benchmark_types.rb +0 -10
  91. data/lib/thrift/deprecation.rb +0 -155
  92. data/lib/thrift/protocol/binaryprotocolaccelerated.rb +0 -19
  93. data/lib/thrift/protocol/tbinaryprotocol.rb +0 -2
  94. data/lib/thrift/protocol/tprotocol.rb +0 -2
  95. data/lib/thrift/protocol.rb +0 -270
  96. data/lib/thrift/serializer.rb +0 -27
  97. data/lib/thrift/server/thttpserver.rb +0 -2
  98. data/lib/thrift/server/tserver.rb +0 -2
  99. data/lib/thrift/server.rb +0 -135
  100. data/lib/thrift/thrift.rb +0 -14
  101. data/lib/thrift/transport/httpclient.rb +0 -29
  102. data/lib/thrift/transport/thttpclient.rb +0 -2
  103. data/lib/thrift/transport/tsocket.rb +0 -2
  104. data/lib/thrift/transport/ttransport.rb +0 -2
  105. data/lib/thrift/transport/unixsocket.rb +0 -58
  106. data/lib/thrift/transport.rb +0 -319
  107. data/spec/backwards_compatibility_spec.rb +0 -136
  108. data/spec/binaryprotocolaccelerated_spec.rb +0 -101
  109. data/spec/deprecation_spec.rb +0 -443
  110. data/spec/gen-rb/NonblockingService.rb +0 -268
  111. data/spec/gen-rb/ThriftSpec_constants.rb +0 -11
  112. data/spec/gen-rb/ThriftSpec_types.rb +0 -134
  113. data/spec/httpclient_spec.rb +0 -31
data/CHANGELOG CHANGED
@@ -1,2 +1,4 @@
1
1
 
2
- v0.0.751142. Initial release
2
+ v0.0.810255.1. Fixes for Ruby 1.9.
3
+
4
+ v0.0.789419. Initial release
data/Manifest CHANGED
@@ -1,22 +1,20 @@
1
1
  CHANGELOG
2
- COPYING
3
- LICENSE
4
- Makefile.am
5
2
  Manifest
6
- README
7
3
  Rakefile
8
- benchmark/Benchmark.thrift
4
+ README
5
+ setup.rb
9
6
  benchmark/benchmark.rb
7
+ benchmark/Benchmark.thrift
10
8
  benchmark/client.rb
11
- benchmark/gen-rb/BenchmarkService.rb
12
- benchmark/gen-rb/Benchmark_constants.rb
13
- benchmark/gen-rb/Benchmark_types.rb
14
9
  benchmark/server.rb
15
10
  benchmark/thin_server.rb
16
11
  ext/binary_protocol_accelerated.c
17
12
  ext/binary_protocol_accelerated.h
13
+ ext/compact_protocol.c
14
+ ext/compact_protocol.h
18
15
  ext/constants.h
19
16
  ext/extconf.rb
17
+ ext/macros.h
20
18
  ext/memory_buffer.c
21
19
  ext/memory_buffer.h
22
20
  ext/protocol.c
@@ -26,53 +24,58 @@ ext/struct.h
26
24
  ext/thrift_native.c
27
25
  lib/thrift.rb
28
26
  lib/thrift/client.rb
29
- lib/thrift/deprecation.rb
27
+ lib/thrift/core_ext.rb
30
28
  lib/thrift/exceptions.rb
31
29
  lib/thrift/processor.rb
32
- lib/thrift/protocol.rb
33
- lib/thrift/protocol/binaryprotocol.rb
34
- lib/thrift/protocol/binaryprotocolaccelerated.rb
35
- lib/thrift/protocol/tbinaryprotocol.rb
36
- lib/thrift/protocol/tprotocol.rb
37
- lib/thrift/serializer.rb
38
- lib/thrift/server.rb
39
- lib/thrift/server/httpserver.rb
40
- lib/thrift/server/nonblockingserver.rb
41
- lib/thrift/server/thttpserver.rb
42
- lib/thrift/server/tserver.rb
43
30
  lib/thrift/struct.rb
44
- lib/thrift/thrift.rb
45
- lib/thrift/transport.rb
46
- lib/thrift/transport/httpclient.rb
47
- lib/thrift/transport/socket.rb
48
- lib/thrift/transport/thttpclient.rb
49
- lib/thrift/transport/tsocket.rb
50
- lib/thrift/transport/ttransport.rb
51
- lib/thrift/transport/unixsocket.rb
31
+ lib/thrift/thrift_native.rb
52
32
  lib/thrift/types.rb
53
- setup.rb
54
- spec/ThriftSpec.thrift
55
- spec/backwards_compatibility_spec.rb
56
- spec/binaryprotocol_spec.rb
57
- spec/binaryprotocol_spec_shared.rb
58
- spec/binaryprotocolaccelerated_spec.rb
33
+ lib/thrift/core_ext/fixnum.rb
34
+ lib/thrift/protocol/base_protocol.rb
35
+ lib/thrift/protocol/binary_protocol.rb
36
+ lib/thrift/protocol/binary_protocol_accelerated.rb
37
+ lib/thrift/protocol/compact_protocol.rb
38
+ lib/thrift/serializer/deserializer.rb
39
+ lib/thrift/serializer/serializer.rb
40
+ lib/thrift/server/base_server.rb
41
+ lib/thrift/server/mongrel_http_server.rb
42
+ lib/thrift/server/nonblocking_server.rb
43
+ lib/thrift/server/simple_server.rb
44
+ lib/thrift/server/thread_pool_server.rb
45
+ lib/thrift/server/threaded_server.rb
46
+ lib/thrift/transport/base_server_transport.rb
47
+ lib/thrift/transport/base_transport.rb
48
+ lib/thrift/transport/buffered_transport.rb
49
+ lib/thrift/transport/framed_transport.rb
50
+ lib/thrift/transport/http_client_transport.rb
51
+ lib/thrift/transport/io_stream_transport.rb
52
+ lib/thrift/transport/memory_buffer_transport.rb
53
+ lib/thrift/transport/server_socket.rb
54
+ lib/thrift/transport/socket.rb
55
+ lib/thrift/transport/unix_server_socket.rb
56
+ lib/thrift/transport/unix_socket.rb
57
+ script/proto_benchmark.rb
58
+ script/read_struct.rb
59
+ script/write_struct.rb
60
+ spec/base_protocol_spec.rb
61
+ spec/base_transport_spec.rb
62
+ spec/binary_protocol_accelerated_spec.rb
63
+ spec/binary_protocol_spec.rb
64
+ spec/binary_protocol_spec_shared.rb
59
65
  spec/client_spec.rb
60
- spec/deprecation_spec.rb
66
+ spec/compact_protocol_spec.rb
61
67
  spec/exception_spec.rb
62
- spec/gen-rb/NonblockingService.rb
63
- spec/gen-rb/ThriftSpec_constants.rb
64
- spec/gen-rb/ThriftSpec_types.rb
65
- spec/httpclient_spec.rb
66
- spec/httpserver_spec.rb
67
- spec/nonblockingserver_spec.rb
68
+ spec/http_client_spec.rb
69
+ spec/mongrel_http_server_spec.rb
70
+ spec/nonblocking_server_spec.rb
68
71
  spec/processor_spec.rb
69
- spec/protocol_spec.rb
70
72
  spec/serializer_spec.rb
73
+ spec/server_socket_spec.rb
71
74
  spec/server_spec.rb
72
75
  spec/socket_spec.rb
73
76
  spec/socket_spec_shared.rb
74
77
  spec/spec_helper.rb
75
78
  spec/struct_spec.rb
76
- spec/transport_spec.rb
79
+ spec/ThriftSpec.thrift
77
80
  spec/types_spec.rb
78
- spec/unixsocket_spec.rb
81
+ spec/unix_socket_spec.rb
data/README CHANGED
@@ -1,7 +1,25 @@
1
1
  Thrift Ruby Software Library
2
- by Kevin Ballard, Kevin Clark, Mark Slee
3
2
  http://incubator.apache.org/thrift/
4
3
 
4
+ == LICENSE:
5
+
6
+ Licensed to the Apache Software Foundation (ASF) under one
7
+ or more contributor license agreements. See the NOTICE file
8
+ distributed with this work for additional information
9
+ regarding copyright ownership. The ASF licenses this file
10
+ to you under the Apache License, Version 2.0 (the
11
+ "License"); you may not use this file except in compliance
12
+ with the License. You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing,
17
+ software distributed under the License is distributed on an
18
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
+ KIND, either express or implied. See the License for the
20
+ specific language governing permissions and limitations
21
+ under the License.
22
+
5
23
  == DESCRIPTION:
6
24
 
7
25
  Thrift is a strongly-typed language-agnostic RPC system.
@@ -23,8 +41,3 @@ thrift software package.
23
41
  This section should get written by someone with the time and inclination.
24
42
  In the meantime, look at existing code, such as the benchmark or the tutorial
25
43
  in the full thrift distribution.
26
-
27
- == LICENSE:
28
-
29
- Thrift is distributed under the Apache Software License.
30
- Please see the included LICENSE file.
data/Rakefile CHANGED
@@ -79,7 +79,7 @@ begin
79
79
  Echoe.new('thrift') do |p|
80
80
  p.author = ['Kevin Ballard', 'Kevin Clark', 'Mark Slee', 'Evan Weaver']
81
81
  p.project = "fauna"
82
- p.summary = "Ruby libraries for Thrift (a language-agnostic RPC system)"
82
+ p.summary = "Ruby libraries for Thrift, with fixes."
83
83
  p.include_rakefile = true
84
84
  p.url = "http://blog.evanweaver.com/files/doc/fauna/thrift/"
85
85
  p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/"
@@ -1,3 +1,22 @@
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
+
1
20
  namespace rb ThriftBenchmark
2
21
 
3
22
  service BenchmarkService {
@@ -1,8 +1,25 @@
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
+
1
20
  require 'rubygems'
2
21
  $:.unshift File.dirname(__FILE__) + '/../lib'
3
22
  require 'thrift'
4
- require 'thrift/server/nonblockingserver'
5
- require 'thrift/transport/unixsocket'
6
23
  require 'stringio'
7
24
 
8
25
  HOST = '127.0.0.1'
@@ -214,7 +231,7 @@ class BenchmarkManager
214
231
  }
215
232
 
216
233
  def tabulate(fmt, *labels_and_values)
217
- labels = labels_and_values.map { |(l,)| Array === l ? l.first : l }
234
+ labels = labels_and_values.map { |l| Array === l ? l.first : l }
218
235
  label_width = labels.inject(0) { |w,l| l.size > w ? l.size : w }
219
236
  labels_and_values.each do |(l,v)|
220
237
  f = fmt
data/benchmark/client.rb CHANGED
@@ -1,8 +1,26 @@
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
+
1
20
  $:.unshift File.dirname(__FILE__) + '/../lib'
2
21
  require 'thrift'
3
- require 'thrift/server/nonblockingserver'
4
22
  $:.unshift File.dirname(__FILE__) + "/gen-rb"
5
- require 'BenchmarkService'
23
+ require 'benchmark_service'
6
24
 
7
25
  class Client
8
26
  def initialize(host, port, clients_per_process, calls_per_client, log_exceptions)
data/benchmark/server.rb CHANGED
@@ -1,8 +1,26 @@
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
+
1
20
  $:.unshift File.dirname(__FILE__) + '/../lib'
2
21
  require 'thrift'
3
- require 'thrift/server/nonblockingserver'
4
22
  $:.unshift File.dirname(__FILE__) + "/gen-rb"
5
- require 'BenchmarkService'
23
+ require 'benchmark_service'
6
24
 
7
25
  module Server
8
26
  include Thrift
@@ -22,8 +40,8 @@ module Server
22
40
  handler = BenchmarkHandler.new
23
41
  processor = ThriftBenchmark::BenchmarkService::Processor.new(handler)
24
42
  transport = ServerSocket.new(host, port)
25
- transportFactory = FramedTransportFactory.new
26
- args = [processor, transport, transportFactory, nil, 20]
43
+ transport_factory = FramedTransportFactory.new
44
+ args = [processor, transport, transport_factory, nil, 20]
27
45
  if serverClass == NonblockingServer
28
46
  logger = Logger.new(STDERR)
29
47
  logger.level = Logger::WARN
@@ -1,8 +1,26 @@
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
+
1
20
  $:.unshift File.dirname(__FILE__) + '/../lib'
2
21
  require 'thrift'
3
- require 'thrift/server/nonblockingserver'
4
22
  $:.unshift File.dirname(__FILE__) + "/gen-rb"
5
- require 'BenchmarkService'
23
+ require 'benchmark_service'
6
24
  HOST = 'localhost'
7
25
  PORT = 42587
8
26
 
@@ -20,7 +38,7 @@ end
20
38
  handler = BenchmarkHandler.new
21
39
  processor = ThriftBenchmark::BenchmarkService::Processor.new(handler)
22
40
  transport = Thrift::ServerSocket.new(HOST, PORT)
23
- transportFactory = Thrift::FramedTransportFactory.new
41
+ transport_factory = Thrift::FramedTransportFactory.new
24
42
  logger = Logger.new(STDERR)
25
43
  logger.level = Logger::WARN
26
- Thrift::NonblockingServer.new(processor, transport, transportFactory, nil, 20, logger).serve
44
+ Thrift::NonblockingServer.new(processor, transport, transport_factory, nil, 20, logger).serve
@@ -1,14 +1,28 @@
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
+
1
20
  #include <ruby.h>
2
21
  #include <stdbool.h>
3
22
  #include <stdint.h>
4
23
  #include <constants.h>
5
24
  #include <struct.h>
6
-
7
- #define GET_TRANSPORT(obj) rb_ivar_get(obj, transport_ivar_id)
8
- #define GET_STRICT_READ(obj) rb_ivar_get(obj, strict_read_ivar_id)
9
- #define GET_STRICT_WRITE(obj) rb_ivar_get(obj, strict_write_ivar_id)
10
- #define WRITE(obj, data, length) rb_funcall(obj, write_method_id, 1, rb_str_new(data, length))
11
- #define CHECK_NIL(obj) if (NIL_P(obj)) { rb_raise(rb_eStandardError, "nil argument not allowed!");}
25
+ #include "macros.h"
12
26
 
13
27
  VALUE rb_thrift_binary_proto_native_qmark(VALUE self) {
14
28
  return Qtrue;
@@ -62,7 +76,7 @@ static void write_i64_direct(VALUE trans, int64_t value) {
62
76
  }
63
77
 
64
78
  static void write_string_direct(VALUE trans, VALUE str) {
65
- write_i32_direct(trans, RSTRING(str)->len);
79
+ write_i32_direct(trans, RSTRING_LEN(str));
66
80
  rb_funcall(trans, write_method_id, 1, str);
67
81
  }
68
82
 
@@ -108,7 +122,7 @@ VALUE rb_thrift_binary_proto_write_message_begin(VALUE self, VALUE name, VALUE t
108
122
  write_i32_direct(trans, FIX2INT(seqid));
109
123
  } else {
110
124
  write_string_direct(trans, name);
111
- write_byte_direct(trans, type);
125
+ write_byte_direct(trans, FIX2INT(type));
112
126
  write_i32_direct(trans, FIX2INT(seqid));
113
127
  }
114
128
 
@@ -186,7 +200,7 @@ VALUE rb_thrift_binary_proto_write_double(VALUE self, VALUE dub) {
186
200
  double f;
187
201
  int64_t t;
188
202
  } transfer;
189
- transfer.f = RFLOAT(rb_Float(dub))->value;
203
+ transfer.f = RFLOAT_VALUE(rb_Float(dub));
190
204
  write_i64_direct(GET_TRANSPORT(self), transfer.t);
191
205
 
192
206
  return Qnil;
@@ -195,8 +209,6 @@ VALUE rb_thrift_binary_proto_write_double(VALUE self, VALUE dub) {
195
209
  VALUE rb_thrift_binary_proto_write_string(VALUE self, VALUE str) {
196
210
  CHECK_NIL(str);
197
211
  VALUE trans = GET_TRANSPORT(self);
198
- // write_i32_direct(trans, RSTRING(str)->len);
199
- // rb_funcall(trans, write_method_id, 1, str);
200
212
  write_string_direct(trans, str);
201
213
  return Qnil;
202
214
  }
@@ -205,28 +217,27 @@ VALUE rb_thrift_binary_proto_write_string(VALUE self, VALUE str) {
205
217
  // interface reading methods
206
218
  //---------------------------------------
207
219
 
208
- #define READ(obj, length) rb_funcall(GET_TRANSPORT(obj), read_method_id, 1, INT2FIX(length))
209
-
210
220
  VALUE rb_thrift_binary_proto_read_string(VALUE self);
211
221
  VALUE rb_thrift_binary_proto_read_byte(VALUE self);
212
222
  VALUE rb_thrift_binary_proto_read_i32(VALUE self);
213
223
  VALUE rb_thrift_binary_proto_read_i16(VALUE self);
214
224
 
215
225
  static char read_byte_direct(VALUE self) {
216
- return (RSTRING(READ(self, 1))->ptr)[0];
226
+ VALUE buf = READ(self, 1);
227
+ return RSTRING_PTR(buf)[0];
217
228
  }
218
229
 
219
230
  static int16_t read_i16_direct(VALUE self) {
220
231
  VALUE buf = READ(self, 2);
221
- return (int16_t)(((uint8_t)(RSTRING(buf)->ptr[1])) | ((uint16_t)((RSTRING(buf)->ptr[0]) << 8)));
232
+ return (int16_t)(((uint8_t)(RSTRING_PTR(buf)[1])) | ((uint16_t)((RSTRING_PTR(buf)[0]) << 8)));
222
233
  }
223
234
 
224
235
  static int32_t read_i32_direct(VALUE self) {
225
236
  VALUE buf = READ(self, 4);
226
- return ((uint8_t)(RSTRING(buf)->ptr[3])) |
227
- (((uint8_t)(RSTRING(buf)->ptr[2])) << 8) |
228
- (((uint8_t)(RSTRING(buf)->ptr[1])) << 16) |
229
- (((uint8_t)(RSTRING(buf)->ptr[0])) << 24);
237
+ return ((uint8_t)(RSTRING_PTR(buf)[3])) |
238
+ (((uint8_t)(RSTRING_PTR(buf)[2])) << 8) |
239
+ (((uint8_t)(RSTRING_PTR(buf)[1])) << 16) |
240
+ (((uint8_t)(RSTRING_PTR(buf)[0])) << 24);
230
241
  }
231
242
 
232
243
  static int64_t read_i64_direct(VALUE self) {
@@ -289,7 +300,7 @@ VALUE rb_thrift_binary_proto_read_message_begin(VALUE self) {
289
300
  rb_exc_raise(get_protocol_exception(INT2FIX(BAD_VERSION), rb_str_new2("No version identifier, old protocol client?")));
290
301
  }
291
302
  name = READ(self, version);
292
- type = rb_thrift_binary_proto_read_byte(self);
303
+ type = read_byte_direct(self);
293
304
  seqid = rb_thrift_binary_proto_read_i32(self);
294
305
  }
295
306
 
@@ -325,7 +336,7 @@ VALUE rb_thrift_binary_proto_read_set_begin(VALUE self) {
325
336
 
326
337
  VALUE rb_thrift_binary_proto_read_bool(VALUE self) {
327
338
  char byte = read_byte_direct(self);
328
- return byte == 1 ? Qtrue : Qfalse;
339
+ return byte != 0 ? Qtrue : Qfalse;
329
340
  }
330
341
 
331
342
  VALUE rb_thrift_binary_proto_read_byte(VALUE self) {
@@ -1 +1,20 @@
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
+
1
20
  void Init_binary_protocol_accelerated();