rice 4.6.1 → 4.7.1

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 (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/CMakeLists.txt +0 -4
  4. data/Rakefile +2 -8
  5. data/bin/rice-doc.rb +211 -0
  6. data/bin/rice-rbs.rb +92 -0
  7. data/include/rice/rice.hpp +4694 -3704
  8. data/include/rice/stl.hpp +840 -294
  9. data/lib/rice/doc/cpp_reference.rb +166 -0
  10. data/lib/rice/doc/doxygen.rb +294 -0
  11. data/lib/rice/doc/mkdocs.rb +298 -0
  12. data/lib/rice/doc/rice.rb +29 -0
  13. data/lib/rice/doc/ruby.rb +37 -0
  14. data/lib/rice/doc.rb +5 -0
  15. data/lib/{make_rice_headers.rb → rice/make_rice_headers.rb} +3 -0
  16. data/lib/rice/native.rb +18 -0
  17. data/lib/rice/native_registry.rb +21 -0
  18. data/lib/rice/parameter.rb +7 -0
  19. data/lib/rice/rbs.rb +104 -0
  20. data/lib/rice/version.rb +1 -1
  21. data/lib/rice.rb +4 -0
  22. data/lib/rubygems/cmake_builder.rb +24 -27
  23. data/rice/Arg.hpp +4 -4
  24. data/rice/Arg.ipp +4 -4
  25. data/rice/Buffer.hpp +32 -28
  26. data/rice/Buffer.ipp +306 -178
  27. data/rice/Data_Object.ipp +136 -88
  28. data/rice/Data_Type.hpp +5 -7
  29. data/rice/Data_Type.ipp +48 -29
  30. data/rice/Enum.ipp +15 -21
  31. data/rice/Function.hpp +17 -0
  32. data/rice/Function.ipp +13 -0
  33. data/rice/Pointer.hpp +15 -0
  34. data/rice/Pointer.ipp +49 -0
  35. data/rice/Return.hpp +1 -1
  36. data/rice/Return.ipp +2 -2
  37. data/rice/api.hpp +30 -0
  38. data/rice/cpp_api/Array.hpp +4 -4
  39. data/rice/cpp_api/Array.ipp +50 -5
  40. data/rice/cpp_api/Class.hpp +0 -5
  41. data/rice/cpp_api/Class.ipp +19 -0
  42. data/rice/cpp_api/Hash.ipp +20 -0
  43. data/rice/cpp_api/Module.hpp +6 -3
  44. data/rice/cpp_api/Module.ipp +49 -11
  45. data/rice/cpp_api/Object.ipp +31 -2
  46. data/rice/cpp_api/String.hpp +1 -2
  47. data/rice/cpp_api/String.ipp +21 -1
  48. data/rice/cpp_api/Struct.ipp +5 -0
  49. data/rice/cpp_api/Symbol.ipp +43 -0
  50. data/rice/cpp_api/shared_methods.hpp +12 -12
  51. data/rice/detail/MethodInfo.hpp +4 -2
  52. data/rice/detail/MethodInfo.ipp +19 -3
  53. data/rice/detail/ModuleRegistry.hpp +18 -0
  54. data/rice/detail/ModuleRegistry.ipp +25 -0
  55. data/rice/detail/Native.hpp +45 -2
  56. data/rice/detail/Native.ipp +196 -6
  57. data/rice/detail/NativeAttributeGet.hpp +9 -4
  58. data/rice/detail/NativeAttributeGet.ipp +65 -11
  59. data/rice/detail/NativeAttributeSet.hpp +4 -0
  60. data/rice/detail/NativeAttributeSet.ipp +30 -2
  61. data/rice/detail/NativeCallbackFFI.ipp +2 -2
  62. data/rice/detail/NativeCallbackSimple.ipp +1 -1
  63. data/rice/detail/NativeFunction.hpp +11 -49
  64. data/rice/detail/NativeFunction.ipp +82 -379
  65. data/rice/detail/NativeInvoker.hpp +74 -0
  66. data/rice/detail/NativeInvoker.ipp +197 -0
  67. data/rice/detail/NativeIterator.hpp +4 -0
  68. data/rice/detail/NativeIterator.ipp +19 -0
  69. data/rice/detail/NativeMethod.hpp +97 -0
  70. data/rice/detail/NativeMethod.ipp +332 -0
  71. data/rice/detail/NativeProc.hpp +51 -0
  72. data/rice/detail/NativeProc.ipp +133 -0
  73. data/rice/detail/NativeRegistry.hpp +8 -0
  74. data/rice/detail/NativeRegistry.ipp +26 -0
  75. data/rice/detail/Parameter.hpp +47 -0
  76. data/rice/detail/Parameter.ipp +105 -0
  77. data/rice/detail/Proc.ipp +14 -13
  78. data/rice/detail/Registries.hpp +1 -0
  79. data/rice/detail/RubyType.hpp +0 -2
  80. data/rice/detail/RubyType.ipp +15 -33
  81. data/rice/detail/Type.hpp +44 -8
  82. data/rice/detail/Type.ipp +151 -49
  83. data/rice/detail/TypeRegistry.hpp +3 -0
  84. data/rice/detail/TypeRegistry.ipp +17 -27
  85. data/rice/detail/Types.ipp +430 -0
  86. data/rice/detail/Wrapper.hpp +12 -0
  87. data/rice/detail/Wrapper.ipp +45 -2
  88. data/rice/detail/from_ruby.ipp +567 -1073
  89. data/rice/detail/ruby.hpp +1 -0
  90. data/rice/detail/to_ruby.ipp +4 -635
  91. data/rice/libc/file.ipp +3 -6
  92. data/rice/rice.hpp +22 -12
  93. data/rice/rice_api/Arg.hpp +7 -0
  94. data/rice/rice_api/Arg.ipp +9 -0
  95. data/rice/rice_api/ModuleRegistry.hpp +7 -0
  96. data/rice/rice_api/ModuleRegistry.ipp +10 -0
  97. data/rice/rice_api/Native.hpp +7 -0
  98. data/rice/rice_api/Native.ipp +52 -0
  99. data/rice/rice_api/NativeRegistry.hpp +7 -0
  100. data/rice/rice_api/NativeRegistry.ipp +21 -0
  101. data/rice/rice_api/Parameter.hpp +7 -0
  102. data/rice/rice_api/Parameter.ipp +11 -0
  103. data/rice/rice_api/Registries.hpp +6 -0
  104. data/rice/rice_api/Registries.ipp +12 -0
  105. data/rice/rice_api/TypeRegistry.hpp +7 -0
  106. data/rice/rice_api/TypeRegistry.ipp +10 -0
  107. data/rice/stl/complex.ipp +35 -0
  108. data/rice/stl/exception.ipp +20 -7
  109. data/rice/stl/filesystem.hpp +6 -0
  110. data/rice/stl/filesystem.ipp +34 -0
  111. data/rice/stl/map.ipp +13 -21
  112. data/rice/stl/monostate.ipp +37 -1
  113. data/rice/stl/multimap.ipp +17 -24
  114. data/rice/stl/optional.ipp +47 -2
  115. data/rice/stl/pair.ipp +23 -58
  116. data/rice/stl/reference_wrapper.ipp +22 -1
  117. data/rice/stl/set.ipp +17 -9
  118. data/rice/stl/shared_ptr.ipp +44 -17
  119. data/rice/stl/string.ipp +175 -7
  120. data/rice/stl/string_view.ipp +23 -0
  121. data/rice/stl/tuple.ipp +38 -9
  122. data/rice/stl/unique_ptr.ipp +46 -2
  123. data/rice/stl/unordered_map.ipp +13 -21
  124. data/rice/stl/variant.ipp +47 -11
  125. data/rice/stl/vector.ipp +183 -104
  126. data/rice/stl.hpp +1 -0
  127. data/rice/traits/function_traits.hpp +2 -2
  128. data/rice/traits/method_traits.hpp +5 -16
  129. data/rice/traits/rice_traits.hpp +24 -4
  130. data/rice.gemspec +10 -22
  131. data/test/embed_ruby.cpp +0 -3
  132. data/test/test_Array.cpp +38 -38
  133. data/test/test_Attribute.cpp +187 -2
  134. data/test/test_Buffer.cpp +302 -26
  135. data/test/test_Callback.cpp +2 -3
  136. data/test/test_Class.cpp +5 -5
  137. data/test/test_Data_Object.cpp +1 -56
  138. data/test/test_Data_Type.cpp +20 -30
  139. data/test/test_Enum.cpp +4 -46
  140. data/test/test_From_Ruby.cpp +89 -82
  141. data/test/test_GVL.cpp +109 -0
  142. data/test/test_Iterator.cpp +1 -1
  143. data/test/test_Keep_Alive_No_Wrapper.cpp +5 -3
  144. data/test/test_Module.cpp +8 -9
  145. data/test/test_Object.cpp +1 -1
  146. data/test/test_Overloads.cpp +58 -10
  147. data/test/test_Stl_Map.cpp +8 -8
  148. data/test/test_Stl_Multimap.cpp +4 -4
  149. data/test/test_Stl_Pair.cpp +5 -3
  150. data/test/test_Stl_SharedPtr.cpp +24 -12
  151. data/test/test_Stl_String_View.cpp +10 -0
  152. data/test/test_Stl_Tuple.cpp +1 -1
  153. data/test/test_Stl_UniquePtr.cpp +8 -0
  154. data/test/test_Stl_Unordered_Map.cpp +9 -9
  155. data/test/test_Stl_Variant.cpp +9 -3
  156. data/test/test_Stl_Vector.cpp +118 -13
  157. data/test/test_Symbol.cpp +12 -0
  158. data/test/test_To_Ruby.cpp +35 -28
  159. data/test/test_Type.cpp +256 -53
  160. data/test/unittest.hpp +35 -0
  161. metadata +52 -34
  162. data/rice/Init.hpp +0 -8
  163. data/rice/Init.ipp +0 -8
  164. data/rice/detail/RubyFunction.hpp +0 -31
  165. data/rice/detail/RubyFunction.ipp +0 -77
  166. data/sample/callbacks/extconf.rb +0 -5
  167. data/sample/callbacks/sample_callbacks.cpp +0 -35
  168. data/sample/callbacks/test.rb +0 -28
  169. data/sample/enum/extconf.rb +0 -5
  170. data/sample/enum/sample_enum.cpp +0 -40
  171. data/sample/enum/test.rb +0 -8
  172. data/sample/inheritance/animals.cpp +0 -82
  173. data/sample/inheritance/extconf.rb +0 -5
  174. data/sample/inheritance/test.rb +0 -7
  175. data/sample/map/extconf.rb +0 -5
  176. data/sample/map/map.cpp +0 -73
  177. data/sample/map/test.rb +0 -7
  178. data/test/ext/t1/Foo.hpp +0 -10
  179. data/test/ext/t1/extconf.rb +0 -4
  180. data/test/ext/t1/t1.cpp +0 -13
  181. data/test/ext/t2/extconf.rb +0 -4
  182. data/test/ext/t2/t2.cpp +0 -11
  183. data/test/ruby/test_callbacks_sample.rb +0 -28
  184. data/test/ruby/test_multiple_extensions.rb +0 -18
  185. data/test/ruby/test_multiple_extensions_same_class.rb +0 -14
  186. data/test/ruby/test_multiple_extensions_with_inheritance.rb +0 -20
  187. /data/test/{test_Stl_Type.cpp → test_Stl_Type_Info.cpp} +0 -0
@@ -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,6 +65,22 @@ TESTCASE(StringVector)
65
65
  result = vec.call("last");
66
66
  ASSERT_EQUAL("four", detail::From_Ruby<std::string>().convert(result));
67
67
  }
