rice 4.5.0 → 4.6.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 +23 -0
- data/CMakeLists.txt +31 -0
- data/CMakePresets.json +75 -0
- data/COPYING +3 -2
- data/FindRuby.cmake +437 -0
- data/Rakefile +5 -4
- data/include/rice/rice.hpp +5436 -3201
- data/include/rice/stl.hpp +2355 -1269
- data/lib/make_rice_headers.rb +79 -0
- data/lib/mkmf-rice.rb +4 -0
- data/lib/rice/version.rb +3 -0
- data/lib/rice.rb +1 -0
- data/lib/rubygems/builder.rb +11 -0
- data/lib/rubygems/cmake_builder.rb +113 -0
- data/lib/rubygems_plugin.rb +9 -0
- data/rice/Arg.hpp +7 -1
- data/rice/Arg.ipp +11 -2
- data/rice/Buffer.hpp +123 -0
- data/rice/Buffer.ipp +599 -0
- data/rice/Constructor.ipp +3 -3
- data/rice/Data_Object.hpp +2 -3
- data/rice/Data_Object.ipp +188 -188
- data/rice/Data_Type.hpp +4 -5
- data/rice/Data_Type.ipp +42 -26
- data/rice/Enum.hpp +0 -1
- data/rice/Enum.ipp +26 -23
- data/rice/Init.hpp +8 -0
- data/rice/Init.ipp +8 -0
- data/rice/MemoryView.ipp +1 -41
- data/rice/Return.hpp +1 -1
- data/rice/Return.ipp +6 -0
- data/rice/cpp_api/Array.hpp +209 -0
- data/rice/cpp_api/Array.ipp +304 -0
- data/rice/cpp_api/Builtin_Object.hpp +31 -0
- data/rice/cpp_api/Builtin_Object.ipp +37 -0
- data/rice/cpp_api/Class.hpp +70 -0
- data/rice/cpp_api/Class.ipp +97 -0
- data/rice/cpp_api/Encoding.hpp +32 -0
- data/rice/cpp_api/Encoding.ipp +59 -0
- data/rice/cpp_api/Hash.hpp +194 -0
- data/rice/cpp_api/Hash.ipp +257 -0
- data/rice/cpp_api/Identifier.hpp +46 -0
- data/rice/cpp_api/Identifier.ipp +31 -0
- data/rice/cpp_api/Module.hpp +72 -0
- data/rice/cpp_api/Module.ipp +101 -0
- data/rice/cpp_api/Object.hpp +272 -0
- data/rice/cpp_api/Object.ipp +235 -0
- data/rice/cpp_api/String.hpp +74 -0
- data/rice/cpp_api/String.ipp +120 -0
- data/rice/cpp_api/Struct.hpp +113 -0
- data/rice/cpp_api/Struct.ipp +92 -0
- data/rice/cpp_api/Symbol.hpp +46 -0
- data/rice/cpp_api/Symbol.ipp +93 -0
- data/rice/cpp_api/shared_methods.hpp +134 -0
- data/rice/detail/MethodInfo.hpp +1 -9
- data/rice/detail/MethodInfo.ipp +5 -72
- data/rice/detail/Native.hpp +3 -2
- data/rice/detail/Native.ipp +32 -4
- data/rice/detail/NativeAttributeGet.hpp +3 -2
- data/rice/detail/NativeAttributeGet.ipp +8 -2
- data/rice/detail/NativeAttributeSet.hpp +3 -2
- data/rice/detail/NativeAttributeSet.ipp +8 -2
- data/rice/detail/NativeCallbackFFI.ipp +1 -1
- data/rice/detail/NativeFunction.hpp +17 -6
- data/rice/detail/NativeFunction.ipp +168 -64
- data/rice/detail/NativeIterator.hpp +3 -2
- data/rice/detail/NativeIterator.ipp +8 -2
- data/rice/detail/RubyType.hpp +2 -5
- data/rice/detail/RubyType.ipp +50 -5
- data/rice/detail/Type.hpp +3 -1
- data/rice/detail/Type.ipp +61 -31
- data/rice/detail/Wrapper.hpp +68 -33
- data/rice/detail/Wrapper.ipp +103 -113
- data/rice/detail/from_ruby.hpp +5 -4
- data/rice/detail/from_ruby.ipp +737 -365
- data/rice/detail/to_ruby.ipp +1092 -186
- data/rice/global_function.ipp +1 -1
- data/rice/libc/file.hpp +11 -0
- data/rice/libc/file.ipp +32 -0
- data/rice/rice.hpp +23 -16
- data/rice/stl/complex.hpp +6 -0
- data/rice/stl/complex.ipp +93 -0
- data/rice/stl/exception.hpp +11 -0
- data/rice/stl/exception.ipp +29 -0
- data/rice/stl/exception_ptr.hpp +6 -0
- data/rice/stl/exception_ptr.ipp +27 -0
- data/rice/stl/map.hpp +12 -0
- data/rice/stl/map.ipp +469 -0
- data/rice/stl/monostate.hpp +6 -0
- data/rice/stl/monostate.ipp +80 -0
- data/rice/stl/multimap.hpp +14 -0
- data/rice/stl/multimap.ipp +448 -0
- data/rice/stl/optional.hpp +6 -0
- data/rice/stl/optional.ipp +118 -0
- data/rice/stl/pair.hpp +13 -0
- data/rice/stl/pair.ipp +155 -0
- data/rice/stl/reference_wrapper.hpp +6 -0
- data/rice/stl/reference_wrapper.ipp +41 -0
- data/rice/stl/set.hpp +12 -0
- data/rice/stl/set.ipp +495 -0
- data/rice/stl/shared_ptr.hpp +28 -0
- data/rice/stl/shared_ptr.ipp +224 -0
- data/rice/stl/string.hpp +6 -0
- data/rice/stl/string.ipp +158 -0
- data/rice/stl/string_view.hpp +6 -0
- data/rice/stl/string_view.ipp +65 -0
- data/rice/stl/tuple.hpp +6 -0
- data/rice/stl/tuple.ipp +128 -0
- data/rice/stl/type_index.hpp +6 -0
- data/rice/stl/type_index.ipp +30 -0
- data/rice/stl/type_info.hpp +6 -0
- data/rice/stl/type_info.ipp +29 -0
- data/rice/stl/unique_ptr.hpp +22 -0
- data/rice/stl/unique_ptr.ipp +139 -0
- data/rice/stl/unordered_map.hpp +12 -0
- data/rice/stl/unordered_map.ipp +469 -0
- data/rice/stl/variant.hpp +6 -0
- data/rice/stl/variant.ipp +242 -0
- data/rice/stl/vector.hpp +12 -0
- data/rice/stl/vector.ipp +590 -0
- data/rice/stl.hpp +7 -3
- data/rice/traits/attribute_traits.hpp +26 -0
- data/rice/traits/function_traits.hpp +95 -0
- data/rice/traits/method_traits.hpp +47 -0
- data/rice/traits/rice_traits.hpp +160 -0
- data/rice.gemspec +85 -0
- data/test/embed_ruby.cpp +3 -0
- data/test/ruby/test_multiple_extensions_same_class.rb +14 -14
- data/test/test_Array.cpp +6 -3
- data/test/test_Attribute.cpp +34 -1
- data/test/test_Buffer.cpp +285 -0
- data/test/test_Callback.cpp +2 -3
- data/test/test_Data_Object.cpp +88 -34
- data/test/test_Data_Type.cpp +106 -65
- data/test/test_Director.cpp +7 -3
- data/test/test_Enum.cpp +5 -2
- data/test/test_File.cpp +1 -1
- data/test/test_From_Ruby.cpp +181 -114
- data/test/test_Iterator.cpp +1 -1
- data/test/{test_JumpException.cpp → test_Jump_Exception.cpp} +1 -0
- data/test/test_Keep_Alive.cpp +7 -18
- data/test/test_Keep_Alive_No_Wrapper.cpp +0 -1
- data/test/test_Module.cpp +13 -6
- data/test/test_Native_Registry.cpp +0 -1
- data/test/test_Overloads.cpp +180 -5
- data/test/test_Ownership.cpp +100 -57
- data/test/test_Proc.cpp +0 -1
- data/test/test_Self.cpp +4 -4
- data/test/test_Stl_Map.cpp +37 -39
- data/test/test_Stl_Multimap.cpp +693 -0
- data/test/test_Stl_Pair.cpp +8 -8
- data/test/test_Stl_Reference_Wrapper.cpp +4 -2
- data/test/test_Stl_Set.cpp +790 -0
- data/test/{test_Stl_SmartPointer.cpp → test_Stl_SharedPtr.cpp} +97 -127
- data/test/test_Stl_Tuple.cpp +116 -0
- data/test/test_Stl_Type.cpp +1 -1
- data/test/test_Stl_UniquePtr.cpp +202 -0
- data/test/test_Stl_Unordered_Map.cpp +28 -34
- data/test/test_Stl_Variant.cpp +217 -89
- data/test/test_Stl_Vector.cpp +209 -83
- data/test/test_To_Ruby.cpp +373 -1
- data/test/test_Type.cpp +85 -14
- data/test/test_global_functions.cpp +17 -4
- metadata +94 -10
- data/rice/detail/TupleIterator.hpp +0 -14
data/test/test_Stl_Map.cpp
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#include <complex>
|
2
2
|
#include <memory>
|
3
3
|
|
4
4
|
#include "unittest.hpp"
|
@@ -47,9 +47,9 @@ TESTCASE(StringMap)
|
|
47
47
|
{
|
48
48
|
Module m = define_module("Testing");
|
49
49
|
|
50
|
-
Class c = define_map<std::
|
50
|
+
Class c = define_map<std::string, std::string>("StringMap");
|
51
51
|
|
52
|
-
Object map = m.module_eval("$map = StringMap.new");
|
52
|
+
Object map = m.module_eval("$map = Std::StringMap.new");
|
53
53
|
Object result = map.call("size");
|
54
54
|
ASSERT_EQUAL(0, detail::From_Ruby<int32_t>().convert(result));
|
55
55
|
|
@@ -66,8 +66,8 @@ TESTCASE(WrongType)
|
|
66
66
|
{
|
67
67
|
Module m = define_module("Testing");
|
68
68
|
|
69
|
-
Class c = define_map<std::
|
70
|
-
Object map = m.module_eval("$map = StringMap.new");
|
69
|
+
Class c = define_map<std::string, std::string>("StringMap");
|
70
|
+
Object map = m.module_eval("$map = Std::StringMap.new");
|
71
71
|
|
72
72
|
ASSERT_EXCEPTION_CHECK(
|
73
73
|
Exception,
|
@@ -84,7 +84,7 @@ TESTCASE(Empty)
|
|
84
84
|
{
|
85
85
|
Module m = define_module("Testing");
|
86
86
|
|
87
|
-
Class c = define_map<std::
|
87
|
+
Class c = define_map<std::string, std::int32_t>("IntMap");
|
88
88
|
Object map = c.call("new");
|
89
89
|
|
90
90
|
Object result = map.call("size");
|
@@ -98,10 +98,14 @@ TESTCASE(Include)
|
|
98
98
|
{
|
99
99
|
Module m = define_module("Testing");
|
100
100
|
|
101
|
-
Class c = define_map<std::
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
Class c = define_map<std::string, std::int32_t>("IntMap");
|
102
|
+
|
103
|
+
std::string code = R"(map = Std::IntMap.new
|
104
|
+
map["one"] = 1
|
105
|
+
map["two"] = 2
|
106
|
+
map)";
|
107
|
+
|
108
|
+
Object map = m.module_eval(code);
|
105
109
|
|
106
110
|
Object result = map.call("include?", "two");
|
107
111
|
ASSERT_EQUAL(Qtrue, result.value());
|
@@ -117,7 +121,7 @@ TESTCASE(Value)
|
|
117
121
|
{
|
118
122
|
Module m = define_module("Testing");
|
119
123
|
|
120
|
-
Class c = define_map<std::
|
124
|
+
Class c = define_map<std::string, std::int32_t>("IntMap");
|
121
125
|
Object map = c.call("new");
|
122
126
|
map.call("[]=", "one", 1);
|
123
127
|
map.call("[]=", "two", 2);
|
@@ -133,7 +137,7 @@ TESTCASE(ToString)
|
|
133
137
|
{
|
134
138
|
Module m = define_module("Testing");
|
135
139
|
|
136
|
-
Class c = define_map<std::
|
140
|
+
Class c = define_map<std::string, std::int32_t>("IntMap");
|
137
141
|
Object map = c.call("new");
|
138
142
|
map.call("[]=", "one", 1);
|
139
143
|
map.call("[]=", "two", 2);
|
@@ -151,7 +155,7 @@ TESTCASE(Update)
|
|
151
155
|
{
|
152
156
|
Module m = define_module("Testing");
|
153
157
|
|
154
|
-
Class c = define_map<std::
|
158
|
+
Class c = define_map<std::string, std::string>("StringMap");
|
155
159
|
Object map = c.call("new");
|
156
160
|
map.call("[]=", "one", "original 1");
|
157
161
|
map.call("[]=", "two", "original 2");
|
@@ -173,7 +177,7 @@ TESTCASE(Modify)
|
|
173
177
|
{
|
174
178
|
Module m = define_module("Testing");
|
175
179
|
|
176
|
-
Class c = define_map<std::
|
180
|
+
Class c = define_map<std::string, int64_t>("Int64Map");
|
177
181
|
Object map = c.call("new");
|
178
182
|
|
179
183
|
Object result = map.call("[]=", "one", 3232323232);
|
@@ -192,7 +196,7 @@ TESTCASE(keysAndValues)
|
|
192
196
|
{
|
193
197
|
Module m = define_module("Testing");
|
194
198
|
|
195
|
-
Class c = define_map<std::
|
199
|
+
Class c = define_map<std::string, int32_t>("Int32Map");
|
196
200
|
Object map = c.call("new");
|
197
201
|
|
198
202
|
map.call("[]=", "one", 1);
|
@@ -220,7 +224,7 @@ TESTCASE(Copy)
|
|
220
224
|
{
|
221
225
|
Module m = define_module("Testing");
|
222
226
|
|
223
|
-
Class c = define_map<std::
|
227
|
+
Class c = define_map<std::string, double>("DoubleMap");
|
224
228
|
Object object = c.call("new");
|
225
229
|
|
226
230
|
object.call("[]=", "one", 11.1);
|
@@ -241,9 +245,9 @@ TESTCASE(Copy)
|
|
241
245
|
TESTCASE(Iterate)
|
242
246
|
{
|
243
247
|
Module m = define_module("Testing");
|
244
|
-
Class c = define_map<std::
|
248
|
+
Class c = define_map<std::string, int>("IntMap");
|
245
249
|
|
246
|
-
std::string code = R"(map = IntMap.new
|
250
|
+
std::string code = R"(map = Std::IntMap.new
|
247
251
|
map["five"] = 5
|
248
252
|
map["six"] = 6
|
249
253
|
map["seven"] = 7
|
@@ -268,9 +272,9 @@ TESTCASE(Iterate)
|
|
268
272
|
TESTCASE(ToEnum)
|
269
273
|
{
|
270
274
|
Module m = define_module("Testing");
|
271
|
-
Class c = define_map<std::
|
275
|
+
Class c = define_map<std::string, int>("IntMap");
|
272
276
|
|
273
|
-
std::string code = R"(map = IntMap.new
|
277
|
+
std::string code = R"(map = Std::IntMap.new
|
274
278
|
map["five"] = 5
|
275
279
|
map["six"] = 6
|
276
280
|
map["seven"] = 7
|
@@ -296,9 +300,9 @@ TESTCASE(ToEnum)
|
|
296
300
|
TESTCASE(ToEnumSize)
|
297
301
|
{
|
298
302
|
Module m = define_module("TestingModule");
|
299
|
-
Class c = define_map<std::
|
303
|
+
Class c = define_map<std::string, int>("IntMap");
|
300
304
|
|
301
|
-
std::string code = R"(map = IntMap.new
|
305
|
+
std::string code = R"(map = Std::IntMap.new
|
302
306
|
map["five"] = 5
|
303
307
|
map["six"] = 6
|
304
308
|
map["seven"] = 7
|
@@ -332,7 +336,7 @@ TESTCASE(NotComparable)
|
|
332
336
|
define_class<NotComparable>("NotComparable").
|
333
337
|
define_constructor(Constructor<NotComparable, uint32_t>());
|
334
338
|
|
335
|
-
Class c = define_map<std::
|
339
|
+
Class c = define_map<std::string, NotComparable>("NotComparableMap");
|
336
340
|
|
337
341
|
Object map = c.call("new");
|
338
342
|
map.call("[]=", "one", NotComparable(1));
|
@@ -351,7 +355,7 @@ TESTCASE(NotPrintable)
|
|
351
355
|
define_class<NotComparable>("NotComparable").
|
352
356
|
define_constructor(Constructor<NotComparable, uint32_t>());
|
353
357
|
|
354
|
-
Class c = define_map<std::
|
358
|
+
Class c = define_map<std::string, NotComparable>("NotComparableMap");
|
355
359
|
|
356
360
|
Object map = c.call("new");
|
357
361
|
map.call("[]=", "one", NotComparable(1));
|
@@ -372,7 +376,7 @@ namespace
|
|
372
376
|
{
|
373
377
|
};
|
374
378
|
|
375
|
-
bool operator==(const Comparable& other)
|
379
|
+
bool operator==(const Comparable& other) const
|
376
380
|
{
|
377
381
|
return this->value_ == other.value_;
|
378
382
|
}
|
@@ -392,7 +396,7 @@ TESTCASE(Comparable)
|
|
392
396
|
define_class<Comparable>("IsComparable").
|
393
397
|
define_constructor(Constructor<Comparable, uint32_t>());
|
394
398
|
|
395
|
-
Class c = define_map<std::
|
399
|
+
Class c = define_map<std::string, Comparable>("ComparableMap");
|
396
400
|
|
397
401
|
Object map = c.call("new");
|
398
402
|
|
@@ -409,7 +413,7 @@ TESTCASE(Printable)
|
|
409
413
|
define_class<Comparable>("IsComparable").
|
410
414
|
define_constructor(Constructor<Comparable, uint32_t>());
|
411
415
|
|
412
|
-
Class c = define_map<std::
|
416
|
+
Class c = define_map<std::string, Comparable>("ComparableMap");
|
413
417
|
|
414
418
|
Object map = c.call("new");
|
415
419
|
map.call("[]=", "one", Comparable(1));
|
@@ -447,7 +451,7 @@ TESTCASE(AutoRegisterReturn)
|
|
447
451
|
|
448
452
|
Module m = define_module("Testing");
|
449
453
|
Object map = m.module_eval("return_complex_map");
|
450
|
-
ASSERT_EQUAL(
|
454
|
+
ASSERT_EQUAL("Std::Map≺string‚ complex≺double≻≻",
|
451
455
|
map.class_name().str());
|
452
456
|
|
453
457
|
std::string code = R"(map = return_complex_map
|
@@ -458,14 +462,8 @@ TESTCASE(AutoRegisterReturn)
|
|
458
462
|
ASSERT_EQUAL(Qtrue, result.value());
|
459
463
|
|
460
464
|
// Now register the map again
|
461
|
-
define_map<std::
|
462
|
-
code = R"(map = ComplexMap.new)";
|
463
|
-
result = m.module_eval(code);
|
464
|
-
ASSERT(result.is_instance_of(map.class_of()));
|
465
|
-
|
466
|
-
// And again in the module
|
467
|
-
define_map_under<std::map<std::string, std::complex<double>>>(m, "ComplexMap2");
|
468
|
-
code = R"(map = Testing::ComplexMap2.new)";
|
465
|
+
define_map<std::string, std::complex<double>>("ComplexMap");
|
466
|
+
code = R"(map = Std::ComplexMap.new)";
|
469
467
|
result = m.module_eval(code);
|
470
468
|
ASSERT(result.is_instance_of(map.class_of()));
|
471
469
|
}
|
@@ -474,7 +472,7 @@ TESTCASE(AutoRegisterParameter)
|
|
474
472
|
{
|
475
473
|
define_global_function("pass_complex_map", &passComplexMap);
|
476
474
|
|
477
|
-
std::string code =
|
475
|
+
std::string code = R"(map = Std::Map≺string‚ complex≺double≻≻.new
|
478
476
|
map["four"] = Complex(4.0, 4.0)
|
479
477
|
map["five"] = Complex(5.0, 5.0)
|
480
478
|
pass_complex_map(map))";
|
@@ -483,7 +481,7 @@ TESTCASE(AutoRegisterParameter)
|
|
483
481
|
Object map = m.module_eval(code);
|
484
482
|
|
485
483
|
Object result = map.call("size");
|
486
|
-
ASSERT_EQUAL(
|
484
|
+
ASSERT_EQUAL("Std::Map≺string‚ complex≺double≻≻",
|
487
485
|
map.class_name().str());
|
488
486
|
ASSERT_EQUAL(2, detail::From_Ruby<int32_t>().convert(result));
|
489
487
|
|
@@ -502,7 +500,7 @@ namespace
|
|
502
500
|
|
503
501
|
TESTCASE(DefaultValue)
|
504
502
|
{
|
505
|
-
define_map<std::
|
503
|
+
define_map<std::string, std::string>("StringMap");
|
506
504
|
define_global_function("default_map", &defaultMap, Arg("strings") = std::map<std::string, std::string>{ {"one", "value 1"}, {"two", "value 2"}, {"three", "value 3"} });
|
507
505
|
|
508
506
|
Module m = define_module("Testing");
|