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/test/test_Callback.cpp
CHANGED
|
@@ -20,7 +20,7 @@ TEARDOWN(Callback)
|
|
|
20
20
|
|
|
21
21
|
namespace
|
|
22
22
|
{
|
|
23
|
-
using Callback_T = char*(*)(int, double, bool, char
|
|
23
|
+
using Callback_T = char*(*)(int, double, bool, char*, int&);
|
|
24
24
|
Callback_T globalCallback;
|
|
25
25
|
|
|
26
26
|
void registerCallback(Callback_T callback)
|
|
@@ -28,11 +28,11 @@ namespace
|
|
|
28
28
|
globalCallback = callback;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
char* triggerCallback(int anInt, double aDouble, bool aBool, char* aString)
|
|
31
|
+
char* triggerCallback(int anInt, double aDouble, bool aBool, char* aString, int& intRef)
|
|
32
32
|
{
|
|
33
33
|
if (globalCallback)
|
|
34
34
|
{
|
|
35
|
-
return globalCallback(anInt, aDouble, aBool, aString);
|
|
35
|
+
return globalCallback(anInt, aDouble, aBool, aString, intRef);
|
|
36
36
|
}
|
|
37
37
|
throw std::runtime_error("Callback has not been registered");
|
|
38
38
|
}
|
|
@@ -41,13 +41,12 @@ namespace
|
|
|
41
41
|
TESTCASE(LambdaCallBack)
|
|
42
42
|
{
|
|
43
43
|
Module m = define_module("TestingLambda");
|
|
44
|
-
m.define_module_function("register_callback", registerCallback)
|
|
45
|
-
define_module_function("trigger_callback", triggerCallback);
|
|
44
|
+
m.define_module_function("register_callback", registerCallback);
|
|
46
45
|
|
|
47
46
|
ASSERT_EQUAL(globalCallback, nullptr);
|
|
48
47
|
|
|
49
|
-
std::string code = R"(callback = lambda do |an_int, a_double, a_bool, a_string|
|
|
50
|
-
values = [an_int, a_double, a_bool, a_string]
|
|
48
|
+
std::string code = R"(callback = lambda do |an_int, a_double, a_bool, a_string, an_intref|
|
|
49
|
+
values = [an_int, a_double, a_bool, a_string, an_intref]
|
|
51
50
|
values.map {|value| value.to_s}.join(" - ")
|
|
52
51
|
end
|
|
53
52
|
register_callback(callback))";
|
|
@@ -55,25 +54,26 @@ TESTCASE(LambdaCallBack)
|
|
|
55
54
|
m.module_eval(code);
|
|
56
55
|
ASSERT((globalCallback != nullptr));
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
int ref = 4;
|
|
58
|
+
char* result = triggerCallback(1, 2, true, "hello", ref);
|
|
59
|
+
ASSERT_EQUAL("1 - 2.0 - true - hello - 4", result);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
TESTCASE(BlockCallBack)
|
|
63
63
|
{
|
|
64
64
|
Module m = define_module("TestingBlock");
|
|
65
|
-
m.define_module_function("register_callback", registerCallback).
|
|
65
|
+
m.define_module_function("register_callback", registerCallback, Arg("callback").setBlock()).
|
|
66
66
|
define_module_function("trigger_callback", triggerCallback);
|
|
67
67
|
|
|
68
|
-
std::string code = R"(register_callback do |an_int, a_double, a_bool, a_string|
|
|
69
|
-
values = [an_int, a_double, a_bool, a_string]
|
|
68
|
+
std::string code = R"(register_callback do |an_int, a_double, a_bool, a_string, an_intref|
|
|
69
|
+
values = [an_int, a_double, a_bool, a_string, an_intref]
|
|
70
70
|
values.map {|value| value.to_s}.join(" - ")
|
|
71
71
|
end)";
|
|
72
72
|
|
|
73
73
|
m.module_eval(code);
|
|
74
74
|
|
|
75
|
-
String result = m.call("trigger_callback", 4, 5.5, false, "Hello block");
|
|
76
|
-
ASSERT_EQUAL("4 - 5.5 - false - Hello block", result.c_str());
|
|
75
|
+
String result = m.call("trigger_callback", 4, 5.5, false, "Hello block", 8);
|
|
76
|
+
ASSERT_EQUAL("4 - 5.5 - false - Hello block - 8", result.c_str());
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
TESTCASE(ProcCallBack)
|
|
@@ -82,16 +82,17 @@ TESTCASE(ProcCallBack)
|
|
|
82
82
|
m.define_module_function("register_callback", registerCallback).
|
|
83
83
|
define_module_function("trigger_callback", triggerCallback);
|
|
84
84
|
|
|
85
|
-
std::string code = R"(callback = Proc.new do |an_int, a_double, a_bool, a_string|
|
|
86
|
-
values = [an_int, a_double, a_bool, a_string]
|
|
85
|
+
std::string code = R"(callback = Proc.new do |an_int, a_double, a_bool, a_string, an_intref|
|
|
86
|
+
values = [an_int, a_double, a_bool, a_string, an_intref]
|
|
87
87
|
values.map {|value| value.to_s}.join(" - ")
|
|
88
88
|
end
|
|
89
89
|
register_callback(callback))";
|
|
90
90
|
|
|
91
91
|
m.module_eval(code);
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
int ref = 9;
|
|
94
|
+
String result = m.call("trigger_callback", 8, 4.4, true, "Hello proc", ref);
|
|
95
|
+
ASSERT_EQUAL("8 - 4.4 - true - Hello proc - 9", result.c_str());
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
TESTCASE(MethodCallBack)
|
|
@@ -100,16 +101,16 @@ TESTCASE(MethodCallBack)
|
|
|
100
101
|
m.define_module_function("register_callback", registerCallback).
|
|
101
102
|
define_module_function("trigger_callback", triggerCallback);
|
|
102
103
|
|
|
103
|
-
std::string code = R"(def self.callback(an_int, a_double, a_bool, a_string)
|
|
104
|
-
values = [an_int, a_double, a_bool, a_string]
|
|
104
|
+
std::string code = R"(def self.callback(an_int, a_double, a_bool, a_string, an_intref)
|
|
105
|
+
values = [an_int, a_double, a_bool, a_string, an_intref]
|
|
105
106
|
values.map {|value| value.to_s}.join(" - ")
|
|
106
107
|
end
|
|
107
108
|
register_callback(method(:callback).to_proc))";
|
|
108
109
|
|
|
109
110
|
m.module_eval(code);
|
|
110
111
|
|
|
111
|
-
String result = m.call("trigger_callback", 11.1, 22.9, true, "Hello method");
|
|
112
|
-
ASSERT_EQUAL("11 - 22.9 - true - Hello method", result.c_str());
|
|
112
|
+
String result = m.call("trigger_callback", 11.1, 22.9, true, "Hello method", 17.2);
|
|
113
|
+
ASSERT_EQUAL("11 - 22.9 - true - Hello method - 17", result.c_str());
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
namespace
|
|
@@ -123,7 +124,7 @@ namespace
|
|
|
123
124
|
TESTCASE(FunctionArg)
|
|
124
125
|
{
|
|
125
126
|
Module m = define_module("TestingFunctionArg");
|
|
126
|
-
m.define_module_function("function_arg", functionArg);
|
|
127
|
+
m.define_module_function("function_arg", functionArg, Arg("i"), Arg("block").setBlock());
|
|
127
128
|
|
|
128
129
|
std::string code = R"(function_arg(4) do |i|
|
|
129
130
|
i * i
|
|
@@ -227,3 +228,56 @@ TESTCASE(UserData)
|
|
|
227
228
|
String result = m.call("trigger_callback");
|
|
228
229
|
ASSERT_EQUAL("TestingUserData::UserDataClass", result.c_str());
|
|
229
230
|
}
|
|
231
|
+
|
|
232
|
+
namespace
|
|
233
|
+
{
|
|
234
|
+
using Callback_T4 = void(*)(void* userData);
|
|
235
|
+
Callback_T4 globalCallback4;
|
|
236
|
+
void* globalUserData4 = nullptr;
|
|
237
|
+
|
|
238
|
+
void registerCallback4(Callback_T4 callback, void* userData)
|
|
239
|
+
{
|
|
240
|
+
globalCallback4 = callback;
|
|
241
|
+
globalUserData4 = userData;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
void triggerCallback4()
|
|
245
|
+
{
|
|
246
|
+
if (globalCallback4)
|
|
247
|
+
{
|
|
248
|
+
globalCallback4(globalUserData4);
|
|
249
|
+
}
|
|
250
|
+
else
|
|
251
|
+
{
|
|
252
|
+
throw std::runtime_error("Callback has not been registered");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
TESTCASE(VoidReturn)
|
|
258
|
+
{
|
|
259
|
+
Module m = define_module("TestingUserData");
|
|
260
|
+
m.define_module_function("register_callback4", registerCallback4, Arg("callback"), Arg("user_data").setOpaque()).
|
|
261
|
+
define_module_function("trigger_callback4", triggerCallback4);
|
|
262
|
+
|
|
263
|
+
define_callback<Callback_T4>(Arg("user_data").setOpaque());
|
|
264
|
+
|
|
265
|
+
std::string code = R"(class UserDataClass
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
user_data_1 = UserDataClass.new
|
|
269
|
+
|
|
270
|
+
callback = Proc.new do |user_data_2|
|
|
271
|
+
unless user_data_1.equal?(user_data_2)
|
|
272
|
+
raise("Unexpected user data object")
|
|
273
|
+
end
|
|
274
|
+
user_data_2.class.name
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
register_callback4(callback, user_data_1))";
|
|
278
|
+
|
|
279
|
+
m.module_eval(code);
|
|
280
|
+
|
|
281
|
+
Object result = m.call("trigger_callback4");
|
|
282
|
+
ASSERT_EQUAL(Qnil, result.value());
|
|
283
|
+
}
|
data/test/test_Data_Object.cpp
CHANGED
|
@@ -33,7 +33,7 @@ namespace
|
|
|
33
33
|
namespace Rice
|
|
34
34
|
{
|
|
35
35
|
template<>
|
|
36
|
-
void ruby_mark(MyDataType*
|
|
36
|
+
void ruby_mark(MyDataType*)
|
|
37
37
|
{
|
|
38
38
|
test_ruby_mark_called = true;
|
|
39
39
|
}
|
|
@@ -95,7 +95,7 @@ TESTCASE(data_object_construct_from_ruby_object_and_wrong_class)
|
|
|
95
95
|
ASSERT_EXCEPTION_CHECK(
|
|
96
96
|
Exception,
|
|
97
97
|
Data_Object<Bar> bar(wrapped_foo),
|
|
98
|
-
ASSERT_EQUAL("Wrong argument type. Expected
|
|
98
|
+
ASSERT_EQUAL("Wrong argument type. Expected Bar. Received MyDataType.", ex.what()));
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
TESTCASE(data_object_copy_construct)
|
data/test/test_Data_Type.cpp
CHANGED
|
@@ -20,7 +20,7 @@ TEARDOWN(Data_Type)
|
|
|
20
20
|
rb_gc_start();
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
namespace
|
|
23
|
+
/*namespace
|
|
24
24
|
{
|
|
25
25
|
class MyClass
|
|
26
26
|
{
|
|
@@ -38,7 +38,7 @@ namespace
|
|
|
38
38
|
multiple_args_called = false;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
static Object singleton_method_object_int(Object object, int
|
|
41
|
+
static Object singleton_method_object_int(Object object, int)
|
|
42
42
|
{
|
|
43
43
|
return object;
|
|
44
44
|
}
|
|
@@ -427,12 +427,12 @@ namespace
|
|
|
427
427
|
RValue(RValue&& other) = default;
|
|
428
428
|
|
|
429
429
|
// Move assignment operator.
|
|
430
|
-
RValue& operator=(RValue&&
|
|
430
|
+
RValue& operator=(RValue&&) noexcept
|
|
431
431
|
{
|
|
432
432
|
return *this;
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
bool takesRValue(RValue&&
|
|
435
|
+
bool takesRValue(RValue&&)
|
|
436
436
|
{
|
|
437
437
|
return true;
|
|
438
438
|
}
|
|
@@ -499,7 +499,7 @@ TESTCASE(null_ptrs)
|
|
|
499
499
|
|
|
500
500
|
result = o.call("set", nullptr);
|
|
501
501
|
ASSERT_EQUAL(Qnil, result.value());
|
|
502
|
-
}
|
|
502
|
+
}*/
|
|
503
503
|
|
|
504
504
|
namespace
|
|
505
505
|
{
|
|
@@ -595,7 +595,7 @@ TESTCASE(pointers)
|
|
|
595
595
|
result = object.call("check_void_helper", helper);
|
|
596
596
|
ASSERT_EQUAL(Qtrue, result.value());
|
|
597
597
|
}
|
|
598
|
-
|
|
598
|
+
/*
|
|
599
599
|
namespace
|
|
600
600
|
{
|
|
601
601
|
class BigObject
|
|
@@ -612,11 +612,11 @@ namespace
|
|
|
612
612
|
class Processor
|
|
613
613
|
{
|
|
614
614
|
public:
|
|
615
|
-
BigObject** createBigObjects(
|
|
615
|
+
BigObject** createBigObjects(int size)
|
|
616
616
|
{
|
|
617
617
|
BigObject** result = new BigObject*[size];
|
|
618
618
|
|
|
619
|
-
for (
|
|
619
|
+
for (int i = 0; i < size; ++i)
|
|
620
620
|
{
|
|
621
621
|
result[i] = new BigObject(i + 5);
|
|
622
622
|
}
|
|
@@ -661,14 +661,14 @@ TESTCASE(pointerToPointer)
|
|
|
661
661
|
.define_constructor(Constructor<Processor>())
|
|
662
662
|
.define_method("create", &Processor::createBigObjects)
|
|
663
663
|
.define_method("sum", &Processor::sumBigObjects,
|
|
664
|
-
|
|
664
|
+
ArgBuffer("bigObjects"), Arg("size"))
|
|
665
665
|
.define_method("sum_const", &Processor::sumBigObjectsConst,
|
|
666
|
-
|
|
666
|
+
ArgBuffer("bigObjects"), Arg("size"));
|
|
667
667
|
|
|
668
668
|
std::string code = R"(count = 2
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
669
|
+
processor = ProcessorClass.new
|
|
670
|
+
big_objects = processor.create(count)
|
|
671
|
+
processor.sum(big_objects, count))";
|
|
672
672
|
|
|
673
673
|
Object result = m.module_eval(code);
|
|
674
674
|
ASSERT_EQUAL(11, detail::From_Ruby<int>().convert(result));
|
|
@@ -688,15 +688,15 @@ namespace
|
|
|
688
688
|
{
|
|
689
689
|
};
|
|
690
690
|
|
|
691
|
-
void undefinedArg(UnknownClass
|
|
691
|
+
void undefinedArg(UnknownClass)
|
|
692
692
|
{
|
|
693
693
|
}
|
|
694
694
|
|
|
695
|
-
void undefinedArg(UnknownClass&
|
|
695
|
+
void undefinedArg(UnknownClass&)
|
|
696
696
|
{
|
|
697
697
|
}
|
|
698
698
|
|
|
699
|
-
void undefinedArg(UnknownClass*
|
|
699
|
+
void undefinedArg(UnknownClass*)
|
|
700
700
|
{
|
|
701
701
|
}
|
|
702
702
|
|
|
@@ -773,8 +773,6 @@ namespace RangesTest
|
|
|
773
773
|
{
|
|
774
774
|
}
|
|
775
775
|
|
|
776
|
-
RangeCustom(const RangeCustom& other) = default;
|
|
777
|
-
|
|
778
776
|
int x;
|
|
779
777
|
int y;
|
|
780
778
|
};
|
|
@@ -826,7 +824,7 @@ TESTCASE(array_of_ranges)
|
|
|
826
824
|
.define_attr("y", &RangesTest::RangeCustom::y);
|
|
827
825
|
|
|
828
826
|
m.define_module_function("sum_ranges_array", RangesTest::sumRangesArray,
|
|
829
|
-
|
|
827
|
+
ArgBuffer("ranges[]"), Arg("size"));
|
|
830
828
|
|
|
831
829
|
std::string code = R"(range1 = RangeCustom.new(1, 2)
|
|
832
830
|
range2 = RangeCustom.new(3, 4)
|
|
@@ -849,7 +847,7 @@ TESTCASE(pointer_of_ranges)
|
|
|
849
847
|
.define_attr("y", &RangesTest::RangeCustom::y);
|
|
850
848
|
|
|
851
849
|
m.define_module_function<int(*)(const RangesTest::RangeCustom*, int)>("sum_ranges", RangesTest::sumRanges,
|
|
852
|
-
|
|
850
|
+
ArgBuffer("ranges"), Arg("size"));
|
|
853
851
|
|
|
854
852
|
std::string code = R"(range1 = RangeCustom.new(1, 2)
|
|
855
853
|
range2 = RangeCustom.new(3, 4)
|
|
@@ -871,7 +869,8 @@ TESTCASE(pointer_of_ranges_wrong)
|
|
|
871
869
|
.define_attr("x", &RangesTest::RangeCustom::x)
|
|
872
870
|
.define_attr("y", &RangesTest::RangeCustom::y);
|
|
873
871
|
|
|
874
|
-
m.define_module_function<int(*)(const RangesTest::RangeCustom*, int)>("sum_ranges_wrong", RangesTest::sumRanges
|
|
872
|
+
m.define_module_function<int(*)(const RangesTest::RangeCustom*, int)>("sum_ranges_wrong", RangesTest::sumRanges,
|
|
873
|
+
ArgBuffer("ranges"));
|
|
875
874
|
|
|
876
875
|
std::string code = R"(range1 = RangeCustom.new(1, 2)
|
|
877
876
|
range2 = RangeCustom.new(3, 4)
|
|
@@ -883,7 +882,7 @@ TESTCASE(pointer_of_ranges_wrong)
|
|
|
883
882
|
ASSERT_EXCEPTION_CHECK(
|
|
884
883
|
Rice::Exception,
|
|
885
884
|
m.module_eval(code),
|
|
886
|
-
ASSERT_EQUAL("Wrong argument type. Expected
|
|
885
|
+
ASSERT_EQUAL("Wrong argument type. Expected Rice::Pointer≺RangesTest꞉꞉RangeCustom≻. Received Rice::Buffer≺RangesTest꞉꞉RangeCustom≻.", ex.what())
|
|
887
886
|
);
|
|
888
887
|
}
|
|
889
888
|
|
|
@@ -896,7 +895,7 @@ TESTCASE(pointer_of_pointer_ranges)
|
|
|
896
895
|
.define_attr("x", &RangesTest::RangeCustom::x)
|
|
897
896
|
.define_attr("y", &RangesTest::RangeCustom::y);
|
|
898
897
|
|
|
899
|
-
m.define_module_function<int(*)(const RangesTest::RangeCustom**, int)>("sum_ranges", RangesTest::sumRanges,
|
|
898
|
+
m.define_module_function<int(*)(const RangesTest::RangeCustom**, int)>("sum_ranges", RangesTest::sumRanges, ArgBuffer("ranges"));
|
|
900
899
|
|
|
901
900
|
std::string code = R"(range1 = RangeCustom.new(1, 2)
|
|
902
901
|
range2 = RangeCustom.new(3, 4)
|
|
@@ -907,3 +906,4 @@ TESTCASE(pointer_of_pointer_ranges)
|
|
|
907
906
|
Object result = m.module_eval(code);
|
|
908
907
|
ASSERT_EQUAL(21, detail::From_Ruby<int>().convert(result));
|
|
909
908
|
}
|
|
909
|
+
*/
|
data/test/test_Director.cpp
CHANGED
|
@@ -85,10 +85,9 @@ namespace {
|
|
|
85
85
|
return detail::From_Ruby<int>().convert( getSelf().call("process", num) );
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
int default_process(int
|
|
88
|
+
int default_process(int)
|
|
89
89
|
{
|
|
90
90
|
raisePureVirtual();
|
|
91
|
-
return 0;
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
virtual int doSomething(int num)
|
|
@@ -222,10 +221,9 @@ namespace {
|
|
|
222
221
|
return detail::From_Ruby<int>().convert( getSelf().call("do_it_impl", in) );
|
|
223
222
|
}
|
|
224
223
|
|
|
225
|
-
int default_doItImpl(int
|
|
224
|
+
int default_doItImpl(int)
|
|
226
225
|
{
|
|
227
226
|
raisePureVirtual();
|
|
228
|
-
return 0;
|
|
229
227
|
}
|
|
230
228
|
};
|
|
231
229
|
|
data/test/test_Enum.cpp
CHANGED
|
@@ -76,7 +76,7 @@ TESTCASE(values)
|
|
|
76
76
|
std::string code = R"(Color.values)";
|
|
77
77
|
|
|
78
78
|
Array a = m.module_eval(code);
|
|
79
|
-
ASSERT_EQUAL(
|
|
79
|
+
ASSERT_EQUAL(3, a.size());
|
|
80
80
|
|
|
81
81
|
Data_Object<Color> enum_0(a[0]);
|
|
82
82
|
ASSERT_EQUAL(RED, *enum_0);
|
|
@@ -96,7 +96,7 @@ TESTCASE(seasons_values)
|
|
|
96
96
|
std::string code = R"(Season.values)";
|
|
97
97
|
|
|
98
98
|
Array a = m.module_eval(code);
|
|
99
|
-
ASSERT_EQUAL(
|
|
99
|
+
ASSERT_EQUAL(4, a.size());
|
|
100
100
|
|
|
101
101
|
Data_Object<Season> enum_0(a[0]);
|
|
102
102
|
ASSERT_EQUAL(Season::Spring, *enum_0);
|
|
@@ -198,8 +198,33 @@ TESTCASE(eql)
|
|
|
198
198
|
Module m = define_module("Testing");
|
|
199
199
|
|
|
200
200
|
Enum<Color> colorEnum = define_color_enum();
|
|
201
|
-
ASSERT_EQUAL(
|
|
202
|
-
ASSERT_EQUAL(
|
|
201
|
+
ASSERT_EQUAL(Qfalse, m.module_eval("Color::RED == Color::BLACK").value());
|
|
202
|
+
ASSERT_EQUAL(Qtrue, m.module_eval("Color::GREEN == Color::GREEN").value());
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
TESTCASE(case_eql)
|
|
206
|
+
{
|
|
207
|
+
Module m = define_module("Testing");
|
|
208
|
+
|
|
209
|
+
Enum<Color> colorEnum = define_color_enum();
|
|
210
|
+
|
|
211
|
+
/* Object result = m.module_eval("Color::RED === Color::BLACK");
|
|
212
|
+
ASSERT_EQUAL(Qfalse, result.value());
|
|
213
|
+
|
|
214
|
+
result = m.module_eval("Color::GREEN === Color::GREEN");
|
|
215
|
+
ASSERT_EQUAL(Qtrue, result.value());*/
|
|
216
|
+
|
|
217
|
+
Object result = m.module_eval("Color::RED === 0");
|
|
218
|
+
ASSERT_EQUAL(Qtrue, result.value());
|
|
219
|
+
|
|
220
|
+
result = m.module_eval("0 == Color::RED");
|
|
221
|
+
ASSERT_EQUAL(Qtrue, result.value());
|
|
222
|
+
|
|
223
|
+
result = m.module_eval("Color::RED === 1");
|
|
224
|
+
ASSERT_EQUAL(Qfalse, result.value());
|
|
225
|
+
|
|
226
|
+
result = m.module_eval("1 == Color::RED");
|
|
227
|
+
ASSERT_EQUAL(Qfalse, result.value());
|
|
203
228
|
}
|
|
204
229
|
|
|
205
230
|
TESTCASE(compare_equal)
|
|
@@ -207,8 +232,12 @@ TESTCASE(compare_equal)
|
|
|
207
232
|
Enum<Color> colorEnum = define_color_enum();
|
|
208
233
|
Object color1 = colorEnum.const_get("RED");
|
|
209
234
|
Object color2 = colorEnum.const_get("RED");
|
|
235
|
+
|
|
210
236
|
Object result = color1.call("<=>", color2);
|
|
211
237
|
ASSERT_EQUAL(0, detail::From_Ruby<int>().convert(result));
|
|
238
|
+
|
|
239
|
+
result = color1.call("<=>", 0);
|
|
240
|
+
ASSERT_EQUAL(0, detail::From_Ruby<int>().convert(result));
|
|
212
241
|
}
|
|
213
242
|
|
|
214
243
|
TESTCASE(compare_less)
|
|
@@ -398,7 +427,7 @@ namespace
|
|
|
398
427
|
{
|
|
399
428
|
enum class Undefined { A, B, C };
|
|
400
429
|
|
|
401
|
-
void undefinedArg(Undefined
|
|
430
|
+
void undefinedArg(Undefined)
|
|
402
431
|
{
|
|
403
432
|
}
|
|
404
433
|
|
data/test/test_File.cpp
CHANGED
|
@@ -26,6 +26,12 @@ namespace
|
|
|
26
26
|
{
|
|
27
27
|
std::filesystem::path path = __FILE__;
|
|
28
28
|
FILE* fptr = fopen(path.string().c_str(), "rb");
|
|
29
|
+
if (!fptr)
|
|
30
|
+
{
|
|
31
|
+
int err = errno;
|
|
32
|
+
throw std::runtime_error("Failed to open file '" + path.string() + "': " +
|
|
33
|
+
std::strerror(err) + " (errno=" + std::to_string(err) + ")");
|
|
34
|
+
}
|
|
29
35
|
return fptr;
|
|
30
36
|
}
|
|
31
37
|
|
|
@@ -41,12 +47,10 @@ namespace
|
|
|
41
47
|
return result.str();
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
bool closeFile(FILE*
|
|
50
|
+
bool closeFile(FILE*)
|
|
45
51
|
{
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
fclose(fptr);
|
|
49
|
-
#endif
|
|
52
|
+
// crashes on windows due to Ruby overriding and mixing UCRTs
|
|
53
|
+
//fclose(fptr);
|
|
50
54
|
return true;
|
|
51
55
|
}
|
|
52
56
|
}
|
data/test/test_From_Ruby.cpp
CHANGED
|
@@ -83,7 +83,7 @@ TESTCASE(bool)
|
|
|
83
83
|
{
|
|
84
84
|
ASSERT_EQUAL(detail::Convertible::Exact, detail::From_Ruby<bool>().is_convertible(Qfalse));
|
|
85
85
|
ASSERT_EQUAL(detail::Convertible::Exact, detail::From_Ruby<bool>().is_convertible(Qtrue));
|
|
86
|
-
ASSERT_EQUAL(detail::Convertible::
|
|
86
|
+
ASSERT_EQUAL(detail::Convertible::Exact, detail::From_Ruby<bool>().is_convertible(Qnil));
|
|
87
87
|
ASSERT_EQUAL(detail::Convertible::None, detail::From_Ruby<bool>().is_convertible(INT2NUM(3)));
|
|
88
88
|
ASSERT_EQUAL(detail::Convertible::None, detail::From_Ruby<bool>().is_convertible(rb_float_new(3.33)));
|
|
89
89
|
ASSERT_EQUAL(detail::Convertible::None, detail::From_Ruby<bool>().is_convertible(rb_str_new2("some string")));
|
|
@@ -200,7 +200,7 @@ TESTCASE(signed_char_pointer)
|
|
|
200
200
|
ASSERT_EXCEPTION_CHECK(
|
|
201
201
|
Exception,
|
|
202
202
|
fromRuby.convert(rb_float_new(11.11)),
|
|
203
|
-
ASSERT_EQUAL("Wrong argument type. Expected
|
|
203
|
+
ASSERT_EQUAL("Wrong argument type. Expected Rice::Pointer≺signed char≻. Received Float.", ex.what())
|
|
204
204
|
);
|
|
205
205
|
}
|
|
206
206
|
|
|
@@ -279,7 +279,7 @@ TESTCASE(unsigned_char_pointer)
|
|
|
279
279
|
ASSERT_EXCEPTION_CHECK(
|
|
280
280
|
Exception,
|
|
281
281
|
detail::From_Ruby<const char*>().convert(rb_float_new(11.11)),
|
|
282
|
-
ASSERT_EQUAL("Wrong argument type. Expected
|
|
282
|
+
ASSERT_EQUAL("Wrong argument type. Expected Rice::Pointer≺char≻. Received Float.", ex.what())
|
|
283
283
|
);
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -327,6 +327,7 @@ TESTCASE(unsigned_char_pointer_array)
|
|
|
327
327
|
|
|
328
328
|
TESTCASE(double)
|
|
329
329
|
{
|
|
330
|
+
#undef min
|
|
330
331
|
ASSERT_EQUAL(0.0, detail::From_Ruby<double>().convert(rb_float_new(0.0)));
|
|
331
332
|
ASSERT_EQUAL(-1.0, detail::From_Ruby<double>().convert(rb_float_new(-1.0)));
|
|
332
333
|
ASSERT_EQUAL(1.0, detail::From_Ruby<double>().convert(rb_float_new(1.0)));
|
|
@@ -414,7 +415,7 @@ TESTCASE(float_array_array)
|
|
|
414
415
|
{
|
|
415
416
|
Module m = define_module("Testing");
|
|
416
417
|
|
|
417
|
-
m.define_singleton_function("array_array_to_string", &arrayofArraysToString<float
|
|
418
|
+
m.define_singleton_function("array_array_to_string", &arrayofArraysToString<float>, ArgBuffer("buffer"));
|
|
418
419
|
|
|
419
420
|
std::string code = R"(buffer = Rice::Buffer≺float∗≻.new([[1.1, 2.2], [3.3, 4.4], [5.5, 6.6]])
|
|
420
421
|
array_array_to_string(buffer.data, buffer.size, 2))";
|
|
@@ -441,7 +442,7 @@ TESTCASE(float_array_array)
|
|
|
441
442
|
ASSERT_EXCEPTION_CHECK(
|
|
442
443
|
Exception,
|
|
443
444
|
m.module_eval(code),
|
|
444
|
-
ASSERT_EQUAL("Wrong argument type. Expected
|
|
445
|
+
ASSERT_EQUAL("Wrong argument type. Expected Rice::Pointer≺float∗≻. Received Array.", ex.what())
|
|
445
446
|
);
|
|
446
447
|
}
|
|
447
448
|
|
|
@@ -517,7 +518,7 @@ TESTCASE(unsigned_long)
|
|
|
517
518
|
{
|
|
518
519
|
ASSERT_EQUAL(0u, detail::From_Ruby<unsigned long>().convert(ULONG2NUM(0)));
|
|
519
520
|
ASSERT_EQUAL(1u, detail::From_Ruby<unsigned long>().convert(ULONG2NUM(1)));
|
|
520
|
-
ASSERT_EQUAL(
|
|
521
|
+
ASSERT_EQUAL((unsigned long)(FIXNUM_MIN),
|
|
521
522
|
detail::From_Ruby<unsigned long>().convert(ULONG2NUM(FIXNUM_MIN)));
|
|
522
523
|
ASSERT_EQUAL(std::numeric_limits<unsigned long>::min(),
|
|
523
524
|
detail::From_Ruby<unsigned long>().convert(ULONG2NUM(std::numeric_limits<unsigned long>::min())));
|
data/test/test_GVL.cpp
CHANGED
|
@@ -44,7 +44,7 @@ namespace
|
|
|
44
44
|
{
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
int run(bool
|
|
47
|
+
int run(bool)
|
|
48
48
|
{
|
|
49
49
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
50
50
|
return this->id_;
|
|
@@ -64,7 +64,7 @@ TESTCASE(Function)
|
|
|
64
64
|
TESTCASE(FunctionViaRuby)
|
|
65
65
|
{
|
|
66
66
|
Module m = define_module("Testing");
|
|
67
|
-
m.define_module_function("slow_function_1", &slowFunction1,
|
|
67
|
+
m.define_module_function("slow_function_1", &slowFunction1, NoGVL());
|
|
68
68
|
|
|
69
69
|
std::string code = R"(slow_function_1)";
|
|
70
70
|
Object result = m.module_eval(code);
|
|
@@ -99,7 +99,7 @@ TESTCASE(MemberFunctionNoGvl)
|
|
|
99
99
|
|
|
100
100
|
Class task = define_class_under<Task>(m, "Task")
|
|
101
101
|
.define_constructor(Constructor<Task, int>())
|
|
102
|
-
.define_method("run", &Task::run,
|
|
102
|
+
.define_method("run", &Task::run, NoGVL());
|
|
103
103
|
|
|
104
104
|
std::string code = R"(task = Task.new(85)
|
|
105
105
|
task.run(true))";
|