68
+ */
69
+ TESTCASE(StringVectorData)
70
+ {
71
+ Module m = define_module("Testing");
72
+ define_vector<std::string>();
73
+
74
+ std::string code = R"(vec = Std::Vector≺string≻.new
75
+ vec.push("Hello")
76
+ vec.push("World")
77
+ buffer = Rice::Buffer≺string≻.new(vec.data, vec.size())
78
+ [buffer[0], buffer[1]])";
79
+ Array array = m.module_eval(code);
80
+ ASSERT_EQUAL(2, array.size());
81
+ ASSERT_EQUAL("Hello", detail::From_Ruby<std::string>().convert(array[0].value()).c_str());
82
+ ASSERT_EQUAL("World", detail::From_Ruby<std::string>().convert(array[1].value()).c_str());
83
+ }
68
84
 
69
85
  TESTCASE(Constructors)
70
86
  {
@@ -171,6 +187,7 @@ TESTCASE(BoolVector)
171
187
  ASSERT_EQUAL(Qtrue, result.value());
172
188
 
173
189
  result = vec.call("[]=", 1, false);
190
+ result = vec.call("[]", 1);
174
191
  ASSERT_EQUAL(Qfalse, result.value());
175
192
 
176
193
  std::string code = R"(array = self.each.to_a
@@ -224,10 +241,30 @@ TESTCASE(Indexing)
224
241
  ASSERT_EQUAL(0, detail::From_Ruby<int32_t>().convert(result));
225
242
 
226
243
  result = vec.call("[]", -4);
227
- ASSERT_EQUAL(2, detail::From_Ruby<int32_t>().convert(result));
244
+ ASSERT_EQUAL(Qnil, result.value());
228
245
 
229
246
  result = vec.call("[]", -7);
230
- ASSERT_EQUAL(2, detail::From_Ruby<int32_t>().convert(result));
247
+ ASSERT_EQUAL(Qnil, result.value());
248
+ }
249
+
250
+ TESTCASE(IndexingEmptyVector)
251
+ {
252
+ Module m = define_module("Testing");
253
+
254
+ Class c = define_vector<std::int32_t>("IntVector");
255
+ Object vec = c.call("new");
256
+
257
+ Object result = vec.call("size");
258
+ ASSERT_EQUAL(0, detail::From_Ruby<int32_t>().convert(result));
259
+
260
+ result = vec.call("[]", 0);
261
+ ASSERT_EQUAL(Qnil, result.value());
262
+
263
+ result = vec.call("[]", 1);
264
+ ASSERT_EQUAL(Qnil, result.value());
265
+
266
+ result = vec.call("[]", -1);
267
+ ASSERT_EQUAL(Qnil, result.value());
231
268
  }
