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 "unittest.hpp"
1
+ #include "unittest.hpp"
2
2
  #include "embed_ruby.hpp"
3
3
  #include <rice/rice.hpp>
4
4
  #include <rice/stl.hpp>
@@ -319,11 +319,19 @@ TESTCASE(invalid_parameters)
319
319
  std::string code = R"(my_class = MyClass.new
320
320
  my_class.run("abc", "def"))";
321
321
 
322
+ std::string expected = R"(Could not resolve method call for MyClass#run
323
+ 6 overload(s) were evaluated based on the types of Ruby parameters provided:
324
+ std::string AnonymousNamespace::MyClass*::run(int, float)
325
+ std::string AnonymousNamespace::MyClass*::run(float, int)
326
+ std::string AnonymousNamespace::MyClass*::run()
327
+ std::string AnonymousNamespace::MyClass*::run(std::string)
328
+ std::string AnonymousNamespace::MyClass*::run(int)
329
+ std::string AnonymousNamespace::MyClass*::run(float))";
330
+
322
331
  ASSERT_EXCEPTION_CHECK(
323
332
  Exception,
324
333
  Rice::String result = m.module_eval(code),
325
- ASSERT_EQUAL("Could not resolve method call for MyClass#run\n 6 overload(s) were evaluated based on the types of Ruby parameters provided.",
326
- ex.what()));
334
+ ASSERT_EQUAL(expected.c_str(), ex.what()));
327
335
  }
328
336
 
329
337
  namespace
@@ -542,11 +550,15 @@ TESTCASE(int_conversion_2)
542
550
  value = 2**64
543
551
  my_class.run(value))";
544
552
 
553
+ std::string expected = R"(Could not resolve method call for MyClass3#run
554
+ 2 overload(s) were evaluated based on the types of Ruby parameters provided:
555
+ std::string AnonymousNamespace::MyClass3*::run(short)
556
+ std::string AnonymousNamespace::MyClass3*::run(float))";
557
+
545
558
  ASSERT_EXCEPTION_CHECK(
546
559
  Exception,
547
560
  result = m.module_eval(code),
548
- ASSERT_EQUAL("Could not resolve method call for MyClass3#run\n 2 overload(s) were evaluated based on the types of Ruby parameters provided.",
549
- ex.what()));
561
+ ASSERT_EQUAL(expected.c_str(), ex.what()));
550
562
  }
551
563
 
552
564
  TESTCASE(int_conversion_3)
@@ -627,5 +639,168 @@ TESTCASE(int_conversion_5)
627
639
  value = "54"
628
640
  my_class.run(value))";
629
641
  String result = m.module_eval(code);
642
+ ASSERT_EQUAL("run<unsigned char>", result.str());
643
+ }
644
+
645
+ TESTCASE(int_conversion_6)
646
+ {
647
+ Class c = define_class<MyClass3>("MyClass3").
648
+ define_constructor(Constructor<MyClass3>()).
649
+ define_method<std::string(MyClass3::*)(unsigned char)>("run", &MyClass3::run).
650
+ define_method<std::string(MyClass3::*)(unsigned char*)>("run", &MyClass3::run);
651
+
652
+ Module m = define_module("Testing");
653
+
654
+ std::string code = R"(my_class = MyClass3.new
655
+ buffer = Rice::Buffer≺unsigned char≻.new("54")
656
+ my_class.run(buffer))";
657
+ String result = m.module_eval(code);
630
658
  ASSERT_EQUAL("run<unsigned char*>", result.str());
631
659
  }
