rice 4.7.1 → 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 +29 -1
- data/CMakeLists.txt +14 -22
- data/CMakePresets.json +203 -75
- data/FindRuby.cmake +358 -123
- data/bin/rice-doc.rb +56 -141
- data/include/rice/api.hpp +248 -0
- data/include/rice/rice.hpp +2237 -1657
- data/include/rice/stl.hpp +346 -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 +2 -2
- 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 +15 -15
- 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 +41 -4
- 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 +7 -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 +282 -130
- 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/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 +1 -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 -3
- 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 +1 -1
- data/test/test_Data_Type.cpp +21 -22
- 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 +4 -3
- 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 +345 -48
- 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 +4 -2
- 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 +1 -1
- 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 -10
- 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_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)
|
|
@@ -872,7 +870,7 @@ TESTCASE(pointer_of_ranges_wrong)
|
|
|
872
870
|
.define_attr("y", &RangesTest::RangeCustom::y);
|
|
873
871
|
|
|
874
872
|
m.define_module_function<int(*)(const RangesTest::RangeCustom*, int)>("sum_ranges_wrong", RangesTest::sumRanges,
|
|
875
|
-
|
|
873
|
+
ArgBuffer("ranges"));
|
|
876
874
|
|
|
877
875
|
std::string code = R"(range1 = RangeCustom.new(1, 2)
|
|
878
876
|
range2 = RangeCustom.new(3, 4)
|
|
@@ -897,7 +895,7 @@ TESTCASE(pointer_of_pointer_ranges)
|
|
|
897
895
|
.define_attr("x", &RangesTest::RangeCustom::x)
|
|
898
896
|
.define_attr("y", &RangesTest::RangeCustom::y);
|
|
899
897
|
|
|
900
|
-
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"));
|
|
901
899
|
|
|
902
900
|
std::string code = R"(range1 = RangeCustom.new(1, 2)
|
|
903
901
|
range2 = RangeCustom.new(3, 4)
|
|
@@ -908,3 +906,4 @@ TESTCASE(pointer_of_pointer_ranges)
|
|
|
908
906
|
Object result = m.module_eval(code);
|
|
909
907
|
ASSERT_EQUAL(21, detail::From_Ruby<int>().convert(result));
|
|
910
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")));
|
|
@@ -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))";
|
|
@@ -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))";
|
data/test/test_Hash.cpp
CHANGED
data/test/test_Iterator.cpp
CHANGED
|
@@ -50,7 +50,7 @@ TESTCASE(define_array_iterator)
|
|
|
50
50
|
Object wrapped_container = Data_Object<Container>(container);
|
|
51
51
|
|
|
52
52
|
Array a = wrapped_container.instance_eval("a = []; each() { |x| a << x }; a");
|
|
53
|
-
ASSERT_EQUAL(
|
|
53
|
+
ASSERT_EQUAL(3, a.size());
|
|
54
54
|
ASSERT_EQUAL(Object(detail::to_ruby(1)), a[0]);
|
|
55
55
|
ASSERT_EQUAL(Object(detail::to_ruby(2)), a[1]);
|
|
56
56
|
ASSERT_EQUAL(Object(detail::to_ruby(3)), a[2]);
|
|
@@ -152,16 +152,16 @@ TESTCASE(iterator_value)
|
|
|
152
152
|
Data_Object<ContainerValues> wrapper(container);
|
|
153
153
|
|
|
154
154
|
Array a = wrapper.instance_eval("each.to_a");
|
|
155
|
-
ASSERT_EQUAL(
|
|
155
|
+
ASSERT_EQUAL(3, a.size());
|
|
156
156
|
|
|
157
157
|
Data_Object<Data> wrappedData(a[0]);
|
|
158
|
-
ASSERT_EQUAL(
|
|
158
|
+
ASSERT_EQUAL(1u, wrappedData->index);
|
|
159
159
|
|
|
160
160
|
wrappedData = (Data_Object<Data>)a[1];
|
|
161
|
-
ASSERT_EQUAL(
|
|
161
|
+
ASSERT_EQUAL(2u, wrappedData->index);
|
|
162
162
|
|
|
163
163
|
wrappedData = (Data_Object<Data>)a[2];
|
|
164
|
-
ASSERT_EQUAL(
|
|
164
|
+
ASSERT_EQUAL(3u, wrappedData->index);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
TESTCASE(const_iterator_value)
|
|
@@ -185,13 +185,13 @@ TESTCASE(const_iterator_value)
|
|
|
185
185
|
Array a = m.module_eval(code);
|
|
186
186
|
|
|
187
187
|
Data_Object<Data> wrappedData(a[0]);
|
|
188
|
-
ASSERT_EQUAL(
|
|
188
|
+
ASSERT_EQUAL(1u, wrappedData->index);
|
|
189
189
|
|
|
190
190
|
wrappedData = (Data_Object<Data>)a[1];
|
|
191
|
-
ASSERT_EQUAL(
|
|
191
|
+
ASSERT_EQUAL(2u, wrappedData->index);
|
|
192
192
|
|
|
193
193
|
wrappedData = (Data_Object<Data>)a[2];
|
|
194
|
-
ASSERT_EQUAL(
|
|
194
|
+
ASSERT_EQUAL(3u, wrappedData->index);
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
TESTCASE(iterator_pointer)
|
|
@@ -218,13 +218,13 @@ TESTCASE(iterator_pointer)
|
|
|
218
218
|
Array a = m.module_eval(code);
|
|
219
219
|
|
|
220
220
|
Data_Object<Data> wrappedData(a[0]);
|
|
221
|
-
ASSERT_EQUAL(
|
|
221
|
+
ASSERT_EQUAL(1u, wrappedData->index);
|
|
222
222
|
|
|
223
223
|
wrappedData = (Data_Object<Data>)a[1];
|
|
224
|
-
ASSERT_EQUAL(
|
|
224
|
+
ASSERT_EQUAL(2u, wrappedData->index);
|
|
225
225
|
|
|
226
226
|
wrappedData = (Data_Object<Data>)a[2];
|
|
227
|
-
ASSERT_EQUAL(
|
|
227
|
+
ASSERT_EQUAL(3u, wrappedData->index);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
TESTCASE(two_iterator_pointer)
|
|
@@ -254,25 +254,25 @@ TESTCASE(two_iterator_pointer)
|
|
|
254
254
|
|
|
255
255
|
Array a = m.module_eval(code);
|
|
256
256
|
|
|
257
|
-
ASSERT_EQUAL(
|
|
257
|
+
ASSERT_EQUAL(6, a.size());
|
|
258
258
|
|
|
259
259
|
Data_Object<Data> wrappedData(a[0]);
|
|
260
|
-
ASSERT_EQUAL(
|
|
260
|
+
ASSERT_EQUAL(1u, wrappedData->index);
|
|
261
261
|
|
|
262
262
|
wrappedData = (Data_Object<Data>)a[1];
|
|
263
|
-
ASSERT_EQUAL(
|
|
263
|
+
ASSERT_EQUAL(2u, wrappedData->index);
|
|
264
264
|
|
|
265
265
|
wrappedData = (Data_Object<Data>)a[2];
|
|
266
|
-
ASSERT_EQUAL(
|
|
266
|
+
ASSERT_EQUAL(3u, wrappedData->index);
|
|
267
267
|
|
|
268
268
|
wrappedData = (Data_Object<Data>)a[3];
|
|
269
|
-
ASSERT_EQUAL(
|
|
269
|
+
ASSERT_EQUAL(3u, wrappedData->index);
|
|
270
270
|
|
|
271
271
|
wrappedData = (Data_Object<Data>)a[4];
|
|
272
|
-
ASSERT_EQUAL(
|
|
272
|
+
ASSERT_EQUAL(2u, wrappedData->index);
|
|
273
273
|
|
|
274
274
|
wrappedData = (Data_Object<Data>)a[5];
|
|
275
|
-
ASSERT_EQUAL(
|
|
275
|
+
ASSERT_EQUAL(1u, wrappedData->index);
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
TESTCASE(map)
|
|
@@ -293,7 +293,7 @@ TESTCASE(map)
|
|
|
293
293
|
end)";
|
|
294
294
|
|
|
295
295
|
Array a = m.module_eval(code);
|
|
296
|
-
ASSERT_EQUAL(
|
|
296
|
+
ASSERT_EQUAL(3, a.size());
|
|
297
297
|
|
|
298
298
|
Object element = a[0];
|
|
299
299
|
ASSERT_EQUAL(2, detail::From_Ruby<int>().convert(element));
|
|
@@ -323,7 +323,7 @@ TESTCASE(to_enum)
|
|
|
323
323
|
|
|
324
324
|
Array a = m.module_eval(code);
|
|
325
325
|
|
|
326
|
-
ASSERT_EQUAL(
|
|
326
|
+
ASSERT_EQUAL(3, a.size());
|
|
327
327
|
|
|
328
328
|
Object element = a[0];
|
|
329
329
|
ASSERT_EQUAL(2, detail::From_Ruby<int>().convert(element));
|
|
@@ -335,6 +335,38 @@ TESTCASE(to_enum)
|
|
|
335
335
|
ASSERT_EQUAL(6, detail::From_Ruby<int>().convert(element));
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
+
TESTCASE(to_a)
|
|
339
|
+
{
|
|
340
|
+
define_class<Data>("Data")
|
|
341
|
+
.define_constructor(Constructor<Data, uint32_t>())
|
|
342
|
+
.define_attr("index", &Data::index, Rice::AttrAccess::Read);
|
|
343
|
+
|
|
344
|
+
define_class<ContainerPointers>("ContainerPointers")
|
|
345
|
+
.define_constructor(Constructor<ContainerPointers>())
|
|
346
|
+
.define_iterator(&ContainerPointers::begin, &ContainerPointers::end);
|
|
347
|
+
|
|
348
|
+
Module m = define_module("TestingModule");
|
|
349
|
+
|
|
350
|
+
std::string code = R"(container = ContainerPointers.new
|
|
351
|
+
container.to_a)";
|
|
352
|
+
|
|
353
|
+
Array a = m.module_eval(code);
|
|
354
|
+
|
|
355
|
+
ASSERT_EQUAL(3, a.size());
|
|
356
|
+
|
|
357
|
+
Object element = a[0];
|
|
358
|
+
Object index = element.call("index");
|
|
359
|
+
ASSERT_EQUAL(1, detail::From_Ruby<int>().convert(index));
|
|
360
|
+
|
|
361
|
+
element = a[1];
|
|
362
|
+
index = element.call("index");
|
|
363
|
+
ASSERT_EQUAL(2, detail::From_Ruby<int>().convert(index));
|
|
364
|
+
|
|
365
|
+
element = a[2];
|
|
366
|
+
index = element.call("index");
|
|
367
|
+
ASSERT_EQUAL(3, detail::From_Ruby<int>().convert(index));
|
|
368
|
+
}
|
|
369
|
+
|
|
338
370
|
TESTCASE(IterateNoCopy)
|
|
339
371
|
{
|
|
340
372
|
define_class<Data>("Data")
|
|
@@ -355,7 +387,7 @@ TESTCASE(IterateNoCopy)
|
|
|
355
387
|
for (size_t i = 0; i < container.data_.size(); i++)
|
|
356
388
|
{
|
|
357
389
|
Data& expected = container.data_[i];
|
|
358
|
-
Data_Object<Data> actual(a[i]);
|
|
390
|
+
Data_Object<Data> actual(a[(long)i]);
|
|
359
391
|
ASSERT_EQUAL(&expected, &(*actual));
|
|
360
392
|
}
|
|
361
|
-
}
|
|
393
|
+
}
|
data/test/test_Keep_Alive.cpp
CHANGED
|
@@ -80,7 +80,7 @@ TESTCASE(test_keep_alive_no_wrapper)
|
|
|
80
80
|
ASSERT_EXCEPTION_CHECK(
|
|
81
81
|
Exception,
|
|
82
82
|
m.module_eval("@zoo.get_pets.each do |pet| puts pet.name; end"),
|
|
83
|
-
ASSERT_EQUAL("
|
|
83
|
+
ASSERT_EQUAL("wrong argument type Array (expected wrapped C++ object)",
|
|
84
84
|
ex.what())
|
|
85
85
|
);
|
|
86
86
|
}
|
data/test/test_Module.cpp
CHANGED
|
@@ -53,27 +53,27 @@ namespace
|
|
|
53
53
|
return i;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
int method_int(Object
|
|
56
|
+
int method_int(Object, int i)
|
|
57
57
|
{
|
|
58
58
|
return i;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
bool method_lvalue(MyClass&
|
|
61
|
+
bool method_lvalue(MyClass&)
|
|
62
62
|
{
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
bool method_rvalue(MyClass&&
|
|
66
|
+
bool method_rvalue(MyClass&&)
|
|
67
67
|
{
|
|
68
68
|
return true;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
void method_lvalue_return_void(int
|
|
71
|
+
void method_lvalue_return_void(int, MyClass&)
|
|
72
72
|
{
|
|
73
73
|
// Do nothing
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
void method_rvalue_return_void(int
|
|
76
|
+
void method_rvalue_return_void(int, MyClass&&)
|
|
77
77
|
{
|
|
78
78
|
// Do nothing
|
|
79
79
|
}
|