232
269
 
233
270
  TESTCASE(Slice)
@@ -312,8 +349,7 @@ TESTCASE(Update)
312
349
  Object result = vec.call("size");
313
350
  ASSERT_EQUAL(2, detail::From_Ruby<int32_t>().convert(result));
314
351
 
315
- result = vec.call("[]=", 1, "new 2");
316
- ASSERT_EQUAL("new 2", detail::From_Ruby<std::string>().convert(result));
352
+ vec.call("[]=", 1, "new 2");
317
353
 
318
354
  result = vec.call("[]", 1);
319
355
  ASSERT_EQUAL("new 2", detail::From_Ruby<std::string>().convert(result));
@@ -346,21 +382,35 @@ TESTCASE(Modify)
346
382
  result = vec.call("to_s");
347
383
  ASSERT_EQUAL("[11, 33, 22]", detail::From_Ruby<std::string>().convert(result));
348
384
 
385
+ result = vec.call("insert", -2, 34);
386
+
387
+ result = vec.call("size");
388
+ ASSERT_EQUAL(4, detail::From_Ruby<int32_t>().convert(result));
389
+
390
+ result = vec.call("to_s");
391
+ ASSERT_EQUAL("[11, 33, 34, 22]", detail::From_Ruby<std::string>().convert(result));
392
+
349
393
  result = vec.call("delete", 11);
