rice 4.3.3 → 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 (237) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +86 -26
  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/README.md +7 -2
  8. data/Rakefile +12 -5
  9. data/include/rice/rice.hpp +9522 -4426
  10. data/include/rice/stl.hpp +2831 -1198
  11. data/lib/make_rice_headers.rb +79 -0
  12. data/lib/mkmf-rice.rb +40 -94
  13. data/lib/rice/version.rb +3 -0
  14. data/lib/rice.rb +1 -0
  15. data/lib/rubygems/builder.rb +11 -0
  16. data/lib/rubygems/cmake_builder.rb +113 -0
  17. data/lib/rubygems_plugin.rb +9 -0
  18. data/rice/Address_Registration_Guard.hpp +72 -3
  19. data/rice/Arg.hpp +26 -6
  20. data/rice/Arg.ipp +35 -2
  21. data/rice/Buffer.hpp +123 -0
  22. data/rice/Buffer.ipp +599 -0
  23. data/rice/Callback.hpp +21 -0
  24. data/rice/Callback.ipp +13 -0
  25. data/rice/Constructor.hpp +4 -27
  26. data/rice/Constructor.ipp +79 -0
  27. data/rice/Data_Object.hpp +73 -3
  28. data/rice/Data_Object.ipp +388 -96
  29. data/rice/Data_Type.hpp +214 -3
  30. data/rice/Data_Type.ipp +144 -67
  31. data/rice/Director.hpp +0 -2
  32. data/rice/Enum.hpp +4 -7
  33. data/rice/Enum.ipp +102 -55
  34. data/rice/Exception.hpp +62 -2
  35. data/rice/Exception.ipp +7 -12
  36. data/rice/Init.hpp +8 -0
  37. data/rice/Init.ipp +8 -0
  38. data/rice/JumpException.hpp +44 -0
  39. data/rice/JumpException.ipp +48 -0
  40. data/rice/MemoryView.hpp +11 -0
  41. data/rice/MemoryView.ipp +3 -0
  42. data/rice/Return.hpp +7 -27
  43. data/rice/Return.ipp +13 -13
  44. data/rice/cpp_api/Array.hpp +209 -0
  45. data/rice/cpp_api/Array.ipp +304 -0
  46. data/rice/cpp_api/Builtin_Object.hpp +31 -0
  47. data/rice/cpp_api/Builtin_Object.ipp +37 -0
  48. data/rice/cpp_api/Class.hpp +70 -0
  49. data/rice/cpp_api/Class.ipp +97 -0
  50. data/rice/cpp_api/Encoding.hpp +32 -0
  51. data/rice/cpp_api/Encoding.ipp +59 -0
  52. data/rice/cpp_api/Hash.hpp +194 -0
  53. data/rice/cpp_api/Hash.ipp +257 -0
  54. data/rice/{Identifier.hpp → cpp_api/Identifier.hpp} +2 -6
  55. data/rice/{Identifier.ipp → cpp_api/Identifier.ipp} +4 -2
  56. data/rice/cpp_api/Module.hpp +72 -0
  57. data/rice/cpp_api/Module.ipp +101 -0
  58. data/rice/cpp_api/Object.hpp +272 -0
  59. data/rice/cpp_api/Object.ipp +235 -0
  60. data/rice/cpp_api/String.hpp +74 -0
  61. data/rice/cpp_api/String.ipp +120 -0
  62. data/rice/cpp_api/Struct.hpp +113 -0
  63. data/rice/cpp_api/Struct.ipp +92 -0
  64. data/rice/cpp_api/Symbol.hpp +46 -0
  65. data/rice/cpp_api/Symbol.ipp +93 -0
  66. data/rice/cpp_api/shared_methods.hpp +134 -0
  67. data/rice/detail/DefaultHandler.hpp +12 -0
  68. data/rice/detail/DefaultHandler.ipp +8 -0
  69. data/rice/detail/HandlerRegistry.hpp +5 -35
  70. data/rice/detail/HandlerRegistry.ipp +7 -11
  71. data/rice/detail/InstanceRegistry.hpp +1 -4
  72. data/rice/detail/MethodInfo.hpp +12 -10
  73. data/rice/detail/MethodInfo.ipp +26 -21
  74. data/rice/detail/Native.hpp +33 -0
  75. data/rice/detail/Native.ipp +157 -0
  76. data/rice/detail/NativeAttributeGet.hpp +52 -0
  77. data/rice/detail/NativeAttributeGet.ipp +57 -0
  78. data/rice/detail/NativeAttributeSet.hpp +44 -0
  79. data/rice/detail/NativeAttributeSet.ipp +88 -0
  80. data/rice/detail/NativeCallbackFFI.hpp +55 -0
  81. data/rice/detail/NativeCallbackFFI.ipp +151 -0
  82. data/rice/detail/NativeCallbackSimple.hpp +30 -0
  83. data/rice/detail/NativeCallbackSimple.ipp +29 -0
  84. data/rice/detail/NativeFunction.hpp +33 -23
  85. data/rice/detail/NativeFunction.ipp +309 -70
  86. data/rice/detail/NativeIterator.hpp +9 -11
  87. data/rice/detail/NativeIterator.ipp +33 -31
  88. data/rice/detail/NativeRegistry.hpp +24 -15
  89. data/rice/detail/NativeRegistry.ipp +23 -48
  90. data/rice/detail/Proc.hpp +4 -0
  91. data/rice/detail/Proc.ipp +85 -0
  92. data/rice/detail/Registries.hpp +0 -7
  93. data/rice/detail/Registries.ipp +0 -18
  94. data/rice/detail/RubyFunction.hpp +0 -3
  95. data/rice/detail/RubyFunction.ipp +4 -8
  96. data/rice/detail/RubyType.hpp +16 -0
  97. data/rice/detail/RubyType.ipp +232 -0
  98. data/rice/detail/Type.hpp +7 -6
  99. data/rice/detail/Type.ipp +192 -45
  100. data/rice/detail/TypeRegistry.hpp +15 -7
  101. data/rice/detail/TypeRegistry.ipp +105 -12
  102. data/rice/detail/Wrapper.hpp +68 -32
  103. data/rice/detail/Wrapper.ipp +121 -109
  104. data/rice/detail/cpp_protect.hpp +5 -6
  105. data/rice/detail/default_allocation_func.ipp +0 -2
  106. data/rice/detail/from_ruby.hpp +38 -3
  107. data/rice/detail/from_ruby.ipp +1321 -492
  108. data/rice/detail/ruby.hpp +18 -0
  109. data/rice/detail/to_ruby.hpp +41 -3
  110. data/rice/detail/to_ruby.ipp +1424 -194
  111. data/rice/global_function.hpp +0 -4
  112. data/rice/global_function.ipp +0 -1
  113. data/rice/libc/file.hpp +11 -0
  114. data/rice/libc/file.ipp +32 -0
  115. data/rice/rice.hpp +116 -26
  116. data/rice/ruby_mark.hpp +4 -3
  117. data/rice/stl/complex.hpp +6 -0
  118. data/rice/stl/complex.ipp +93 -0
  119. data/rice/stl/exception.hpp +11 -0
  120. data/rice/stl/exception.ipp +29 -0
  121. data/rice/stl/exception_ptr.hpp +6 -0
  122. data/rice/stl/exception_ptr.ipp +27 -0
  123. data/rice/stl/map.hpp +12 -0
  124. data/rice/stl/map.ipp +469 -0
  125. data/rice/stl/monostate.hpp +6 -0
  126. data/rice/stl/monostate.ipp +80 -0
  127. data/rice/stl/multimap.hpp +14 -0
  128. data/rice/stl/multimap.ipp +448 -0
  129. data/rice/stl/optional.hpp +6 -0
  130. data/rice/stl/optional.ipp +118 -0
  131. data/rice/stl/pair.hpp +13 -0
  132. data/rice/stl/pair.ipp +155 -0
  133. data/rice/stl/reference_wrapper.hpp +6 -0
  134. data/rice/stl/reference_wrapper.ipp +41 -0
  135. data/rice/stl/set.hpp +12 -0
  136. data/rice/stl/set.ipp +495 -0
  137. data/rice/stl/shared_ptr.hpp +28 -0
  138. data/rice/stl/shared_ptr.ipp +224 -0
  139. data/rice/stl/string.hpp +6 -0
  140. data/rice/stl/string.ipp +158 -0
  141. data/rice/stl/string_view.hpp +6 -0
  142. data/rice/stl/string_view.ipp +65 -0
  143. data/rice/stl/tuple.hpp +6 -0
  144. data/rice/stl/tuple.ipp +128 -0
  145. data/rice/stl/type_index.hpp +6 -0
  146. data/rice/stl/type_index.ipp +30 -0
  147. data/rice/stl/type_info.hpp +6 -0
  148. data/rice/stl/type_info.ipp +29 -0
  149. data/rice/stl/unique_ptr.hpp +22 -0
  150. data/rice/stl/unique_ptr.ipp +139 -0
  151. data/rice/stl/unordered_map.hpp +12 -0
  152. data/rice/stl/unordered_map.ipp +469 -0
  153. data/rice/stl/variant.hpp +6 -0
  154. data/rice/stl/variant.ipp +242 -0
  155. data/rice/stl/vector.hpp +12 -0
  156. data/rice/stl/vector.ipp +590 -0
  157. data/rice/stl.hpp +11 -3
  158. data/rice/traits/attribute_traits.hpp +26 -0
  159. data/rice/traits/function_traits.hpp +95 -0
  160. data/rice/traits/method_traits.hpp +47 -0
  161. data/rice/traits/rice_traits.hpp +160 -0
  162. data/rice.gemspec +85 -0
  163. data/test/embed_ruby.cpp +7 -1
  164. data/test/extconf.rb +2 -0
  165. data/test/test_Address_Registration_Guard.cpp +5 -0
  166. data/test/test_Array.cpp +18 -4
  167. data/test/test_Attribute.cpp +136 -21
  168. data/test/test_Buffer.cpp +285 -0
  169. data/test/test_Builtin_Object.cpp +5 -0
  170. data/test/test_Callback.cpp +230 -0
  171. data/test/test_Class.cpp +5 -31
  172. data/test/test_Constructor.cpp +69 -6
  173. data/test/test_Data_Object.cpp +97 -38
  174. data/test/test_Data_Type.cpp +470 -65
  175. data/test/test_Director.cpp +17 -8
  176. data/test/test_Enum.cpp +155 -40
  177. data/test/test_Exception.cpp +235 -0
  178. data/test/test_File.cpp +70 -0
  179. data/test/test_From_Ruby.cpp +609 -0
  180. data/test/test_Hash.cpp +5 -0
  181. data/test/test_Identifier.cpp +5 -0
  182. data/test/test_Inheritance.cpp +6 -1
  183. data/test/test_Iterator.cpp +6 -1
  184. data/test/test_Jump_Exception.cpp +23 -0
  185. data/test/test_Keep_Alive.cpp +13 -19
  186. data/test/test_Keep_Alive_No_Wrapper.cpp +5 -1
  187. data/test/test_Memory_Management.cpp +5 -0
  188. data/test/test_Module.cpp +128 -67
  189. data/test/test_Native_Registry.cpp +2 -34
  190. data/test/test_Object.cpp +5 -0
  191. data/test/test_Overloads.cpp +806 -0
  192. data/test/test_Ownership.cpp +160 -54
  193. data/test/test_Proc.cpp +44 -0
  194. data/test/test_Self.cpp +9 -4
  195. data/test/test_Stl_Exception.cpp +109 -0
  196. data/test/test_Stl_Map.cpp +54 -42
  197. data/test/test_Stl_Multimap.cpp +693 -0
  198. data/test/test_Stl_Optional.cpp +5 -0
  199. data/test/test_Stl_Pair.cpp +14 -9
  200. data/test/test_Stl_Reference_Wrapper.cpp +9 -2
  201. data/test/test_Stl_Set.cpp +790 -0
  202. data/test/test_Stl_SharedPtr.cpp +458 -0
  203. data/test/test_Stl_String.cpp +5 -0
  204. data/test/test_Stl_String_View.cpp +5 -0
  205. data/test/test_Stl_Tuple.cpp +116 -0
  206. data/test/test_Stl_Type.cpp +147 -0
  207. data/test/test_Stl_UniquePtr.cpp +202 -0
  208. data/test/test_Stl_Unordered_Map.cpp +43 -38
  209. data/test/test_Stl_Variant.cpp +217 -84
  210. data/test/test_Stl_Vector.cpp +306 -58
  211. data/test/test_String.cpp +5 -0
  212. data/test/test_Struct.cpp +5 -0
  213. data/test/test_Symbol.cpp +5 -0
  214. data/test/test_Template.cpp +192 -0
  215. data/test/test_To_Ruby.cpp +524 -0
  216. data/test/test_Tracking.cpp +1 -0
  217. data/test/test_Type.cpp +171 -0
  218. data/test/test_global_functions.cpp +67 -7
  219. data/test/unittest.cpp +8 -0
  220. metadata +127 -26
  221. data/lib/version.rb +0 -3
  222. data/rice/Address_Registration_Guard_defn.hpp +0 -79
  223. data/rice/Data_Object_defn.hpp +0 -84
  224. data/rice/Data_Type_defn.hpp +0 -190
  225. data/rice/Exception_defn.hpp +0 -68
  226. data/rice/HandlerRegistration.hpp +0 -15
  227. data/rice/detail/ExceptionHandler.hpp +0 -8
  228. data/rice/detail/ExceptionHandler.ipp +0 -28
  229. data/rice/detail/ExceptionHandler_defn.hpp +0 -77
  230. data/rice/detail/Jump_Tag.hpp +0 -21
  231. data/rice/detail/NativeAttribute.hpp +0 -64
  232. data/rice/detail/NativeAttribute.ipp +0 -112
  233. data/rice/detail/from_ruby_defn.hpp +0 -38
  234. data/rice/detail/to_ruby_defn.hpp +0 -48
  235. data/test/test_Jump_Tag.cpp +0 -17
  236. data/test/test_Stl_SmartPointer.cpp +0 -283
  237. data/test/test_To_From_Ruby.cpp +0 -399
