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
data/rice/detail/from_ruby.ipp
CHANGED
|
@@ -73,7 +73,11 @@ namespace Rice::detail
|
|
|
73
73
|
}
|
|
74
74
|
case RUBY_T_DATA:
|
|
75
75
|
{
|
|
76
|
-
|
|
76
|
+
if (Data_Type<Pointer<T>>::is_descendant(value))
|
|
77
|
+
{
|
|
78
|
+
return Convertible::Exact;
|
|
79
|
+
}
|
|
80
|
+
[[fallthrough]];
|
|
77
81
|
}
|
|
78
82
|
default:
|
|
79
83
|
{
|
|
@@ -82,7 +86,7 @@ namespace Rice::detail
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
static T* convert(VALUE value
|
|
89
|
+
static T* convert(VALUE value)
|
|
86
90
|
{
|
|
87
91
|
ruby_value_type valueType = rb_type(value);
|
|
88
92
|
|
|
@@ -94,21 +98,16 @@ namespace Rice::detail
|
|
|
94
98
|
}
|
|
95
99
|
case RUBY_T_DATA:
|
|
96
100
|
{
|
|
97
|
-
if (Data_Type<
|
|
101
|
+
if (Data_Type<Pointer<T>>::is_descendant(value))
|
|
98
102
|
{
|
|
99
|
-
|
|
100
|
-
if (arg && arg->isOwner())
|
|
101
|
-
{
|
|
102
|
-
buffer->release();
|
|
103
|
-
}
|
|
104
|
-
return buffer->ptr();
|
|
103
|
+
return unwrap<T>(value, Data_Type<Pointer<T>>::ruby_data_type(), false);
|
|
105
104
|
}
|
|
106
105
|
[[fallthrough]];
|
|
107
106
|
}
|
|
108
107
|
default:
|
|
109
108
|
{
|
|
110
|
-
|
|
111
|
-
std::string expected =
|
|
109
|
+
detail::TypeMapper<Pointer<T>> typeMapper;
|
|
110
|
+
std::string expected = typeMapper.rubyName();
|
|
112
111
|
throw Exception(rb_eTypeError, "wrong argument type %s (expected % s)",
|
|
113
112
|
detail::protect(rb_obj_classname, value), expected.c_str());
|
|
114
113
|
}
|
|
@@ -133,7 +132,11 @@ namespace Rice::detail
|
|
|
133
132
|
}
|
|
134
133
|
case RUBY_T_DATA:
|
|
135
134
|
{
|
|
136
|
-
|
|
135
|
+
if (Data_Type<Pointer<T*>>::is_descendant(value))
|
|
136
|
+
{
|
|
137
|
+
return Convertible::Exact;
|
|
138
|
+
}
|
|
139
|
+
[[fallthrough]];
|
|
137
140
|
}
|
|
138
141
|
default:
|
|
139
142
|
{
|
|
@@ -142,7 +145,7 @@ namespace Rice::detail
|
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
147
|
|
|
145
|
-
static T** convert(VALUE value
|
|
148
|
+
static T** convert(VALUE value)
|
|
146
149
|
{
|
|
147
150
|
ruby_value_type valueType = rb_type(value);
|
|
148
151
|
|
|
@@ -154,21 +157,16 @@ namespace Rice::detail
|
|
|
154
157
|
}
|
|
155
158
|
case RUBY_T_DATA:
|
|
156
159
|
{
|
|
157
|
-
if (Data_Type<
|
|
160
|
+
if (Data_Type<Pointer<T*>>::is_descendant(value))
|
|
158
161
|
{
|
|
159
|
-
|
|
160
|
-
if (arg && arg->isOwner())
|
|
161
|
-
{
|
|
162
|
-
buffer->release();
|
|
163
|
-
}
|
|
164
|
-
return buffer->ptr();
|
|
162
|
+
return unwrap<T*>(value, Data_Type<Pointer<T*>>::ruby_data_type(), false);
|
|
165
163
|
}
|
|
166
164
|
[[fallthrough]];
|
|
167
165
|
}
|
|
168
166
|
default:
|
|
169
167
|
{
|
|
170
|
-
|
|
171
|
-
std::string expected =
|
|
168
|
+
detail::TypeMapper<Pointer<T*>> typeMapper;
|
|
169
|
+
std::string expected = typeMapper.rubyName();
|
|
172
170
|
throw Exception(rb_eTypeError, "wrong argument type %s (expected % s)",
|
|
173
171
|
detail::protect(rb_obj_classname, value), expected.c_str());
|
|
174
172
|
}
|
|
@@ -205,7 +203,7 @@ namespace Rice::detail
|
|
|
205
203
|
class From_Ruby<bool&>
|
|
206
204
|
{
|
|
207
205
|
public:
|
|
208
|
-
using
|
|
206
|
+
using Pointer_T = Pointer<bool>;
|
|
209
207
|
|
|
210
208
|
From_Ruby() = default;
|
|
211
209
|
|
|
@@ -215,27 +213,40 @@ namespace Rice::detail
|
|
|
215
213
|
|
|
216
214
|
Convertible is_convertible(VALUE value)
|
|
217
215
|
{
|
|
218
|
-
|
|
219
|
-
{
|
|
220
|
-
return Convertible::Exact;
|
|
221
|
-
}
|
|
222
|
-
else
|
|
216
|
+
switch (rb_type(value))
|
|
223
217
|
{
|
|
224
|
-
|
|
218
|
+
case RUBY_T_DATA:
|
|
219
|
+
{
|
|
220
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
221
|
+
{
|
|
222
|
+
return Convertible::Exact;
|
|
223
|
+
}
|
|
224
|
+
[[fallthrough]];
|
|
225
|
+
}
|
|
226
|
+
default:
|
|
227
|
+
{
|
|
228
|
+
return FromRubyFundamental<bool>::is_convertible(value);
|
|
229
|
+
}
|
|
225
230
|
}
|
|
226
231
|
}
|
|
227
232
|
|
|
228
233
|
bool& convert(VALUE value)
|
|
229
234
|
{
|
|
230
|
-
|
|
231
|
-
{
|
|
232
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
233
|
-
return buffer->reference();
|
|
234
|
-
}
|
|
235
|
-
else
|
|
235
|
+
switch (rb_type(value))
|
|
236
236
|
{
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
case RUBY_T_DATA:
|
|
238
|
+
{
|
|
239
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
240
|
+
{
|
|
241
|
+
return (bool&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
242
|
+
}
|
|
243
|
+
[[fallthrough]];
|
|
244
|
+
}
|
|
245
|
+
default:
|
|
246
|
+
{
|
|
247
|
+
this->converted_ = FromRubyFundamental<bool>::convert(value);
|
|
248
|
+
return this->converted_;
|
|
249
|
+
}
|
|
239
250
|
}
|
|
240
251
|
}
|
|
241
252
|
|
|
@@ -244,30 +255,6 @@ namespace Rice::detail
|
|
|
244
255
|
bool converted_ = false;
|
|
245
256
|
};
|
|
246
257
|
|
|
247
|
-
template<>
|
|
248
|
-
class From_Ruby<bool*>
|
|
249
|
-
{
|
|
250
|
-
public:
|
|
251
|
-
From_Ruby() = default;
|
|
252
|
-
|
|
253
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
254
|
-
{
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
Convertible is_convertible(VALUE value)
|
|
258
|
-
{
|
|
259
|
-
return FromRubyFundamental<bool>::is_convertible(value);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
bool* convert(VALUE value)
|
|
263
|
-
{
|
|
264
|
-
return FromRubyFundamental<bool*>::convert(value, this->arg_);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
private:
|
|
268
|
-
Arg* arg_ = nullptr;
|
|
269
|
-
};
|
|
270
|
-
|
|
271
258
|
// =========== char ============
|
|
272
259
|
template<>
|
|
273
260
|
class From_Ruby<char>
|
|
@@ -297,7 +284,7 @@ namespace Rice::detail
|
|
|
297
284
|
class From_Ruby<char&>
|
|
298
285
|
{
|
|
299
286
|
public:
|
|
300
|
-
using
|
|
287
|
+
using Pointer_T = Pointer<char>;
|
|
301
288
|
|
|
302
289
|
From_Ruby() = default;
|
|
303
290
|
|
|
@@ -307,27 +294,40 @@ namespace Rice::detail
|
|
|
307
294
|
|
|
308
295
|
Convertible is_convertible(VALUE value)
|
|
309
296
|
{
|
|
310
|
-
|
|
311
|
-
{
|
|
312
|
-
return Convertible::Exact;
|
|
313
|
-
}
|
|
314
|
-
else
|
|
297
|
+
switch (rb_type(value))
|
|
315
298
|
{
|
|
316
|
-
|
|
299
|
+
case RUBY_T_DATA:
|
|
300
|
+
{
|
|
301
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
302
|
+
{
|
|
303
|
+
return Convertible::Exact;
|
|
304
|
+
}
|
|
305
|
+
[[fallthrough]];
|
|
306
|
+
}
|
|
307
|
+
default:
|
|
308
|
+
{
|
|
309
|
+
return FromRubyFundamental<char>::is_convertible(value);
|
|
310
|
+
}
|
|
317
311
|
}
|
|
318
312
|
}
|
|
319
313
|
|
|
320
314
|
char& convert(VALUE value)
|
|
321
315
|
{
|
|
322
|
-
|
|
323
|
-
{
|
|
324
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
325
|
-
return buffer->reference();
|
|
326
|
-
}
|
|
327
|
-
else
|
|
316
|
+
switch (rb_type(value))
|
|
328
317
|
{
|
|
329
|
-
|
|
330
|
-
|
|
318
|
+
case RUBY_T_DATA:
|
|
319
|
+
{
|
|
320
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
321
|
+
{
|
|
322
|
+
return (char&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
323
|
+
}
|
|
324
|
+
[[fallthrough]];
|
|
325
|
+
}
|
|
326
|
+
default:
|
|
327
|
+
{
|
|
328
|
+
this->converted_ = FromRubyFundamental<char>::convert(value);
|
|
329
|
+
return this->converted_;
|
|
330
|
+
}
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
@@ -335,7 +335,7 @@ namespace Rice::detail
|
|
|
335
335
|
Arg* arg_ = nullptr;
|
|
336
336
|
char converted_ = 0;
|
|
337
337
|
};
|
|
338
|
-
|
|
338
|
+
|
|
339
339
|
template<>
|
|
340
340
|
class From_Ruby<char*>
|
|
341
341
|
{
|
|
@@ -350,18 +350,18 @@ namespace Rice::detail
|
|
|
350
350
|
{
|
|
351
351
|
switch (rb_type(value))
|
|
352
352
|
{
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
353
|
+
case RUBY_T_NIL:
|
|
354
|
+
{
|
|
355
|
+
return Convertible::Exact;
|
|
356
|
+
}
|
|
357
|
+
case RUBY_T_STRING:
|
|
358
|
+
{
|
|
359
|
+
return Convertible::Exact;
|
|
360
|
+
}
|
|
361
|
+
default:
|
|
362
|
+
{
|
|
363
|
+
return FromRubyFundamental<char*>::is_convertible(value);
|
|
364
|
+
}
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
|
|
@@ -382,7 +382,7 @@ namespace Rice::detail
|
|
|
382
382
|
default:
|
|
383
383
|
{
|
|
384
384
|
char* rb_string_value_cstr(volatile VALUE * ptr);
|
|
385
|
-
return FromRubyFundamental<char*>::convert(value
|
|
385
|
+
return FromRubyFundamental<char*>::convert(value);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
}
|
|
@@ -390,40 +390,7 @@ namespace Rice::detail
|
|
|
390
390
|
private:
|
|
391
391
|
Arg* arg_ = nullptr;
|
|
392
392
|
};
|
|
393
|
-
|
|
394
|
-
template<>
|
|
395
|
-
class From_Ruby<const char*> : public From_Ruby<char*>
|
|
396
|
-
{
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
template<>
|
|
400
|
-
class From_Ruby<char**>
|
|
401
|
-
{
|
|
402
|
-
public:
|
|
403
|
-
From_Ruby() = default;
|
|
404
|
-
|
|
405
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
406
|
-
{
|
|
407
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
408
|
-
{
|
|
409
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
Convertible is_convertible(VALUE value)
|
|
414
|
-
{
|
|
415
|
-
return FromRubyFundamental<char**>::is_convertible(value);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
char** convert(VALUE value)
|
|
419
|
-
{
|
|
420
|
-
return FromRubyFundamental<char**>::convert(value, this->arg_);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
private:
|
|
424
|
-
Arg* arg_ = nullptr;
|
|
425
|
-
};
|
|
426
|
-
|
|
393
|
+
|
|
427
394
|
// =========== unsigned char ============
|
|
428
395
|
template<>
|
|
429
396
|
class From_Ruby<unsigned char>
|
|
@@ -453,7 +420,7 @@ namespace Rice::detail
|
|
|
453
420
|
class From_Ruby<unsigned char&>
|
|
454
421
|
{
|
|
455
422
|
public:
|
|
456
|
-
using
|
|
423
|
+
using Pointer_T = Pointer<unsigned char>;
|
|
457
424
|
|
|
458
425
|
From_Ruby() = default;
|
|
459
426
|
|
|
@@ -463,27 +430,40 @@ namespace Rice::detail
|
|
|
463
430
|
|
|
464
431
|
Convertible is_convertible(VALUE value)
|
|
465
432
|
{
|
|
466
|
-
|
|
467
|
-
{
|
|
468
|
-
return Convertible::Exact;
|
|
469
|
-
}
|
|
470
|
-
else
|
|
433
|
+
switch (rb_type(value))
|
|
471
434
|
{
|
|
472
|
-
|
|
435
|
+
case RUBY_T_DATA:
|
|
436
|
+
{
|
|
437
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
438
|
+
{
|
|
439
|
+
return Convertible::Exact;
|
|
440
|
+
}
|
|
441
|
+
[[fallthrough]];
|
|
442
|
+
}
|
|
443
|
+
default:
|
|
444
|
+
{
|
|
445
|
+
return FromRubyFundamental<unsigned char>::is_convertible(value);
|
|
446
|
+
}
|
|
473
447
|
}
|
|
474
448
|
}
|
|
475
449
|
|
|
476
450
|
unsigned char& convert(VALUE value)
|
|
477
451
|
{
|
|
478
|
-
|
|
479
|
-
{
|
|
480
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
481
|
-
return buffer->reference();
|
|
482
|
-
}
|
|
483
|
-
else
|
|
452
|
+
switch (rb_type(value))
|
|
484
453
|
{
|
|
485
|
-
|
|
486
|
-
|
|
454
|
+
case RUBY_T_DATA:
|
|
455
|
+
{
|
|
456
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
457
|
+
{
|
|
458
|
+
return (unsigned char&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
459
|
+
}
|
|
460
|
+
[[fallthrough]];
|
|
461
|
+
}
|
|
462
|
+
default:
|
|
463
|
+
{
|
|
464
|
+
this->converted_ = FromRubyFundamental<unsigned char>::convert(value);
|
|
465
|
+
return this->converted_;
|
|
466
|
+
}
|
|
487
467
|
}
|
|
488
468
|
}
|
|
489
469
|
|
|
@@ -492,8 +472,9 @@ namespace Rice::detail
|
|
|
492
472
|
unsigned char converted_ = 0;
|
|
493
473
|
};
|
|
494
474
|
|
|
475
|
+
// =========== signed char ============
|
|
495
476
|
template<>
|
|
496
|
-
class From_Ruby<
|
|
477
|
+
class From_Ruby<signed char>
|
|
497
478
|
{
|
|
498
479
|
public:
|
|
499
480
|
From_Ruby() = default;
|
|
@@ -504,12 +485,12 @@ namespace Rice::detail
|
|
|
504
485
|
|
|
505
486
|
Convertible is_convertible(VALUE value)
|
|
506
487
|
{
|
|
507
|
-
return FromRubyFundamental<
|
|
488
|
+
return FromRubyFundamental<signed char>::is_convertible(value);
|
|
508
489
|
}
|
|
509
490
|
|
|
510
|
-
|
|
491
|
+
signed char convert(VALUE value)
|
|
511
492
|
{
|
|
512
|
-
return FromRubyFundamental<
|
|
493
|
+
return FromRubyFundamental<signed char>::convert(value);
|
|
513
494
|
}
|
|
514
495
|
|
|
515
496
|
private:
|
|
@@ -517,36 +498,64 @@ namespace Rice::detail
|
|
|
517
498
|
};
|
|
518
499
|
|
|
519
500
|
template<>
|
|
520
|
-
class From_Ruby<
|
|
501
|
+
class From_Ruby<signed char&>
|
|
521
502
|
{
|
|
522
503
|
public:
|
|
504
|
+
using Pointer_T = Pointer<signed char>;
|
|
505
|
+
|
|
523
506
|
From_Ruby() = default;
|
|
524
507
|
|
|
525
508
|
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
526
509
|
{
|
|
527
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
528
|
-
{
|
|
529
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
530
|
-
}
|
|
531
510
|
}
|
|
532
511
|
|
|
533
512
|
Convertible is_convertible(VALUE value)
|
|
534
513
|
{
|
|
535
|
-
|
|
514
|
+
switch (rb_type(value))
|
|
515
|
+
{
|
|
516
|
+
case RUBY_T_DATA:
|
|
517
|
+
{
|
|
518
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
519
|
+
{
|
|
520
|
+
return Convertible::Exact;
|
|
521
|
+
}
|
|
522
|
+
[[fallthrough]];
|
|
523
|
+
}
|
|
524
|
+
default:
|
|
525
|
+
{
|
|
526
|
+
return FromRubyFundamental<signed char>::is_convertible(value);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
536
529
|
}
|
|
537
530
|
|
|
538
|
-
|
|
531
|
+
signed char& convert(VALUE value)
|
|
539
532
|
{
|
|
540
|
-
|
|
533
|
+
switch (rb_type(value))
|
|
534
|
+
{
|
|
535
|
+
case RUBY_T_DATA:
|
|
536
|
+
{
|
|
537
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
538
|
+
{
|
|
539
|
+
return (signed char&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
540
|
+
}
|
|
541
|
+
[[fallthrough]];
|
|
542
|
+
}
|
|
543
|
+
default:
|
|
544
|
+
{
|
|
545
|
+
this->converted_ = FromRubyFundamental<signed char>::convert(value);
|
|
546
|
+
return this->converted_;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
541
549
|
}
|
|
542
550
|
|
|
543
551
|
private:
|
|
544
552
|
Arg* arg_ = nullptr;
|
|
553
|
+
signed char converted_ = 0;
|
|
545
554
|
};
|
|
546
555
|
|
|
547
|
-
// ===========
|
|
556
|
+
// =========== double ============
|
|
548
557
|
template<>
|
|
549
|
-
class From_Ruby<
|
|
558
|
+
class From_Ruby<double>
|
|
550
559
|
{
|
|
551
560
|
public:
|
|
552
561
|
From_Ruby() = default;
|
|
@@ -557,12 +566,12 @@ namespace Rice::detail
|
|
|
557
566
|
|
|
558
567
|
Convertible is_convertible(VALUE value)
|
|
559
568
|
{
|
|
560
|
-
return FromRubyFundamental<
|
|
569
|
+
return FromRubyFundamental<double>::is_convertible(value);
|
|
561
570
|
}
|
|
562
571
|
|
|
563
|
-
|
|
572
|
+
double convert(VALUE value)
|
|
564
573
|
{
|
|
565
|
-
return FromRubyFundamental<
|
|
574
|
+
return FromRubyFundamental<double>::convert(value);
|
|
566
575
|
}
|
|
567
576
|
|
|
568
577
|
private:
|
|
@@ -570,10 +579,10 @@ namespace Rice::detail
|
|
|
570
579
|
};
|
|
571
580
|
|
|
572
581
|
template<>
|
|
573
|
-
class From_Ruby<
|
|
582
|
+
class From_Ruby<double&>
|
|
574
583
|
{
|
|
575
584
|
public:
|
|
576
|
-
using
|
|
585
|
+
using Pointer_T = Pointer<double>;
|
|
577
586
|
|
|
578
587
|
From_Ruby() = default;
|
|
579
588
|
|
|
@@ -583,37 +592,51 @@ namespace Rice::detail
|
|
|
583
592
|
|
|
584
593
|
Convertible is_convertible(VALUE value)
|
|
585
594
|
{
|
|
586
|
-
|
|
587
|
-
{
|
|
588
|
-
return Convertible::Exact;
|
|
589
|
-
}
|
|
590
|
-
else
|
|
595
|
+
switch (rb_type(value))
|
|
591
596
|
{
|
|
592
|
-
|
|
597
|
+
case RUBY_T_DATA:
|
|
598
|
+
{
|
|
599
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
600
|
+
{
|
|
601
|
+
return Convertible::Exact;
|
|
602
|
+
}
|
|
603
|
+
[[fallthrough]];
|
|
604
|
+
}
|
|
605
|
+
default:
|
|
606
|
+
{
|
|
607
|
+
return FromRubyFundamental<double>::is_convertible(value);
|
|
608
|
+
}
|
|
593
609
|
}
|
|
594
610
|
}
|
|
595
611
|
|
|
596
|
-
|
|
612
|
+
double& convert(VALUE value)
|
|
597
613
|
{
|
|
598
|
-
|
|
599
|
-
{
|
|
600
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
601
|
-
return buffer->reference();
|
|
602
|
-
}
|
|
603
|
-
else
|
|
614
|
+
switch (rb_type(value))
|
|
604
615
|
{
|
|
605
|
-
|
|
606
|
-
|
|
616
|
+
case RUBY_T_DATA:
|
|
617
|
+
{
|
|
618
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
619
|
+
{
|
|
620
|
+
return (double&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
621
|
+
}
|
|
622
|
+
[[fallthrough]];
|
|
623
|
+
}
|
|
624
|
+
default:
|
|
625
|
+
{
|
|
626
|
+
this->converted_ = FromRubyFundamental<double>::convert(value);
|
|
627
|
+
return this->converted_;
|
|
628
|
+
}
|
|
607
629
|
}
|
|
608
630
|
}
|
|
609
631
|
|
|
610
632
|
private:
|
|
611
633
|
Arg* arg_ = nullptr;
|
|
612
|
-
|
|
634
|
+
double converted_;
|
|
613
635
|
};
|
|
614
636
|
|
|
637
|
+
// =========== float ============
|
|
615
638
|
template<>
|
|
616
|
-
class From_Ruby<
|
|
639
|
+
class From_Ruby<float>
|
|
617
640
|
{
|
|
618
641
|
public:
|
|
619
642
|
From_Ruby() = default;
|
|
@@ -624,12 +647,12 @@ namespace Rice::detail
|
|
|
624
647
|
|
|
625
648
|
Convertible is_convertible(VALUE value)
|
|
626
649
|
{
|
|
627
|
-
return FromRubyFundamental<
|
|
650
|
+
return FromRubyFundamental<float>::is_convertible(value);
|
|
628
651
|
}
|
|
629
652
|
|
|
630
|
-
|
|
653
|
+
float convert(VALUE value)
|
|
631
654
|
{
|
|
632
|
-
return FromRubyFundamental<
|
|
655
|
+
return FromRubyFundamental<float>::convert(value);
|
|
633
656
|
}
|
|
634
657
|
|
|
635
658
|
private:
|
|
@@ -637,103 +660,64 @@ namespace Rice::detail
|
|
|
637
660
|
};
|
|
638
661
|
|
|
639
662
|
template<>
|
|
640
|
-
class From_Ruby<
|
|
663
|
+
class From_Ruby<float&>
|
|
641
664
|
{
|
|
642
665
|
public:
|
|
666
|
+
using Pointer_T = Pointer<float>;
|
|
667
|
+
|
|
643
668
|
From_Ruby() = default;
|
|
644
669
|
|
|
645
670
|
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
646
671
|
{
|
|
647
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
648
|
-
{
|
|
649
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
650
|
-
}
|
|
651
672
|
}
|
|
652
673
|
|
|
653
674
|
Convertible is_convertible(VALUE value)
|
|
654
675
|
{
|
|
655
|
-
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
signed char** convert(VALUE value)
|
|
659
|
-
{
|
|
660
|
-
return FromRubyFundamental<signed char**>::convert(value, this->arg_);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
private:
|
|
664
|
-
Arg* arg_ = nullptr;
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
// =========== double ============
|
|
668
|
-
template<>
|
|
669
|
-
class From_Ruby<double>
|
|
670
|
-
{
|
|
671
|
-
public:
|
|
672
|
-
From_Ruby() = default;
|
|
673
|
-
|
|
674
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
675
|
-
{
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
Convertible is_convertible(VALUE value)
|
|
679
|
-
{
|
|
680
|
-
return FromRubyFundamental<double>::is_convertible(value);
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
double convert(VALUE value)
|
|
684
|
-
{
|
|
685
|
-
return FromRubyFundamental<double>::convert(value);
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
private:
|
|
689
|
-
Arg* arg_ = nullptr;
|
|
690
|
-
};
|
|
691
|
-
|
|
692
|
-
template<>
|
|
693
|
-
class From_Ruby<double&>
|
|
694
|
-
{
|
|
695
|
-
public:
|
|
696
|
-
using Buffer_T = Buffer<double>;
|
|
697
|
-
|
|
698
|
-
From_Ruby() = default;
|
|
699
|
-
|
|
700
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
701
|
-
{
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
Convertible is_convertible(VALUE value)
|
|
705
|
-
{
|
|
706
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
707
|
-
{
|
|
708
|
-
return Convertible::Exact;
|
|
709
|
-
}
|
|
710
|
-
else
|
|
676
|
+
switch (rb_type(value))
|
|
711
677
|
{
|
|
712
|
-
|
|
678
|
+
case RUBY_T_DATA:
|
|
679
|
+
{
|
|
680
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
681
|
+
{
|
|
682
|
+
return Convertible::Exact;
|
|
683
|
+
}
|
|
684
|
+
[[fallthrough]];
|
|
685
|
+
}
|
|
686
|
+
default:
|
|
687
|
+
{
|
|
688
|
+
return FromRubyFundamental<float>::is_convertible(value);
|
|
689
|
+
}
|
|
713
690
|
}
|
|
714
691
|
}
|
|
715
692
|
|
|
716
|
-
|
|
693
|
+
float& convert(VALUE value)
|
|
717
694
|
{
|
|
718
|
-
|
|
719
|
-
{
|
|
720
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
721
|
-
return buffer->reference();
|
|
722
|
-
}
|
|
723
|
-
else
|
|
695
|
+
switch (rb_type(value))
|
|
724
696
|
{
|
|
725
|
-
|
|
726
|
-
|
|
697
|
+
case RUBY_T_DATA:
|
|
698
|
+
{
|
|
699
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
700
|
+
{
|
|
701
|
+
return (float&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
702
|
+
}
|
|
703
|
+
[[fallthrough]];
|
|
704
|
+
}
|
|
705
|
+
default:
|
|
706
|
+
{
|
|
707
|
+
this->converted_ = FromRubyFundamental<float>::convert(value);
|
|
708
|
+
return this->converted_;
|
|
709
|
+
}
|
|
727
710
|
}
|
|
728
711
|
}
|
|
729
712
|
|
|
730
713
|
private:
|
|
731
714
|
Arg* arg_ = nullptr;
|
|
732
|
-
|
|
715
|
+
float converted_;
|
|
733
716
|
};
|
|
734
717
|
|
|
718
|
+
// =========== int ============
|
|
735
719
|
template<>
|
|
736
|
-
class From_Ruby<
|
|
720
|
+
class From_Ruby<int>
|
|
737
721
|
{
|
|
738
722
|
public:
|
|
739
723
|
From_Ruby() = default;
|
|
@@ -744,76 +728,34 @@ namespace Rice::detail
|
|
|
744
728
|
|
|
745
729
|
Convertible is_convertible(VALUE value)
|
|
746
730
|
{
|
|
747
|
-
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
double* convert(VALUE value)
|
|
751
|
-
{
|
|
752
|
-
return FromRubyFundamental<double*>::convert(value, this->arg_);
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
private:
|
|
756
|
-
Arg* arg_ = nullptr;
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
template<>
|
|
760
|
-
class From_Ruby<double**>
|
|
761
|
-
{
|
|
762
|
-
public:
|
|
763
|
-
From_Ruby() = default;
|
|
731
|
+
Convertible result = FromRubyFundamental<int>::is_convertible(value);
|
|
764
732
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
733
|
+
// Is this an enum? If so we want to support converting it to an integer
|
|
734
|
+
if (result == Convertible::None && rb_type(value) == RUBY_T_DATA)
|
|
768
735
|
{
|
|
769
|
-
|
|
736
|
+
static ID id = protect(rb_intern, "to_int");
|
|
737
|
+
if (protect(rb_respond_to, value, id))
|
|
738
|
+
{
|
|
739
|
+
result = Convertible::Cast;
|
|
740
|
+
}
|
|
770
741
|
}
|
|
742
|
+
return result;
|
|
771
743
|
}
|
|
772
744
|
|
|
773
|
-
|
|
774
|
-
{
|
|
775
|
-
return FromRubyFundamental<double**>::is_convertible(value);
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
double** convert(VALUE value)
|
|
779
|
-
{
|
|
780
|
-
return FromRubyFundamental<double**>::convert(value, this->arg_);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
private:
|
|
784
|
-
Arg* arg_ = nullptr;
|
|
785
|
-
};
|
|
786
|
-
|
|
787
|
-
// =========== float ============
|
|
788
|
-
template<>
|
|
789
|
-
class From_Ruby<float>
|
|
790
|
-
{
|
|
791
|
-
public:
|
|
792
|
-
From_Ruby() = default;
|
|
793
|
-
|
|
794
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
795
|
-
{
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
Convertible is_convertible(VALUE value)
|
|
799
|
-
{
|
|
800
|
-
return FromRubyFundamental<float>::is_convertible(value);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
float convert(VALUE value)
|
|
745
|
+
int convert(VALUE value)
|
|
804
746
|
{
|
|
805
|
-
return FromRubyFundamental<
|
|
747
|
+
return FromRubyFundamental<int>::convert(value);
|
|
806
748
|
}
|
|
807
|
-
|
|
749
|
+
|
|
808
750
|
private:
|
|
809
751
|
Arg* arg_ = nullptr;
|
|
810
752
|
};
|
|
811
753
|
|
|
812
754
|
template<>
|
|
813
|
-
class From_Ruby<
|
|
755
|
+
class From_Ruby<int&>
|
|
814
756
|
{
|
|
815
757
|
public:
|
|
816
|
-
using
|
|
758
|
+
using Pointer_T = Pointer<int>;
|
|
817
759
|
|
|
818
760
|
From_Ruby() = default;
|
|
819
761
|
|
|
@@ -823,37 +765,51 @@ namespace Rice::detail
|
|
|
823
765
|
|
|
824
766
|
Convertible is_convertible(VALUE value)
|
|
825
767
|
{
|
|
826
|
-
|
|
827
|
-
{
|
|
828
|
-
return Convertible::Exact;
|
|
829
|
-
}
|
|
830
|
-
else
|
|
768
|
+
switch (rb_type(value))
|
|
831
769
|
{
|
|
832
|
-
|
|
770
|
+
case RUBY_T_DATA:
|
|
771
|
+
{
|
|
772
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
773
|
+
{
|
|
774
|
+
return Convertible::Exact;
|
|
775
|
+
}
|
|
776
|
+
[[fallthrough]];
|
|
777
|
+
}
|
|
778
|
+
default:
|
|
779
|
+
{
|
|
780
|
+
return FromRubyFundamental<int>::is_convertible(value);
|
|
781
|
+
}
|
|
833
782
|
}
|
|
834
783
|
}
|
|
835
784
|
|
|
836
|
-
|
|
785
|
+
int& convert(VALUE value)
|
|
837
786
|
{
|
|
838
|
-
|
|
839
|
-
{
|
|
840
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
841
|
-
return buffer->reference();
|
|
842
|
-
}
|
|
843
|
-
else
|
|
787
|
+
switch (rb_type(value))
|
|
844
788
|
{
|
|
845
|
-
|
|
846
|
-
|
|
789
|
+
case RUBY_T_DATA:
|
|
790
|
+
{
|
|
791
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
792
|
+
{
|
|
793
|
+
return (int&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
794
|
+
}
|
|
795
|
+
[[fallthrough]];
|
|
796
|
+
}
|
|
797
|
+
default:
|
|
798
|
+
{
|
|
799
|
+
this->converted_ = FromRubyFundamental<int>::convert(value);
|
|
800
|
+
return this->converted_;
|
|
801
|
+
}
|
|
847
802
|
}
|
|
848
803
|
}
|
|
849
804
|
|
|
850
805
|
private:
|
|
851
806
|
Arg* arg_ = nullptr;
|
|
852
|
-
|
|
807
|
+
int converted_ = 0;
|
|
853
808
|
};
|
|
854
809
|
|
|
810
|
+
// =========== unsigned int ============
|
|
855
811
|
template<>
|
|
856
|
-
class From_Ruby<
|
|
812
|
+
class From_Ruby<unsigned int>
|
|
857
813
|
{
|
|
858
814
|
public:
|
|
859
815
|
From_Ruby() = default;
|
|
@@ -864,12 +820,12 @@ namespace Rice::detail
|
|
|
864
820
|
|
|
865
821
|
Convertible is_convertible(VALUE value)
|
|
866
822
|
{
|
|
867
|
-
return FromRubyFundamental<
|
|
823
|
+
return FromRubyFundamental<unsigned int>::is_convertible(value);
|
|
868
824
|
}
|
|
869
825
|
|
|
870
|
-
|
|
826
|
+
unsigned int convert(VALUE value)
|
|
871
827
|
{
|
|
872
|
-
return FromRubyFundamental<
|
|
828
|
+
return FromRubyFundamental<unsigned int>::convert(value);
|
|
873
829
|
}
|
|
874
830
|
|
|
875
831
|
private:
|
|
@@ -877,38 +833,11 @@ namespace Rice::detail
|
|
|
877
833
|
};
|
|
878
834
|
|
|
879
835
|
template<>
|
|
880
|
-
class From_Ruby<
|
|
836
|
+
class From_Ruby<unsigned int&>
|
|
881
837
|
{
|
|
882
838
|
public:
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
886
|
-
{
|
|
887
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
888
|
-
{
|
|
889
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
Convertible is_convertible(VALUE value)
|
|
894
|
-
{
|
|
895
|
-
return FromRubyFundamental<float**>::is_convertible(value);
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
float** convert(VALUE value)
|
|
899
|
-
{
|
|
900
|
-
return FromRubyFundamental<float**>::convert(value, this->arg_);
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
private:
|
|
904
|
-
Arg* arg_ = nullptr;
|
|
905
|
-
};
|
|
839
|
+
using Pointer_T = Pointer<unsigned int>;
|
|
906
840
|
|
|
907
|
-
// =========== int ============
|
|
908
|
-
template<>
|
|
909
|
-
class From_Ruby<int>
|
|
910
|
-
{
|
|
911
|
-
public:
|
|
912
841
|
From_Ruby() = default;
|
|
913
842
|
|
|
914
843
|
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
@@ -917,35 +846,53 @@ namespace Rice::detail
|
|
|
917
846
|
|
|
918
847
|
Convertible is_convertible(VALUE value)
|
|
919
848
|
{
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
// Is this an enum? If so we want to support converting it to an integer
|
|
923
|
-
if (result == Convertible::None && rb_type(value) == RUBY_T_DATA)
|
|
849
|
+
switch (rb_type(value))
|
|
924
850
|
{
|
|
925
|
-
|
|
926
|
-
if (protect(rb_respond_to, value, id))
|
|
851
|
+
case RUBY_T_DATA:
|
|
927
852
|
{
|
|
928
|
-
|
|
853
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
854
|
+
{
|
|
855
|
+
return Convertible::Exact;
|
|
856
|
+
}
|
|
857
|
+
[[fallthrough]];
|
|
858
|
+
}
|
|
859
|
+
default:
|
|
860
|
+
{
|
|
861
|
+
return FromRubyFundamental<unsigned int>::is_convertible(value);
|
|
929
862
|
}
|
|
930
863
|
}
|
|
931
|
-
return result;
|
|
932
864
|
}
|
|
933
865
|
|
|
934
|
-
int convert(VALUE value)
|
|
866
|
+
unsigned int& convert(VALUE value)
|
|
935
867
|
{
|
|
936
|
-
|
|
868
|
+
switch (rb_type(value))
|
|
869
|
+
{
|
|
870
|
+
case RUBY_T_DATA:
|
|
871
|
+
{
|
|
872
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
873
|
+
{
|
|
874
|
+
return (unsigned int&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
875
|
+
}
|
|
876
|
+
[[fallthrough]];
|
|
877
|
+
}
|
|
878
|
+
default:
|
|
879
|
+
{
|
|
880
|
+
this->converted_ = FromRubyFundamental<unsigned int>::convert(value);
|
|
881
|
+
return this->converted_;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
937
884
|
}
|
|
938
|
-
|
|
885
|
+
|
|
939
886
|
private:
|
|
940
887
|
Arg* arg_ = nullptr;
|
|
888
|
+
unsigned int converted_ = 0;
|
|
941
889
|
};
|
|
942
890
|
|
|
891
|
+
// =========== long ============
|
|
943
892
|
template<>
|
|
944
|
-
class From_Ruby<
|
|
893
|
+
class From_Ruby<long>
|
|
945
894
|
{
|
|
946
895
|
public:
|
|
947
|
-
using Buffer_T = Buffer<int>;
|
|
948
|
-
|
|
949
896
|
From_Ruby() = default;
|
|
950
897
|
|
|
951
898
|
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
@@ -954,600 +901,12 @@ namespace Rice::detail
|
|
|
954
901
|
|
|
955
902
|
Convertible is_convertible(VALUE value)
|
|
956
903
|
{
|
|
957
|
-
|
|
958
|
-
{
|
|
959
|
-
return Convertible::Exact;
|
|
960
|
-
}
|
|
961
|
-
else
|
|
962
|
-
{
|
|
963
|
-
return FromRubyFundamental<int>::is_convertible(value);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
int& convert(VALUE value)
|
|
968
|
-
{
|
|
969
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
970
|
-
{
|
|
971
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
972
|
-
return buffer->reference();
|
|
973
|
-
}
|
|
974
|
-
else
|
|
975
|
-
{
|
|
976
|
-
this->converted_ = FromRubyFundamental<int>::convert(value);
|
|
977
|
-
return this->converted_;
|
|
978
|
-
}
|
|
904
|
+
return FromRubyFundamental<long>::is_convertible(value);
|
|
979
905
|
}
|
|
980
906
|
|
|
981
|
-
|
|
982
|
-
Arg* arg_ = nullptr;
|
|
983
|
-
int converted_ = 0;
|
|
984
|
-
};
|
|
985
|
-
|
|
986
|
-
template<>
|
|
987
|
-
class From_Ruby<int*>
|
|
988
|
-
{
|
|
989
|
-
public:
|
|
990
|
-
From_Ruby() = default;
|
|
991
|
-
|
|
992
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
993
|
-
{
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
Convertible is_convertible(VALUE value)
|
|
997
|
-
{
|
|
998
|
-
return FromRubyFundamental<int*>::is_convertible(value);
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
int* convert(VALUE value)
|
|
1002
|
-
{
|
|
1003
|
-
return FromRubyFundamental<int*>::convert(value, this->arg_);
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
private:
|
|
1007
|
-
Arg* arg_ = nullptr;
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
|
-
template<>
|
|
1011
|
-
class From_Ruby<int**>
|
|
1012
|
-
{
|
|
1013
|
-
public:
|
|
1014
|
-
From_Ruby() = default;
|
|
1015
|
-
|
|
1016
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1017
|
-
{
|
|
1018
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
1019
|
-
{
|
|
1020
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
Convertible is_convertible(VALUE value)
|
|
1025
|
-
{
|
|
1026
|
-
return FromRubyFundamental<int**>::is_convertible(value);
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
int** convert(VALUE value)
|
|
1030
|
-
{
|
|
1031
|
-
return FromRubyFundamental<int**>::convert(value, this->arg_);
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
private:
|
|
1035
|
-
Arg* arg_ = nullptr;
|
|
1036
|
-
};
|
|
1037
|
-
|
|
1038
|
-
// =========== unsigned int ============
|
|
1039
|
-
template<>
|
|
1040
|
-
class From_Ruby<unsigned int>
|
|
1041
|
-
{
|
|
1042
|
-
public:
|
|
1043
|
-
From_Ruby() = default;
|
|
1044
|
-
|
|
1045
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1046
|
-
{
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
Convertible is_convertible(VALUE value)
|
|
1050
|
-
{
|
|
1051
|
-
return FromRubyFundamental<unsigned int>::is_convertible(value);
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
unsigned int convert(VALUE value)
|
|
1055
|
-
{
|
|
1056
|
-
return FromRubyFundamental<unsigned int>::convert(value);
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
private:
|
|
1060
|
-
Arg* arg_ = nullptr;
|
|
1061
|
-
};
|
|
1062
|
-
|
|
1063
|
-
template<>
|
|
1064
|
-
class From_Ruby<unsigned int&>
|
|
1065
|
-
{
|
|
1066
|
-
public:
|
|
1067
|
-
using Buffer_T = Buffer<unsigned int>;
|
|
1068
|
-
|
|
1069
|
-
From_Ruby() = default;
|
|
1070
|
-
|
|
1071
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1072
|
-
{
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
Convertible is_convertible(VALUE value)
|
|
1076
|
-
{
|
|
1077
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
1078
|
-
{
|
|
1079
|
-
return Convertible::Exact;
|
|
1080
|
-
}
|
|
1081
|
-
else
|
|
1082
|
-
{
|
|
1083
|
-
return FromRubyFundamental<unsigned int>::is_convertible(value);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
unsigned int& convert(VALUE value)
|
|
1088
|
-
{
|
|
1089
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
1090
|
-
{
|
|
1091
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
1092
|
-
return buffer->reference();
|
|
1093
|
-
}
|
|
1094
|
-
else
|
|
1095
|
-
{
|
|
1096
|
-
this->converted_ = FromRubyFundamental<unsigned int>::convert(value);
|
|
1097
|
-
return this->converted_;
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
private:
|
|
1102
|
-
Arg* arg_ = nullptr;
|
|
1103
|
-
unsigned int converted_ = 0;
|
|
1104
|
-
};
|
|
1105
|
-
|
|
1106
|
-
template<>
|
|
1107
|
-
class From_Ruby<unsigned int*>
|
|
1108
|
-
{
|
|
1109
|
-
public:
|
|
1110
|
-
From_Ruby() = default;
|
|
1111
|
-
|
|
1112
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1113
|
-
{
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
Convertible is_convertible(VALUE value)
|
|
1117
|
-
{
|
|
1118
|
-
return FromRubyFundamental<unsigned int*>::is_convertible(value);
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
unsigned int* convert(VALUE value)
|
|
1122
|
-
{
|
|
1123
|
-
return FromRubyFundamental<unsigned int*>::convert(value, this->arg_);
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
private:
|
|
1127
|
-
Arg* arg_ = nullptr;
|
|
1128
|
-
};
|
|
1129
|
-
|
|
1130
|
-
template<>
|
|
1131
|
-
class From_Ruby<unsigned int**>
|
|
1132
|
-
{
|
|
1133
|
-
public:
|
|
1134
|
-
From_Ruby() = default;
|
|
1135
|
-
|
|
1136
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1137
|
-
{
|
|
1138
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
1139
|
-
{
|
|
1140
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
Convertible is_convertible(VALUE value)
|
|
1145
|
-
{
|
|
1146
|
-
return FromRubyFundamental<unsigned int**>::is_convertible(value);
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
unsigned int** convert(VALUE value)
|
|
1150
|
-
{
|
|
1151
|
-
return FromRubyFundamental<unsigned int**>::convert(value, this->arg_);
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
private:
|
|
1155
|
-
Arg* arg_ = nullptr;
|
|
1156
|
-
};
|
|
1157
|
-
|
|
1158
|
-
// =========== long ============
|
|
1159
|
-
template<>
|
|
1160
|
-
class From_Ruby<long>
|
|
1161
|
-
{
|
|
1162
|
-
public:
|
|
1163
|
-
From_Ruby() = default;
|
|
1164
|
-
|
|
1165
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1166
|
-
{
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
Convertible is_convertible(VALUE value)
|
|
1170
|
-
{
|
|
1171
|
-
return FromRubyFundamental<long>::is_convertible(value);
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
long convert(VALUE value)
|
|
1175
|
-
{
|
|
1176
|
-
return FromRubyFundamental<long>::convert(value);
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
private:
|
|
1180
|
-
Arg* arg_ = nullptr;
|
|
1181
|
-
};
|
|
1182
|
-
|
|
1183
|
-
template<>
|
|
1184
|
-
class From_Ruby<long&>
|
|
1185
|
-
{
|
|
1186
|
-
public:
|
|
1187
|
-
using Buffer_T = Buffer<long>;
|
|
1188
|
-
|
|
1189
|
-
From_Ruby() = default;
|
|
1190
|
-
|
|
1191
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1192
|
-
{
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
Convertible is_convertible(VALUE value)
|
|
1196
|
-
{
|
|
1197
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
1198
|
-
{
|
|
1199
|
-
return Convertible::Exact;
|
|
1200
|
-
}
|
|
1201
|
-
else
|
|
1202
|
-
{
|
|
1203
|
-
return FromRubyFundamental<long>::is_convertible(value);
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
long& convert(VALUE value)
|
|
1208
|
-
{
|
|
1209
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
1210
|
-
{
|
|
1211
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
1212
|
-
return buffer->reference();
|
|
1213
|
-
}
|
|
1214
|
-
else
|
|
1215
|
-
{
|
|
1216
|
-
this->converted_ = FromRubyFundamental<long>::convert(value);
|
|
1217
|
-
return this->converted_;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
private:
|
|
1222
|
-
Arg* arg_ = nullptr;
|
|
1223
|
-
long converted_ = 0;
|
|
1224
|
-
};
|
|
1225
|
-
|
|
1226
|
-
template<>
|
|
1227
|
-
class From_Ruby<long*>
|
|
1228
|
-
{
|
|
1229
|
-
public:
|
|
1230
|
-
From_Ruby() = default;
|
|
1231
|
-
|
|
1232
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1233
|
-
{
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
Convertible is_convertible(VALUE value)
|
|
1237
|
-
{
|
|
1238
|
-
return FromRubyFundamental<long*>::is_convertible(value);
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
long* convert(VALUE value)
|
|
1242
|
-
{
|
|
1243
|
-
return FromRubyFundamental<long*>::convert(value, this->arg_);
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
private:
|
|
1247
|
-
Arg* arg_ = nullptr;
|
|
1248
|
-
};
|
|
1249
|
-
|
|
1250
|
-
template<>
|
|
1251
|
-
class From_Ruby<long**>
|
|
1252
|
-
{
|
|
1253
|
-
public:
|
|
1254
|
-
From_Ruby() = default;
|
|
1255
|
-
|
|
1256
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1257
|
-
{
|
|
1258
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
1259
|
-
{
|
|
1260
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
Convertible is_convertible(VALUE value)
|
|
1265
|
-
{
|
|
1266
|
-
return FromRubyFundamental<long**>::is_convertible(value);
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
long** convert(VALUE value)
|
|
1270
|
-
{
|
|
1271
|
-
return FromRubyFundamental<long**>::convert(value, this->arg_);
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
private:
|
|
1275
|
-
Arg* arg_ = nullptr;
|
|
1276
|
-
};
|
|
1277
|
-
|
|
1278
|
-
// =========== unsigned long ============
|
|
1279
|
-
template<>
|
|
1280
|
-
class From_Ruby<unsigned long>
|
|
1281
|
-
{
|
|
1282
|
-
public:
|
|
1283
|
-
From_Ruby() = default;
|
|
1284
|
-
|
|
1285
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1286
|
-
{
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
Convertible is_convertible(VALUE value)
|
|
1290
|
-
{
|
|
1291
|
-
return FromRubyFundamental<unsigned long>::is_convertible(value);
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
unsigned long convert(VALUE value)
|
|
1295
|
-
{
|
|
1296
|
-
if (this->arg_ && this->arg_->isValue())
|
|
1297
|
-
{
|
|
1298
|
-
return (unsigned long)value;
|
|
1299
|
-
}
|
|
1300
|
-
else
|
|
1301
|
-
{
|
|
1302
|
-
return FromRubyFundamental<unsigned long>::convert(value);
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
private:
|
|
1307
|
-
Arg* arg_ = nullptr;
|
|
1308
|
-
};
|
|
1309
|
-
|
|
1310
|
-
template<>
|
|
1311
|
-
class From_Ruby<unsigned long&>
|
|
1312
|
-
{
|
|
1313
|
-
public:
|
|
1314
|
-
using Buffer_T = Buffer<unsigned long>;
|
|
1315
|
-
|
|
1316
|
-
From_Ruby() = default;
|
|
1317
|
-
|
|
1318
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1319
|
-
{
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
Convertible is_convertible(VALUE value)
|
|
1323
|
-
{
|
|
1324
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
1325
|
-
{
|
|
1326
|
-
return Convertible::Exact;
|
|
1327
|
-
}
|
|
1328
|
-
else
|
|
1329
|
-
{
|
|
1330
|
-
return FromRubyFundamental<unsigned long>::is_convertible(value);
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
unsigned long& convert(VALUE value)
|
|
1335
|
-
{
|
|
1336
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
1337
|
-
{
|
|
1338
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
1339
|
-
return buffer->reference();
|
|
1340
|
-
}
|
|
1341
|
-
else
|
|
1342
|
-
{
|
|
1343
|
-
this->converted_ = FromRubyFundamental<unsigned long>::convert(value);
|
|
1344
|
-
return this->converted_;
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
private:
|
|
1349
|
-
Arg* arg_ = nullptr;
|
|
1350
|
-
unsigned long converted_ = 0;
|
|
1351
|
-
};
|
|
1352
|
-
|
|
1353
|
-
template<>
|
|
1354
|
-
class From_Ruby<unsigned long*>
|
|
1355
|
-
{
|
|
1356
|
-
public:
|
|
1357
|
-
From_Ruby() = default;
|
|
1358
|
-
|
|
1359
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1360
|
-
{
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
Convertible is_convertible(VALUE value)
|
|
1364
|
-
{
|
|
1365
|
-
return FromRubyFundamental<unsigned long*>::is_convertible(value);
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
unsigned long* convert(VALUE value)
|
|
1369
|
-
{
|
|
1370
|
-
return FromRubyFundamental<unsigned long*>::convert(value, this->arg_);
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
private:
|
|
1374
|
-
Arg* arg_ = nullptr;
|
|
1375
|
-
};
|
|
1376
|
-
|
|
1377
|
-
template<>
|
|
1378
|
-
class From_Ruby<unsigned long**>
|
|
1379
|
-
{
|
|
1380
|
-
public:
|
|
1381
|
-
From_Ruby() = default;
|
|
1382
|
-
|
|
1383
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1384
|
-
{
|
|
1385
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
1386
|
-
{
|
|
1387
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
Convertible is_convertible(VALUE value)
|
|
1392
|
-
{
|
|
1393
|
-
return FromRubyFundamental<unsigned long**>::is_convertible(value);
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
unsigned long** convert(VALUE value)
|
|
1397
|
-
{
|
|
1398
|
-
return FromRubyFundamental<unsigned long**>::convert(value, this->arg_);
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
private:
|
|
1402
|
-
Arg* arg_ = nullptr;
|
|
1403
|
-
};
|
|
1404
|
-
|
|
1405
|
-
// =========== unsigned long long ============
|
|
1406
|
-
template<>
|
|
1407
|
-
class From_Ruby<unsigned long long>
|
|
1408
|
-
{
|
|
1409
|
-
public:
|
|
1410
|
-
From_Ruby() = default;
|
|
1411
|
-
|
|
1412
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1413
|
-
{
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1416
|
-
Convertible is_convertible(VALUE value)
|
|
1417
|
-
{
|
|
1418
|
-
return FromRubyFundamental<unsigned long long>::is_convertible(value);
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
unsigned long long convert(VALUE value)
|
|
1422
|
-
{
|
|
1423
|
-
if (this->arg_ && this->arg_->isValue())
|
|
1424
|
-
{
|
|
1425
|
-
return value;
|
|
1426
|
-
}
|
|
1427
|
-
else
|
|
1428
|
-
{
|
|
1429
|
-
return FromRubyFundamental<unsigned long long>::convert(value);
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
private:
|
|
1434
|
-
Arg* arg_ = nullptr;
|
|
1435
|
-
};
|
|
1436
|
-
|
|
1437
|
-
template<>
|
|
1438
|
-
class From_Ruby<unsigned long long&>
|
|
1439
|
-
{
|
|
1440
|
-
public:
|
|
1441
|
-
using Buffer_T = Buffer<unsigned long long>;
|
|
1442
|
-
|
|
1443
|
-
From_Ruby() = default;
|
|
1444
|
-
|
|
1445
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1446
|
-
{
|
|
1447
|
-
}
|
|
1448
|
-
|
|
1449
|
-
Convertible is_convertible(VALUE value)
|
|
1450
|
-
{
|
|
1451
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
1452
|
-
{
|
|
1453
|
-
return Convertible::Exact;
|
|
1454
|
-
}
|
|
1455
|
-
else
|
|
1456
|
-
{
|
|
1457
|
-
return FromRubyFundamental<unsigned long long>::is_convertible(value);
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
unsigned long long& convert(VALUE value)
|
|
1462
|
-
{
|
|
1463
|
-
if (rb_type(value) == RUBY_T_DATA && Data_Type<Buffer_T>::is_descendant(value))
|
|
1464
|
-
{
|
|
1465
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
1466
|
-
return buffer->reference();
|
|
1467
|
-
}
|
|
1468
|
-
else
|
|
1469
|
-
{
|
|
1470
|
-
this->converted_ = FromRubyFundamental<unsigned long long>::convert(value);
|
|
1471
|
-
return this->converted_;
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
private:
|
|
1476
|
-
Arg* arg_ = nullptr;
|
|
1477
|
-
unsigned long long converted_ = 0;
|
|
1478
|
-
};
|
|
1479
|
-
|
|
1480
|
-
template<>
|
|
1481
|
-
class From_Ruby<unsigned long long*>
|
|
1482
|
-
{
|
|
1483
|
-
public:
|
|
1484
|
-
From_Ruby() = default;
|
|
1485
|
-
|
|
1486
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1487
|
-
{
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
Convertible is_convertible(VALUE value)
|
|
1491
|
-
{
|
|
1492
|
-
return FromRubyFundamental<unsigned long long*>::is_convertible(value);
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
unsigned long long* convert(VALUE value)
|
|
1496
|
-
{
|
|
1497
|
-
return FromRubyFundamental<unsigned long long*>::convert(value, this->arg_);
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
private:
|
|
1501
|
-
Arg* arg_ = nullptr;
|
|
1502
|
-
};
|
|
1503
|
-
|
|
1504
|
-
template<>
|
|
1505
|
-
class From_Ruby<unsigned long long**>
|
|
1506
|
-
{
|
|
1507
|
-
public:
|
|
1508
|
-
From_Ruby() = default;
|
|
1509
|
-
|
|
1510
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1511
|
-
{
|
|
1512
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
1513
|
-
{
|
|
1514
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
Convertible is_convertible(VALUE value)
|
|
1519
|
-
{
|
|
1520
|
-
return FromRubyFundamental<unsigned long long**>::is_convertible(value);
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
unsigned long long** convert(VALUE value)
|
|
1524
|
-
{
|
|
1525
|
-
return FromRubyFundamental<unsigned long long**>::convert(value, this->arg_);
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
private:
|
|
1529
|
-
Arg* arg_ = nullptr;
|
|
1530
|
-
};
|
|
1531
|
-
|
|
1532
|
-
// =========== long long ============
|
|
1533
|
-
template<>
|
|
1534
|
-
class From_Ruby<long long>
|
|
1535
|
-
{
|
|
1536
|
-
public:
|
|
1537
|
-
From_Ruby() = default;
|
|
1538
|
-
|
|
1539
|
-
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1540
|
-
{
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
Convertible is_convertible(VALUE value)
|
|
1544
|
-
{
|
|
1545
|
-
return FromRubyFundamental<long long>::is_convertible(value);
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
long long convert(VALUE value)
|
|
907
|
+
long convert(VALUE value)
|
|
1549
908
|
{
|
|
1550
|
-
return FromRubyFundamental<long
|
|
909
|
+
return FromRubyFundamental<long>::convert(value);
|
|
1551
910
|
}
|
|
1552
911
|
|
|
1553
912
|
private:
|
|
@@ -1555,10 +914,10 @@ namespace Rice::detail
|
|
|
1555
914
|
};
|
|
1556
915
|
|
|
1557
916
|
template<>
|
|
1558
|
-
class From_Ruby<long
|
|
917
|
+
class From_Ruby<long&>
|
|
1559
918
|
{
|
|
1560
919
|
public:
|
|
1561
|
-
using
|
|
920
|
+
using Pointer_T = Pointer<long>;
|
|
1562
921
|
|
|
1563
922
|
From_Ruby() = default;
|
|
1564
923
|
|
|
@@ -1568,37 +927,51 @@ namespace Rice::detail
|
|
|
1568
927
|
|
|
1569
928
|
Convertible is_convertible(VALUE value)
|
|
1570
929
|
{
|
|
1571
|
-
|
|
1572
|
-
{
|
|
1573
|
-
return Convertible::Exact;
|
|
1574
|
-
}
|
|
1575
|
-
else
|
|
930
|
+
switch (rb_type(value))
|
|
1576
931
|
{
|
|
1577
|
-
|
|
932
|
+
case RUBY_T_DATA:
|
|
933
|
+
{
|
|
934
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
935
|
+
{
|
|
936
|
+
return Convertible::Exact;
|
|
937
|
+
}
|
|
938
|
+
[[fallthrough]];
|
|
939
|
+
}
|
|
940
|
+
default:
|
|
941
|
+
{
|
|
942
|
+
return FromRubyFundamental<long>::is_convertible(value);
|
|
943
|
+
}
|
|
1578
944
|
}
|
|
1579
945
|
}
|
|
1580
946
|
|
|
1581
|
-
long
|
|
947
|
+
long& convert(VALUE value)
|
|
1582
948
|
{
|
|
1583
|
-
|
|
1584
|
-
{
|
|
1585
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
1586
|
-
return buffer->reference();
|
|
1587
|
-
}
|
|
1588
|
-
else
|
|
949
|
+
switch (rb_type(value))
|
|
1589
950
|
{
|
|
1590
|
-
|
|
1591
|
-
|
|
951
|
+
case RUBY_T_DATA:
|
|
952
|
+
{
|
|
953
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
954
|
+
{
|
|
955
|
+
return (long&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
956
|
+
}
|
|
957
|
+
[[fallthrough]];
|
|
958
|
+
}
|
|
959
|
+
default:
|
|
960
|
+
{
|
|
961
|
+
this->converted_ = FromRubyFundamental<long>::convert(value);
|
|
962
|
+
return this->converted_;
|
|
963
|
+
}
|
|
1592
964
|
}
|
|
1593
965
|
}
|
|
1594
966
|
|
|
1595
967
|
private:
|
|
1596
968
|
Arg* arg_ = nullptr;
|
|
1597
|
-
long
|
|
969
|
+
long converted_ = 0;
|
|
1598
970
|
};
|
|
1599
971
|
|
|
972
|
+
// =========== unsigned long ============
|
|
1600
973
|
template<>
|
|
1601
|
-
class From_Ruby<
|
|
974
|
+
class From_Ruby<unsigned long>
|
|
1602
975
|
{
|
|
1603
976
|
public:
|
|
1604
977
|
From_Ruby() = default;
|
|
@@ -1609,12 +982,19 @@ namespace Rice::detail
|
|
|
1609
982
|
|
|
1610
983
|
Convertible is_convertible(VALUE value)
|
|
1611
984
|
{
|
|
1612
|
-
return FromRubyFundamental<
|
|
985
|
+
return FromRubyFundamental<unsigned long>::is_convertible(value);
|
|
1613
986
|
}
|
|
1614
987
|
|
|
1615
|
-
|
|
988
|
+
unsigned long convert(VALUE value)
|
|
1616
989
|
{
|
|
1617
|
-
|
|
990
|
+
if (this->arg_ && this->arg_->isValue())
|
|
991
|
+
{
|
|
992
|
+
return (unsigned long)value;
|
|
993
|
+
}
|
|
994
|
+
else
|
|
995
|
+
{
|
|
996
|
+
return FromRubyFundamental<unsigned long>::convert(value);
|
|
997
|
+
}
|
|
1618
998
|
}
|
|
1619
999
|
|
|
1620
1000
|
private:
|
|
@@ -1622,36 +1002,64 @@ namespace Rice::detail
|
|
|
1622
1002
|
};
|
|
1623
1003
|
|
|
1624
1004
|
template<>
|
|
1625
|
-
class From_Ruby<
|
|
1005
|
+
class From_Ruby<unsigned long&>
|
|
1626
1006
|
{
|
|
1627
1007
|
public:
|
|
1008
|
+
using Pointer_T = Pointer<unsigned long>;
|
|
1009
|
+
|
|
1628
1010
|
From_Ruby() = default;
|
|
1629
1011
|
|
|
1630
1012
|
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1631
1013
|
{
|
|
1632
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
1633
|
-
{
|
|
1634
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
1635
|
-
}
|
|
1636
1014
|
}
|
|
1637
1015
|
|
|
1638
1016
|
Convertible is_convertible(VALUE value)
|
|
1639
1017
|
{
|
|
1640
|
-
|
|
1018
|
+
switch (rb_type(value))
|
|
1019
|
+
{
|
|
1020
|
+
case RUBY_T_DATA:
|
|
1021
|
+
{
|
|
1022
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1023
|
+
{
|
|
1024
|
+
return Convertible::Exact;
|
|
1025
|
+
}
|
|
1026
|
+
[[fallthrough]];
|
|
1027
|
+
}
|
|
1028
|
+
default:
|
|
1029
|
+
{
|
|
1030
|
+
return FromRubyFundamental<unsigned long>::is_convertible(value);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1641
1033
|
}
|
|
1642
1034
|
|
|
1643
|
-
|
|
1035
|
+
unsigned long& convert(VALUE value)
|
|
1644
1036
|
{
|
|
1645
|
-
|
|
1037
|
+
switch (rb_type(value))
|
|
1038
|
+
{
|
|
1039
|
+
case RUBY_T_DATA:
|
|
1040
|
+
{
|
|
1041
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1042
|
+
{
|
|
1043
|
+
return (unsigned long&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
1044
|
+
}
|
|
1045
|
+
[[fallthrough]];
|
|
1046
|
+
}
|
|
1047
|
+
default:
|
|
1048
|
+
{
|
|
1049
|
+
this->converted_ = FromRubyFundamental<unsigned long>::convert(value);
|
|
1050
|
+
return this->converted_;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1646
1053
|
}
|
|
1647
1054
|
|
|
1648
1055
|
private:
|
|
1649
1056
|
Arg* arg_ = nullptr;
|
|
1057
|
+
unsigned long converted_ = 0;
|
|
1650
1058
|
};
|
|
1651
1059
|
|
|
1652
|
-
// ===========
|
|
1060
|
+
// =========== unsigned long long ============
|
|
1653
1061
|
template<>
|
|
1654
|
-
class From_Ruby<
|
|
1062
|
+
class From_Ruby<unsigned long long>
|
|
1655
1063
|
{
|
|
1656
1064
|
public:
|
|
1657
1065
|
From_Ruby() = default;
|
|
@@ -1662,12 +1070,19 @@ namespace Rice::detail
|
|
|
1662
1070
|
|
|
1663
1071
|
Convertible is_convertible(VALUE value)
|
|
1664
1072
|
{
|
|
1665
|
-
return FromRubyFundamental<
|
|
1073
|
+
return FromRubyFundamental<unsigned long long>::is_convertible(value);
|
|
1666
1074
|
}
|
|
1667
1075
|
|
|
1668
|
-
|
|
1076
|
+
unsigned long long convert(VALUE value)
|
|
1669
1077
|
{
|
|
1670
|
-
|
|
1078
|
+
if (this->arg_ && this->arg_->isValue())
|
|
1079
|
+
{
|
|
1080
|
+
return value;
|
|
1081
|
+
}
|
|
1082
|
+
else
|
|
1083
|
+
{
|
|
1084
|
+
return FromRubyFundamental<unsigned long long>::convert(value);
|
|
1085
|
+
}
|
|
1671
1086
|
}
|
|
1672
1087
|
|
|
1673
1088
|
private:
|
|
@@ -1675,10 +1090,10 @@ namespace Rice::detail
|
|
|
1675
1090
|
};
|
|
1676
1091
|
|
|
1677
1092
|
template<>
|
|
1678
|
-
class From_Ruby<
|
|
1093
|
+
class From_Ruby<unsigned long long&>
|
|
1679
1094
|
{
|
|
1680
1095
|
public:
|
|
1681
|
-
using
|
|
1096
|
+
using Pointer_T = Pointer<unsigned long long>;
|
|
1682
1097
|
|
|
1683
1098
|
From_Ruby() = default;
|
|
1684
1099
|
|
|
@@ -1688,37 +1103,51 @@ namespace Rice::detail
|
|
|
1688
1103
|
|
|
1689
1104
|
Convertible is_convertible(VALUE value)
|
|
1690
1105
|
{
|
|
1691
|
-
|
|
1692
|
-
{
|
|
1693
|
-
return Convertible::Exact;
|
|
1694
|
-
}
|
|
1695
|
-
else
|
|
1106
|
+
switch (rb_type(value))
|
|
1696
1107
|
{
|
|
1697
|
-
|
|
1108
|
+
case RUBY_T_DATA:
|
|
1109
|
+
{
|
|
1110
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1111
|
+
{
|
|
1112
|
+
return Convertible::Exact;
|
|
1113
|
+
}
|
|
1114
|
+
[[fallthrough]];
|
|
1115
|
+
}
|
|
1116
|
+
default:
|
|
1117
|
+
{
|
|
1118
|
+
return FromRubyFundamental<unsigned long long>::is_convertible(value);
|
|
1119
|
+
}
|
|
1698
1120
|
}
|
|
1699
1121
|
}
|
|
1700
1122
|
|
|
1701
|
-
|
|
1123
|
+
unsigned long long& convert(VALUE value)
|
|
1702
1124
|
{
|
|
1703
|
-
|
|
1704
|
-
{
|
|
1705
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
1706
|
-
return buffer->reference();
|
|
1707
|
-
}
|
|
1708
|
-
else
|
|
1125
|
+
switch (rb_type(value))
|
|
1709
1126
|
{
|
|
1710
|
-
|
|
1711
|
-
|
|
1127
|
+
case RUBY_T_DATA:
|
|
1128
|
+
{
|
|
1129
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1130
|
+
{
|
|
1131
|
+
return (unsigned long long&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
1132
|
+
}
|
|
1133
|
+
[[fallthrough]];
|
|
1134
|
+
}
|
|
1135
|
+
default:
|
|
1136
|
+
{
|
|
1137
|
+
this->converted_ = FromRubyFundamental<unsigned long long>::convert(value);
|
|
1138
|
+
return this->converted_;
|
|
1139
|
+
}
|
|
1712
1140
|
}
|
|
1713
1141
|
}
|
|
1714
1142
|
|
|
1715
1143
|
private:
|
|
1716
1144
|
Arg* arg_ = nullptr;
|
|
1717
|
-
|
|
1145
|
+
unsigned long long converted_ = 0;
|
|
1718
1146
|
};
|
|
1719
|
-
|
|
1147
|
+
|
|
1148
|
+
// =========== long long ============
|
|
1720
1149
|
template<>
|
|
1721
|
-
class From_Ruby<
|
|
1150
|
+
class From_Ruby<long long>
|
|
1722
1151
|
{
|
|
1723
1152
|
public:
|
|
1724
1153
|
From_Ruby() = default;
|
|
@@ -1729,48 +1158,77 @@ namespace Rice::detail
|
|
|
1729
1158
|
|
|
1730
1159
|
Convertible is_convertible(VALUE value)
|
|
1731
1160
|
{
|
|
1732
|
-
return FromRubyFundamental<
|
|
1161
|
+
return FromRubyFundamental<long long>::is_convertible(value);
|
|
1733
1162
|
}
|
|
1734
1163
|
|
|
1735
|
-
|
|
1164
|
+
long long convert(VALUE value)
|
|
1736
1165
|
{
|
|
1737
|
-
return FromRubyFundamental<
|
|
1166
|
+
return FromRubyFundamental<long long>::convert(value);
|
|
1738
1167
|
}
|
|
1739
|
-
|
|
1168
|
+
|
|
1740
1169
|
private:
|
|
1741
1170
|
Arg* arg_ = nullptr;
|
|
1742
1171
|
};
|
|
1743
1172
|
|
|
1744
1173
|
template<>
|
|
1745
|
-
class From_Ruby<
|
|
1174
|
+
class From_Ruby<long long&>
|
|
1746
1175
|
{
|
|
1747
1176
|
public:
|
|
1177
|
+
using Pointer_T = Pointer<long long>;
|
|
1178
|
+
|
|
1748
1179
|
From_Ruby() = default;
|
|
1749
1180
|
|
|
1750
1181
|
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1751
1182
|
{
|
|
1752
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
1753
|
-
{
|
|
1754
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
1755
|
-
}
|
|
1756
1183
|
}
|
|
1757
1184
|
|
|
1758
1185
|
Convertible is_convertible(VALUE value)
|
|
1759
1186
|
{
|
|
1760
|
-
|
|
1187
|
+
switch (rb_type(value))
|
|
1188
|
+
{
|
|
1189
|
+
case RUBY_T_DATA:
|
|
1190
|
+
{
|
|
1191
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1192
|
+
{
|
|
1193
|
+
return Convertible::Exact;
|
|
1194
|
+
}
|
|
1195
|
+
[[fallthrough]];
|
|
1196
|
+
}
|
|
1197
|
+
default:
|
|
1198
|
+
{
|
|
1199
|
+
return FromRubyFundamental<long long>::is_convertible(value);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1761
1202
|
}
|
|
1762
1203
|
|
|
1763
|
-
|
|
1204
|
+
long long& convert(VALUE value)
|
|
1764
1205
|
{
|
|
1765
|
-
|
|
1206
|
+
switch (rb_type(value))
|
|
1207
|
+
{
|
|
1208
|
+
case RUBY_T_DATA:
|
|
1209
|
+
{
|
|
1210
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1211
|
+
{
|
|
1212
|
+
return (long long&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
1213
|
+
}
|
|
1214
|
+
[[fallthrough]];
|
|
1215
|
+
}
|
|
1216
|
+
default:
|
|
1217
|
+
{
|
|
1218
|
+
this->converted_ = FromRubyFundamental<long long>::convert(value);
|
|
1219
|
+
return this->converted_;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1766
1222
|
}
|
|
1223
|
+
|
|
1767
1224
|
private:
|
|
1768
1225
|
Arg* arg_ = nullptr;
|
|
1226
|
+
long long converted_ = 0;
|
|
1769
1227
|
};
|
|
1770
1228
|
|
|
1771
|
-
// ===========
|
|
1229
|
+
// =========== short ============
|
|
1772
1230
|
template<>
|
|
1773
|
-
class From_Ruby<
|
|
1231
|
+
class From_Ruby<short>
|
|
1774
1232
|
{
|
|
1775
1233
|
public:
|
|
1776
1234
|
From_Ruby() = default;
|
|
@@ -1781,23 +1239,23 @@ namespace Rice::detail
|
|
|
1781
1239
|
|
|
1782
1240
|
Convertible is_convertible(VALUE value)
|
|
1783
1241
|
{
|
|
1784
|
-
return FromRubyFundamental<
|
|
1242
|
+
return FromRubyFundamental<short>::is_convertible(value);
|
|
1785
1243
|
}
|
|
1786
1244
|
|
|
1787
|
-
|
|
1245
|
+
short convert(VALUE value)
|
|
1788
1246
|
{
|
|
1789
|
-
return FromRubyFundamental<
|
|
1247
|
+
return FromRubyFundamental<short>::convert(value);
|
|
1790
1248
|
}
|
|
1791
|
-
|
|
1249
|
+
|
|
1792
1250
|
private:
|
|
1793
1251
|
Arg* arg_ = nullptr;
|
|
1794
1252
|
};
|
|
1795
1253
|
|
|
1796
1254
|
template<>
|
|
1797
|
-
class From_Ruby<
|
|
1255
|
+
class From_Ruby<short&>
|
|
1798
1256
|
{
|
|
1799
1257
|
public:
|
|
1800
|
-
using
|
|
1258
|
+
using Pointer_T = Pointer<short>;
|
|
1801
1259
|
|
|
1802
1260
|
From_Ruby() = default;
|
|
1803
1261
|
|
|
@@ -1807,37 +1265,51 @@ namespace Rice::detail
|
|
|
1807
1265
|
|
|
1808
1266
|
Convertible is_convertible(VALUE value)
|
|
1809
1267
|
{
|
|
1810
|
-
|
|
1811
|
-
{
|
|
1812
|
-
return Convertible::Exact;
|
|
1813
|
-
}
|
|
1814
|
-
else
|
|
1268
|
+
switch (rb_type(value))
|
|
1815
1269
|
{
|
|
1816
|
-
|
|
1270
|
+
case RUBY_T_DATA:
|
|
1271
|
+
{
|
|
1272
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1273
|
+
{
|
|
1274
|
+
return Convertible::Exact;
|
|
1275
|
+
}
|
|
1276
|
+
[[fallthrough]];
|
|
1277
|
+
}
|
|
1278
|
+
default:
|
|
1279
|
+
{
|
|
1280
|
+
return FromRubyFundamental<short>::is_convertible(value);
|
|
1281
|
+
}
|
|
1817
1282
|
}
|
|
1818
1283
|
}
|
|
1819
1284
|
|
|
1820
|
-
|
|
1285
|
+
short& convert(VALUE value)
|
|
1821
1286
|
{
|
|
1822
|
-
|
|
1823
|
-
{
|
|
1824
|
-
Buffer_T* buffer = unwrap<Buffer_T>(value, Data_Type<Buffer_T>::ruby_data_type(), false);
|
|
1825
|
-
return buffer->reference();
|
|
1826
|
-
}
|
|
1827
|
-
else
|
|
1287
|
+
switch (rb_type(value))
|
|
1828
1288
|
{
|
|
1829
|
-
|
|
1830
|
-
|
|
1289
|
+
case RUBY_T_DATA:
|
|
1290
|
+
{
|
|
1291
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1292
|
+
{
|
|
1293
|
+
return (short&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
1294
|
+
}
|
|
1295
|
+
[[fallthrough]];
|
|
1296
|
+
}
|
|
1297
|
+
default:
|
|
1298
|
+
{
|
|
1299
|
+
this->converted_ = FromRubyFundamental<short>::convert(value);
|
|
1300
|
+
return this->converted_;
|
|
1301
|
+
}
|
|
1831
1302
|
}
|
|
1832
1303
|
}
|
|
1833
1304
|
|
|
1834
1305
|
private:
|
|
1835
1306
|
Arg* arg_ = nullptr;
|
|
1836
|
-
|
|
1307
|
+
short converted_ = 0;
|
|
1837
1308
|
};
|
|
1838
1309
|
|
|
1310
|
+
// =========== unsigned short ============
|
|
1839
1311
|
template<>
|
|
1840
|
-
class From_Ruby<unsigned short
|
|
1312
|
+
class From_Ruby<unsigned short>
|
|
1841
1313
|
{
|
|
1842
1314
|
public:
|
|
1843
1315
|
From_Ruby() = default;
|
|
@@ -1848,44 +1320,72 @@ namespace Rice::detail
|
|
|
1848
1320
|
|
|
1849
1321
|
Convertible is_convertible(VALUE value)
|
|
1850
1322
|
{
|
|
1851
|
-
return FromRubyFundamental<unsigned short
|
|
1323
|
+
return FromRubyFundamental<unsigned short>::is_convertible(value);
|
|
1852
1324
|
}
|
|
1853
1325
|
|
|
1854
|
-
unsigned short
|
|
1326
|
+
unsigned short convert(VALUE value)
|
|
1855
1327
|
{
|
|
1856
|
-
return FromRubyFundamental<unsigned short
|
|
1328
|
+
return FromRubyFundamental<unsigned short>::convert(value);
|
|
1857
1329
|
}
|
|
1858
|
-
|
|
1330
|
+
|
|
1859
1331
|
private:
|
|
1860
1332
|
Arg* arg_ = nullptr;
|
|
1861
1333
|
};
|
|
1862
1334
|
|
|
1863
1335
|
template<>
|
|
1864
|
-
class From_Ruby<unsigned short
|
|
1336
|
+
class From_Ruby<unsigned short&>
|
|
1865
1337
|
{
|
|
1866
1338
|
public:
|
|
1339
|
+
using Pointer_T = Pointer<unsigned short>;
|
|
1340
|
+
|
|
1867
1341
|
From_Ruby() = default;
|
|
1868
1342
|
|
|
1869
1343
|
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1870
1344
|
{
|
|
1871
|
-
if (this->arg_ && this->arg_->isOwner())
|
|
1872
|
-
{
|
|
1873
|
-
throw std::runtime_error("Cannot transfer ownership of an array of pointers to a fundamental type");
|
|
1874
|
-
}
|
|
1875
1345
|
}
|
|
1876
1346
|
|
|
1877
1347
|
Convertible is_convertible(VALUE value)
|
|
1878
1348
|
{
|
|
1879
|
-
|
|
1349
|
+
switch (rb_type(value))
|
|
1350
|
+
{
|
|
1351
|
+
case RUBY_T_DATA:
|
|
1352
|
+
{
|
|
1353
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1354
|
+
{
|
|
1355
|
+
return Convertible::Exact;
|
|
1356
|
+
}
|
|
1357
|
+
[[fallthrough]];
|
|
1358
|
+
}
|
|
1359
|
+
default:
|
|
1360
|
+
{
|
|
1361
|
+
return FromRubyFundamental<unsigned short>::is_convertible(value);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1880
1364
|
}
|
|
1881
1365
|
|
|
1882
|
-
unsigned short
|
|
1366
|
+
unsigned short& convert(VALUE value)
|
|
1883
1367
|
{
|
|
1884
|
-
|
|
1368
|
+
switch (rb_type(value))
|
|
1369
|
+
{
|
|
1370
|
+
case RUBY_T_DATA:
|
|
1371
|
+
{
|
|
1372
|
+
if (Data_Type<Pointer_T>::is_descendant(value))
|
|
1373
|
+
{
|
|
1374
|
+
return (unsigned short&)*unwrap<Pointer_T>(value, Data_Type<Pointer_T>::ruby_data_type(), false);
|
|
1375
|
+
}
|
|
1376
|
+
[[fallthrough]];
|
|
1377
|
+
}
|
|
1378
|
+
default:
|
|
1379
|
+
{
|
|
1380
|
+
this->converted_ = FromRubyFundamental<unsigned short>::convert(value);
|
|
1381
|
+
return this->converted_;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1885
1384
|
}
|
|
1886
1385
|
|
|
1887
1386
|
private:
|
|
1888
1387
|
Arg* arg_ = nullptr;
|
|
1388
|
+
unsigned short converted_ = 0;
|
|
1889
1389
|
};
|
|
1890
1390
|
|
|
1891
1391
|
// =========== std::nullptr_t ============
|
|
@@ -1961,13 +1461,10 @@ namespace Rice::detail
|
|
|
1961
1461
|
public:
|
|
1962
1462
|
From_Ruby()
|
|
1963
1463
|
{
|
|
1964
|
-
detail::Type<Buffer<void>>::verify();
|
|
1965
1464
|
};
|
|
1966
1465
|
|
|
1967
1466
|
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1968
1467
|
{
|
|
1969
|
-
detail::Type<Buffer<void>>::verify();
|
|
1970
|
-
|
|
1971
1468
|
if (this->arg_->isOwner())
|
|
1972
1469
|
{
|
|
1973
1470
|
throw Exception(rb_eTypeError, "Cannot transfer ownership of C++ void pointer");
|
|
@@ -2028,12 +1525,9 @@ namespace Rice::detail
|
|
|
2028
1525
|
// from the Ruby object.
|
|
2029
1526
|
const rb_data_type_t* rb_type = RTYPEDDATA_TYPE(value);
|
|
2030
1527
|
|
|
2031
|
-
|
|
2032
|
-
// a C++ paramter that takes void*
|
|
2033
|
-
if (rb_type == Data_Type<Buffer<void>>::ruby_data_type())
|
|
1528
|
+
if (Data_Type<Pointer<void>>::is_descendant(value))
|
|
2034
1529
|
{
|
|
2035
|
-
|
|
2036
|
-
return buffer->ptr();
|
|
1530
|
+
return unwrap<void>(value, Data_Type<Pointer<void>>::ruby_data_type(), false);
|
|
2037
1531
|
}
|
|
2038
1532
|
else
|
|
2039
1533
|
{
|