350
394
  ASSERT_EQUAL(11, detail::From_Ruby<int64_t>().convert(result));
351
395
 
352
396
  result = vec.call("size");
353
- ASSERT_EQUAL(2, detail::From_Ruby<int32_t>().convert(result));
397
+ ASSERT_EQUAL(3, detail::From_Ruby<int32_t>().convert(result));
354
398
 
355
399
  result = vec.call("delete_at", 0);
356
400
  ASSERT_EQUAL(33, detail::From_Ruby<int64_t>().convert(result));
357
401
 
358
402
  result = vec.call("size");
359
- ASSERT_EQUAL(1, detail::From_Ruby<int32_t>().convert(result));
403
+ ASSERT_EQUAL(2, detail::From_Ruby<int32_t>().convert(result));
360
404
 
361
405
  result = vec.call("pop");
362
406
  ASSERT_EQUAL(22, detail::From_Ruby<int64_t>().convert(result));
363
407
 
408
+ result = vec.call("size");
409
+ ASSERT_EQUAL(1, detail::From_Ruby<int32_t>().convert(result));
410
+
411
+ result = vec.call("pop");
412
+ ASSERT_EQUAL(34, detail::From_Ruby<int32_t>().convert(result));
413
+
364
414
  result = vec.call("size");
365
415
  ASSERT_EQUAL(0, detail::From_Ruby<int32_t>().convert(result));