@@ -1,7 +1,6 @@
1
1
  #include "unittest.hpp"
2
2
  #include "embed_ruby.hpp"
3
3
  #include <rice/rice.hpp>
4
- #include <rice/stl.hpp>
5
4
 
6
5
  using namespace Rice;
7
6
 
@@ -60,6 +59,11 @@ SETUP(Keep_Alive)
60
59
  embed_ruby();
61
60
  }
62
61
 
62
+ TEARDOWN(Keep_Alive)
63
+ {
64
+ rb_gc_start();
65
+ }
66
+
63
67
  TESTCASE(test_arg)
64
68
  {
65
69
  define_class<Listener>("Listener")
@@ -107,7 +111,10 @@ namespace
107
111
  {
108
112
  }
109
113
 
110
- std::string name();
114
+ uint32_t index()
115
+ {
116
+ return this->index_;
117
+ }
111
118
 
112
119
  private:
113
120
  Connection& connection_;
@@ -121,20 +128,7 @@ namespace
121
128
  {
122
129
  return Column(*this, index);
123
130
  }
124
-
125
- std::string getName(uint32_t index)
126
- {
127
- return this->prefix_ + std::to_string(index);
128
- }
129
-
130
- private:
131
- std::string prefix_ = "column_";
132
131
  };
