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.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/CMakeLists.txt +31 -0
  4. data/CMakePresets.json +75 -0
  5. data/COPYING +3 -2
  6. data/FindRuby.cmake +437 -0
  7. data/Rakefile +5 -4
  8. data/include/rice/rice.hpp +5436 -3201
  9. data/include/rice/stl.hpp +2355 -1269
  10. data/lib/make_rice_headers.rb +79 -0
  11. data/lib/mkmf-rice.rb +4 -0
  12. data/lib/rice/version.rb +3 -0
  13. data/lib/rice.rb +1 -0
  14. data/lib/rubygems/builder.rb +11 -0
  15. data/lib/rubygems/cmake_builder.rb +113 -0
  16. data/lib/rubygems_plugin.rb +9 -0
  17. data/rice/Arg.hpp +7 -1
  18. data/rice/Arg.ipp +11 -2
  19. data/rice/Buffer.hpp +123 -0
  20. data/rice/Buffer.ipp +599 -0
  21. data/rice/Constructor.ipp +3 -3
  22. data/rice/Data_Object.hpp +2 -3
  23. data/rice/Data_Object.ipp +188 -188
  24. data/rice/Data_Type.hpp +4 -5
  25. data/rice/Data_Type.ipp +42 -26
  26. data/rice/Enum.hpp +0 -1
  27. data/rice/Enum.ipp +26 -23
  28. data/rice/Init.hpp +8 -0
  29. data/rice/Init.ipp +8 -0
  30. data/rice/MemoryView.ipp +1 -41
  31. data/rice/Return.hpp +1 -1
  32. data/rice/Return.ipp +6 -0
  33. data/rice/cpp_api/Array.hpp +209 -0
  34. data/rice/cpp_api/Array.ipp +304 -0
  35. data/rice/cpp_api/Builtin_Object.hpp +31 -0
  36. data/rice/cpp_api/Builtin_Object.ipp +37 -0
  37. data/rice/cpp_api/Class.hpp +70 -0
  38. data/rice/cpp_api/Class.ipp +97 -0
  39. data/rice/cpp_api/Encoding.hpp +32 -0
  40. data/rice/cpp_api/Encoding.ipp +59 -0
  41. data/rice/cpp_api/Hash.hpp +194 -0
  42. data/rice/cpp_api/Hash.ipp +257 -0
  43. data/rice/cpp_api/Identifier.hpp +46 -0
  44. data/rice/cpp_api/Identifier.ipp +31 -0
  45. data/rice/cpp_api/Module.hpp +72 -0
  46. data/rice/cpp_api/Module.ipp +101 -0
  47. data/rice/cpp_api/Object.hpp +272 -0
  48. data/rice/cpp_api/Object.ipp +235 -0
  49. data/rice/cpp_api/String.hpp +74 -0
  50. data/rice/cpp_api/String.ipp +120 -0
  51. data/rice/cpp_api/Struct.hpp +113 -0
  52. data/rice/cpp_api/Struct.ipp +92 -0
  53. data/rice/cpp_api/Symbol.hpp +46 -0
  54. data/rice/cpp_api/Symbol.ipp +93 -0
  55. data/rice/cpp_api/shared_methods.hpp +134 -0
  56. data/rice/detail/MethodInfo.hpp +1 -9
  57. data/rice/detail/MethodInfo.ipp +5 -72
  58. data/rice/detail/Native.hpp +3 -2
  59. data/rice/detail/Native.ipp +32 -4
  60. data/rice/detail/NativeAttributeGet.hpp +3 -2
  61. data/rice/detail/NativeAttributeGet.ipp +8 -2
  62. data/rice/detail/NativeAttributeSet.hpp +3 -2
  63. data/rice/detail/NativeAttributeSet.ipp +8 -2
  64. data/rice/detail/NativeCallbackFFI.ipp +1 -1
  65. data/rice/detail/NativeFunction.hpp +17 -6
  66. data/rice/detail/NativeFunction.ipp +168 -64
  67. data/rice/detail/NativeIterator.hpp +3 -2
  68. data/rice/detail/NativeIterator.ipp +8 -2
  69. data/rice/detail/RubyType.hpp +2 -5
  70. data/rice/detail/RubyType.ipp +50 -5
  71. data/rice/detail/Type.hpp +3 -1
  72. data/rice/detail/Type.ipp +61 -31
  73. data/rice/detail/Wrapper.hpp +68 -33
  74. data/rice/detail/Wrapper.ipp +103 -113
  75. data/rice/detail/from_ruby.hpp +5 -4
  76. data/rice/detail/from_ruby.ipp +737 -365
  77. data/rice/detail/to_ruby.ipp +1092 -186
  78. data/rice/global_function.ipp +1 -1
  79. data/rice/libc/file.hpp +11 -0
  80. data/rice/libc/file.ipp +32 -0
  81. data/rice/rice.hpp +23 -16
  82. data/rice/stl/complex.hpp +6 -0
  83. data/rice/stl/complex.ipp +93 -0
  84. data/rice/stl/exception.hpp +11 -0
  85. data/rice/stl/exception.ipp +29 -0
  86. data/rice/stl/exception_ptr.hpp +6 -0
  87. data/rice/stl/exception_ptr.ipp +27 -0
  88. data/rice/stl/map.hpp +12 -0
  89. data/rice/stl/map.ipp +469 -0
  90. data/rice/stl/monostate.hpp +6 -0
  91. data/rice/stl/monostate.ipp +80 -0
  92. data/rice/stl/multimap.hpp +14 -0
  93. data/rice/stl/multimap.ipp +448 -0
  94. data/rice/stl/optional.hpp +6 -0
  95. data/rice/stl/optional.ipp +118 -0
  96. data/rice/stl/pair.hpp +13 -0
  97. data/rice/stl/pair.ipp +155 -0
  98. data/rice/stl/reference_wrapper.hpp +6 -0
  99. data/rice/stl/reference_wrapper.ipp +41 -0
  100. data/rice/stl/set.hpp +12 -0
  101. data/rice/stl/set.ipp +495 -0
  102. data/rice/stl/shared_ptr.hpp +28 -0
  103. data/rice/stl/shared_ptr.ipp +224 -0
  104. data/rice/stl/string.hpp +6 -0
  105. data/rice/stl/string.ipp +158 -0
  106. data/rice/stl/string_view.hpp +6 -0
  107. data/rice/stl/string_view.ipp +65 -0
  108. data/rice/stl/tuple.hpp +6 -0
  109. data/rice/stl/tuple.ipp +128 -0
  110. data/rice/stl/type_index.hpp +6 -0
  111. data/rice/stl/type_index.ipp +30 -0
  112. data/rice/stl/type_info.hpp +6 -0
  113. data/rice/stl/type_info.ipp +29 -0
  114. data/rice/stl/unique_ptr.hpp +22 -0
  115. data/rice/stl/unique_ptr.ipp +139 -0
  116. data/rice/stl/unordered_map.hpp +12 -0
  117. data/rice/stl/unordered_map.ipp +469 -0
  118. data/rice/stl/variant.hpp +6 -0
  119. data/rice/stl/variant.ipp +242 -0
  120. data/rice/stl/vector.hpp +12 -0
  121. data/rice/stl/vector.ipp +590 -0
  122. data/rice/stl.hpp +7 -3
  123. data/rice/traits/attribute_traits.hpp +26 -0
  124. data/rice/traits/function_traits.hpp +95 -0
  125. data/rice/traits/method_traits.hpp +47 -0
  126. data/rice/traits/rice_traits.hpp +160 -0
  127. data/rice.gemspec +85 -0
  128. data/test/embed_ruby.cpp +3 -0
  129. data/test/ruby/test_multiple_extensions_same_class.rb +14 -14
  130. data/test/test_Array.cpp +6 -3
  131. data/test/test_Attribute.cpp +34 -1
  132. data/test/test_Buffer.cpp +285 -0
  133. data/test/test_Callback.cpp +2 -3
  134. data/test/test_Data_Object.cpp +88 -34
  135. data/test/test_Data_Type.cpp +106 -65
  136. data/test/test_Director.cpp +7 -3
  137. data/test/test_Enum.cpp +5 -2
  138. data/test/test_File.cpp +1 -1
  139. data/test/test_From_Ruby.cpp +181 -114
  140. data/test/test_Iterator.cpp +1 -1
  141. data/test/{test_JumpException.cpp → test_Jump_Exception.cpp} +1 -0
  142. data/test/test_Keep_Alive.cpp +7 -18
  143. data/test/test_Keep_Alive_No_Wrapper.cpp +0 -1
  144. data/test/test_Module.cpp +13 -6
  145. data/test/test_Native_Registry.cpp +0 -1
  146. data/test/test_Overloads.cpp +180 -5
  147. data/test/test_Ownership.cpp +100 -57
  148. data/test/test_Proc.cpp +0 -1
  149. data/test/test_Self.cpp +4 -4
  150. data/test/test_Stl_Map.cpp +37 -39
  151. data/test/test_Stl_Multimap.cpp +693 -0
  152. data/test/test_Stl_Pair.cpp +8 -8
  153. data/test/test_Stl_Reference_Wrapper.cpp +4 -2
  154. data/test/test_Stl_Set.cpp +790 -0
  155. data/test/{test_Stl_SmartPointer.cpp → test_Stl_SharedPtr.cpp} +97 -127
  156. data/test/test_Stl_Tuple.cpp +116 -0
  157. data/test/test_Stl_Type.cpp +1 -1
  158. data/test/test_Stl_UniquePtr.cpp +202 -0
  159. data/test/test_Stl_Unordered_Map.cpp +28 -34
  160. data/test/test_Stl_Variant.cpp +217 -89
  161. data/test/test_Stl_Vector.cpp +209 -83
  162. data/test/test_To_Ruby.cpp +373 -1
  163. data/test/test_Type.cpp +85 -14
  164. data/test/test_global_functions.cpp +17 -4
  165. metadata +94 -10
  166. data/rice/detail/TupleIterator.hpp +0 -14