660
+
661
+ namespace
662
+ {
663
+ class MyClass4
664
+ {
665
+ public:
666
+ static const MyClass4& constRef()
667
+ {
668
+ if (!instance_)
669
+ {
670
+ instance_ = new MyClass4();
671
+ }
672
+ return *instance_;
673
+ }
674
+
675
+ private:
676
+ static inline MyClass4* instance_ = nullptr;
677
+ };
678
+
679
+ class MyClass5
680
+ {
681
+ public:
682
+ MyClass5(MyClass4& class4)
683
+ {
684
+ this->result = "non-const ref";
685
+ }
686
+
687
+ MyClass5(const MyClass4& class4)
688
+ {
689
+ this->result = "const ref";
690
+ }
691
+
692
+ public:
693
+ std::string result = "";
694
+ };
695
+ }
696
+
697
+ TESTCASE(NonConstRef)
698
+ {
699
+ Class c4 = define_class<MyClass4>("MyClass4").
700
+ define_constructor(Constructor<MyClass4>());
701
+
702
+ Class c5 = define_class<MyClass5>("MyClass5").
703
+ define_constructor(Constructor<MyClass5, const MyClass4&>()).
704
+ define_constructor(Constructor<MyClass5, MyClass4&>()).
705
+ define_attr("result", &MyClass5::result);
706
+
707
+ Module m = define_module("Testing");
708
+
709
+ std::string code = R"(my_class4 = MyClass4.new
710
+ my_class5 = MyClass5.new(my_class4)
711
+ my_class5.result)";
712
+ String result = m.module_eval(code);
713
+ ASSERT_EQUAL("non-const ref", result.str());
714
+ }
715
+
716
+ TESTCASE(ConstRef)
717
+ {
718
+ Class c4 = define_class<MyClass4>("MyClass4").
719
+ define_singleton_function("const_instance", MyClass4::constRef);
720
+
721
+ Class c5 = define_class<MyClass5>("MyClass5").
722
+ define_constructor(Constructor<MyClass5, const MyClass4&>()).
723
+ define_constructor(Constructor<MyClass5, MyClass4&>()).
724
+ define_attr("result", &MyClass5::result);
725
+
726
+ Module m = define_module("Testing");
727
+
728
+ std::string code = R"(my_class4 = MyClass4.const_instance
729
+ my_class5 = MyClass5.new(my_class4)
730
+ my_class5.result)";
731
+ String result = m.module_eval(code);
732
+ ASSERT_EQUAL("const ref", result.str());
733
+ }
734
+
735
+ namespace
736
+ {
737
+ class MyClass6
738
+ {
739
+ public:
740
+ static const MyClass6* constPointer()
741
+ {
742
+ if (!instance_)
743
+ {
744
+ instance_ = new MyClass6();
745
+ }
746
+ return instance_;
747
+ }
748
+
749
+ private:
750
+ static inline MyClass6* instance_ = nullptr;
751
+ };
752
+
753
+ class MyClass7
754
+ {
755
+ public:
756
+ MyClass7(MyClass6* class6)
757
+ {
758
+ this->result = "non-const pointer";
759
+ }
760
+
761
+ MyClass7(const MyClass6* class6)
762
+ {
763
+ this->result = "const pointer";
764
+ }
765
+ public:
766
+ std::string result = "";
767
+ };
768
+ }
769
+
770
+ TESTCASE(NonConstPointer)
771
+ {
772
+ Class c6 = define_class<MyClass6>("MyClass6").
773
+ define_constructor(Constructor<MyClass6>());
774
+
775
+ Class c7 = define_class<MyClass7>("MyClass7").
776
+ define_constructor(Constructor<MyClass7, const MyClass6*>()).
777
+ define_constructor(Constructor<MyClass7, MyClass6*>()).
778
+ define_attr("result", &MyClass7::result);
779
+
780
+ Module m = define_module("Testing");
781
+
782
+ std::string code = R"(my_class6 = MyClass6.new
783
+ my_class7 = MyClass7.new(my_class6)
784
+ my_class7.result)";
785
+ String result = m.module_eval(code);
786
+ ASSERT_EQUAL("non-const pointer", result.str());
787
+ }
788
+
789
+ TESTCASE(ConstPointer)
790
+ {
791
+ Class c6 = define_class<MyClass6>("MyClass6").
792
+ define_singleton_function("const_instance", MyClass6::constPointer);
793
+
794
+ Class c7 = define_class<MyClass7>("MyClass7").
795
+ define_constructor(Constructor<MyClass7, const MyClass6*>()).
796
+ define_constructor(Constructor<MyClass7, MyClass6*>()).
797
+ define_attr("result", &MyClass7::result);
798
+
799
+ Module m = define_module("Testing");
800
+
801
+ std::string code = R"(my_class6 = MyClass6.const_instance
802
+ my_class7 = MyClass7.new(my_class6)
803
+ my_class7.result)";
804
+ String result = m.module_eval(code);
805
+ ASSERT_EQUAL("const pointer", result.str());
806
+ }
@@ -10,12 +10,11 @@ TESTSUITE(Ownership);
10
10
 