133
-
134
- std::string Column::name()
135
- {
136
- return this->connection_.getName(this->index_);
137
- }
138
132
  }
139
133
 
140
134
  Object getColumn(Module& m, uint32_t index)
@@ -146,7 +140,7 @@ Object getColumn(Module& m, uint32_t index)
146
140
  TESTCASE(test_return)
147
141
  {
148
142
  define_class<Column>("Column")
149
- .define_method("name", &Column::name);
143
+ .define_method("index", &Column::index);
150
144
 
151
145
  define_class<Connection>("Connection")
152
146
  .define_constructor(Constructor<Connection>())
@@ -156,6 +150,6 @@ TESTCASE(test_return)
156
150
 
157
151
  Object column = getColumn(m, 3);
158
152
  rb_gc_start();
159
- String name = column.call("name");
160
- ASSERT_EQUAL("column_3", name.c_str());
161
- }
153
+ Object index = column.call("index");
154
+ ASSERT_EQUAL(3, detail::From_Ruby<int>().convert(index));
155
+ }
@@ -1,7 +1,6 @@
1
1
  #include "unittest.hpp"
2
2
  #include "embed_ruby.hpp"
3
3
  #include <rice/rice.hpp>
4
- #include <rice/stl.hpp>
5
4
 
6
5
  using namespace Rice;