@@ -1,4 +1,4 @@
1
- #include <complex>
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::map<std::string, std::string>>("StringMap");
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::map<std::string, std::string>>("StringMap");
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::map<std::string, std::int32_t>>("IntMap");
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::map<std::string, std::int32_t>>("IntMap");
102
- Object map = c.call("new");
103
- map.call("[]=", "one", 1);
104
- map.call("[]=", "two", 2);
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::map<std::string, std::int32_t>>("IntMap");
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::map<std::string, std::int32_t>>("IntMap");
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::map<std::string, std::string>>("StringMap");
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::map<std::string, int64_t>>("Int64Map");
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::map<std::string, int32_t>>("Int32Map");
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::map<std::string, double>>("DoubleMap");
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::map<std::string, int>>("IntMap");
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::map<std::string, int>>("IntMap");
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::map<std::string, int>>("IntMap");
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::map<std::string, NotComparable>>("NotComparableMap");
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::map<std::string, NotComparable>>("NotComparableMap");
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::map<std::string, Comparable>>("ComparableMap");
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::map<std::string, Comparable>>("ComparableMap");
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(u8"Rice::Std::Map≺string≺char≻‚ complex≺double≻≻",
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::map<std::string, std::complex<double>>>("ComplexMap");
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 = u8R"(map = Rice::Std::Map≺string≺char≻‚ complex≺double≻≻.new
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(u8"Rice::Std::Map≺string≺char≻‚ complex≺double≻≻",
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::map<std::string, std::string>>("StringMap");
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");