rice 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -1
- data/CMakeLists.txt +14 -22
- data/CMakePresets.json +203 -75
- data/FindRuby.cmake +358 -123
- data/bin/rice-doc.rb +56 -142
- data/bin/rice-rbs.rb +1 -2
- data/include/rice/api.hpp +248 -0
- data/include/rice/rice.hpp +2281 -1668
- data/include/rice/stl.hpp +364 -443
- data/lib/rice/doc/config.rb +70 -0
- data/lib/rice/doc/cpp_reference.rb +1 -4
- data/lib/rice/doc/mkdocs.rb +58 -20
- data/lib/rice/doc/rice.rb +20 -0
- data/lib/rice/doc.rb +1 -0
- data/lib/rice/make_rice_headers.rb +7 -0
- data/lib/rice/native_registry.rb +2 -2
- data/lib/rice/rbs.rb +4 -4
- data/lib/rice/version.rb +1 -1
- data/lib/rubygems_plugin.rb +12 -9
- data/rice/Arg.hpp +12 -6
- data/rice/Arg.ipp +14 -7
- data/rice/Buffer.ipp +44 -40
- data/rice/Callback.hpp +1 -1
- data/rice/Callback.ipp +2 -7
- data/rice/Constructor.hpp +1 -1
- data/rice/Constructor.ipp +11 -11
- data/rice/Data_Object.ipp +59 -30
- data/rice/Data_Type.hpp +9 -10
- data/rice/Data_Type.ipp +22 -25
- data/rice/Director.hpp +1 -0
- data/rice/Enum.ipp +58 -39
- data/rice/Exception.hpp +4 -4
- data/rice/Exception.ipp +7 -7
- data/rice/NoGVL.hpp +13 -0
- data/rice/Reference.hpp +56 -0
- data/rice/Reference.ipp +96 -0
- data/rice/Return.hpp +4 -1
- data/rice/Return.ipp +0 -6
- data/rice/cpp_api/Array.hpp +44 -7
- data/rice/cpp_api/Array.ipp +105 -9
- data/rice/cpp_api/Class.hpp +2 -2
- data/rice/cpp_api/Class.ipp +4 -4
- data/rice/cpp_api/Hash.ipp +7 -4
- data/rice/cpp_api/Module.hpp +4 -4
- data/rice/cpp_api/Module.ipp +12 -10
- data/rice/cpp_api/Object.hpp +4 -4
- data/rice/cpp_api/Object.ipp +15 -12
- data/rice/cpp_api/String.hpp +2 -2
- data/rice/cpp_api/String.ipp +11 -8
- data/rice/cpp_api/Symbol.ipp +16 -7
- data/rice/cpp_api/shared_methods.hpp +5 -9
- data/rice/detail/InstanceRegistry.hpp +0 -2
- data/rice/detail/Native.hpp +31 -21
- data/rice/detail/Native.ipp +281 -133
- data/rice/detail/NativeAttributeGet.hpp +5 -7
- data/rice/detail/NativeAttributeGet.ipp +26 -26
- data/rice/detail/NativeAttributeSet.hpp +2 -4
- data/rice/detail/NativeAttributeSet.ipp +20 -16
- data/rice/detail/NativeCallback.hpp +77 -0
- data/rice/detail/NativeCallback.ipp +280 -0
- data/rice/detail/NativeFunction.hpp +11 -21
- data/rice/detail/NativeFunction.ipp +58 -119
- data/rice/detail/NativeInvoker.hpp +4 -4
- data/rice/detail/NativeInvoker.ipp +7 -7
- data/rice/detail/NativeIterator.hpp +2 -4
- data/rice/detail/NativeIterator.ipp +18 -14
- data/rice/detail/NativeMethod.hpp +10 -20
- data/rice/detail/NativeMethod.ipp +54 -114
- data/rice/detail/NativeProc.hpp +5 -7
- data/rice/detail/NativeProc.ipp +39 -28
- data/rice/detail/NativeRegistry.hpp +0 -1
- data/rice/detail/NativeRegistry.ipp +0 -1
- data/rice/detail/Parameter.hpp +15 -8
- data/rice/detail/Parameter.ipp +102 -43
- data/rice/detail/Proc.ipp +14 -28
- data/rice/detail/RubyType.ipp +2 -53
- data/rice/detail/Type.hpp +23 -7
- data/rice/detail/Type.ipp +73 -93
- data/rice/detail/TypeRegistry.ipp +5 -4
- data/rice/detail/Wrapper.hpp +1 -1
- data/rice/detail/Wrapper.ipp +18 -10
- data/rice/detail/from_ruby.hpp +8 -6
- data/rice/detail/from_ruby.ipp +306 -173
- data/rice/detail/ruby.hpp +23 -0
- data/rice/libc/file.hpp +4 -4
- data/rice/rice.hpp +6 -8
- data/rice/rice_api/Native.ipp +5 -1
- data/rice/rice_api/Parameter.ipp +1 -1
- data/rice/ruby_mark.hpp +2 -1
- data/rice/stl/complex.ipp +12 -8
- data/rice/stl/map.ipp +27 -22
- data/rice/stl/monostate.ipp +16 -12
- data/rice/stl/multimap.hpp +0 -2
- data/rice/stl/multimap.ipp +27 -22
- data/rice/stl/optional.ipp +27 -11
- data/rice/stl/pair.ipp +5 -5
- data/rice/stl/reference_wrapper.ipp +5 -4
- data/rice/stl/set.ipp +16 -16
- data/rice/stl/shared_ptr.hpp +0 -16
- data/rice/stl/shared_ptr.ipp +34 -190
- data/rice/stl/string.ipp +18 -18
- data/rice/stl/string_view.ipp +19 -1
- data/rice/stl/tuple.ipp +15 -36
- data/rice/stl/unique_ptr.ipp +18 -8
- data/rice/stl/unordered_map.ipp +20 -15
- data/rice/stl/variant.ipp +37 -21
- data/rice/stl/vector.ipp +41 -36
- data/rice/traits/function_traits.hpp +19 -19
- data/rice/traits/method_traits.hpp +4 -4
- data/rice/traits/rice_traits.hpp +162 -39
- data/rice.gemspec +1 -4
- data/test/test_Array.cpp +261 -3
- data/test/test_Attribute.cpp +6 -3
- data/test/test_Buffer.cpp +6 -42
- data/test/test_Callback.cpp +77 -23
- data/test/test_Data_Object.cpp +2 -2
- data/test/test_Data_Type.cpp +23 -23
- data/test/test_Director.cpp +2 -4
- data/test/test_Enum.cpp +34 -5
- data/test/test_File.cpp +9 -5
- data/test/test_From_Ruby.cpp +7 -6
- data/test/test_GVL.cpp +3 -3
- data/test/test_Hash.cpp +1 -1
- data/test/test_Iterator.cpp +54 -22
- data/test/test_Keep_Alive.cpp +1 -1
- data/test/test_Keep_Alive_No_Wrapper.cpp +1 -1
- data/test/test_Module.cpp +5 -5
- data/test/test_Overloads.cpp +395 -50
- data/test/test_Proc.cpp +54 -0
- data/test/test_Reference.cpp +181 -0
- data/test/test_Self.cpp +2 -2
- data/test/test_Stl_Set.cpp +6 -6
- data/test/test_Stl_SharedPtr.cpp +54 -30
- data/test/test_Stl_String_View.cpp +12 -0
- data/test/test_Stl_Tuple.cpp +1 -1
- data/test/test_Stl_Variant.cpp +6 -14
- data/test/test_Stl_Vector.cpp +61 -30
- data/test/test_String.cpp +4 -2
- data/test/test_Struct.cpp +1 -1
- data/test/test_Symbol.cpp +12 -0
- data/test/test_To_Ruby.cpp +1 -0
- data/test/test_Type.cpp +36 -35
- data/test/test_global_functions.cpp +1 -1
- data/test/unittest.cpp +1 -1
- data/test/unittest.hpp +5 -5
- metadata +10 -24
- data/rice/Function.hpp +0 -17
- data/rice/Function.ipp +0 -13
- data/rice/detail/MethodInfo.hpp +0 -48
- data/rice/detail/MethodInfo.ipp +0 -99
- data/rice/detail/NativeCallbackFFI.hpp +0 -55
- data/rice/detail/NativeCallbackFFI.ipp +0 -152
- data/rice/detail/NativeCallbackSimple.hpp +0 -30
- data/rice/detail/NativeCallbackSimple.ipp +0 -29
data/rice/cpp_api/Array.ipp
CHANGED
|
@@ -186,7 +186,7 @@ namespace Rice
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
template<typename Array_Ptr_T, typename Value_T>
|
|
189
|
-
inline Value_T Array::Iterator<Array_Ptr_T, Value_T>::operator*()
|
|
189
|
+
inline Value_T Array::Iterator<Array_Ptr_T, Value_T>::operator*() const
|
|
190
190
|
{
|
|
191
191
|
return (*array_)[index_];
|
|
192
192
|
}
|
|
@@ -212,6 +212,99 @@ namespace Rice
|
|
|
212
212
|
return !(*this == rhs);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
216
|
+
template<typename Array_Ptr_T_, typename Value_T_>
|
|
217
|
+
inline bool Array::Iterator<Array_Ptr_T, Value_T>::operator<(Iterator<Array_Ptr_T_, Value_T_> const& rhs) const
|
|
218
|
+
{
|
|
219
|
+
return index_ < rhs.index_;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
223
|
+
template<typename Array_Ptr_T_, typename Value_T_>
|
|
224
|
+
inline bool Array::Iterator<Array_Ptr_T, Value_T>::operator>(Iterator<Array_Ptr_T_, Value_T_> const& rhs) const
|
|
225
|
+
{
|
|
226
|
+
return index_ > rhs.index_;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
230
|
+
template<typename Array_Ptr_T_, typename Value_T_>
|
|
231
|
+
inline bool Array::Iterator<Array_Ptr_T, Value_T>::operator<=(Iterator<Array_Ptr_T_, Value_T_> const& rhs) const
|
|
232
|
+
{
|
|
233
|
+
return index_ <= rhs.index_;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
237
|
+
template<typename Array_Ptr_T_, typename Value_T_>
|
|
238
|
+
inline bool Array::Iterator<Array_Ptr_T, Value_T>::operator>=(Iterator<Array_Ptr_T_, Value_T_> const& rhs) const
|
|
239
|
+
{
|
|
240
|
+
return index_ >= rhs.index_;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Bidirectional iterator operations
|
|
244
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
245
|
+
inline Array::Iterator<Array_Ptr_T, Value_T>& Array::Iterator<Array_Ptr_T, Value_T>::operator--()
|
|
246
|
+
{
|
|
247
|
+
--index_;
|
|
248
|
+
return *this;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
252
|
+
inline Array::Iterator<Array_Ptr_T, Value_T> Array::Iterator<Array_Ptr_T, Value_T>::operator--(int)
|
|
253
|
+
{
|
|
254
|
+
Iterator copy(*this);
|
|
255
|
+
--(*this);
|
|
256
|
+
return copy;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Random access iterator operations
|
|
260
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
261
|
+
inline Array::Iterator<Array_Ptr_T, Value_T>& Array::Iterator<Array_Ptr_T, Value_T>::operator+=(difference_type n)
|
|
262
|
+
{
|
|
263
|
+
index_ += n;
|
|
264
|
+
return *this;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
268
|
+
inline Array::Iterator<Array_Ptr_T, Value_T>& Array::Iterator<Array_Ptr_T, Value_T>::operator-=(difference_type n)
|
|
269
|
+
{
|
|
270
|
+
index_ -= n;
|
|
271
|
+
return *this;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
275
|
+
inline Array::Iterator<Array_Ptr_T, Value_T> Array::Iterator<Array_Ptr_T, Value_T>::operator+(difference_type n) const
|
|
276
|
+
{
|
|
277
|
+
return Iterator(array_, index_ + n);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
281
|
+
inline Array::Iterator<Array_Ptr_T, Value_T> Array::Iterator<Array_Ptr_T, Value_T>::operator-(difference_type n) const
|
|
282
|
+
{
|
|
283
|
+
return Iterator(array_, index_ - n);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
287
|
+
inline typename Array::Iterator<Array_Ptr_T, Value_T>::difference_type
|
|
288
|
+
Array::Iterator<Array_Ptr_T, Value_T>::operator-(Iterator const& rhs) const
|
|
289
|
+
{
|
|
290
|
+
return index_ - rhs.index_;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
294
|
+
inline Value_T Array::Iterator<Array_Ptr_T, Value_T>::operator[](difference_type n) const
|
|
295
|
+
{
|
|
296
|
+
return (*array_)[index_ + n];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Non-member operator+ (allows n + iterator syntax)
|
|
300
|
+
template<typename Array_Ptr_T, typename Value_T>
|
|
301
|
+
inline Array::Iterator<Array_Ptr_T, Value_T> operator+(
|
|
302
|
+
long n,
|
|
303
|
+
Array::Iterator<Array_Ptr_T, Value_T> const& it)
|
|
304
|
+
{
|
|
305
|
+
return it + n;
|
|
306
|
+
}
|
|
307
|
+
|
|
215
308
|
template<typename Array_Ptr_T, typename Value_T>
|
|
216
309
|
Array_Ptr_T Array::Iterator<Array_Ptr_T, Value_T>::array() const
|
|
217
310
|
{
|
|
@@ -267,7 +360,7 @@ namespace Rice::detail
|
|
|
267
360
|
public:
|
|
268
361
|
To_Ruby() = default;
|
|
269
362
|
|
|
270
|
-
explicit To_Ruby(
|
|
363
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
271
364
|
{
|
|
272
365
|
}
|
|
273
366
|
|
|
@@ -277,7 +370,7 @@ namespace Rice::detail
|
|
|
277
370
|
}
|
|
278
371
|
|
|
279
372
|
private:
|
|
280
|
-
|
|
373
|
+
Arg* arg_ = nullptr;
|
|
281
374
|
};
|
|
282
375
|
|
|
283
376
|
template<>
|
|
@@ -286,7 +379,7 @@ namespace Rice::detail
|
|
|
286
379
|
public:
|
|
287
380
|
To_Ruby() = default;
|
|
288
381
|
|
|
289
|
-
explicit To_Ruby(
|
|
382
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
290
383
|
{
|
|
291
384
|
}
|
|
292
385
|
|
|
@@ -296,7 +389,7 @@ namespace Rice::detail
|
|
|
296
389
|
}
|
|
297
390
|
|
|
298
391
|
private:
|
|
299
|
-
|
|
392
|
+
Arg* arg_ = nullptr;
|
|
300
393
|
};
|
|
301
394
|
|
|
302
395
|
template<>
|
|
@@ -305,7 +398,7 @@ namespace Rice::detail
|
|
|
305
398
|
public:
|
|
306
399
|
To_Ruby() = default;
|
|
307
400
|
|
|
308
|
-
explicit To_Ruby(
|
|
401
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
309
402
|
{
|
|
310
403
|
}
|
|
311
404
|
|
|
@@ -315,7 +408,7 @@ namespace Rice::detail
|
|
|
315
408
|
}
|
|
316
409
|
|
|
317
410
|
private:
|
|
318
|
-
|
|
411
|
+
Arg* arg_ = nullptr;
|
|
319
412
|
};
|
|
320
413
|
|
|
321
414
|
template<>
|
|
@@ -324,11 +417,11 @@ namespace Rice::detail
|
|
|
324
417
|
public:
|
|
325
418
|
From_Ruby() = default;
|
|
326
419
|
|
|
327
|
-
explicit From_Ruby(Arg* arg)
|
|
420
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
328
421
|
{
|
|
329
422
|
}
|
|
330
423
|
|
|
331
|
-
|
|
424
|
+
double is_convertible(VALUE value)
|
|
332
425
|
{
|
|
333
426
|
switch (rb_type(value))
|
|
334
427
|
{
|
|
@@ -344,6 +437,9 @@ namespace Rice::detail
|
|
|
344
437
|
{
|
|
345
438
|
return Array(value);
|
|
346
439
|
}
|
|
440
|
+
|
|
441
|
+
private:
|
|
442
|
+
Arg* arg_ = nullptr;
|
|
347
443
|
};
|
|
348
444
|
}
|
|
349
445
|
#endif // Rice__Array__ipp_
|
data/rice/cpp_api/Class.hpp
CHANGED
|
@@ -24,8 +24,8 @@ namespace Rice
|
|
|
24
24
|
Class & undef_creation_funcs();
|
|
25
25
|
|
|
26
26
|
// Create a new instance
|
|
27
|
-
template<typename ...
|
|
28
|
-
Object create(
|
|
27
|
+
template<typename ...Parameter_Ts>
|
|
28
|
+
Object create(Parameter_Ts ...args);
|
|
29
29
|
|
|
30
30
|
//! Class name
|
|
31
31
|
/*! \return std::string.
|
data/rice/cpp_api/Class.ipp
CHANGED
|
@@ -13,8 +13,8 @@ namespace Rice
|
|
|
13
13
|
return *this;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
template<typename ...
|
|
17
|
-
inline Object Class::create(
|
|
16
|
+
template<typename ...Parameter_Ts>
|
|
17
|
+
inline Object Class::create(Parameter_Ts ...args)
|
|
18
18
|
{
|
|
19
19
|
return this->call("new", args...);
|
|
20
20
|
}
|
|
@@ -91,7 +91,7 @@ namespace Rice::detail
|
|
|
91
91
|
public:
|
|
92
92
|
To_Ruby() = default;
|
|
93
93
|
|
|
94
|
-
explicit To_Ruby(
|
|
94
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
95
95
|
{
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -101,7 +101,7 @@ namespace Rice::detail
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
private:
|
|
104
|
-
|
|
104
|
+
Arg* arg_ = nullptr;
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
template<>
|
data/rice/cpp_api/Hash.ipp
CHANGED
|
@@ -234,7 +234,7 @@ namespace Rice::detail
|
|
|
234
234
|
public:
|
|
235
235
|
To_Ruby() = default;
|
|
236
236
|
|
|
237
|
-
explicit To_Ruby(
|
|
237
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
238
238
|
{
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -244,7 +244,7 @@ namespace Rice::detail
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
private:
|
|
247
|
-
|
|
247
|
+
Arg* arg_ = nullptr;
|
|
248
248
|
};
|
|
249
249
|
|
|
250
250
|
template<>
|
|
@@ -253,11 +253,11 @@ namespace Rice::detail
|
|
|
253
253
|
public:
|
|
254
254
|
From_Ruby() = default;
|
|
255
255
|
|
|
256
|
-
explicit From_Ruby(Arg* arg)
|
|
256
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
257
257
|
{
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
double is_convertible(VALUE value)
|
|
261
261
|
{
|
|
262
262
|
switch (rb_type(value))
|
|
263
263
|
{
|
|
@@ -273,5 +273,8 @@ namespace Rice::detail
|
|
|
273
273
|
{
|
|
274
274
|
return Hash(value);
|
|
275
275
|
}
|
|
276
|
+
|
|
277
|
+
private:
|
|
278
|
+
Arg* arg_ = nullptr;
|
|
276
279
|
};
|
|
277
280
|
}
|
data/rice/cpp_api/Module.hpp
CHANGED
|
@@ -49,11 +49,11 @@ namespace Rice
|
|
|
49
49
|
|
|
50
50
|
#include "shared_methods.hpp"
|
|
51
51
|
protected:
|
|
52
|
-
template<typename Function_T>
|
|
53
|
-
void wrap_native_function(VALUE klass, std::string name, Function_T&& function,
|
|
52
|
+
template<typename Function_T, typename ...Arg_Ts>
|
|
53
|
+
void wrap_native_function(VALUE klass, std::string name, Function_T&& function, const Arg_Ts&...args);
|
|
54
54
|
|
|
55
|
-
template<typename Class_T = VALUE, typename Method_T>
|
|
56
|
-
void wrap_native_method(VALUE klass, std::string name, Method_T&& method,
|
|
55
|
+
template<typename Class_T = VALUE, typename Method_T, typename ...Arg_Ts>
|
|
56
|
+
void wrap_native_method(VALUE klass, std::string name, Method_T&& method, const Arg_Ts&...args);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
//! Define a new module in the namespace given by module.
|
data/rice/cpp_api/Module.ipp
CHANGED
|
@@ -32,16 +32,18 @@ namespace Rice
|
|
|
32
32
|
this->set_value(result);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
template<typename Function_T>
|
|
36
|
-
inline void Module::wrap_native_function(VALUE klass, std::string name, Function_T&& function,
|
|
35
|
+
template<typename Function_T, typename ...Arg_Ts>
|
|
36
|
+
inline void Module::wrap_native_function(VALUE klass, std::string name, Function_T&& function, const Arg_Ts&...args)
|
|
37
37
|
{
|
|
38
|
-
detail::
|
|
38
|
+
constexpr bool isNoGVL = detail::tuple_element_index_v<std::tuple<Arg_Ts...>, NoGVL> < (sizeof...(Arg_Ts));
|
|
39
|
+
detail::NativeFunction<Function_T, isNoGVL>::define(klass, name, std::forward<Function_T>(function), args...);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
template<typename Class_T, typename Method_T>
|
|
42
|
-
inline void Module::wrap_native_method(VALUE klass, std::string name, Method_T&& method,
|
|
42
|
+
template<typename Class_T, typename Method_T, typename ...Arg_Ts>
|
|
43
|
+
inline void Module::wrap_native_method(VALUE klass, std::string name, Method_T&& method, const Arg_Ts&...args)
|
|
43
44
|
{
|
|
44
|
-
detail::
|
|
45
|
+
constexpr bool isNoGVL = detail::tuple_element_index_v<std::tuple<Arg_Ts...>, NoGVL> < (sizeof...(Arg_Ts));
|
|
46
|
+
detail::NativeMethod<Class_T, Method_T, isNoGVL>::define(klass, name, std::forward<Method_T>(method), args...);
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
inline Module define_module_under(Object parent, char const* name)
|
|
@@ -94,7 +96,7 @@ namespace Rice::detail
|
|
|
94
96
|
public:
|
|
95
97
|
To_Ruby() = default;
|
|
96
98
|
|
|
97
|
-
explicit To_Ruby(
|
|
99
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
98
100
|
{
|
|
99
101
|
}
|
|
100
102
|
|
|
@@ -104,7 +106,7 @@ namespace Rice::detail
|
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
private:
|
|
107
|
-
|
|
109
|
+
Arg* arg_ = nullptr;
|
|
108
110
|
};
|
|
109
111
|
|
|
110
112
|
|
|
@@ -114,7 +116,7 @@ namespace Rice::detail
|
|
|
114
116
|
public:
|
|
115
117
|
To_Ruby() = default;
|
|
116
118
|
|
|
117
|
-
explicit To_Ruby(
|
|
119
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
118
120
|
{
|
|
119
121
|
}
|
|
120
122
|
|
|
@@ -124,7 +126,7 @@ namespace Rice::detail
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
private:
|
|
127
|
-
|
|
129
|
+
Arg* arg_ = nullptr;
|
|
128
130
|
};
|
|
129
131
|
|
|
130
132
|
template<>
|
data/rice/cpp_api/Object.hpp
CHANGED
|
@@ -181,8 +181,8 @@ namespace Rice
|
|
|
181
181
|
* float ret = x.call<float>("foo", z, 42);
|
|
182
182
|
* \endcode
|
|
183
183
|
*/
|
|
184
|
-
template<typename ...
|
|
185
|
-
Object call(Identifier id,
|
|
184
|
+
template<typename ...Parameter_Ts>
|
|
185
|
+
Object call(Identifier id, Parameter_Ts... args) const;
|
|
186
186
|
|
|
187
187
|
//! Call the Ruby method specified by 'id' on object 'obj'.
|
|
188
188
|
/*! Pass in arguments (arg1, arg2, ...). The arguments will be converted to
|
|
@@ -204,8 +204,8 @@ namespace Rice
|
|
|
204
204
|
* float ret = x.call_kw<float>("foo", kw);
|
|
205
205
|
* \endcode
|
|
206
206
|
*/
|
|
207
|
-
template<typename ...
|
|
208
|
-
Object call_kw(Identifier id,
|
|
207
|
+
template<typename ...Parameter_Ts>
|
|
208
|
+
Object call_kw(Identifier id, Parameter_Ts... args) const;
|
|
209
209
|
|
|
210
210
|
//! Vectorized call.
|
|
211
211
|
/*! Calls the method identified by id with the list of arguments
|
data/rice/cpp_api/Object.ipp
CHANGED
|
@@ -27,8 +27,8 @@ namespace Rice
|
|
|
27
27
|
return *this;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
template<typename ...
|
|
31
|
-
inline Object Object::call(Identifier id,
|
|
30
|
+
template<typename ...Parameter_Ts>
|
|
31
|
+
inline Object Object::call(Identifier id, Parameter_Ts... args) const
|
|
32
32
|
{
|
|
33
33
|
/* IMPORTANT - We store VALUEs in an array that is a local variable.
|
|
34
34
|
That allows the Ruby garbage collector to find them when scanning
|
|
@@ -37,15 +37,15 @@ namespace Rice
|
|
|
37
37
|
to the destination method resulting in a segmentation fault. This is
|
|
38
38
|
easy to duplicate by setting GC.stress to true and calling a constructor
|
|
39
39
|
that takes multiple values like a std::pair wrapper. */
|
|
40
|
-
std::array<VALUE, sizeof...(
|
|
40
|
+
std::array<VALUE, sizeof...(Parameter_Ts)> values = { detail::To_Ruby<detail::remove_cv_recursive_t<Parameter_Ts>>().convert(std::forward<Parameter_Ts>(args))... };
|
|
41
41
|
return detail::protect(rb_funcallv, value(), id.id(), (int)values.size(), (const VALUE*)values.data());
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
template<typename ...
|
|
45
|
-
inline Object Object::call_kw(Identifier id,
|
|
44
|
+
template<typename ...Parameter_Ts>
|
|
45
|
+
inline Object Object::call_kw(Identifier id, Parameter_Ts... args) const
|
|
46
46
|
{
|
|
47
47
|
/* IMPORTANT - See call() above */
|
|
48
|
-
std::array<VALUE, sizeof...(
|
|
48
|
+
std::array<VALUE, sizeof...(Parameter_Ts)> values = { detail::To_Ruby<detail::remove_cv_recursive_t<Parameter_Ts>>().convert(args)... };
|
|
49
49
|
return detail::protect(rb_funcallv_kw, value(), id.id(), (int)values.size(), (const VALUE*)values.data(), RB_PASS_KEYWORDS);
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -202,7 +202,7 @@ namespace Rice::detail
|
|
|
202
202
|
public:
|
|
203
203
|
To_Ruby() = default;
|
|
204
204
|
|
|
205
|
-
explicit To_Ruby(
|
|
205
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
206
206
|
{
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -212,7 +212,7 @@ namespace Rice::detail
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
private:
|
|
215
|
-
|
|
215
|
+
Arg* arg_ = nullptr;
|
|
216
216
|
};
|
|
217
217
|
|
|
218
218
|
template<>
|
|
@@ -221,7 +221,7 @@ namespace Rice::detail
|
|
|
221
221
|
public:
|
|
222
222
|
To_Ruby() = default;
|
|
223
223
|
|
|
224
|
-
explicit To_Ruby(
|
|
224
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
225
225
|
{
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -231,7 +231,7 @@ namespace Rice::detail
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
private:
|
|
234
|
-
|
|
234
|
+
Arg* arg_ = nullptr;
|
|
235
235
|
};
|
|
236
236
|
|
|
237
237
|
template<>
|
|
@@ -240,11 +240,11 @@ namespace Rice::detail
|
|
|
240
240
|
public:
|
|
241
241
|
From_Ruby() = default;
|
|
242
242
|
|
|
243
|
-
explicit From_Ruby(Arg* arg)
|
|
243
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
244
244
|
{
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
|
|
247
|
+
double is_convertible(VALUE value)
|
|
248
248
|
{
|
|
249
249
|
switch (rb_type(value))
|
|
250
250
|
{
|
|
@@ -260,5 +260,8 @@ namespace Rice::detail
|
|
|
260
260
|
{
|
|
261
261
|
return Object(value);
|
|
262
262
|
}
|
|
263
|
+
|
|
264
|
+
private:
|
|
265
|
+
Arg* arg_ = nullptr;
|
|
263
266
|
};
|
|
264
267
|
}
|
data/rice/cpp_api/String.hpp
CHANGED
|
@@ -38,8 +38,8 @@ namespace Rice
|
|
|
38
38
|
String(std::string_view const& s);
|
|
39
39
|
|
|
40
40
|
//! Format a string using printf-style formatting.
|
|
41
|
-
template <typename...
|
|
42
|
-
static inline String format(char const* fmt,
|
|
41
|
+
template <typename... Parameter_Ts>
|
|
42
|
+
static inline String format(char const* fmt, Parameter_Ts&&...args);
|
|
43
43
|
|
|
44
44
|
//! Get the length of the String.
|
|
45
45
|
/*! \return the length of the string.
|
data/rice/cpp_api/String.ipp
CHANGED
|
@@ -28,16 +28,16 @@ namespace Rice
|
|
|
28
28
|
{
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
template <typename...
|
|
32
|
-
inline String String::format(char const* fmt,
|
|
31
|
+
template <typename... Parameter_Ts>
|
|
32
|
+
inline String String::format(char const* fmt, Parameter_Ts&&...args)
|
|
33
33
|
{
|
|
34
|
-
size_t size = std::snprintf(nullptr, 0, fmt, std::forward<
|
|
34
|
+
size_t size = std::snprintf(nullptr, 0, fmt, std::forward<Parameter_Ts>(args)...);
|
|
35
35
|
std::string temp(size, '\0');
|
|
36
36
|
|
|
37
37
|
// size+1 avoids truncating the string. Otherwise snprintf writes n - 1 characters
|
|
38
38
|
// to allow space for null character but we don't need that since std::string
|
|
39
39
|
// will add a null character internally at n + 1
|
|
40
|
-
std::snprintf(&temp[0], size + 1, fmt, std::forward<
|
|
40
|
+
std::snprintf(&temp[0], size + 1, fmt, std::forward<Parameter_Ts>(args)...);
|
|
41
41
|
|
|
42
42
|
String s = String(temp.c_str());
|
|
43
43
|
return s;
|
|
@@ -97,7 +97,7 @@ namespace Rice::detail
|
|
|
97
97
|
public:
|
|
98
98
|
To_Ruby() = default;
|
|
99
99
|
|
|
100
|
-
explicit To_Ruby(
|
|
100
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
101
101
|
{
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -107,7 +107,7 @@ namespace Rice::detail
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
private:
|
|
110
|
-
|
|
110
|
+
Arg* arg_ = nullptr;
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
template<>
|
|
@@ -116,11 +116,11 @@ namespace Rice::detail
|
|
|
116
116
|
public:
|
|
117
117
|
From_Ruby() = default;
|
|
118
118
|
|
|
119
|
-
explicit From_Ruby(Arg* arg)
|
|
119
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
120
120
|
{
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
double is_convertible(VALUE value)
|
|
124
124
|
{
|
|
125
125
|
switch (rb_type(value))
|
|
126
126
|
{
|
|
@@ -136,5 +136,8 @@ namespace Rice::detail
|
|
|
136
136
|
{
|
|
137
137
|
return String(value);
|
|
138
138
|
}
|
|
139
|
+
|
|
140
|
+
private:
|
|
141
|
+
Arg* arg_ = nullptr;
|
|
139
142
|
};
|
|
140
143
|
}
|
data/rice/cpp_api/Symbol.ipp
CHANGED
|
@@ -67,7 +67,7 @@ namespace Rice::detail
|
|
|
67
67
|
public:
|
|
68
68
|
To_Ruby() = default;
|
|
69
69
|
|
|
70
|
-
explicit To_Ruby(
|
|
70
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
71
71
|
{
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -77,7 +77,7 @@ namespace Rice::detail
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
private:
|
|
80
|
-
|
|
80
|
+
Arg* arg_ = nullptr;
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
|
|
@@ -87,7 +87,7 @@ namespace Rice::detail
|
|
|
87
87
|
public:
|
|
88
88
|
To_Ruby() = default;
|
|
89
89
|
|
|
90
|
-
explicit To_Ruby(
|
|
90
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
91
91
|
{
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -97,22 +97,28 @@ namespace Rice::detail
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
private:
|
|
100
|
-
|
|
100
|
+
Arg* arg_ = nullptr;
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
template<>
|
|
104
104
|
class From_Ruby<Symbol>
|
|
105
105
|
{
|
|
106
106
|
public:
|
|
107
|
-
|
|
107
|
+
From_Ruby() = default;
|
|
108
|
+
|
|
109
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
110
|
+
{
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
double is_convertible(VALUE value)
|
|
108
114
|
{
|
|
109
115
|
switch (rb_type(value))
|
|
110
116
|
{
|
|
111
117
|
case RUBY_T_SYMBOL:
|
|
112
118
|
return Convertible::Exact;
|
|
113
119
|
break;
|
|
114
|
-
|
|
115
|
-
return Convertible::
|
|
120
|
+
case RUBY_T_STRING:
|
|
121
|
+
return Convertible::Exact;
|
|
116
122
|
break;
|
|
117
123
|
default:
|
|
118
124
|
return Convertible::None;
|
|
@@ -123,5 +129,8 @@ namespace Rice::detail
|
|
|
123
129
|
{
|
|
124
130
|
return Symbol(value);
|
|
125
131
|
}
|
|
132
|
+
|
|
133
|
+
private:
|
|
134
|
+
Arg* arg_ = nullptr;
|
|
126
135
|
};
|
|
127
136
|
}
|
|
@@ -33,8 +33,7 @@ inline auto& include_module(Module const& inc)
|
|
|
33
33
|
template<typename Method_T, typename...Arg_Ts>
|
|
34
34
|
inline auto& define_method(std::string name, Method_T&& method, const Arg_Ts&...args)
|
|
35
35
|
{
|
|
36
|
-
|
|
37
|
-
this->wrap_native_method(this->value(), name, std::forward<Method_T>(method), methodInfo);
|
|
36
|
+
this->wrap_native_method(this->value(), name, std::forward<Method_T>(method), args...);
|
|
38
37
|
return *this;
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -52,8 +51,7 @@ inline auto& define_method(std::string name, Method_T&& method, const Arg_Ts&...
|
|
|
52
51
|
template<typename Function_T, typename...Arg_Ts>
|
|
53
52
|
inline auto& define_function(std::string name, Function_T&& func, const Arg_Ts&...args)
|
|
54
53
|
{
|
|
55
|
-
|
|
56
|
-
this->wrap_native_function(this->value(), name, std::forward<Function_T>(func), methodInfo);
|
|
54
|
+
this->wrap_native_function(this->value(), name, std::forward<Function_T>(func), args...);
|
|
57
55
|
return *this;
|
|
58
56
|
}
|
|
59
57
|
|
|
@@ -75,8 +73,7 @@ inline auto& define_function(std::string name, Function_T&& func, const Arg_Ts&.
|
|
|
75
73
|
template<typename Method_T, typename...Arg_Ts>
|
|
76
74
|
inline auto& define_singleton_method(std::string name, Method_T&& method, const Arg_Ts&...args)
|
|
77
75
|
{
|
|
78
|
-
|
|
79
|
-
this->wrap_native_method(rb_singleton_class(*this), name, std::forward<Method_T>(method), methodInfo);
|
|
76
|
+
this->wrap_native_method(rb_singleton_class(*this), name, std::forward<Method_T>(method), args...);
|
|
80
77
|
return *this;
|
|
81
78
|
}
|
|
82
79
|
|
|
@@ -94,8 +91,7 @@ inline auto& define_singleton_method(std::string name, Method_T&& method, const
|
|
|
94
91
|
template<typename Function_T, typename...Arg_Ts>
|
|
95
92
|
inline auto& define_singleton_function(std::string name, Function_T&& func, const Arg_Ts& ...args)
|
|
96
93
|
{
|
|
97
|
-
|
|
98
|
-
this->wrap_native_function(rb_singleton_class(*this), name, std::forward<Function_T>(func), methodInfo);
|
|
94
|
+
this->wrap_native_function(rb_singleton_class(*this), name, std::forward<Function_T>(func), args...);
|
|
99
95
|
return *this;
|
|
100
96
|
}
|
|
101
97
|
|
|
@@ -112,7 +108,7 @@ inline auto& define_singleton_function(std::string name, Function_T&& func, cons
|
|
|
112
108
|
* \return *this
|
|
113
109
|
*/
|
|
114
110
|
template<typename Function_T, typename...Arg_Ts>
|
|
115
|
-
inline auto& define_module_function(std::string name, Function_T&& func,
|
|
111
|
+
inline auto& define_module_function(std::string name, Function_T&& func, Arg_Ts&& ...args)
|
|
116
112
|
{
|
|
117
113
|
if (this->rb_type() != T_MODULE)
|
|
118
114
|
{
|