7
6
 
@@ -56,6 +55,11 @@ SETUP(Keep_Alive_No_Wrapper)
56
55
  embed_ruby();
57
56
  }
58
57
 
58
+ TEARDOWN(Keep_Alive_No_Wrapper)
59
+ {
60
+ rb_gc_start();
61
+ }
62
+
59
63
  TESTCASE(test_keep_alive_no_wrapper)
60
64
  {
61
65
  define_class<Animal>("Animal")
@@ -11,6 +11,11 @@ SETUP(Memory_Management)
11
11
  embed_ruby();
12
12
  }
13
13
 
14
+ TEARDOWN(Memory_Management)
15
+ {
16
+ rb_gc_start();
17
+ }
18
+
14
19
  namespace
15
20
  {
16
21
  class TestClass {
data/test/test_Module.cpp CHANGED
@@ -1,4 +1,4 @@
1
- #include "unittest.hpp"
1
+ #include "unittest.hpp"
2
2
  #include "embed_ruby.hpp"
3
3
 
4
4
  #include <rice/rice.hpp>
@@ -11,6 +11,12 @@ TESTSUITE(Module);
11
11
  SETUP(Module)
12
12
  {
13
13
  embed_ruby();
14
+ define_fundamental_buffer_types();
15
+ }
16
+
17
+ TEARDOWN(Module)
18
+ {
19
+ rb_gc_start();
14
20
  }
15
21
 
16
22
  TESTCASE(FromConstant)
@@ -27,59 +33,51 @@ TESTCASE(FromName)
27
33
 
28
34
  namespace
29
35
  {
36
+ class MyClass
37
+ {
38
+ public:
39
+ MyClass() = default;
40
+ };
30
41
 
31
- class Quite_Silly_Exception
32
- : public std::exception
33
- {
34
- };
35
-
36
- void handle_silly_exception(Quite_Silly_Exception const & ex)
37
- {
38
- throw Exception(rb_eRuntimeError, "SILLY");
39
- }
40
-
41
- void throw_silly_exception(Object self)
42
- {
43
- throw Quite_Silly_Exception();
44
- }
45
-
46
- } // namespace
47
-
48
- TESTCASE(add_handler)
49
- {
50
- register_handler<Quite_Silly_Exception>(handle_silly_exception);
42
+ bool some_function()
43
+ {
44
+ return true;
45
+ }
51
46
 
52
- Module m(anonymous_module());
53
- m.define_singleton_method("foo", throw_silly_exception);
54
- Object exc = m.module_eval("begin; foo; rescue Exception; $!; end");
55
- ASSERT_EQUAL(rb_eRuntimeError, CLASS_OF(exc));
56
- Exception ex(exc);
57
- ASSERT_EQUAL(String("SILLY"), String(ex.what()));
58
- }
47
+ Object some_method(Object o)
48
+ {
49
+ return o;
50
+ }
59
51
 
60
- namespace
61
- {
52
+ int function_int(int i)
53
+ {
54
+ return i;
55
+ }
62
56
 
63
- bool some_function()
64
- {
65
- return true;
66
- }
57
+ int method_int(Object object, int i)
58
+ {
59
+ return i;
60
+ }
67
61
 
68
- Object some_method(Object o)
69
- {
70
- return o;
71
- }
62
+ bool method_lvalue(MyClass& myClass)
63
+ {
64
+ return true;
65
+ }
72
66
 
73
- int function_int(int i)
74
- {
75
- return i;
76
- }
67
+ bool method_rvalue(MyClass&& myClass)
68
+ {
69
+ return true;
70
+ }
77
71
 
78
- int method_int(Object object, int i)
79
- {
80
- return i;
81
- }
72
+ void method_lvalue_return_void(int a, MyClass& myClass)
73
+ {
74
+ // Do nothing
75
+ }
82
76
 
77
+ void method_rvalue_return_void(int b, MyClass&& myClass)
78
+ {
79
+ // Do nothing
80
+ }
83
81
  } // namespace
84
82
 
85
83
  TESTCASE(define_method)
@@ -180,14 +178,18 @@ TESTCASE(method_int_passed_no_args)
180
178
  {
181
179
  Module m(anonymous_module());
182
180
  m.define_method("foo", method_int);
181
+
183
182
  ASSERT_EXCEPTION_CHECK(
184
183
  Exception,
185
184
  m.module_eval("o = Object.new; o.extend(self); o.foo"),
186
- ASSERT_EQUAL(
187
- Object(rb_eArgError),
188
- Object(CLASS_OF(ex.value()))
189
- )
185
+ ASSERT_EQUAL(Object(rb_eArgError), Object(CLASS_OF(ex.value())))
190
186
  );
187
+
188
+ ASSERT_EXCEPTION_CHECK(
189
+ Exception,
190
+ m.module_eval("o = Object.new; o.extend(self); o.foo"),
191
+ ASSERT_EQUAL("Missing argument. Name: arg_0. Index: 0.", ex.what())
192
+ );
191
193
  }
192
194
 
193
195
  TESTCASE(define_singleton_method_int_foo)
@@ -263,22 +265,28 @@ TESTCASE(default_arguments_still_throws_argument_error)
263
265
  m.define_function("foo", &defaults_method_one, Arg("arg1"), Arg("arg2") = 3, Arg("arg3") = true);
264
266
 
265
267
  ASSERT_EXCEPTION_CHECK(
266
- Exception,
267
- m.module_eval("o = Object.new; o.extend(self); o.foo()"),
268
- ASSERT_EQUAL(
269
- Object(rb_eArgError),
270
- Object(CLASS_OF(ex.value()))
271
- )
272
- );
268
+ Exception,
269
+ m.module_eval("o = Object.new; o.extend(self); o.foo()"),
270
+ ASSERT_EQUAL(Object(rb_eArgError), Object(CLASS_OF(ex.value())))
271
+ );
273
272
 
274
273
  ASSERT_EXCEPTION_CHECK(
275
- Exception,
276
- m.module_eval("o = Object.new; o.extend(self); o.foo(3, 4, false, 17)"),
277
- ASSERT_EQUAL(
278
- Object(rb_eArgError),
279
- Object(CLASS_OF(ex.value()))
280
- )
281
- );
274
+ Exception,
275
+ m.module_eval("o = Object.new; o.extend(self); o.foo()"),
276
+ ASSERT_EQUAL("Missing argument. Name: arg1. Index: 0.", ex.what())
277
+ );
278
+
279
+ ASSERT_EXCEPTION_CHECK(
280
+ Exception,
281
+ m.module_eval("o = Object.new; o.extend(self); o.foo(3, 4, false, 17)"),
282
+ ASSERT_EQUAL(Object(rb_eArgError), Object(CLASS_OF(ex.value())))
283
+ );
284
+
285
+ ASSERT_EXCEPTION_CHECK(
286
+ Exception,
287
+ m.module_eval("o = Object.new; o.extend(self); o.foo(3, 4, false, 17)"),
288
+ ASSERT_EQUAL("wrong number of arguments (given 4, expected 3)", ex.what())
289
+ );
282
290
  }