11
11
  namespace
12
12
  {
13
- class MyClass
13
+ class MyCopyableClass
14
14
  {
15
15
  public:
16
16
  static inline int constructorCalls = 0;
17
17
  static inline int copyConstructorCalls = 0;
18
- static inline int moveConstructorCalls = 0;
19
18
  static inline int destructorCalls = 0;
20
19
  static inline int methodCalls = 0;
21
20
 
@@ -23,7 +22,6 @@ namespace
23
22
  {
24
23
  constructorCalls = 0;
25
24
  copyConstructorCalls = 0;
26
- moveConstructorCalls = 0;
27
25
  destructorCalls = 0;
28
26
  methodCalls = 0;
29
27
  }
@@ -32,22 +30,68 @@ namespace
32
30
  int flag = 0;
33
31
 
34
32
  public:
35
- MyClass()
33
+ MyCopyableClass()
36
34
  {
37
35
  constructorCalls++;
38
36
  }
39
37
 
40
- ~MyClass()
38
+ ~MyCopyableClass()
41
39
  {
42
40
  destructorCalls++;
43
41
  }
44
42
 
45
- MyClass(const MyClass& other): flag(other.flag)
43
+ MyCopyableClass(const MyCopyableClass& other): flag(other.flag)
46
44
  {
47
45
  copyConstructorCalls++;
48
46
  }
49
47
 
50
- MyClass(MyClass&& other) : flag(other.flag)
48
+ MyCopyableClass(MyCopyableClass&& other) = delete;
49
+
50
+ int32_t process()
51
+ {
52
+ methodCalls++;
53
+ return methodCalls;
54
+ }
55
+
56
+ void setFlag(int value)
57
+ {
58
+ this->flag = value;
59
+ }
60
+ };
61
+
62
+ class MyMovableClass
63
+ {
64
+ public:
65
+ static inline int constructorCalls = 0;
66
+ static inline int moveConstructorCalls = 0;
67
+ static inline int destructorCalls = 0;
68
+ static inline int methodCalls = 0;
69
+
70
+ static void reset()
71
+ {
72
+ constructorCalls = 0;
73
+ moveConstructorCalls = 0;
74
+ destructorCalls = 0;
75
+ methodCalls = 0;
76
+ }
77
+
78
+ public:
79
+ int flag = 0;
80
+
81
+ public:
82
+ MyMovableClass()
83
+ {
84
+ constructorCalls++;
85
+ }
86
+
87
+ ~MyMovableClass()
88
+ {
89
+ destructorCalls++;
90
+ }
91
+
92
+ MyMovableClass(const MyMovableClass& other) = delete;
93
+
94
+ MyMovableClass(MyMovableClass&& other) : flag(other.flag)
51
95
  {
52
96
  moveConstructorCalls++;
53
97
  }
@@ -74,47 +118,47 @@ namespace
74
118
  }
75
119
 
76
120
  public:
77
- MyClass* transferPointerToRuby()
121
+ MyCopyableClass* transferPointerToRuby()
78
122
  {
79
- return new MyClass();
123
+ return new MyCopyableClass();
80
124
  }
81
125
 
82
- MyClass* keepPointer()
126
+ MyCopyableClass* keepPointer()
83
127
  {
84
128
  return this->instance();
85
129
  }
86
130
 
87
- MyClass& keepReference()
131
+ MyCopyableClass& keepReference()
88
132
  {
89
133
  return *this->instance();
90
134
  }
91
135
 
92
- MyClass value()
136
+ MyCopyableClass value()
93
137
  {
94
- return MyClass();
138
+ return MyCopyableClass();
95
139
  }
96
140
 
97
- MyClass moveValue()
141
+ MyMovableClass moveValue()
98
142
  {
99
- return std::move(MyClass());
143
+ return MyMovableClass();
100
144
  }
101
145
 
102
- void transferPointerToCpp(MyClass* myClass)
146
+ void transferPointerToCpp(MyCopyableClass* myClass)
103
147
  {
104
148
  delete myClass;
105
149
  }
106
150
 
107
- MyClass* instance()
151
+ MyCopyableClass* instance()
108
152
  {
109
153
  if (!instance_)
110
154
  {
111
- instance_ = new MyClass();
155
+ instance_ = new MyCopyableClass();
112
156
  }
113
157
  return instance_;
114
158
  }
115
159
 
116
160
  public:
117
- static inline MyClass* instance_ = nullptr;
161
+ static inline MyCopyableClass* instance_ = nullptr;
118
162
  };
