rice 4.6.1 → 4.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/CMakeLists.txt +0 -4
- data/Rakefile +2 -8
- data/bin/rice-doc.rb +212 -0
- data/bin/rice-rbs.rb +93 -0
- data/include/rice/rice.hpp +4972 -4015
- data/include/rice/stl.hpp +822 -294
- data/lib/rice/doc/cpp_reference.rb +166 -0
- data/lib/rice/doc/doxygen.rb +294 -0
- data/lib/rice/doc/mkdocs.rb +298 -0
- data/lib/rice/doc/rice.rb +29 -0
- data/lib/rice/doc/ruby.rb +37 -0
- data/lib/rice/doc.rb +5 -0
- data/lib/{make_rice_headers.rb → rice/make_rice_headers.rb} +3 -0
- data/lib/rice/native.rb +18 -0
- data/lib/rice/native_registry.rb +21 -0
- data/lib/rice/parameter.rb +7 -0
- data/lib/rice/rbs.rb +104 -0
- data/lib/rice/version.rb +1 -1
- data/lib/rice.rb +4 -0
- data/lib/rubygems/cmake_builder.rb +24 -27
- data/rice/Arg.hpp +4 -4
- data/rice/Arg.ipp +4 -4
- data/rice/Buffer.hpp +32 -28
- data/rice/Buffer.ipp +306 -178
- data/rice/Data_Object.ipp +101 -82
- data/rice/Data_Type.hpp +5 -7
- data/rice/Data_Type.ipp +48 -29
- data/rice/Enum.ipp +15 -21
- data/rice/Function.hpp +17 -0
- data/rice/Function.ipp +13 -0
- data/rice/Pointer.hpp +15 -0
- data/rice/Pointer.ipp +49 -0
- data/rice/Return.hpp +1 -1
- data/rice/Return.ipp +2 -2
- data/rice/api.hpp +30 -0
- data/rice/cpp_api/Array.hpp +2 -2
- data/rice/cpp_api/Array.ipp +50 -5
- data/rice/cpp_api/Class.hpp +0 -5
- data/rice/cpp_api/Class.ipp +19 -0
- data/rice/cpp_api/Hash.ipp +20 -0
- data/rice/cpp_api/Module.hpp +6 -3
- data/rice/cpp_api/Module.ipp +49 -11
- data/rice/cpp_api/Object.ipp +31 -2
- data/rice/cpp_api/String.hpp +1 -2
- data/rice/cpp_api/String.ipp +21 -1
- data/rice/cpp_api/Struct.ipp +5 -0
- data/rice/cpp_api/Symbol.ipp +34 -0
- data/rice/cpp_api/shared_methods.hpp +12 -12
- data/rice/detail/MethodInfo.hpp +4 -2
- data/rice/detail/MethodInfo.ipp +19 -3
- data/rice/detail/ModuleRegistry.hpp +18 -0
- data/rice/detail/ModuleRegistry.ipp +25 -0
- data/rice/detail/Native.hpp +45 -2
- data/rice/detail/Native.ipp +196 -2
- data/rice/detail/NativeAttributeGet.hpp +9 -4
- data/rice/detail/NativeAttributeGet.ipp +65 -11
- data/rice/detail/NativeAttributeSet.hpp +4 -0
- data/rice/detail/NativeAttributeSet.ipp +30 -2
- data/rice/detail/NativeCallbackFFI.ipp +2 -2
- data/rice/detail/NativeCallbackSimple.ipp +1 -1
- data/rice/detail/NativeFunction.hpp +11 -49
- data/rice/detail/NativeFunction.ipp +82 -379
- data/rice/detail/NativeInvoker.hpp +74 -0
- data/rice/detail/NativeInvoker.ipp +197 -0
- data/rice/detail/NativeIterator.hpp +4 -0
- data/rice/detail/NativeIterator.ipp +19 -0
- data/rice/detail/NativeMethod.hpp +97 -0
- data/rice/detail/NativeMethod.ipp +332 -0
- data/rice/detail/NativeProc.hpp +51 -0
- data/rice/detail/NativeProc.ipp +133 -0
- data/rice/detail/NativeRegistry.hpp +8 -0
- data/rice/detail/NativeRegistry.ipp +27 -0
- data/rice/detail/Parameter.hpp +47 -0
- data/rice/detail/Parameter.ipp +105 -0
- data/rice/detail/Proc.ipp +14 -13
- data/rice/detail/Registries.hpp +1 -0
- data/rice/detail/RubyType.hpp +0 -2
- data/rice/detail/RubyType.ipp +15 -33
- data/rice/detail/Type.hpp +44 -8
- data/rice/detail/Type.ipp +151 -49
- data/rice/detail/TypeRegistry.hpp +3 -0
- data/rice/detail/TypeRegistry.ipp +17 -27
- data/rice/detail/Types.ipp +430 -0
- data/rice/detail/Wrapper.hpp +12 -0
- data/rice/detail/Wrapper.ipp +45 -2
- data/rice/detail/from_ruby.ipp +567 -1073
- data/rice/detail/ruby.hpp +1 -0
- data/rice/detail/to_ruby.ipp +4 -635
- data/rice/libc/file.ipp +3 -6
- data/rice/rice.hpp +22 -12
- data/rice/rice_api/Arg.hpp +7 -0
- data/rice/rice_api/Arg.ipp +9 -0
- data/rice/rice_api/ModuleRegistry.hpp +7 -0
- data/rice/rice_api/ModuleRegistry.ipp +10 -0
- data/rice/rice_api/Native.hpp +7 -0
- data/rice/rice_api/Native.ipp +52 -0
- data/rice/rice_api/NativeRegistry.hpp +7 -0
- data/rice/rice_api/NativeRegistry.ipp +21 -0
- data/rice/rice_api/Parameter.hpp +7 -0
- data/rice/rice_api/Parameter.ipp +11 -0
- data/rice/rice_api/Registries.hpp +6 -0
- data/rice/rice_api/Registries.ipp +12 -0
- data/rice/rice_api/TypeRegistry.hpp +7 -0
- data/rice/rice_api/TypeRegistry.ipp +10 -0
- data/rice/stl/complex.ipp +35 -0
- data/rice/stl/exception.ipp +20 -7
- data/rice/stl/filesystem.hpp +6 -0
- data/rice/stl/filesystem.ipp +34 -0
- data/rice/stl/map.ipp +13 -21
- data/rice/stl/monostate.ipp +37 -1
- data/rice/stl/multimap.ipp +17 -24
- data/rice/stl/optional.ipp +47 -2
- data/rice/stl/pair.ipp +23 -58
- data/rice/stl/reference_wrapper.ipp +22 -1
- data/rice/stl/set.ipp +17 -9
- data/rice/stl/shared_ptr.ipp +44 -17
- data/rice/stl/string.ipp +175 -7
- data/rice/stl/string_view.ipp +5 -0
- data/rice/stl/tuple.ipp +38 -9
- data/rice/stl/unique_ptr.ipp +46 -2
- data/rice/stl/unordered_map.ipp +13 -21
- data/rice/stl/variant.ipp +47 -11
- data/rice/stl/vector.ipp +183 -104
- data/rice/stl.hpp +1 -0
- data/rice/traits/function_traits.hpp +2 -2
- data/rice/traits/method_traits.hpp +5 -16
- data/rice/traits/rice_traits.hpp +24 -4
- data/rice.gemspec +11 -22
- data/test/embed_ruby.cpp +0 -3
- data/test/test_Array.cpp +38 -38
- data/test/test_Attribute.cpp +187 -2
- data/test/test_Buffer.cpp +302 -26
- data/test/test_Callback.cpp +2 -3
- data/test/test_Class.cpp +5 -5
- data/test/test_Data_Object.cpp +0 -55
- data/test/test_Data_Type.cpp +19 -30
- data/test/test_Enum.cpp +4 -46
- data/test/test_From_Ruby.cpp +88 -81
- data/test/test_GVL.cpp +109 -0
- data/test/test_Iterator.cpp +1 -1
- data/test/test_Keep_Alive_No_Wrapper.cpp +5 -3
- data/test/test_Module.cpp +8 -9
- data/test/test_Object.cpp +1 -1
- data/test/test_Overloads.cpp +3 -3
- data/test/test_Stl_Map.cpp +8 -8
- data/test/test_Stl_Multimap.cpp +4 -4
- data/test/test_Stl_Pair.cpp +5 -3
- data/test/test_Stl_SharedPtr.cpp +24 -12
- data/test/test_Stl_Tuple.cpp +1 -1
- data/test/test_Stl_UniquePtr.cpp +8 -0
- data/test/test_Stl_Unordered_Map.cpp +9 -9
- data/test/test_Stl_Variant.cpp +9 -3
- data/test/test_Stl_Vector.cpp +118 -13
- data/test/test_To_Ruby.cpp +35 -28
- data/test/test_Type.cpp +256 -53
- data/test/unittest.hpp +35 -0
- metadata +66 -34
- data/rice/Init.hpp +0 -8
- data/rice/Init.ipp +0 -8
- data/rice/detail/RubyFunction.hpp +0 -31
- data/rice/detail/RubyFunction.ipp +0 -77
- data/sample/callbacks/extconf.rb +0 -5
- data/sample/callbacks/sample_callbacks.cpp +0 -35
- data/sample/callbacks/test.rb +0 -28
- data/sample/enum/extconf.rb +0 -5
- data/sample/enum/sample_enum.cpp +0 -40
- data/sample/enum/test.rb +0 -8
- data/sample/inheritance/animals.cpp +0 -82
- data/sample/inheritance/extconf.rb +0 -5
- data/sample/inheritance/test.rb +0 -7
- data/sample/map/extconf.rb +0 -5
- data/sample/map/map.cpp +0 -73
- data/sample/map/test.rb +0 -7
- data/test/ext/t1/Foo.hpp +0 -10
- data/test/ext/t1/extconf.rb +0 -4
- data/test/ext/t1/t1.cpp +0 -13
- data/test/ext/t2/extconf.rb +0 -4
- data/test/ext/t2/t2.cpp +0 -11
- data/test/ruby/test_callbacks_sample.rb +0 -28
- data/test/ruby/test_multiple_extensions.rb +0 -18
- data/test/ruby/test_multiple_extensions_same_class.rb +0 -14
- data/test/ruby/test_multiple_extensions_with_inheritance.rb +0 -20
- /data/test/{test_Stl_Type.cpp → test_Stl_Type_Info.cpp} +0 -0
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rice
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paul Brannan
|
|
@@ -11,6 +11,20 @@ bindir: bin
|
|
|
11
11
|
cert_chain: []
|
|
12
12
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: ostruct
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - ">="
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '0'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '0'
|
|
14
28
|
- !ruby/object:Gem::Dependency
|
|
15
29
|
name: bundler
|
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -61,7 +75,9 @@ email:
|
|
|
61
75
|
- curlypaul924@gmail.com
|
|
62
76
|
- jasongroelofs@gmail.com
|
|
63
77
|
- cfis@savagexi.com
|
|
64
|
-
executables:
|
|
78
|
+
executables:
|
|
79
|
+
- rice-doc.rb
|
|
80
|
+
- rice-rbs.rb
|
|
65
81
|
extensions: []
|
|
66
82
|
extra_rdoc_files:
|
|
67
83
|
- README.md
|
|
@@ -75,11 +91,23 @@ files:
|
|
|
75
91
|
- Gemfile
|
|
76
92
|
- README.md
|
|
77
93
|
- Rakefile
|
|
94
|
+
- bin/rice-doc.rb
|
|
95
|
+
- bin/rice-rbs.rb
|
|
78
96
|
- include/rice/rice.hpp
|
|
79
97
|
- include/rice/stl.hpp
|
|
80
|
-
- lib/make_rice_headers.rb
|
|
81
98
|
- lib/mkmf-rice.rb
|
|
82
99
|
- lib/rice.rb
|
|
100
|
+
- lib/rice/doc.rb
|
|
101
|
+
- lib/rice/doc/cpp_reference.rb
|
|
102
|
+
- lib/rice/doc/doxygen.rb
|
|
103
|
+
- lib/rice/doc/mkdocs.rb
|
|
104
|
+
- lib/rice/doc/rice.rb
|
|
105
|
+
- lib/rice/doc/ruby.rb
|
|
106
|
+
- lib/rice/make_rice_headers.rb
|
|
107
|
+
- lib/rice/native.rb
|
|
108
|
+
- lib/rice/native_registry.rb
|
|
109
|
+
- lib/rice/parameter.rb
|
|
110
|
+
- lib/rice/rbs.rb
|
|
83
111
|
- lib/rice/version.rb
|
|
84
112
|
- lib/rubygems/builder.rb
|
|
85
113
|
- lib/rubygems/cmake_builder.rb
|
|
@@ -104,14 +132,17 @@ files:
|
|
|
104
132
|
- rice/Enum.ipp
|
|
105
133
|
- rice/Exception.hpp
|
|
106
134
|
- rice/Exception.ipp
|
|
107
|
-
- rice/
|
|
108
|
-
- rice/
|
|
135
|
+
- rice/Function.hpp
|
|
136
|
+
- rice/Function.ipp
|
|
109
137
|
- rice/JumpException.hpp
|
|
110
138
|
- rice/JumpException.ipp
|
|
111
139
|
- rice/MemoryView.hpp
|
|
112
140
|
- rice/MemoryView.ipp
|
|
141
|
+
- rice/Pointer.hpp
|
|
142
|
+
- rice/Pointer.ipp
|
|
113
143
|
- rice/Return.hpp
|
|
114
144
|
- rice/Return.ipp
|
|
145
|
+
- rice/api.hpp
|
|
115
146
|
- rice/cpp_api/Array.hpp
|
|
116
147
|
- rice/cpp_api/Array.ipp
|
|
117
148
|
- rice/cpp_api/Builtin_Object.hpp
|
|
@@ -143,6 +174,8 @@ files:
|
|
|
143
174
|
- rice/detail/InstanceRegistry.ipp
|
|
144
175
|
- rice/detail/MethodInfo.hpp
|
|
145
176
|
- rice/detail/MethodInfo.ipp
|
|
177
|
+
- rice/detail/ModuleRegistry.hpp
|
|
178
|
+
- rice/detail/ModuleRegistry.ipp
|
|
146
179
|
- rice/detail/Native.hpp
|
|
147
180
|
- rice/detail/Native.ipp
|
|
148
181
|
- rice/detail/NativeAttributeGet.hpp
|
|
@@ -155,22 +188,29 @@ files:
|
|
|
155
188
|
- rice/detail/NativeCallbackSimple.ipp
|
|
156
189
|
- rice/detail/NativeFunction.hpp
|
|
157
190
|
- rice/detail/NativeFunction.ipp
|
|
191
|
+
- rice/detail/NativeInvoker.hpp
|
|
192
|
+
- rice/detail/NativeInvoker.ipp
|
|
158
193
|
- rice/detail/NativeIterator.hpp
|
|
159
194
|
- rice/detail/NativeIterator.ipp
|
|
195
|
+
- rice/detail/NativeMethod.hpp
|
|
196
|
+
- rice/detail/NativeMethod.ipp
|
|
197
|
+
- rice/detail/NativeProc.hpp
|
|
198
|
+
- rice/detail/NativeProc.ipp
|
|
160
199
|
- rice/detail/NativeRegistry.hpp
|
|
161
200
|
- rice/detail/NativeRegistry.ipp
|
|
201
|
+
- rice/detail/Parameter.hpp
|
|
202
|
+
- rice/detail/Parameter.ipp
|
|
162
203
|
- rice/detail/Proc.hpp
|
|
163
204
|
- rice/detail/Proc.ipp
|
|
164
205
|
- rice/detail/Registries.hpp
|
|
165
206
|
- rice/detail/Registries.ipp
|
|
166
|
-
- rice/detail/RubyFunction.hpp
|
|
167
|
-
- rice/detail/RubyFunction.ipp
|
|
168
207
|
- rice/detail/RubyType.hpp
|
|
169
208
|
- rice/detail/RubyType.ipp
|
|
170
209
|
- rice/detail/Type.hpp
|
|
171
210
|
- rice/detail/Type.ipp
|
|
172
211
|
- rice/detail/TypeRegistry.hpp
|
|
173
212
|
- rice/detail/TypeRegistry.ipp
|
|
213
|
+
- rice/detail/Types.ipp
|
|
174
214
|
- rice/detail/Wrapper.hpp
|
|
175
215
|
- rice/detail/Wrapper.ipp
|
|
176
216
|
- rice/detail/cpp_protect.hpp
|
|
@@ -187,6 +227,20 @@ files:
|
|
|
187
227
|
- rice/libc/file.hpp
|
|
188
228
|
- rice/libc/file.ipp
|
|
189
229
|
- rice/rice.hpp
|
|
230
|
+
- rice/rice_api/Arg.hpp
|
|
231
|
+
- rice/rice_api/Arg.ipp
|
|
232
|
+
- rice/rice_api/ModuleRegistry.hpp
|
|
233
|
+
- rice/rice_api/ModuleRegistry.ipp
|
|
234
|
+
- rice/rice_api/Native.hpp
|
|
235
|
+
- rice/rice_api/Native.ipp
|
|
236
|
+
- rice/rice_api/NativeRegistry.hpp
|
|
237
|
+
- rice/rice_api/NativeRegistry.ipp
|
|
238
|
+
- rice/rice_api/Parameter.hpp
|
|
239
|
+
- rice/rice_api/Parameter.ipp
|
|
240
|
+
- rice/rice_api/Registries.hpp
|
|
241
|
+
- rice/rice_api/Registries.ipp
|
|
242
|
+
- rice/rice_api/TypeRegistry.hpp
|
|
243
|
+
- rice/rice_api/TypeRegistry.ipp
|
|
190
244
|
- rice/ruby_mark.hpp
|
|
191
245
|
- rice/stl.hpp
|
|
192
246
|
- rice/stl/complex.hpp
|
|
@@ -195,6 +249,8 @@ files:
|
|
|
195
249
|
- rice/stl/exception.ipp
|
|
196
250
|
- rice/stl/exception_ptr.hpp
|
|
197
251
|
- rice/stl/exception_ptr.ipp
|
|
252
|
+
- rice/stl/filesystem.hpp
|
|
253
|
+
- rice/stl/filesystem.ipp
|
|
198
254
|
- rice/stl/map.hpp
|
|
199
255
|
- rice/stl/map.ipp
|
|
200
256
|
- rice/stl/monostate.hpp
|
|
@@ -233,30 +289,9 @@ files:
|
|
|
233
289
|
- rice/traits/function_traits.hpp
|
|
234
290
|
- rice/traits/method_traits.hpp
|
|
235
291
|
- rice/traits/rice_traits.hpp
|
|
236
|
-
- sample/callbacks/extconf.rb
|
|
237
|
-
- sample/callbacks/sample_callbacks.cpp
|
|
238
|
-
- sample/callbacks/test.rb
|
|
239
|
-
- sample/enum/extconf.rb
|
|
240
|
-
- sample/enum/sample_enum.cpp
|
|
241
|
-
- sample/enum/test.rb
|
|
242
|
-
- sample/inheritance/animals.cpp
|
|
243
|
-
- sample/inheritance/extconf.rb
|
|
244
|
-
- sample/inheritance/test.rb
|
|
245
|
-
- sample/map/extconf.rb
|
|
246
|
-
- sample/map/map.cpp
|
|
247
|
-
- sample/map/test.rb
|
|
248
292
|
- test/embed_ruby.cpp
|
|
249
293
|
- test/embed_ruby.hpp
|
|
250
|
-
- test/ext/t1/Foo.hpp
|
|
251
|
-
- test/ext/t1/extconf.rb
|
|
252
|
-
- test/ext/t1/t1.cpp
|
|
253
|
-
- test/ext/t2/extconf.rb
|
|
254
|
-
- test/ext/t2/t2.cpp
|
|
255
294
|
- test/extconf.rb
|
|
256
|
-
- test/ruby/test_callbacks_sample.rb
|
|
257
|
-
- test/ruby/test_multiple_extensions.rb
|
|
258
|
-
- test/ruby/test_multiple_extensions_same_class.rb
|
|
259
|
-
- test/ruby/test_multiple_extensions_with_inheritance.rb
|
|
260
295
|
- test/test_Address_Registration_Guard.cpp
|
|
261
296
|
- test/test_Array.cpp
|
|
262
297
|
- test/test_Attribute.cpp
|
|
@@ -272,6 +307,7 @@ files:
|
|
|
272
307
|
- test/test_Exception.cpp
|
|
273
308
|
- test/test_File.cpp
|
|
274
309
|
- test/test_From_Ruby.cpp
|
|
310
|
+
- test/test_GVL.cpp
|
|
275
311
|
- test/test_Hash.cpp
|
|
276
312
|
- test/test_Identifier.cpp
|
|
277
313
|
- test/test_Inheritance.cpp
|
|
@@ -298,7 +334,7 @@ files:
|
|
|
298
334
|
- test/test_Stl_String.cpp
|
|
299
335
|
- test/test_Stl_String_View.cpp
|
|
300
336
|
- test/test_Stl_Tuple.cpp
|
|
301
|
-
- test/
|
|
337
|
+
- test/test_Stl_Type_Info.cpp
|
|
302
338
|
- test/test_Stl_UniquePtr.cpp
|
|
303
339
|
- test/test_Stl_Unordered_Map.cpp
|
|
304
340
|
- test/test_Stl_Variant.cpp
|
|
@@ -338,8 +374,4 @@ requirements: []
|
|
|
338
374
|
rubygems_version: 3.6.9
|
|
339
375
|
specification_version: 4
|
|
340
376
|
summary: Ruby Interface for C++ Extensions
|
|
341
|
-
test_files:
|
|
342
|
-
- test/ruby/test_callbacks_sample.rb
|
|
343
|
-
- test/ruby/test_multiple_extensions.rb
|
|
344
|
-
- test/ruby/test_multiple_extensions_same_class.rb
|
|
345
|
-
- test/ruby/test_multiple_extensions_with_inheritance.rb
|
|
377
|
+
test_files: []
|
data/rice/Init.hpp
DELETED
data/rice/Init.ipp
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
#ifndef Rice__detail__ruby_function__hpp_
|
|
2
|
-
#define Rice__detail__ruby_function__hpp_
|
|
3
|
-
|
|
4
|
-
namespace Rice::detail
|
|
5
|
-
{
|
|
6
|
-
/* This is functor class that wraps calls to a Ruby C API method. It is needed because
|
|
7
|
-
rb_protect only supports calling methods that take one argument. Thus
|
|
8
|
-
we invoke rb_protect telling it to invoke Ruby_Function::call with an
|
|
9
|
-
instance of a Ruby_Function. That instance then in turn calls the original
|
|
10
|
-
Ruby method passing along its required arguments. */
|
|
11
|
-
|
|
12
|
-
template<typename Function_T, typename...Arg_Ts>
|
|
13
|
-
class RubyFunction
|
|
14
|
-
{
|
|
15
|
-
public:
|
|
16
|
-
using Return_T = typename function_traits<Function_T>::return_type;
|
|
17
|
-
|
|
18
|
-
public:
|
|
19
|
-
RubyFunction(Function_T func, const Arg_Ts&... args);
|
|
20
|
-
Return_T operator()();
|
|
21
|
-
|
|
22
|
-
private:
|
|
23
|
-
Function_T func_;
|
|
24
|
-
std::tuple<Arg_Ts...> args_;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
template<typename Function_T, typename ...Arg_Ts>
|
|
28
|
-
auto protect(Function_T func, Arg_Ts...args);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
#endif // Rice__detail__ruby_function__hpp_
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#include <any>
|
|
3
|
-
#include <tuple>
|
|
4
|
-
|
|
5
|
-
namespace Rice::detail
|
|
6
|
-
{
|
|
7
|
-
template<typename Function_T, typename...Arg_Ts>
|
|
8
|
-
inline RubyFunction<Function_T, Arg_Ts...>::RubyFunction(Function_T func, const Arg_Ts&... args)
|
|
9
|
-
: func_(func), args_(std::forward_as_tuple(args...))
|
|
10
|
-
{
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
template<typename Function_T, typename...Arg_Ts>
|
|
14
|
-
inline typename RubyFunction<Function_T, Arg_Ts...>::Return_T RubyFunction<Function_T, Arg_Ts...>::operator()()
|
|
15
|
-
{
|
|
16
|
-
// Setup a thread local variable to capture the result of the Ruby function call.
|
|
17
|
-
// We use thread_local because the lambda has to be captureless so it can
|
|
18
|
-
// be converted to a function pointer callable by C.
|
|
19
|
-
// The thread local variable avoids having to cast the result to VALUE and then
|
|
20
|
-
// back again to Return_T. The problem with that is the translation is not lossless
|
|
21
|
-
// in some cases - for example a double with value of -1.0 does not roundrip.
|
|
22
|
-
//
|
|
23
|
-
thread_local std::any result;
|
|
24
|
-
|
|
25
|
-
// Callback that will invoke the Ruby function
|
|
26
|
-
using Functor_T = RubyFunction<Function_T, Arg_Ts...>;
|
|
27
|
-
auto callback = [](VALUE value) -> VALUE
|
|
28
|
-
{
|
|
29
|
-
Functor_T* functor = (Functor_T*)value;
|
|
30
|
-
|
|
31
|
-
if constexpr (std::is_same_v<Return_T, void>)
|
|
32
|
-
{
|
|
33
|
-
std::apply(functor->func_, functor->args_);
|
|
34
|
-
}
|
|
35
|
-
else
|
|
36
|
-
{
|
|
37
|
-
result = std::apply(functor->func_, functor->args_);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return Qnil;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Now call rb_protect which will invoke the callback lambda above
|
|
44
|
-
int state = (int)JumpException::RUBY_TAG_NONE;
|
|
45
|
-
rb_protect(callback, (VALUE)this, &state);
|
|
46
|
-
|
|
47
|
-
// Did anything go wrong?
|
|
48
|
-
if (state == JumpException::RUBY_TAG_NONE)
|
|
49
|
-
{
|
|
50
|
-
if constexpr (!std::is_same_v<Return_T, void>)
|
|
51
|
-
{
|
|
52
|
-
return std::any_cast<Return_T>(result);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else
|
|
56
|
-
{
|
|
57
|
-
VALUE err = rb_errinfo();
|
|
58
|
-
if (state == JumpException::RUBY_TAG_RAISE && RB_TEST(err))
|
|
59
|
-
{
|
|
60
|
-
rb_set_errinfo(Qnil);
|
|
61
|
-
throw Rice::Exception(err);
|
|
62
|
-
}
|
|
63
|
-
else
|
|
64
|
-
{
|
|
65
|
-
throw Rice::JumpException((Rice::JumpException::ruby_tag_type)state);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Create a functor for calling a Ruby function and define some aliases for readability.
|
|
71
|
-
template<typename Function_T, typename ...Arg_Ts>
|
|
72
|
-
auto protect(Function_T func, Arg_Ts...args)
|
|
73
|
-
{
|
|
74
|
-
auto rubyFunction = RubyFunction<Function_T, Arg_Ts...>(func, std::forward<Arg_Ts>(args)...);
|
|
75
|
-
return rubyFunction();
|
|
76
|
-
}
|
|
77
|
-
}
|
data/sample/callbacks/extconf.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
#include <rice/rice.hpp>
|
|
2
|
-
|
|
3
|
-
using namespace Rice;
|
|
4
|
-
|
|
5
|
-
namespace
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
class CallbackHolder
|
|
9
|
-
{
|
|
10
|
-
public:
|
|
11
|
-
|
|
12
|
-
void registerCallback(Rice::Object cb)
|
|
13
|
-
{
|
|
14
|
-
callback_ = cb;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
Rice::Object fireCallback(Rice::String param)
|
|
18
|
-
{
|
|
19
|
-
return callback_.call("call", param);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
Rice::Object callback_;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
} // namespace
|
|
26
|
-
|
|
27
|
-
extern "C"
|
|
28
|
-
void Init_sample_callbacks()
|
|
29
|
-
{
|
|
30
|
-
define_class<CallbackHolder>("CallbackHolder")
|
|
31
|
-
.define_constructor(Constructor<CallbackHolder>())
|
|
32
|
-
.define_method("register_callback", &CallbackHolder::registerCallback)
|
|
33
|
-
.define_method("fire_callback", &CallbackHolder::fireCallback);
|
|
34
|
-
}
|
|
35
|
-
|
data/sample/callbacks/test.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require 'sample_callbacks'
|
|
2
|
-
|
|
3
|
-
def hello(message)
|
|
4
|
-
"Hello #{message}"
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
cb1 = CallbackHolder.new
|
|
8
|
-
cb2 = CallbackHolder.new
|
|
9
|
-
cb3 = CallbackHolder.new
|
|
10
|
-
|
|
11
|
-
cb1.register_callback(lambda do |param|
|
|
12
|
-
"Callback 1 got param #{param}"
|
|
13
|
-
end)
|
|
14
|
-
|
|
15
|
-
cb2.register_callback(lambda do |param|
|
|
16
|
-
"Callback 2 got param #{param}"
|
|
17
|
-
end)
|
|
18
|
-
|
|
19
|
-
cb3.register_callback method(:hello)
|
|
20
|
-
|
|
21
|
-
puts "Calling Callback 1"
|
|
22
|
-
puts cb1.fire_callback("Hello")
|
|
23
|
-
|
|
24
|
-
puts "Calling Callback 2"
|
|
25
|
-
puts cb2.fire_callback("World")
|
|
26
|
-
|
|
27
|
-
puts "Calling Callback 3"
|
|
28
|
-
puts cb3.fire_callback("Ruby")
|
data/sample/enum/extconf.rb
DELETED
data/sample/enum/sample_enum.cpp
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#include <rice/rice.hpp>
|
|
2
|
-
|
|
3
|
-
using namespace Rice;
|
|
4
|
-
|
|
5
|
-
namespace
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
enum Sample_Enum
|
|
9
|
-
{
|
|
10
|
-
SE_FOO = 1,
|
|
11
|
-
SE_BAR = 42,
|
|
12
|
-
SE_BAZ = 100,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
char const * description(Sample_Enum e)
|
|
16
|
-
{
|
|
17
|
-
switch(e)
|
|
18
|
-
{
|
|
19
|
-
case SE_FOO: return "Fairly Ordinary Object";
|
|
20
|
-
case SE_BAR: return "Beginner's All-purpose Ratchet";
|
|
21
|
-
case SE_BAZ: return "Better than A Zebra";
|
|
22
|
-
}
|
|
23
|
-
return "???";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
} // namespace
|
|
27
|
-
|
|
28
|
-
extern "C"
|
|
29
|
-
void Init_sample_enum()
|
|
30
|
-
{
|
|
31
|
-
Rice::Enum<Sample_Enum> sample_enum_type =
|
|
32
|
-
define_enum<Sample_Enum>("Sample_Enum")
|
|
33
|
-
.define_value("FOO", SE_FOO)
|
|
34
|
-
.define_value("BAR", SE_BAR)
|
|
35
|
-
.define_value("BAZ", SE_BAZ);
|
|
36
|
-
|
|
37
|
-
sample_enum_type
|
|
38
|
-
.define_method("description", description);
|
|
39
|
-
}
|
|
40
|
-
|
data/sample/enum/test.rb
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
#include <rice/rice.hpp>
|
|
2
|
-
|
|
3
|
-
using namespace Rice;
|
|
4
|
-
|
|
5
|
-
class Organism
|
|
6
|
-
{
|
|
7
|
-
public:
|
|
8
|
-
virtual ~Organism() = default;
|
|
9
|
-
virtual char const * name() = 0;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
class Animal
|
|
13
|
-
: public Organism
|
|
14
|
-
{
|
|
15
|
-
public:
|
|
16
|
-
virtual char const * speak() = 0;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
class Bear
|
|
20
|
-
: public Animal
|
|
21
|
-
{
|
|
22
|
-
public:
|
|
23
|
-
char const * name() override
|
|
24
|
-
{
|
|
25
|
-
return "Bear";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
char const * speak() override
|
|
29
|
-
{
|
|
30
|
-
return "I'm smarter than the average bear";
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
class Dog
|
|
35
|
-
: public Animal
|
|
36
|
-
{
|
|
37
|
-
public:
|
|
38
|
-
char const * name() override
|
|
39
|
-
{
|
|
40
|
-
return "Dog";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
char const * speak() override
|
|
44
|
-
{
|
|
45
|
-
return "Woof woof";
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
class Rabbit
|
|
50
|
-
: public Animal
|
|
51
|
-
{
|
|
52
|
-
public:
|
|
53
|
-
char const * name() override
|
|
54
|
-
{
|
|
55
|
-
return "Rabbit";
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
char const * speak() override
|
|
59
|
-
{
|
|
60
|
-
return "What's up, doc?";
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
extern "C"
|
|
65
|
-
void Init_animals(void)
|
|
66
|
-
{
|
|
67
|
-
define_class<Organism>("Organism")
|
|
68
|
-
.define_method("name", &Organism::name);
|
|
69
|
-
|
|
70
|
-
define_class<Animal, Organism>("Animal")
|
|
71
|
-
.define_method("speak", &Animal::speak);
|
|
72
|
-
|
|
73
|
-
define_class<Bear, Animal>("Bear")
|
|
74
|
-
.define_constructor(Constructor<Bear>());
|
|
75
|
-
|
|
76
|
-
define_class<Dog, Animal>("Dog")
|
|
77
|
-
.define_constructor(Constructor<Dog>());
|
|
78
|
-
|
|
79
|
-
define_class<Rabbit, Animal>("Rabbit")
|
|
80
|
-
.define_constructor(Constructor<Rabbit>());
|
|
81
|
-
}
|
|
82
|
-
|
data/sample/inheritance/test.rb
DELETED
data/sample/map/extconf.rb
DELETED
data/sample/map/map.cpp
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
#include <rice/rice.hpp>
|
|
2
|
-
|
|
3
|
-
#include <map>
|
|
4
|
-
|
|
5
|
-
using namespace Rice;
|
|
6
|
-
|
|
7
|
-
namespace
|
|
8
|
-
{
|
|
9
|
-
|
|
10
|
-
class Map
|
|
11
|
-
{
|
|
12
|
-
private:
|
|
13
|
-
struct Ruby_Value_Compare
|
|
14
|
-
{
|
|
15
|
-
bool operator()(Object lhs, Object rhs) const
|
|
16
|
-
{
|
|
17
|
-
Object result = lhs.call("<", rhs);
|
|
18
|
-
return result.test();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
typedef std::map<Object, Object, Ruby_Value_Compare> Value_Map;
|
|
23
|
-
|
|
24
|
-
public:
|
|
25
|
-
Object bracket(Object k)
|
|
26
|
-
{
|
|
27
|
-
Value_Map::iterator it = map_.find(k);
|
|
28
|
-
return it == map_.end() ? Object(Qnil) : it->second;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
Object bracket_equals(Object k, Object v)
|
|
32
|
-
{
|
|
33
|
-
map_[k] = v;
|
|
34
|
-
return Qnil;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
Value_Map::iterator begin() { return map_.begin(); }
|
|
38
|
-
Value_Map::iterator end() { return map_.end(); }
|
|
39
|
-
|
|
40
|
-
typedef Value_Map::value_type value_type;
|
|
41
|
-
typedef Value_Map::iterator iterator;
|
|
42
|
-
|
|
43
|
-
private:
|
|
44
|
-
Value_Map map_;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
} // namespace
|
|
48
|
-
|
|
49
|
-
template<>
|
|
50
|
-
struct detail::To_Ruby<Map::value_type>
|
|
51
|
-
{
|
|
52
|
-
static VALUE convert(Map::value_type const & pair)
|
|
53
|
-
{
|
|
54
|
-
return detail::protect(rb_assoc_new, pair.first.value(), pair.second.value());
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
#include <iostream>
|
|
59
|
-
extern "C"
|
|
60
|
-
void Init_map(void)
|
|
61
|
-
{
|
|
62
|
-
Rice::Module rb_mStd = define_module("Std");
|
|
63
|
-
|
|
64
|
-
// TODO: no delete method on the map, because I'm not sure how to
|
|
65
|
-
// make delete work properly while iterating
|
|
66
|
-
Data_Type<Map> rb_cMap =
|
|
67
|
-
define_class_under<Map>(rb_mStd, "Map")
|
|
68
|
-
.define_constructor(Constructor<Map>())
|
|
69
|
-
.define_method("[]", &Map::bracket)
|
|
70
|
-
.define_method("[]=", &Map::bracket_equals)
|
|
71
|
-
.define_iterator(&Map::begin, &Map::end)
|
|
72
|
-
.include_module(rb_mEnumerable);
|
|
73
|
-
}
|
data/sample/map/test.rb
DELETED
data/test/ext/t1/Foo.hpp
DELETED
data/test/ext/t1/extconf.rb
DELETED
data/test/ext/t1/t1.cpp
DELETED
data/test/ext/t2/extconf.rb
DELETED