283
291
 
284
292
  namespace {
@@ -457,7 +465,9 @@ TESTCASE(define_method_works_with_pointers)
457
465
  Module m(anonymous_module());
458
466
  m.define_module_function("bar", &with_pointers);
459
467
 
460
- m.call("bar", 3, "testing");
468
+ int anInt = 3;
469
+ Buffer<int> buffer(&anInt, 1);
470
+ m.call("bar", std::move(buffer), "testing");
461
471
 
462
472
  ASSERT_EQUAL(3, with_pointers_x);
463
473
  ASSERT_EQUAL("testing", with_pointers_str);
@@ -492,8 +502,12 @@ TESTCASE(pointers)
492
502
  define_global_function("with_pointers", &withPointers);
493
503
 
494
504
  Module m = define_module("TestingModule");
505
+ std::string code = R"(int_buffer = Rice::Buffer≺int≻.new(32)
506
+ bool_buffer = Rice::Buffer≺bool≻.new(true)
507
+ double_buffer = Rice::Buffer≺float≻.new(33.0)
508
+ float_buffer = Rice::Buffer≺double≻.new(34.0)
509
+ with_pointers(int_buffer, bool_buffer, double_buffer, float_buffer))";
495
510
 
496
- std::string code = "with_pointers(32, true, 33.0, 34.0)";
497
511
  m.module_eval(code);