366
416
 
@@ -390,6 +440,44 @@ TESTCASE(Clone)
390
440
  ASSERT_NOT_EQUAL(vec.size(), vecClone.size());
391
441
  }
392
442
 
443
+
444
+ namespace
445
+ {
446
+ class SomeClass
447
+ {
448
+ public:
449
+ SomeClass(int value) : value(value)
450
+ {
451
+ }
452
+ int value;
453
+ };
454
+
455
+ std::vector<std::unique_ptr<SomeClass>> uniqueVector()
456
+ {
457
+ std::vector<std::unique_ptr<SomeClass>> result;
458
+ result.push_back(std::make_unique<SomeClass>(1));
459
+ result.push_back(std::make_unique<SomeClass>(2));
460
+ return result;
461
+ }
462
+ }
463
+
464
+ TESTCASE(UniqueVector)
465
+ {
466
+ Module m(anonymous_module());
467
+
468
+ Class c = define_class<SomeClass>("SomeClass").
469
+ define_constructor(Constructor<SomeClass, int>()).
470
+ define_attr("value", &SomeClass::value);
471
+
472
+ m.define_module_function("unique_vector", &uniqueVector);
473
+
474
+ std::string code = R"(vector = unique_vector
475
+ vector.size)";
476
+
477
+ Object result = m.module_eval(code);
478
+ ASSERT_EQUAL(2, detail::From_Ruby<int32_t>().convert(result));
479
+ }
480
+
393
481
  namespace
394
482
  {
395
483
  class NotComparable
@@ -637,9 +725,9 @@ TESTCASE(AutoRegisterParameter)
637
725
  define_global_function("pass_complex_vector", &passComplexVector);
638
726
 
639
727
  std::string code = R"(vector = Std::Vector≺complex≺double≻≻.new
640
- vector << Complex(4.0, 4.0)
641
- vector << Complex(5.0, 5.0)
642
- pass_complex_vector(vector))";
728
+ vector << Complex(4.0, 4.0)
729
+ vector << Complex(5.0, 5.0)
730
+ pass_complex_vector(vector))";
643
731
 
644
732
  Module m = define_module("Testing");
645
733
  Object vec = m.module_eval(code);
@@ -653,6 +741,24 @@ TESTCASE(AutoRegisterParameter)
653
741
  ASSERT_EQUAL(complexes[1], std::complex<double>(5, 5));
654
742
  }
655
743
 
744
+ TESTCASE(AutoRegisterException)
745
+ {
746
+ std::string code = R"(
747
+ begin
748
+ Std::Vector≺complex≺double≻≻.new('!!!!')
749
+ rescue => e
750
+ name = e.class.name
751
+ "#{e.class.name} #{e.message} #{(e.backtrace || []).join("\n")}" # shoud not raise 'incompatible character encodings: BINARY (ASCII-8BIT) and UTF-8' ?
752
+ end
753
+ "reachable! - #{name}"
754
+ )";
755
+
756
+ Module m = define_module("Testing");
757
+ Object result = m.module_eval(code);
758
+ std::string actual = detail::From_Ruby<std::string>().convert(result);
759
+ ASSERT_EQUAL("reachable! - ArgumentError", actual);
760
+ }
761
+
656
762
  namespace
657
763
  {
658
764
  std::vector<std::string> defaultVector(std::vector<std::string> strings = {"one", "two", "three"})
@@ -1005,9 +1111,8 @@ TESTCASE(StringPointerVector)
1005
1111
  ASSERT_EQUAL(expected, *actual);
1006
1112
 
1007
1113
  std::string code = R"(vec = vector_of_string_pointers
1008
- outer_buffer = vec.data
1009
- inner_buffers = outer_buffer.to_ary(2)
1010
- inner_buffer = inner_buffers[1]
1114
+ outer_buffer = vec.data.buffer
1115
+ inner_buffer = Rice::Buffer≺string≻.new(outer_buffer[1])
1011
1116
  inner_buffer.to_ary(1))";
1012
1117
  Array array = m.module_eval(code);
1013
1118
  ASSERT_EQUAL(1, array.size());
data/test/test_Symbol.cpp CHANGED
@@ -73,3 +73,15 @@ TESTCASE(to_id)
73
73
  Symbol symbol("Foo");
