rice 4.7.1 → 4.9.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 +37 -1
- data/CMakeLists.txt +14 -22
- data/CMakePresets.json +203 -75
- data/FindRuby.cmake +358 -123
- data/bin/rice-doc.rb +58 -141
- data/include/rice/api.hpp +261 -0
- data/include/rice/rice.hpp +2459 -1693
- data/include/rice/stl.hpp +450 -546
- 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 +21 -0
- data/lib/rice/doc.rb +1 -0
- data/lib/rice/make_rice_headers.rb +7 -0
- data/lib/rice/native_registry.rb +5 -10
- data/lib/rice/rbs.rb +6 -6
- 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 +33 -31
- 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 +7 -2
- data/rice/cpp_api/Class.ipp +9 -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 +10 -4
- data/rice/cpp_api/Object.ipp +20 -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/Forwards.hpp +18 -0
- data/rice/detail/Forwards.ipp +60 -0
- 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 +1 -1
- data/rice/detail/NativeRegistry.ipp +29 -0
- 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 +77 -93
- data/rice/detail/TypeRegistry.ipp +5 -4
- data/rice/detail/Wrapper.hpp +13 -12
- data/rice/detail/Wrapper.ipp +97 -44
- 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 +9 -8
- data/rice/rice_api/Native.ipp +5 -1
- data/rice/rice_api/NativeRegistry.ipp +14 -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 +9 -9
- data/rice/stl/shared_ptr.ipp +52 -185
- 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.hpp +9 -3
- data/rice/stl/unique_ptr.ipp +86 -120
- 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_Inheritance.cpp +14 -14
- data/test/test_Iterator.cpp +54 -22
- data/test/test_Keep_Alive.cpp +1 -1
- data/test/test_Keep_Alive_No_Wrapper.cpp +7 -3
- 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 +172 -33
- data/test/test_Stl_String_View.cpp +4 -2
- data/test/test_Stl_Tuple.cpp +1 -1
- data/test/test_Stl_UniquePtr.cpp +48 -3
- 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 +12 -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_Stl_UniquePtr.cpp
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#include "unittest.hpp"
|
|
1
|
+
#include "unittest.hpp"
|
|
2
2
|
#include "embed_ruby.hpp"
|
|
3
3
|
#include <rice/rice.hpp>
|
|
4
4
|
#include <rice/stl.hpp>
|
|
@@ -55,6 +55,11 @@ namespace
|
|
|
55
55
|
{
|
|
56
56
|
this->flag = value;
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
int getFlag()
|
|
60
|
+
{
|
|
61
|
+
return this->flag;
|
|
62
|
+
}
|
|
58
63
|
};
|
|
59
64
|
|
|
60
65
|
class Factory
|
|
@@ -97,7 +102,8 @@ SETUP(UniquePtr)
|
|
|
97
102
|
|
|
98
103
|
define_class<MyClass>("MyClass").
|
|
99
104
|
define_constructor(Constructor<MyClass>()).
|
|
100
|
-
define_method("set_flag", &MyClass::setFlag)
|
|
105
|
+
define_method("set_flag", &MyClass::setFlag).
|
|
106
|
+
define_method("get_flag", &MyClass::getFlag);
|
|
101
107
|
|
|
102
108
|
define_class<Factory>("Factory").
|
|
103
109
|
define_constructor(Constructor<Factory>()).
|
|
@@ -203,8 +209,47 @@ TESTCASE(Update)
|
|
|
203
209
|
|
|
204
210
|
TESTCASE(Klass)
|
|
205
211
|
{
|
|
212
|
+
define_unique_ptr<MyClass>();
|
|
206
213
|
detail::TypeMapper<std::unique_ptr<MyClass>> typeMapper;
|
|
207
|
-
|
|
214
|
+
Module aModule("Std");
|
|
215
|
+
Object expected = aModule.const_get("UniquePtr≺AnonymousNamespace꞉꞉MyClass≻");
|
|
208
216
|
VALUE actual = typeMapper.rubyKlass();
|
|
209
217
|
ASSERT_EQUAL(expected.value(), actual);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
TESTCASE(Empty)
|
|
221
|
+
{
|
|
222
|
+
Module m = define_module("TestingModule");
|
|
223
|
+
|
|
224
|
+
std::string code = R"(factory = Factory.new
|
|
225
|
+
unique_ptr = factory.transfer
|
|
226
|
+
unique_ptr.empty?)";
|
|
227
|
+
|
|
228
|
+
Object result = m.module_eval(code);
|
|
229
|
+
ASSERT_EQUAL(Qfalse, result.value());
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
TESTCASE(Release)
|
|
233
|
+
{
|
|
234
|
+
MyClass::reset();
|
|
235
|
+
|
|
236
|
+
Module m = define_module("TestingModule");
|
|
237
|
+
|
|
238
|
+
std::string code = R"(factory = Factory.new
|
|
239
|
+
$unique_ptr = factory.transfer
|
|
240
|
+
$unique_ptr.release)";
|
|
241
|
+
|
|
242
|
+
Object result = m.module_eval(code);
|
|
243
|
+
ASSERT_EQUAL("MyClass", result.class_name().str());
|
|
244
|
+
|
|
245
|
+
code = R"($unique_ptr.empty?)";
|
|
246
|
+
result = m.module_eval(code);
|
|
247
|
+
ASSERT_EQUAL(Qtrue, result.value());
|
|
248
|
+
|
|
249
|
+
code = R"($unique_ptr.set_flag(8))";
|
|
250
|
+
|
|
251
|
+
ASSERT_EXCEPTION_CHECK(
|
|
252
|
+
Exception,
|
|
253
|
+
m.module_eval(code),
|
|
254
|
+
ASSERT(std::string(ex.what()).find("undefined method") == 0));
|
|
210
255
|
}
|
data/test/test_Stl_Variant.cpp
CHANGED
|
@@ -21,12 +21,6 @@ namespace
|
|
|
21
21
|
int
|
|
22
22
|
>;
|
|
23
23
|
|
|
24
|
-
inline std::ostream& operator<<(std::ostream& stream, Intrinsic_Variant_T const& variant)
|
|
25
|
-
{
|
|
26
|
-
stream << "Variant(" << "index: " << variant.index() << ")";
|
|
27
|
-
return stream;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
24
|
class MyClass
|
|
31
25
|
{
|
|
32
26
|
public:
|
|
@@ -111,7 +105,6 @@ namespace
|
|
|
111
105
|
public:
|
|
112
106
|
MyClass1()
|
|
113
107
|
{
|
|
114
|
-
int a = 1;
|
|
115
108
|
}
|
|
116
109
|
|
|
117
110
|
std::string sayHello()
|
|
@@ -125,7 +118,6 @@ namespace
|
|
|
125
118
|
public:
|
|
126
119
|
MyClass2()
|
|
127
120
|
{
|
|
128
|
-
int a = 2;
|
|
129
121
|
}
|
|
130
122
|
|
|
131
123
|
std::string sayHello()
|
|
@@ -207,7 +199,7 @@ TESTCASE(IntrinsicReturns)
|
|
|
207
199
|
|
|
208
200
|
result = myClass.call("variant_vector");
|
|
209
201
|
std::vector<int> converted = detail::From_Ruby<std::vector<int>>().convert(result);
|
|
210
|
-
ASSERT_EQUAL(
|
|
202
|
+
ASSERT_EQUAL(3u, converted.size());
|
|
211
203
|
|
|
212
204
|
result = myClass.call("variant_double");
|
|
213
205
|
ASSERT_EQUAL(3.3, detail::From_Ruby<double>().convert(result));
|
|
@@ -334,9 +326,9 @@ TESTCASE(Roundtrip)
|
|
|
334
326
|
/* This test case runs successfully on MSVC but not g++. Having stepped through the code with
|
|
335
327
|
GDB, this sure seems due to a bug with g++. The issue is this variable in created operator():
|
|
336
328
|
|
|
337
|
-
|
|
329
|
+
Parameter_Ts nativeValues = this->getNativeValues(rubyValues, indices);
|
|
338
330
|
|
|
339
|
-
And is then passed to invokeNativeFunction as a const
|
|
331
|
+
And is then passed to invokeNativeFunction as a const Parameter_Ts& nativeArgs where Parameter_Ts& is
|
|
340
332
|
std::tuple with one element, a reference to a variant. So it doesn't change and the address
|
|
341
333
|
of the variable doesn't change. But for some reason g++ resets the
|
|
342
334
|
the std::variant index to 0 thus breaking the test. Maybe something to do with storing
|
|
@@ -416,19 +408,19 @@ TESTCASE(VariantWithTwoVectors)
|
|
|
416
408
|
my_class.variant_index(vector))";
|
|
417
409
|
|
|
418
410
|
Object result = m.module_eval(code);
|
|
419
|
-
ASSERT_EQUAL(
|
|
411
|
+
ASSERT_EQUAL(0u, detail::From_Ruby<size_t>().convert(result));
|
|
420
412
|
|
|
421
413
|
code = R"(vector = Std::Vector≺int≻.new
|
|
422
414
|
vector.push_back(4)
|
|
423
415
|
my_class = MyClass4.new
|
|
424
416
|
my_class.variant_index(vector))";
|
|
425
417
|
result = m.module_eval(code);
|
|
426
|
-
ASSERT_EQUAL(
|
|
418
|
+
ASSERT_EQUAL(1u, detail::From_Ruby<size_t>().convert(result));
|
|
427
419
|
|
|
428
420
|
code = R"(my_class = MyClass4.new
|
|
429
421
|
my_class.variant_index(["x", "y", "z"]))";
|
|
430
422
|
result = m.module_eval(code);
|
|
431
|
-
ASSERT_EQUAL(
|
|
423
|
+
ASSERT_EQUAL(0u, detail::From_Ruby<size_t>().convert(result));
|
|
432
424
|
|
|
433
425
|
code = R"(my_class = MyClass4.new
|
|
434
426
|
my_class.variant_index([5, 6]))";
|
data/test/test_Stl_Vector.cpp
CHANGED
|
@@ -18,7 +18,7 @@ TEARDOWN(Vector)
|
|
|
18
18
|
{
|
|
19
19
|
rb_gc_start();
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
namespace
|
|
23
23
|
{
|
|
24
24
|
class MyClass
|
|
@@ -65,7 +65,7 @@ TESTCASE(StringVector)
|
|
|
65
65
|
result = vec.call("last");
|
|
66
66
|
ASSERT_EQUAL("four", detail::From_Ruby<std::string>().convert(result));
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
TESTCASE(StringVectorData)
|
|
70
70
|
{
|
|
71
71
|
Module m = define_module("Testing");
|
|
@@ -282,24 +282,24 @@ TESTCASE(Slice)
|
|
|
282
282
|
|
|
283
283
|
Array result = vec.call("[]", 3, 1);
|
|
284
284
|
std::vector<std::int32_t> slice = result.to_vector<int32_t>();
|
|
285
|
-
ASSERT_EQUAL(
|
|
285
|
+
ASSERT_EQUAL(1u, slice.size());
|
|
286
286
|
ASSERT_EQUAL(10, slice[0]);
|
|
287
287
|
|
|
288
288
|
result = vec.call("[]", 3, 2);
|
|
289
289
|
slice = result.to_vector<int32_t>();
|
|
290
|
-
ASSERT_EQUAL(
|
|
290
|
+
ASSERT_EQUAL(2u, slice.size());
|
|
291
291
|
ASSERT_EQUAL(10, slice[0]);
|
|
292
292
|
ASSERT_EQUAL(11, slice[1]);
|
|
293
293
|
|
|
294
294
|
result = vec.call("[]", 4, 10);
|
|
295
295
|
slice = result.to_vector<int32_t>();
|
|
296
|
-
ASSERT_EQUAL(
|
|
296
|
+
ASSERT_EQUAL(2u, slice.size());
|
|
297
297
|
ASSERT_EQUAL(11, slice[0]);
|
|
298
298
|
ASSERT_EQUAL(12, slice[1]);
|
|
299
299
|
|
|
300
300
|
result = vec.call("[]", -1, 2);
|
|
301
301
|
slice = result.to_vector<int32_t>();
|
|
302
|
-
ASSERT_EQUAL(
|
|
302
|
+
ASSERT_EQUAL(1u, slice.size());
|
|
303
303
|
ASSERT_EQUAL(12, slice[0]);
|
|
304
304
|
}
|
|
305
305
|
|
|
@@ -528,7 +528,7 @@ TESTCASE(NotDefaultConstructable)
|
|
|
528
528
|
ASSERT_EQUAL(Qnil, result.value());
|
|
529
529
|
|
|
530
530
|
result = vec.call("length");
|
|
531
|
-
ASSERT_EQUAL(
|
|
531
|
+
ASSERT_EQUAL(0u, detail::From_Ruby<size_t>().convert(result));
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
TESTCASE(NotPrintable)
|
|
@@ -591,16 +591,47 @@ TESTCASE(Comparable)
|
|
|
591
591
|
|
|
592
592
|
Object result = vec.call("delete", Comparable(1));
|
|
593
593
|
Comparable comparable = detail::From_Ruby<Comparable>().convert(result);
|
|
594
|
-
ASSERT_EQUAL(
|
|
594
|
+
ASSERT_EQUAL(1u, comparable.value_);
|
|
595
595
|
|
|
596
596
|
result = vec.call("length");
|
|
597
|
-
ASSERT_EQUAL(
|
|
597
|
+
ASSERT_EQUAL(2u, detail::From_Ruby<size_t>().convert(result));
|
|
598
598
|
|
|
599
599
|
result = vec.call("include?", Comparable(2));
|
|
600
600
|
ASSERT_EQUAL(Qtrue, result.value());
|
|
601
601
|
|
|
602
602
|
result = vec.call("index", Comparable(3));
|
|
603
|
-
ASSERT_EQUAL(
|
|
603
|
+
ASSERT_EQUAL(1u, detail::From_Ruby<size_t>().convert(result.value()));
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
TESTCASE(ComparableEqual)
|
|
607
|
+
{
|
|
608
|
+
define_class<Comparable>("IsComparable").
|
|
609
|
+
define_constructor(Constructor<Comparable, uint32_t>());
|
|
610
|
+
|
|
611
|
+
Comparable comparable1a(1);
|
|
612
|
+
Comparable comparable1b(1);
|
|
613
|
+
Comparable comparable2(2);
|
|
614
|
+
|
|
615
|
+
Class c = define_vector<Comparable>("ComparableVector");
|
|
616
|
+
|
|
617
|
+
Object vec1 = c.call("new");
|
|
618
|
+
Object vec2 = c.call("new");
|
|
619
|
+
Object vec3 = c.call("new");
|
|
620
|
+
|
|
621
|
+
Object result = vec1.call("eql?", vec2);
|
|
622
|
+
ASSERT_EQUAL(Qtrue, result.value());
|
|
623
|
+
|
|
624
|
+
vec1.call("push", comparable1a);
|
|
625
|
+
result = vec1.call("==", vec2);
|
|
626
|
+
ASSERT_EQUAL(Qfalse, result.value());
|
|
627
|
+
|
|
628
|
+
vec2.call("push", comparable1b);
|
|
629
|
+
result = vec1.call("==", vec2);
|
|
630
|
+
ASSERT_EQUAL(Qtrue, result.value());
|
|
631
|
+
|
|
632
|
+
vec3.call("push", comparable2);
|
|
633
|
+
result = vec1.call("==", vec3);
|
|
634
|
+
ASSERT_EQUAL(Qfalse, result.value());
|
|
604
635
|
}
|
|
605
636
|
|
|
606
637
|
namespace
|
|
@@ -612,7 +643,7 @@ namespace
|
|
|
612
643
|
{
|
|
613
644
|
};
|
|
614
645
|
|
|
615
|
-
std::string operator==(const ComparableButNotBool&
|
|
646
|
+
std::string operator==(const ComparableButNotBool&)
|
|
616
647
|
{
|
|
617
648
|
return "not a boolean";
|
|
618
649
|
}
|
|
@@ -658,7 +689,7 @@ TESTCASE(DefaultConstructable)
|
|
|
658
689
|
ASSERT_EQUAL(Qnil, result.value());
|
|
659
690
|
|
|
660
691
|
result = vec.call("length");
|
|
661
|
-
ASSERT_EQUAL(
|
|
692
|
+
ASSERT_EQUAL(0u, detail::From_Ruby<size_t>().convert(result));
|
|
662
693
|
}
|
|
663
694
|
|
|
664
695
|
TESTCASE(Printable)
|
|
@@ -798,7 +829,7 @@ TESTCASE(ToArray)
|
|
|
798
829
|
vector.to_a)";
|
|
799
830
|
|
|
800
831
|
Array array = m.module_eval(code);
|
|
801
|
-
ASSERT_EQUAL(
|
|
832
|
+
ASSERT_EQUAL(3, array.size());
|
|
802
833
|
|
|
803
834
|
ASSERT_EQUAL("abc", detail::From_Ruby<std::string>().convert(array[0].value()));
|
|
804
835
|
ASSERT_EQUAL("def", detail::From_Ruby<std::string>().convert(array[1].value()));
|
|
@@ -842,17 +873,17 @@ TESTCASE(ArrayToVector)
|
|
|
842
873
|
std::string code = "array_to_vector([7, 9, 1_000_000], [49.0, 78.0, 999.0], %w[one two three])";
|
|
843
874
|
m.module_eval(code);
|
|
844
875
|
|
|
845
|
-
ASSERT_EQUAL(
|
|
876
|
+
ASSERT_EQUAL(3u, ints.size());
|
|
846
877
|
ASSERT_EQUAL(7, ints[0]);
|
|
847
878
|
ASSERT_EQUAL(9, ints[1]);
|
|
848
879
|
ASSERT_EQUAL(1'000'000, ints[2]);
|
|
849
880
|
|
|
850
|
-
ASSERT_EQUAL(
|
|
881
|
+
ASSERT_EQUAL(3u, floats.size());
|
|
851
882
|
ASSERT_EQUAL(49.0, floats[0]);
|
|
852
883
|
ASSERT_EQUAL(78.0, floats[1]);
|
|
853
884
|
ASSERT_EQUAL(999.0, floats[2]);
|
|
854
885
|
|
|
855
|
-
ASSERT_EQUAL(
|
|
886
|
+
ASSERT_EQUAL(3u, strings.size());
|
|
856
887
|
ASSERT_EQUAL("one", strings[0]);
|
|
857
888
|
ASSERT_EQUAL("two", strings[1]);
|
|
858
889
|
ASSERT_EQUAL("three", strings[2]);
|
|
@@ -867,17 +898,17 @@ TESTCASE(ArrayToVectorRefs)
|
|
|
867
898
|
std::string code = "array_to_vector_refs([8, 10, 1_000_001], [50.0, 79.0, 1_000.0], %w[eleven twelve thirteen])";
|
|
868
899
|
m.module_eval(code);
|
|
869
900
|
|
|
870
|
-
ASSERT_EQUAL(
|
|
901
|
+
ASSERT_EQUAL(3u, ints.size());
|
|
871
902
|
ASSERT_EQUAL(8, ints[0]);
|
|
872
903
|
ASSERT_EQUAL(10, ints[1]);
|
|
873
904
|
ASSERT_EQUAL(1'000'001, ints[2]);
|
|
874
905
|
|
|
875
|
-
ASSERT_EQUAL(
|
|
906
|
+
ASSERT_EQUAL(3u, floats.size());
|
|
876
907
|
ASSERT_EQUAL(50.0, floats[0]);
|
|
877
908
|
ASSERT_EQUAL(79.0, floats[1]);
|
|
878
909
|
ASSERT_EQUAL(1'000.0, floats[2]);
|
|
879
910
|
|
|
880
|
-
ASSERT_EQUAL(
|
|
911
|
+
ASSERT_EQUAL(3u, strings.size());
|
|
881
912
|
ASSERT_EQUAL("eleven", strings[0]);
|
|
882
913
|
ASSERT_EQUAL("twelve", strings[1]);
|
|
883
914
|
ASSERT_EQUAL("thirteen", strings[2]);
|
|
@@ -892,17 +923,17 @@ TESTCASE(ArrayToVectorPointers)
|
|
|
892
923
|
std::string code = "array_to_vector_pointers([9, 11, 1_000_002], [51.0, 80.0, 1_001.0], %w[fourteen fifteen sixteen])";
|
|
893
924
|
m.module_eval(code);
|
|
894
925
|
|
|
895
|
-
ASSERT_EQUAL(
|
|
926
|
+
ASSERT_EQUAL(3u, ints.size());
|
|
896
927
|
ASSERT_EQUAL(9, ints[0]);
|
|
897
928
|
ASSERT_EQUAL(11, ints[1]);
|
|
898
929
|
ASSERT_EQUAL(1'000'002, ints[2]);
|
|
899
930
|
|
|
900
|
-
ASSERT_EQUAL(
|
|
931
|
+
ASSERT_EQUAL(3u, floats.size());
|
|
901
932
|
ASSERT_EQUAL(51.0, floats[0]);
|
|
902
933
|
ASSERT_EQUAL(80.0, floats[1]);
|
|
903
934
|
ASSERT_EQUAL(1'001.0, floats[2]);
|
|
904
935
|
|
|
905
|
-
ASSERT_EQUAL(
|
|
936
|
+
ASSERT_EQUAL(3u, strings.size());
|
|
906
937
|
ASSERT_EQUAL("fourteen", strings[0]);
|
|
907
938
|
ASSERT_EQUAL("fifteen", strings[1]);
|
|
908
939
|
ASSERT_EQUAL("sixteen", strings[2]);
|
|
@@ -962,11 +993,11 @@ namespace
|
|
|
962
993
|
static inline std::vector<std::string> instance_{ "one", "two", "three" };
|
|
963
994
|
};
|
|
964
995
|
|
|
965
|
-
|
|
996
|
+
/* std::ostream& operator<<(std::ostream& stream, const std::vector<std::string>& vector)
|
|
966
997
|
{
|
|
967
|
-
stream <<
|
|
998
|
+
stream << vector;
|
|
968
999
|
return stream;
|
|
969
|
-
}
|
|
1000
|
+
}*/
|
|
970
1001
|
|
|
971
1002
|
void createFactoryClass()
|
|
972
1003
|
{
|
|
@@ -1104,7 +1135,7 @@ TESTCASE(StringPointerVector)
|
|
|
1104
1135
|
|
|
1105
1136
|
Module m(rb_mKernel);
|
|
1106
1137
|
Data_Object<std::vector<std::string*>> vec = m.call("vector_of_string_pointers");
|
|
1107
|
-
ASSERT_EQUAL(
|
|
1138
|
+
ASSERT_EQUAL(2u, vec->size());
|
|
1108
1139
|
|
|
1109
1140
|
std::string expected("Hello");
|
|
1110
1141
|
std::string* actual = (*vec)[0];
|
|
@@ -1149,7 +1180,7 @@ TESTCASE(MyClass2PointerVector)
|
|
|
1149
1180
|
|
|
1150
1181
|
Module m(rb_mKernel);
|
|
1151
1182
|
Data_Object<std::vector<MyClass2*>> result = m.call("vector_of_myclass2_pointers");
|
|
1152
|
-
ASSERT_EQUAL(
|
|
1183
|
+
ASSERT_EQUAL(1u, result->size());
|
|
1153
1184
|
|
|
1154
1185
|
MyClass2* pMyClass = (*result)[0];
|
|
1155
1186
|
ASSERT_EQUAL("Hello MyClass2", pMyClass->name);
|
|
@@ -1157,17 +1188,17 @@ TESTCASE(MyClass2PointerVector)
|
|
|
1157
1188
|
|
|
1158
1189
|
namespace
|
|
1159
1190
|
{
|
|
1160
|
-
bool typeCheckValue(std::vector<std::string>
|
|
1191
|
+
bool typeCheckValue(std::vector<std::string>)
|
|
1161
1192
|
{
|
|
1162
1193
|
return true;
|
|
1163
1194
|
}
|
|
1164
1195
|
|
|
1165
|
-
bool typeCheckRef(std::vector<std::string>&
|
|
1196
|
+
bool typeCheckRef(std::vector<std::string>&)
|
|
1166
1197
|
{
|
|
1167
1198
|
return true;
|
|
1168
1199
|
}
|
|
1169
1200
|
|
|
1170
|
-
bool typeCheckPtr(std::vector<std::string>*
|
|
1201
|
+
bool typeCheckPtr(std::vector<std::string>*)
|
|
1171
1202
|
{
|
|
1172
1203
|
return true;
|
|
1173
1204
|
}
|
data/test/test_String.cpp
CHANGED
|
@@ -118,10 +118,12 @@ TESTCASE(intern)
|
|
|
118
118
|
*/
|
|
119
119
|
|
|
120
120
|
namespace {
|
|
121
|
-
void testStringArg(Object
|
|
121
|
+
void testStringArg(Object, String)
|
|
122
|
+
{
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
TESTCASE(use_string_in_wrapped_function)
|
|
126
|
+
TESTCASE(use_string_in_wrapped_function)
|
|
127
|
+
{
|
|
126
128
|
define_global_function("test_string_arg", &testStringArg);
|
|
127
129
|
}
|
data/test/test_Struct.cpp
CHANGED
data/test/test_Symbol.cpp
CHANGED
data/test/test_To_Ruby.cpp
CHANGED
data/test/test_Type.cpp
CHANGED
|
@@ -41,83 +41,84 @@ TESTCASE(FindGroup)
|
|
|
41
41
|
{
|
|
42
42
|
std::string name = "class std::vector<class cv::Vec<unsigned char, 2>, class std::allocator<class cv::Vec<unsigned char, 2> > >";
|
|
43
43
|
|
|
44
|
-
detail::
|
|
45
|
-
|
|
44
|
+
detail::TypeIndexParser parser(typeid(int), true);
|
|
45
|
+
|
|
46
|
+
std::string group = parser.findGroup(name, 0);
|
|
46
47
|
ASSERT_EQUAL("<class cv::Vec<unsigned char, 2>, class std::allocator<class cv::Vec<unsigned char, 2> > >", group.c_str());
|
|
47
48
|
|
|
48
|
-
group =
|
|
49
|
+
group = parser.findGroup(name, 18);
|
|
49
50
|
ASSERT_EQUAL("<unsigned char, 2>", group.c_str());
|
|
50
51
|
|
|
51
|
-
group =
|
|
52
|
+
group = parser.findGroup(name, 49);
|
|
52
53
|
ASSERT_EQUAL("<class cv::Vec<unsigned char, 2> >", group.c_str());
|
|
53
54
|
|
|
54
55
|
ASSERT_EXCEPTION_CHECK(
|
|
55
56
|
std::runtime_error,
|
|
56
|
-
|
|
57
|
+
parser.findGroup(name, 48),
|
|
57
58
|
ASSERT_EQUAL("Unbalanced Group", ex.what())
|
|
58
59
|
);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
TESTCASE(SimplifiedName)
|
|
62
63
|
{
|
|
63
|
-
detail::
|
|
64
|
-
std::string className =
|
|
64
|
+
detail::TypeIndexParser typeIndexParser1(typeid(char*));
|
|
65
|
+
std::string className = typeIndexParser1.simplifiedName();
|
|
65
66
|
ASSERT_EQUAL("char*", className.c_str());
|
|
66
67
|
|
|
67
|
-
detail::
|
|
68
|
-
className =
|
|
68
|
+
detail::TypeIndexParser typeIndexParser2(typeid(char**));
|
|
69
|
+
className = typeIndexParser2.simplifiedName();
|
|
69
70
|
ASSERT_EQUAL("char**", className.c_str());
|
|
70
71
|
|
|
71
|
-
detail::
|
|
72
|
-
className =
|
|
72
|
+
detail::TypeIndexParser typeIndexParser3(typeid(double));
|
|
73
|
+
className = typeIndexParser3.simplifiedName();
|
|
73
74
|
ASSERT_EQUAL("double", className.c_str());
|
|
74
75
|
|
|
75
|
-
detail::
|
|
76
|
-
className =
|
|
76
|
+
detail::TypeIndexParser typeIndexParser4(typeid(double*));
|
|
77
|
+
className = typeIndexParser4.simplifiedName();
|
|
77
78
|
ASSERT_EQUAL("double*", className.c_str());
|
|
78
79
|
|
|
79
|
-
detail::
|
|
80
|
-
className =
|
|
80
|
+
detail::TypeIndexParser typeIndexParser5(typeid(std::string));
|
|
81
|
+
className = typeIndexParser5.simplifiedName();
|
|
81
82
|
ASSERT_EQUAL("std::string", className.c_str());
|
|
82
83
|
|
|
83
|
-
detail::
|
|
84
|
-
className =
|
|
84
|
+
detail::TypeIndexParser typeIndexParser6(typeid(std::wstring));
|
|
85
|
+
className = typeIndexParser6.simplifiedName();
|
|
85
86
|
ASSERT_EQUAL("std::wstring", className.c_str());
|
|
86
87
|
|
|
87
|
-
detail::
|
|
88
|
-
className =
|
|
88
|
+
detail::TypeIndexParser typeIndexParser7(typeid(std::vector<std::string>));
|
|
89
|
+
className = typeIndexParser7.simplifiedName();
|
|
89
90
|
ASSERT_EQUAL("std::vector<std::string>", className.c_str());
|
|
90
91
|
|
|
91
|
-
detail::
|
|
92
|
-
className =
|
|
92
|
+
detail::TypeIndexParser typeIndexParser8(typeid(std::vector<std::wstring>));
|
|
93
|
+
className = typeIndexParser8.simplifiedName();
|
|
93
94
|
ASSERT_EQUAL("std::vector<std::wstring>", className.c_str());
|
|
94
95
|
|
|
95
|
-
detail::
|
|
96
|
-
className =
|
|
96
|
+
detail::TypeIndexParser typeIndexParser9(typeid(std::vector<double*>));
|
|
97
|
+
className = typeIndexParser9.simplifiedName();
|
|
97
98
|
ASSERT_EQUAL("std::vector<double*>", className.c_str());
|
|
98
99
|
|
|
99
|
-
detail::
|
|
100
|
-
className =
|
|
100
|
+
detail::TypeIndexParser typeIndexParser10(typeid(std::vector<double**>));
|
|
101
|
+
className = typeIndexParser10.simplifiedName();
|
|
101
102
|
ASSERT_EQUAL("std::vector<double**>", className.c_str());
|
|
102
103
|
|
|
103
|
-
detail::
|
|
104
|
-
className =
|
|
104
|
+
detail::TypeIndexParser typeIndexParser11(typeid(Outer::Inner::Vec1));
|
|
105
|
+
className = typeIndexParser11.simplifiedName();
|
|
105
106
|
ASSERT_EQUAL("std::vector<std::complex<float>>", className.c_str());
|
|
106
107
|
|
|
107
|
-
detail::
|
|
108
|
-
className =
|
|
108
|
+
detail::TypeIndexParser typeIndexParser12(typeid(Outer::Inner::Vec2));
|
|
109
|
+
className = typeIndexParser12.simplifiedName();
|
|
109
110
|
ASSERT_EQUAL("std::vector<unsigned char*>", className.c_str());
|
|
110
111
|
|
|
111
|
-
detail::
|
|
112
|
-
className =
|
|
112
|
+
detail::TypeIndexParser typeIndexParser13(typeid(Outer::Inner::Vec3));
|
|
113
|
+
className = typeIndexParser13.simplifiedName();
|
|
113
114
|
ASSERT_EQUAL("std::vector<Outer::Inner::SomeClass>", className.c_str());
|
|
114
115
|
|
|
115
|
-
detail::
|
|
116
|
-
className =
|
|
116
|
+
detail::TypeIndexParser typeIndexParser14(typeid(Outer::Inner::Map1));
|
|
117
|
+
className = typeIndexParser14.simplifiedName();
|
|
117
118
|
ASSERT_EQUAL("std::map<std::string, std::vector<std::complex<float>>>", className.c_str());
|
|
118
119
|
|
|
119
|
-
detail::
|
|
120
|
-
className =
|
|
120
|
+
detail::TypeIndexParser typeIndexParser15(typeid(Outer::Inner::UnorderedMap1));
|
|
121
|
+
className = typeIndexParser15.simplifiedName();
|
|
121
122
|
ASSERT_EQUAL("std::unordered_map<std::string, std::complex<float>>", className.c_str());
|
|
122
123
|
}
|
|
123
124
|
|
data/test/unittest.cpp
CHANGED
data/test/unittest.hpp
CHANGED
|
@@ -268,11 +268,11 @@ void assert_in_delta(
|
|
|
268
268
|
T const& expected,
|
|
269
269
|
U const& actual,
|
|
270
270
|
V const& delta,
|
|
271
|
-
std::string const
|
|
272
|
-
std::string const
|
|
273
|
-
std::string const
|
|
274
|
-
std::string const
|
|
275
|
-
size_t
|
|
271
|
+
std::string const&,
|
|
272
|
+
std::string const&,
|
|
273
|
+
std::string const&,
|
|
274
|
+
std::string const&,
|
|
275
|
+
size_t)
|
|
276
276
|
{
|
|
277
277
|
// Negative deltas don't make sense; treat as failure for clarity.
|
|
278
278
|
if (delta < 0)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rice
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paul Brannan
|
|
@@ -79,11 +79,13 @@ files:
|
|
|
79
79
|
- Rakefile
|
|
80
80
|
- bin/rice-doc.rb
|
|
81
81
|
- bin/rice-rbs.rb
|
|
82
|
+
- include/rice/api.hpp
|
|
82
83
|
- include/rice/rice.hpp
|
|
83
84
|
- include/rice/stl.hpp
|
|
84
85
|
- lib/mkmf-rice.rb
|
|
85
86
|
- lib/rice.rb
|
|
86
87
|
- lib/rice/doc.rb
|
|
88
|
+
- lib/rice/doc/config.rb
|
|
87
89
|
- lib/rice/doc/cpp_reference.rb
|
|
88
90
|
- lib/rice/doc/doxygen.rb
|
|
89
91
|
- lib/rice/doc/mkdocs.rb
|
|
@@ -118,14 +120,15 @@ files:
|
|
|
118
120
|
- rice/Enum.ipp
|
|
119
121
|
- rice/Exception.hpp
|
|
120
122
|
- rice/Exception.ipp
|
|
121
|
-
- rice/Function.hpp
|
|
122
|
-
- rice/Function.ipp
|
|
123
123
|
- rice/JumpException.hpp
|
|
124
124
|
- rice/JumpException.ipp
|
|
125
125
|
- rice/MemoryView.hpp
|
|
126
126
|
- rice/MemoryView.ipp
|
|
127
|
+
- rice/NoGVL.hpp
|
|
127
128
|
- rice/Pointer.hpp
|
|
128
129
|
- rice/Pointer.ipp
|
|
130
|
+
- rice/Reference.hpp
|
|
131
|
+
- rice/Reference.ipp
|
|
129
132
|
- rice/Return.hpp
|
|
130
133
|
- rice/Return.ipp
|
|
131
134
|
- rice/api.hpp
|
|
@@ -154,12 +157,12 @@ files:
|
|
|
154
157
|
- rice/cpp_api/shared_methods.hpp
|
|
155
158
|
- rice/detail/DefaultHandler.hpp
|
|
156
159
|
- rice/detail/DefaultHandler.ipp
|
|
160
|
+
- rice/detail/Forwards.hpp
|
|
161
|
+
- rice/detail/Forwards.ipp
|
|
157
162
|
- rice/detail/HandlerRegistry.hpp
|
|
158
163
|
- rice/detail/HandlerRegistry.ipp
|
|
159
164
|
- rice/detail/InstanceRegistry.hpp
|
|
160
165
|
- rice/detail/InstanceRegistry.ipp
|
|
161
|
-
- rice/detail/MethodInfo.hpp
|
|
162
|
-
- rice/detail/MethodInfo.ipp
|
|
163
166
|
- rice/detail/ModuleRegistry.hpp
|
|
164
167
|
- rice/detail/ModuleRegistry.ipp
|
|
165
168
|
- rice/detail/Native.hpp
|
|
@@ -168,10 +171,8 @@ files:
|
|
|
168
171
|
- rice/detail/NativeAttributeGet.ipp
|
|
169
172
|
- rice/detail/NativeAttributeSet.hpp
|
|
170
173
|
- rice/detail/NativeAttributeSet.ipp
|
|
171
|
-
- rice/detail/
|
|
172
|
-
- rice/detail/
|
|
173
|
-
- rice/detail/NativeCallbackSimple.hpp
|
|
174
|
-
- rice/detail/NativeCallbackSimple.ipp
|
|
174
|
+
- rice/detail/NativeCallback.hpp
|
|
175
|
+
- rice/detail/NativeCallback.ipp
|
|
175
176
|
- rice/detail/NativeFunction.hpp
|
|
176
177
|
- rice/detail/NativeFunction.ipp
|
|
177
178
|
- rice/detail/NativeInvoker.hpp
|
|
@@ -308,6 +309,7 @@ files:
|
|
|
308
309
|
- test/test_Overloads.cpp
|
|
309
310
|
- test/test_Ownership.cpp
|
|
310
311
|
- test/test_Proc.cpp
|
|
312
|
+
- test/test_Reference.cpp
|
|
311
313
|
- test/test_Self.cpp
|
|
312
314
|
- test/test_Stl_Exception.cpp
|
|
313
315
|
- test/test_Stl_Map.cpp
|
|
@@ -357,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
357
359
|
- !ruby/object:Gem::Version
|
|
358
360
|
version: '0'
|
|
359
361
|
requirements: []
|
|
360
|
-
rubygems_version:
|
|
362
|
+
rubygems_version: 4.0.2
|
|
361
363
|
specification_version: 4
|
|
362
364
|
summary: Ruby Interface for C++ Extensions
|
|
363
365
|
test_files: []
|