498
512
 
499
513
  ASSERT_EQUAL(intValue, 32);
@@ -515,4 +529,51 @@ TESTCASE(references)
515
529
  ASSERT_EQUAL(boolValue, true);
516
530
  ASSERT_EQUAL(floatValue, 43.0);
517
531
  ASSERT_EQUAL(doubleValue, 44.0);
518
- }
532
+ }
533
+
534
+ TESTCASE(lvalue_function)
535
+ {
536
+ Module m(anonymous_module());
537
+ Class c = define_class<MyClass>("MyClass").
538
+ define_constructor(Constructor<MyClass>());
539
+
540
+ m.define_module_function("method_lvalue", &method_lvalue);
541
+ m.define_module_function("method_lvalue_return_void", &method_lvalue_return_void);
542
+
543
+ Object result = m.module_eval(R"(o = MyClass.new
544
+ method_lvalue_return_void(1, o)
545
+ method_lvalue(o))");
546
+
547
+ ASSERT_EQUAL(Qtrue, result.value());
548
+ }
549
+
550
+ TESTCASE(rvalue_function)
551
+ {
552
+ Module m(anonymous_module());
553
+ Class c = define_class<MyClass>("MyClass").
554
+ define_constructor(Constructor<MyClass>());
555
+
556
+ m.define_module_function("method_rvalue", &method_rvalue);
557
+ m.define_module_function("method_rvalue_return_void", &method_rvalue_return_void);
558
+
559
+ Object result = m.module_eval(R"(o = MyClass.new
560
+ method_rvalue_return_void(1, o)
561
+ method_rvalue(o))");
562
+
563
+ ASSERT_EQUAL(Qtrue, result.value());
564
+ }
565
+
566
+ namespace {
567
+ namespace Constants {
568
+ #define MY_PI 314
569
+ }
570
+ }
571
+
572
+ TESTCASE(constants)
573
+ {
574
+ Module m = anonymous_module().
575
+ define_constant("MY_PI", MY_PI);
576
+
577
+ Object result = m.module_eval(R"(MY_PI)");
578
+ ASSERT_EQUAL(314, detail::From_Ruby<int>().convert(result.value()));
579
+ }
@@ -2,7 +2,6 @@
2
2
  #include "embed_ruby.hpp"