74
74
  ASSERT_EQUAL(Identifier("Foo"), symbol.to_id());
75
75
  }
76
+
77
+ namespace
78
+ {
79
+ void testSymbolArg(Object self, Symbol string)
80
+ {
81
+ }
82
+ }
83
+
84
+ TESTCASE(use_symbol_in_wrapped_function)
85
+ {
86
+ define_global_function("test_symbol_arg", &testSymbolArg);
87
+ }
@@ -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
 
@@ -13,7 +13,6 @@ TESTSUITE(ToRuby);
13
13
  SETUP(ToRuby)
14
14
  {
15
15
  embed_ruby();
16
- define_fundamental_buffer_types();
17
16
  }
18
17
 
19
18
  TEARDOWN(ToRuby)
@@ -210,13 +209,20 @@ TESTCASE(unsigned_char_ptr_buffer)
210
209
  .define_attr("data", &Matrix2UnsignedChar::data, Rice::AttrAccess::Read);
211
210
 
212
211
  std::string code = R"(matrix = Matrix2UnsignedChar.new
213
- buffer = matrix.ptr
212
+ buffer = matrix.ptr.buffer
214
213
  buffer.bytes(5))";
215
214
  String buffer = m.module_eval(code);
216
215
  ASSERT_EQUAL("\x1\x2\x3\x4\x5", buffer.str());
217
216
 
218
217
  code = R"(matrix = Matrix2UnsignedChar.new
219
- buffer = matrix.ptr
218
+ ptr = matrix.ptr
219
+ buffer = Rice::Buffer≺unsigned char≻.new(ptr)
220
+ buffer.bytes(5))";
221
+ buffer = m.module_eval(code);
222
+ ASSERT_EQUAL("\x1\x2\x3\x4\x5", buffer.str());
223
+
224
+ code = R"(matrix = Matrix2UnsignedChar.new
225
+ buffer = matrix.ptr.buffer
220
226
  buffer.bytes(0))";
221
227
  buffer = m.module_eval(code);
222
228
  ASSERT_EQUAL("", buffer.str());
@@ -238,7 +244,7 @@ TESTCASE(unsigned_char_ptr_array)
238
244
  .define_method("ptr", &Matrix2UnsignedChar::ptr);
239
245
 
240
246
  std::string code = R"(matrix = Matrix2UnsignedChar.new
241
- buffer = matrix.ptr
247
+ buffer = matrix.ptr.buffer
242
248
  buffer.to_ary(5))";
243
249
 
244
250
  std::vector<unsigned char> expected = std::vector<unsigned char>{ 1,2,3,4,5 };
@@ -247,8 +253,8 @@ TESTCASE(unsigned_char_ptr_array)
247
253
  ASSERT_EQUAL(expected, actual);
248
254
 
249
255
  code = R"(matrix = Matrix2UnsignedChar.new
250
- buffer = matrix.ptr
251
- buffer.to_ary(1))";
256
+ buffer = matrix.ptr.buffer
257
+ buffer.to_ary(1))";
252
258
 
253
259
  expected = std::vector<unsigned char>{ 1 };
254
260
  array = m.module_eval(code);
@@ -266,9 +272,9 @@ TESTCASE(unsigned_char_ptr_ptr_buffer)
266
272
  .define_attr("data", &Matrix3UnsignedChar::data, Rice::AttrAccess::Read);
267
273
 
268
274
  std::string code = R"(matrix = Matrix3UnsignedChar.new
269
- buffer = matrix.ptr
270
- buffer2 = buffer.to_ary(1).first
271
- buffer2.to_ary(5))";
275
+ buffer = matrix.ptr.buffer
276
+ buffer2 = buffer.to_ary(1).first
277
+ buffer2.to_ary(5))";
272
278
  Array array = m.module_eval(code);
273
279
  ASSERT_EQUAL(5, array.size());
274
280
 
@@ -276,7 +282,7 @@ TESTCASE(unsigned_char_ptr_ptr_buffer)
276
282
  std::vector<unsigned char> actual = array.to_vector<unsigned char>();
277
283
  ASSERT_EQUAL(expected, actual);
278
284
  }
