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_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
|
}
|