3
3
 
4
4
  #include <rice/rice.hpp>
5
- #include <rice/stl.hpp>
6
5
 
7
6
  using namespace Rice;
8
7
 
@@ -13,38 +12,7 @@ SETUP(NativeRegistry)
13
12
  embed_ruby();
14
13
  }
15
14
 
16
- TESTCASE(collisions)
15
+ TEARDOWN(NativeRegistry)
17
16
  {
18
- std::array<Class, 100> classes;
19
- int scale = 1000;
20
-
21
- for (int i = 0; i < std::size(classes); i++)
22
- {
23
- Class cls(anonymous_class());
24
-
25
- for (int j = 0; j < scale; j++)
26
- {
27
- cls.define_function("int" + std::to_string(j), []() { return 1; });
28
- cls.define_function("long" + std::to_string(j), []() { return 1L; });
29
- cls.define_function("double" + std::to_string(j), []() { return 1.0; });
30
- cls.define_function("float" + std::to_string(j), []() { return 1.0f; });
31
- cls.define_function("bool" + std::to_string(j), []() { return true; });
32
- }
33
-
34
- classes[i] = cls;
35
- }
36
-
37
- for (auto& cls : classes)
38
- {
39
- auto obj = cls.call("new");
40
-
41
- for (int j = 0; j < scale; j++)
42
- {
43
- obj.call("int" + std::to_string(j));
44
- obj.call("long" + std::to_string(j));
45
- obj.call("double" + std::to_string(j));
46
- obj.call("float" + std::to_string(j));
47
- obj.call("bool" + std::to_string(j));
48
- }
49
- }
17
+ rb_gc_start();
50
18
  }
data/test/test_Object.cpp CHANGED
@@ -11,6 +11,11 @@ SETUP(Object)
11
11
  embed_ruby();
12
12
  }
13
13
 
14
+ TEARDOWN(Object)
15
+ {
16
+ rb_gc_start();
17
+ }
18
+
14
19
  TESTCASE(default_construct)
15
20
  {
16
21
  Object o;