279
-
285
+ /*
280
286
  TESTCASE(unsigned_char_ptr_ptr_array)
281
287
  {
282
288
  Module m = define_module("ToRubyPtr");
@@ -286,7 +292,7 @@ TESTCASE(unsigned_char_ptr_ptr_array)
286
292
  .define_method("ptr", &Matrix3UnsignedChar::ptr);
287
293
 
288
294
  std::string code = R"(matrix = Matrix3UnsignedChar.new
289
- buffer = matrix.ptr
295
+ buffer = matrix.ptr.buffer
290
296
  buffer.to_ary(5))";
291
297
 
292
298
  Array pointers = m.module_eval(code);
@@ -312,7 +318,7 @@ TESTCASE(short_ptr_buffer)
312
318
  .define_method("ptr", &Matrix2Short::ptr);
313
319
 
314
320
  std::string code = R"(matrix = Matrix2Short.new
315
- buffer = matrix.ptr
321
+ buffer = matrix.ptr.buffer
316
322
  buffer.bytes(5))";
317
323
 
318
324
  std::string expected = "\x1\0\x2\0\x3\0\x4\0\x5\0"s;
@@ -320,7 +326,7 @@ TESTCASE(short_ptr_buffer)
320
326
  ASSERT_EQUAL(expected, buffer.str());
321
327
 
322
328
  code = R"(matrix = Matrix2Short.new
323
- buffer = matrix.ptr
329
+ buffer = matrix.ptr.buffer
324
330
  buffer.bytes(0))";
325
331
  expected = ""s;
326
332
  buffer = m.module_eval(code);
@@ -336,7 +342,7 @@ TESTCASE(short_ptr_array)
336
342
  .define_method("ptr", &Matrix2Short::ptr);
337
343
 
338
344
  std::string code = R"(matrix = Matrix2Short.new
339
- buffer = matrix.ptr
345
+ buffer = matrix.ptr.buffer
340
346
  buffer.to_ary(5))";
341
347
 
342
348
  std::vector<short> expected = std::vector<short>{1,2,3,4,5};
@@ -354,7 +360,7 @@ TESTCASE(unsigned_short_ptr_buffer)
354
360
  .define_method("ptr", &Matrix2UnsignedShort::ptr);
355
361
 
356
362
  std::string code = R"(matrix = Matrix2UnsignedShort.new
357
- buffer = matrix.ptr
363
+ buffer = matrix.ptr.buffer
358
364
  buffer.bytes(5))";
359
365
 
360
366
  std::string expected = "\x1\0\x2\0\x3\0\x4\0\x5\0"s;
@@ -362,7 +368,7 @@ TESTCASE(unsigned_short_ptr_buffer)
362
368
  ASSERT_EQUAL(expected, buffer.str());
363
369
 
364
370
  code = R"(matrix = Matrix2UnsignedShort.new
365
- buffer = matrix.ptr
371
+ buffer = matrix.ptr.buffer
366
372
  buffer.bytes(0))";
367
373
  expected = ""s;
368
374
  buffer = m.module_eval(code);
@@ -378,7 +384,7 @@ TESTCASE(unsigned_short_ptr_array)
378
384
  .define_method("ptr", &Matrix2UnsignedShort::ptr);
379
385
 
380
386
  std::string code = R"(matrix = Matrix2UnsignedShort.new
381
- buffer = matrix.ptr
387
+ buffer = matrix.ptr.buffer
382
388
  buffer.to_ary(5))";
383
389
 
384
390
  std::vector<unsigned short> expected = std::vector<unsigned short>{ 1,2,3,4,5 };
@@ -396,7 +402,7 @@ TESTCASE(int_ptr_buffer)
396
402
  .define_method("ptr", &Matrix2Int::ptr);
397
403
 
398
404
  std::string code = R"(matrix = Matrix2Int.new
399
- buffer = matrix.ptr
405
+ buffer = matrix.ptr.buffer
400
406
  buffer.bytes(5))";
401
407
 
402
408
  std::string expected = "\x1\0\0\0\x2\0\0\0\x3\0\0\0\x4\0\0\0\x5\0\0\0"s;
@@ -404,7 +410,7 @@ TESTCASE(int_ptr_buffer)
404
410
  ASSERT_EQUAL(expected, buffer.str());
405
411
 
406
412
  code = R"(matrix = Matrix2Int.new
407
- buffer = matrix.ptr
413
+ buffer = matrix.ptr.buffer
408
414
  buffer.bytes(0))";
409
415
  expected = ""s;
410
416
  buffer = m.module_eval(code);
@@ -420,7 +426,7 @@ TESTCASE(int_ptr_array)
420
426
  .define_method("ptr", &Matrix2Int::ptr);
421
427
 
422
428
  std::string code = R"(matrix = Matrix2Int.new
423
- buffer = matrix.ptr
429
+ buffer = matrix.ptr.buffer
424
430
  buffer.to_ary(5))";
425
431
 
426
432
  std::vector<int> expected = std::vector<int>{ 1,2,3,4,5 };
@@ -438,7 +444,7 @@ TESTCASE(float_ptr_buffer)
438
444
  .define_method("ptr", &Matrix2Float::ptr);
439
445
 
440
446
  std::string code = R"(matrix = Matrix2Float.new
441
- buffer = matrix.ptr
447
+ buffer = matrix.ptr.buffer
442
448
  buffer.bytes(5))";
443
449
 
444
450
  std::string expected = "\0\0\x80\x3f\0\0\0\x40\0\0\x40\x40\0\0\x80\x40\0\0\xa0\x40"s;
@@ -446,7 +452,7 @@ TESTCASE(float_ptr_buffer)
446
452
  ASSERT_EQUAL(expected, buffer.str());
447
453
 
448
454
  code = R"(matrix = Matrix2Float.new
449
- buffer = matrix.ptr
455
+ buffer = matrix.ptr.buffer
450
456
  buffer.bytes(0))";
451
457
  expected = ""s;
452
458
  buffer = m.module_eval(code);
@@ -462,7 +468,7 @@ TESTCASE(float_ptr_array)
462
468
  .define_method("ptr", &Matrix2Float::ptr);
463
469
 
464
470
  std::string code = R"(matrix = Matrix2Float.new
465
- buffer = matrix.ptr
471
+ buffer = matrix.ptr.buffer
466
472
  buffer.to_ary(5))";
467
473
 
468
474
  std::vector<float> expected = std::vector<float>{ 1.0,2.0,3.0,4.0,5.0 };
@@ -480,7 +486,7 @@ TESTCASE(double_ptr_buffer)
480
486
  .define_method("ptr", &Matrix2Double::ptr);
481
487
 
482
488
  std::string code = R"(matrix = Matrix2Double.new
483
- buffer = matrix.ptr
489
+ buffer = matrix.ptr.buffer
484
490
  buffer.bytes(5))";
485
491
 
486
492
  std::string expected = "\0\0\0\0\0\0\xf0\x3f\0\0\0\0\0\0\0\x40\0\0\0\0\0\0\x08\x40\0\0\0\0\0\0\x10\x40\0\0\0\0\0\0\x14\x40"s;
@@ -489,7 +495,7 @@ TESTCASE(double_ptr_buffer)
489
495
  ASSERT_EQUAL(expected, buffer.str());
490
496
 
491
497
  code = R"(matrix = Matrix2Double.new
492
- buffer = matrix.ptr
498
+ buffer = matrix.ptr.buffer
493
499
  buffer.bytes(0))";
494
500
  expected = ""s;
495
501
  buffer = m.module_eval(code);
@@ -505,7 +511,7 @@ TESTCASE(double_ptr_array)
505
511
  .define_method("ptr", &Matrix2Double::ptr);
506
512
 
507
513
  std::string code = R"(matrix = Matrix2Double.new
508
- buffer = matrix.ptr
514
+ buffer = matrix.ptr.buffer
509
515
  buffer.to_ary(5))";
510
516
 
511
517
  std::vector<double> expected = std::vector<double>{ 1.0,2.0,3.0,4.0,5.0 };
@@ -514,7 +520,7 @@ TESTCASE(double_ptr_array)
514
520
  ASSERT_EQUAL(expected, actual);
515
521
 
516
522
  code = R"(matrix = Matrix2Double.new
517
- buffer = matrix.ptr
523
+ buffer = matrix.ptr.buffer
518
524
  buffer.to_ary(0))";
519
525
 
520
526
  expected = std::vector<double>{ };
@@ -522,3 +528,4 @@ TESTCASE(double_ptr_array)
522
528
  actual = array.to_vector<double>();
523
529
  ASSERT_EQUAL(expected, actual);
524
530
  }
531
+ */