119
163
  }
120
164
 
@@ -122,10 +166,15 @@ SETUP(Ownership)
122
166
  {
123
167
  embed_ruby();
124
168
 
125
- define_class<MyClass>("MyClass").
126
- define_constructor(Constructor<MyClass>()).
127
- define_method("process", &MyClass::process).
128
- define_method("set_flag", &MyClass::setFlag);
169
+ define_class<MyCopyableClass>("MyCopyableClass").
170
+ define_constructor(Constructor<MyCopyableClass>()).
171
+ define_method("process", &MyCopyableClass::process).
172
+ define_method("set_flag", &MyCopyableClass::setFlag);
173
+
174
+ define_class<MyMovableClass>("MyMovableClass").
175
+ define_constructor(Constructor<MyMovableClass>()).
176
+ define_method("process", &MyMovableClass::process).
177
+ define_method("set_flag", &MyMovableClass::setFlag);
129
178
 
130
179
  define_class<Factory>("Factory").
131
180
  define_constructor(Constructor<Factory>()).
@@ -146,7 +195,7 @@ TEARDOWN(Ownership)
146
195
  TESTCASE(TransferPointerToRuby)
147
196
  {
148
197
  Factory::reset();
149
- MyClass::reset();
198
+ MyCopyableClass::reset();
150
199
 
151
200
  Module m = define_module("TestingModule");
152
201
 
@@ -160,21 +209,20 @@ TESTCASE(TransferPointerToRuby)
160
209
  m.module_eval(code);
161
210
  rb_gc_start();
162
211
 
163
- ASSERT_EQUAL(10, MyClass::constructorCalls);
164
- ASSERT_EQUAL(0, MyClass::copyConstructorCalls);
165
- ASSERT_EQUAL(0, MyClass::moveConstructorCalls);
166
- ASSERT_EQUAL(10, MyClass::destructorCalls);
212
+ ASSERT_EQUAL(10, MyCopyableClass::constructorCalls);
213
+ ASSERT_EQUAL(0, MyCopyableClass::copyConstructorCalls);
214
+ ASSERT_EQUAL(10, MyCopyableClass::destructorCalls);
167
215
  ASSERT(!Factory::instance_);
168
216
  }
169
217
 
170
218
  TESTCASE(TransferPointerToCpp)
171
219
  {
172
220
  Factory::reset();
173
- MyClass::reset();
221
+ MyCopyableClass::reset();
174
222
 
175
223
  Module m = define_module("TestingModule");
176
224
 
177
- std::string code = R"(myClass = MyClass.new
225
+ std::string code = R"(myClass = MyCopyableClass.new
178
226
  factory = Factory.new
179
227
  factory.transfer_pointer_to_cpp(myClass))";
180
228
 
@@ -187,7 +235,7 @@ TESTCASE(TransferPointerToCpp)
187
235
  TESTCASE(KeepPointer)
188
236
  {
189
237
  Factory::reset();
190
- MyClass::reset();
238
+ MyCopyableClass::reset();
191
239
 
192
240
  Module m = define_module("TestingModule");
193
241
 
@@ -201,17 +249,16 @@ TESTCASE(KeepPointer)
201
249
  m.module_eval(code);
202
250
  rb_gc_start();
203
251
 
204
- ASSERT_EQUAL(1, MyClass::constructorCalls);
205
- ASSERT_EQUAL(0, MyClass::copyConstructorCalls);
206
- ASSERT_EQUAL(0, MyClass::moveConstructorCalls);
207
- ASSERT_EQUAL(0, MyClass::destructorCalls);
252
+ ASSERT_EQUAL(1, MyCopyableClass::constructorCalls);
253
+ ASSERT_EQUAL(0, MyCopyableClass::copyConstructorCalls);
254
+ ASSERT_EQUAL(0, MyCopyableClass::destructorCalls);
208
255
  ASSERT_EQUAL(9, Factory::instance_->flag);
209
256
  }
210
257
 
211
258
  TESTCASE(KeepReference)
212
259
  {
213
260
  Factory::reset();
214
- MyClass::reset();
261
+ MyCopyableClass::reset();
215
262
 
216
263
  Module m = define_module("TestingModule");
217
264
 
@@ -225,17 +272,16 @@ TESTCASE(KeepReference)
225
272
  m.module_eval(code);
226
273
  rb_gc_start();
227
274
 
228
- ASSERT_EQUAL(1, MyClass::constructorCalls);
229
- ASSERT_EQUAL(0, MyClass::copyConstructorCalls);
230
- ASSERT_EQUAL(0, MyClass::moveConstructorCalls);
231
- ASSERT_EQUAL(0, MyClass::destructorCalls);
275
+ ASSERT_EQUAL(1, MyCopyableClass::constructorCalls);
276
+ ASSERT_EQUAL(0, MyCopyableClass::copyConstructorCalls);
277
+ ASSERT_EQUAL(0, MyCopyableClass::destructorCalls);
232
278
  ASSERT_EQUAL(9, Factory::instance_->flag);
233
279
  }
234
280
 
235
281
  TESTCASE(CopyReference)
236
282
  {
237
283
  Factory::reset();
238
- MyClass::reset();
284
+ MyCopyableClass::reset();
239
285
 
240
286
  Module m = define_module("TestingModule");
241
287
 
@@ -249,17 +295,16 @@ TESTCASE(CopyReference)
249
295
  m.module_eval(code);
250
296
  rb_gc_start();
251
297
 
252
- ASSERT_EQUAL(1, MyClass::constructorCalls);
253
- ASSERT_EQUAL(0, MyClass::copyConstructorCalls);
254
- ASSERT_EQUAL(10, MyClass::moveConstructorCalls);
255
- ASSERT_EQUAL(10, MyClass::destructorCalls);
298
+ ASSERT_EQUAL(1, MyCopyableClass::constructorCalls);
299
+ ASSERT_EQUAL(10, MyCopyableClass::copyConstructorCalls);
300
+ ASSERT_EQUAL(10, MyCopyableClass::destructorCalls);
256
301
  ASSERT_EQUAL(0, Factory::instance_->flag);
257
302
  }
258
303
 
259
304
  TESTCASE(TransferValue)
260
305
  {
261
306
  Factory::reset();
262
- MyClass::reset();
307
+ MyCopyableClass::reset();
263
308
 
264
309
  Module m = define_module("TestingModule");
265
310
 
@@ -272,17 +317,16 @@ TESTCASE(TransferValue)
272
317
  m.module_eval(code);
273
318
  rb_gc_start();
274
319
 
275
- ASSERT_EQUAL(10, MyClass::constructorCalls);
276
- ASSERT_EQUAL(0, MyClass::copyConstructorCalls);
277
- ASSERT_EQUAL(10, MyClass::moveConstructorCalls);
278
- ASSERT_EQUAL(20, MyClass::destructorCalls);
320
+ ASSERT_EQUAL(10, MyCopyableClass::constructorCalls);
321
+ ASSERT_EQUAL(10, MyCopyableClass::copyConstructorCalls);
322
+ ASSERT_EQUAL(20, MyCopyableClass::destructorCalls);
279
323
  ASSERT(!Factory::instance_);
280
324
  }
281
325
 
282
326
  TESTCASE(MoveValue)
283
327
  {
284
328
  Factory::reset();
285
- MyClass::reset();
329
+ MyCopyableClass::reset();
286
330
 
287
331
  Module m = define_module("TestingModule");
288
332
 
@@ -295,10 +339,9 @@ TESTCASE(MoveValue)
295
339
  m.module_eval(code);
296
340
  rb_gc_start();
297
341
 
298
- ASSERT_EQUAL(10, MyClass::constructorCalls);
299
- ASSERT_EQUAL(0, MyClass::copyConstructorCalls);
300
- ASSERT_EQUAL(20, MyClass::moveConstructorCalls);
301
- ASSERT_EQUAL(30, MyClass::destructorCalls);
342
+ ASSERT_EQUAL(10, MyMovableClass::constructorCalls);
343
+ ASSERT_EQUAL(10, MyMovableClass::moveConstructorCalls);
344
+ ASSERT_EQUAL(20, MyMovableClass::destructorCalls);
302
345
  ASSERT(!Factory::instance_);
303
346
  }
304
347
 
@@ -323,9 +366,9 @@ TESTCASE(NotCopyable)
323
366
  MyClassNotCopyable instance;
324
367
 
325
368
  #ifdef _MSC_VER
326
- const char* expected = "Ruby was directed to take ownership of a C++ object but it does not have an accessible copy or move constructor. Type: class `anonymous namespace'::MyClassNotCopyable";
369
+ const char* expected = "Rice was directed to take ownership of a C++ object but it does not have an accessible copy or move constructor. Type: class `anonymous namespace'::MyClassNotCopyable";
327
370
  #else
328
- const char* expected = "Ruby was directed to take ownership of a C++ object but it does not have an accessible copy or move constructor. Type: (anonymous namespace)::MyClassNotCopyable";
371
+ const char* expected = "Rice was directed to take ownership of a C++ object but it does not have an accessible copy or move constructor. Type: (anonymous namespace)::MyClassNotCopyable";
329
372
  #endif
330
373
 
331
374
  // Trying to take ownership should fail
data/test/test_Proc.cpp CHANGED
@@ -3,7 +3,6 @@
3
3
  #include "unittest.hpp"
4
4
  #include "embed_ruby.hpp"
5
5
  #include <rice/rice.hpp>
6
- #include <rice/stl.hpp>
7
6
 
8
7
  using namespace Rice;
9
8
 
data/test/test_Self.cpp CHANGED
@@ -146,8 +146,8 @@ TESTCASE(SelfValue)
146
146
  ASSERT((pointer1 != pointer2));
147
147
 
148
148
  ASSERT_EQUAL(1, SelfClass::constructorCalls);
149
- ASSERT_EQUAL(1, SelfClass::copyConstructorCalls);
150
- ASSERT_EQUAL(1, SelfClass::moveConstructorCalls);
149
+ ASSERT_EQUAL(2, SelfClass::copyConstructorCalls);
150
+ ASSERT_EQUAL(0, SelfClass::moveConstructorCalls);
151
151
  ASSERT_EQUAL(1, SelfClass::destructorCalls);
152
152
  }
153
153
 
@@ -203,7 +203,7 @@ TESTCASE(SelfValueLambda)
203
203
  ASSERT((pointer1 != pointer2));
204
204
 
205
205
  ASSERT_EQUAL(1, SelfClass::constructorCalls);
206
- ASSERT_EQUAL(1, SelfClass::copyConstructorCalls);
207
- ASSERT_EQUAL(1, SelfClass::moveConstructorCalls);
206
+ ASSERT_EQUAL(2, SelfClass::copyConstructorCalls);
207
+ ASSERT_EQUAL(0, SelfClass::moveConstructorCalls);
208
208
  ASSERT_EQUAL(1, SelfClass::destructorCalls);
209
209
  }