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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +86 -26
- data/CMakeLists.txt +31 -0
- data/CMakePresets.json +75 -0
- data/COPYING +3 -2
- data/FindRuby.cmake +437 -0
- data/README.md +7 -2
- data/Rakefile +12 -5
- data/include/rice/rice.hpp +9522 -4426
- data/include/rice/stl.hpp +2831 -1198
- data/lib/make_rice_headers.rb +79 -0
- data/lib/mkmf-rice.rb +40 -94
- 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/Address_Registration_Guard.hpp +72 -3
- data/rice/Arg.hpp +26 -6
- data/rice/Arg.ipp +35 -2
- data/rice/Buffer.hpp +123 -0
- data/rice/Buffer.ipp +599 -0
- data/rice/Callback.hpp +21 -0
- data/rice/Callback.ipp +13 -0
- data/rice/Constructor.hpp +4 -27
- data/rice/Constructor.ipp +79 -0
- data/rice/Data_Object.hpp +73 -3
- data/rice/Data_Object.ipp +388 -96
- data/rice/Data_Type.hpp +214 -3
- data/rice/Data_Type.ipp +144 -67
- data/rice/Director.hpp +0 -2
- data/rice/Enum.hpp +4 -7
- data/rice/Enum.ipp +102 -55
- data/rice/Exception.hpp +62 -2
- data/rice/Exception.ipp +7 -12
- data/rice/Init.hpp +8 -0
- data/rice/Init.ipp +8 -0
- data/rice/JumpException.hpp +44 -0
- data/rice/JumpException.ipp +48 -0
- data/rice/MemoryView.hpp +11 -0
- data/rice/MemoryView.ipp +3 -0
- data/rice/Return.hpp +7 -27
- data/rice/Return.ipp +13 -13
- 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/{Identifier.hpp → cpp_api/Identifier.hpp} +2 -6
- data/rice/{Identifier.ipp → cpp_api/Identifier.ipp} +4 -2
- 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/DefaultHandler.hpp +12 -0
- data/rice/detail/DefaultHandler.ipp +8 -0
- data/rice/detail/HandlerRegistry.hpp +5 -35
- data/rice/detail/HandlerRegistry.ipp +7 -11
- data/rice/detail/InstanceRegistry.hpp +1 -4
- data/rice/detail/MethodInfo.hpp +12 -10
- data/rice/detail/MethodInfo.ipp +26 -21
- data/rice/detail/Native.hpp +33 -0
- data/rice/detail/Native.ipp +157 -0
- data/rice/detail/NativeAttributeGet.hpp +52 -0
- data/rice/detail/NativeAttributeGet.ipp +57 -0
- data/rice/detail/NativeAttributeSet.hpp +44 -0
- data/rice/detail/NativeAttributeSet.ipp +88 -0
- data/rice/detail/NativeCallbackFFI.hpp +55 -0
- data/rice/detail/NativeCallbackFFI.ipp +151 -0
- data/rice/detail/NativeCallbackSimple.hpp +30 -0
- data/rice/detail/NativeCallbackSimple.ipp +29 -0
- data/rice/detail/NativeFunction.hpp +33 -23
- data/rice/detail/NativeFunction.ipp +309 -70
- data/rice/detail/NativeIterator.hpp +9 -11
- data/rice/detail/NativeIterator.ipp +33 -31
- data/rice/detail/NativeRegistry.hpp +24 -15
- data/rice/detail/NativeRegistry.ipp +23 -48
- data/rice/detail/Proc.hpp +4 -0
- data/rice/detail/Proc.ipp +85 -0
- data/rice/detail/Registries.hpp +0 -7
- data/rice/detail/Registries.ipp +0 -18
- data/rice/detail/RubyFunction.hpp +0 -3
- data/rice/detail/RubyFunction.ipp +4 -8
- data/rice/detail/RubyType.hpp +16 -0
- data/rice/detail/RubyType.ipp +232 -0
- data/rice/detail/Type.hpp +7 -6
- data/rice/detail/Type.ipp +192 -45
- data/rice/detail/TypeRegistry.hpp +15 -7
- data/rice/detail/TypeRegistry.ipp +105 -12
- data/rice/detail/Wrapper.hpp +68 -32
- data/rice/detail/Wrapper.ipp +121 -109
- data/rice/detail/cpp_protect.hpp +5 -6
- data/rice/detail/default_allocation_func.ipp +0 -2
- data/rice/detail/from_ruby.hpp +38 -3
- data/rice/detail/from_ruby.ipp +1321 -492
- data/rice/detail/ruby.hpp +18 -0
- data/rice/detail/to_ruby.hpp +41 -3
- data/rice/detail/to_ruby.ipp +1424 -194
- data/rice/global_function.hpp +0 -4
- data/rice/global_function.ipp +0 -1
- data/rice/libc/file.hpp +11 -0
- data/rice/libc/file.ipp +32 -0
- data/rice/rice.hpp +116 -26
- data/rice/ruby_mark.hpp +4 -3
- 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 +11 -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 +7 -1
- data/test/extconf.rb +2 -0
- data/test/test_Address_Registration_Guard.cpp +5 -0
- data/test/test_Array.cpp +18 -4
- data/test/test_Attribute.cpp +136 -21
- data/test/test_Buffer.cpp +285 -0
- data/test/test_Builtin_Object.cpp +5 -0
- data/test/test_Callback.cpp +230 -0
- data/test/test_Class.cpp +5 -31
- data/test/test_Constructor.cpp +69 -6
- data/test/test_Data_Object.cpp +97 -38
- data/test/test_Data_Type.cpp +470 -65
- data/test/test_Director.cpp +17 -8
- data/test/test_Enum.cpp +155 -40
- data/test/test_Exception.cpp +235 -0
- data/test/test_File.cpp +70 -0
- data/test/test_From_Ruby.cpp +609 -0
- data/test/test_Hash.cpp +5 -0
- data/test/test_Identifier.cpp +5 -0
- data/test/test_Inheritance.cpp +6 -1
- data/test/test_Iterator.cpp +6 -1
- data/test/test_Jump_Exception.cpp +23 -0
- data/test/test_Keep_Alive.cpp +13 -19
- data/test/test_Keep_Alive_No_Wrapper.cpp +5 -1
- data/test/test_Memory_Management.cpp +5 -0
- data/test/test_Module.cpp +128 -67
- data/test/test_Native_Registry.cpp +2 -34
- data/test/test_Object.cpp +5 -0
- data/test/test_Overloads.cpp +806 -0
- data/test/test_Ownership.cpp +160 -54
- data/test/test_Proc.cpp +44 -0
- data/test/test_Self.cpp +9 -4
- data/test/test_Stl_Exception.cpp +109 -0
- data/test/test_Stl_Map.cpp +54 -42
- data/test/test_Stl_Multimap.cpp +693 -0
- data/test/test_Stl_Optional.cpp +5 -0
- data/test/test_Stl_Pair.cpp +14 -9
- data/test/test_Stl_Reference_Wrapper.cpp +9 -2
- data/test/test_Stl_Set.cpp +790 -0
- data/test/test_Stl_SharedPtr.cpp +458 -0
- data/test/test_Stl_String.cpp +5 -0
- data/test/test_Stl_String_View.cpp +5 -0
- data/test/test_Stl_Tuple.cpp +116 -0
- data/test/test_Stl_Type.cpp +147 -0
- data/test/test_Stl_UniquePtr.cpp +202 -0
- data/test/test_Stl_Unordered_Map.cpp +43 -38
- data/test/test_Stl_Variant.cpp +217 -84
- data/test/test_Stl_Vector.cpp +306 -58
- data/test/test_String.cpp +5 -0
- data/test/test_Struct.cpp +5 -0
- data/test/test_Symbol.cpp +5 -0
- data/test/test_Template.cpp +192 -0
- data/test/test_To_Ruby.cpp +524 -0
- data/test/test_Tracking.cpp +1 -0
- data/test/test_Type.cpp +171 -0
- data/test/test_global_functions.cpp +67 -7
- data/test/unittest.cpp +8 -0
- metadata +127 -26
- data/lib/version.rb +0 -3
- data/rice/Address_Registration_Guard_defn.hpp +0 -79
- data/rice/Data_Object_defn.hpp +0 -84
- data/rice/Data_Type_defn.hpp +0 -190
- data/rice/Exception_defn.hpp +0 -68
- data/rice/HandlerRegistration.hpp +0 -15
- data/rice/detail/ExceptionHandler.hpp +0 -8
- data/rice/detail/ExceptionHandler.ipp +0 -28
- data/rice/detail/ExceptionHandler_defn.hpp +0 -77
- data/rice/detail/Jump_Tag.hpp +0 -21
- data/rice/detail/NativeAttribute.hpp +0 -64
- data/rice/detail/NativeAttribute.ipp +0 -112
- data/rice/detail/from_ruby_defn.hpp +0 -38
- data/rice/detail/to_ruby_defn.hpp +0 -48
- data/test/test_Jump_Tag.cpp +0 -17
- data/test/test_Stl_SmartPointer.cpp +0 -283
- data/test/test_To_From_Ruby.cpp +0 -399
data/test/test_Tracking.cpp
CHANGED
data/test/test_Type.cpp
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
#include "unittest.hpp"
|
2
|
+
#include "embed_ruby.hpp"
|
3
|
+
|
4
|
+
#include <rice/rice.hpp>
|
5
|
+
|
6
|
+
#include <complex>
|
7
|
+
|
8
|
+
using namespace Rice;
|
9
|
+
|
10
|
+
TESTSUITE(Type);
|
11
|
+
|
12
|
+
namespace Outer
|
13
|
+
{
|
14
|
+
namespace Inner
|
15
|
+
{
|
16
|
+
using Vec1 = std::vector<std::complex<float>>;
|
17
|
+
using Vec2 = std::vector<unsigned char*>;
|
18
|
+
using Map1 = std::map<std::string, std::vector<std::complex<float>>>;
|
19
|
+
using UnorderedMap1 = std::unordered_map<std::string, std::complex<float>>;
|
20
|
+
|
21
|
+
class SomeClass
|
22
|
+
{
|
23
|
+
};
|
24
|
+
|
25
|
+
using Vec3 = std::vector<SomeClass>;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
SETUP(Type)
|
30
|
+
{
|
31
|
+
embed_ruby();
|
32
|
+
}
|
33
|
+
|
34
|
+
TEARDOWN(Type)
|
35
|
+
{
|
36
|
+
rb_gc_start();
|
37
|
+
}
|
38
|
+
|
39
|
+
TESTCASE(FindGroup)
|
40
|
+
{
|
41
|
+
std::string name = "class std::vector<class cv::Vec<unsigned char, 2>, class std::allocator<class cv::Vec<unsigned char, 2> > >";
|
42
|
+
|
43
|
+
std::string group = detail::findGroup(name, 0);
|
44
|
+
ASSERT_EQUAL("<class cv::Vec<unsigned char, 2>, class std::allocator<class cv::Vec<unsigned char, 2> > >", group.c_str());
|
45
|
+
|
46
|
+
group = detail::findGroup(name, 18);
|
47
|
+
ASSERT_EQUAL("<unsigned char, 2>", group.c_str());
|
48
|
+
|
49
|
+
group = detail::findGroup(name, 49);
|
50
|
+
ASSERT_EQUAL("<class cv::Vec<unsigned char, 2> >", group.c_str());
|
51
|
+
|
52
|
+
ASSERT_EXCEPTION_CHECK(
|
53
|
+
std::runtime_error,
|
54
|
+
detail::findGroup(name, 48),
|
55
|
+
ASSERT_EQUAL("Unbalanced Group", ex.what())
|
56
|
+
);
|
57
|
+
}
|
58
|
+
|
59
|
+
TESTCASE(CppClassName)
|
60
|
+
{
|
61
|
+
std::string typeName = detail::typeName(typeid(std::string));
|
62
|
+
std::string className = detail::cppClassName(typeName);
|
63
|
+
ASSERT_EQUAL("std::string", className.c_str());
|
64
|
+
|
65
|
+
typeName = detail::typeName(typeid(std::wstring));
|
66
|
+
className = detail::cppClassName(typeName);
|
67
|
+
ASSERT_EQUAL("std::wstring", className.c_str());
|
68
|
+
|
69
|
+
typeName = detail::typeName(typeid(std::vector<std::string>));
|
70
|
+
className = detail::cppClassName(typeName);
|
71
|
+
ASSERT_EQUAL("std::vector<std::string>", className.c_str());
|
72
|
+
|
73
|
+
typeName = detail::typeName(typeid(std::vector<std::wstring>));
|
74
|
+
className = detail::cppClassName(typeName);
|
75
|
+
ASSERT_EQUAL("std::vector<std::wstring>", className.c_str());
|
76
|
+
|
77
|
+
typeName = detail::typeName(typeid(std::vector<double*>));
|
78
|
+
className = detail::cppClassName(typeName);
|
79
|
+
ASSERT_EQUAL("std::vector<double*>", className.c_str());
|
80
|
+
|
81
|
+
typeName = detail::typeName(typeid(std::vector<double**>));
|
82
|
+
className = detail::cppClassName(typeName);
|
83
|
+
ASSERT_EQUAL("std::vector<double**>", className.c_str());
|
84
|
+
|
85
|
+
typeName = detail::typeName(typeid(Outer::Inner::Vec1));
|
86
|
+
className = detail::cppClassName(typeName);
|
87
|
+
ASSERT_EQUAL("std::vector<std::complex<float>>", className.c_str());
|
88
|
+
|
89
|
+
typeName = detail::typeName(typeid(Outer::Inner::Vec2));
|
90
|
+
className = detail::cppClassName(typeName);
|
91
|
+
ASSERT_EQUAL("std::vector<unsigned char*>", className.c_str());
|
92
|
+
|
93
|
+
typeName = detail::typeName(typeid(Outer::Inner::Vec3));
|
94
|
+
className = detail::cppClassName(typeName);
|
95
|
+
ASSERT_EQUAL("std::vector<Outer::Inner::SomeClass>", className.c_str());
|
96
|
+
|
97
|
+
typeName = detail::typeName(typeid(Outer::Inner::Map1));
|
98
|
+
className = detail::cppClassName(typeName);
|
99
|
+
ASSERT_EQUAL("std::map<std::string, std::vector<std::complex<float>>>", className.c_str());
|
100
|
+
|
101
|
+
typeName = detail::typeName(typeid(Outer::Inner::UnorderedMap1));
|
102
|
+
className = detail::cppClassName(typeName);
|
103
|
+
ASSERT_EQUAL("std::unordered_map<std::string, std::complex<float>>", className.c_str());
|
104
|
+
}
|
105
|
+
|
106
|
+
TESTCASE(RubyClassName)
|
107
|
+
{
|
108
|
+
std::string typeName = detail::typeName(typeid(std::string));
|
109
|
+
std::string className = detail::rubyClassName(typeName);
|
110
|
+
ASSERT_EQUAL("String", className.c_str());
|
111
|
+
|
112
|
+
typeName = detail::typeName(typeid(std::wstring));
|
113
|
+
className = detail::rubyClassName(typeName);
|
114
|
+
ASSERT_EQUAL("Wstring", className.c_str());
|
115
|
+
|
116
|
+
typeName = detail::typeName(typeid(std::vector<std::string>));
|
117
|
+
className = detail::rubyClassName(typeName);
|
118
|
+
ASSERT_EQUAL("Vector≺string≻", className.c_str());
|
119
|
+
|
120
|
+
typeName = detail::typeName(typeid(std::vector<std::wstring>));
|
121
|
+
className = detail::rubyClassName(typeName);
|
122
|
+
ASSERT_EQUAL("Vector≺wstring≻", className.c_str());
|
123
|
+
|
124
|
+
typeName = detail::typeName(typeid(std::vector<double*>));
|
125
|
+
className = detail::rubyClassName(typeName);
|
126
|
+
ASSERT_EQUAL("Vector≺double∗≻", className.c_str());
|
127
|
+
|
128
|
+
typeName = detail::typeName(typeid(std::vector<double**>));
|
129
|
+
className = detail::rubyClassName(typeName);
|
130
|
+
ASSERT_EQUAL("Vector≺double∗∗≻", className.c_str());
|
131
|
+
|
132
|
+
typeName = detail::typeName(typeid(Outer::Inner::Vec1));
|
133
|
+
className = detail::rubyClassName(typeName);
|
134
|
+
ASSERT_EQUAL("Vector≺complex≺float≻≻", className.c_str());
|
135
|
+
|
136
|
+
typeName = detail::typeName(typeid(Outer::Inner::Vec2));
|
137
|
+
className = detail::rubyClassName(typeName);
|
138
|
+
ASSERT_EQUAL("Vector≺unsigned char∗≻", className.c_str());
|
139
|
+
|
140
|
+
typeName = detail::typeName(typeid(Outer::Inner::Vec3));
|
141
|
+
className = detail::rubyClassName(typeName);
|
142
|
+
ASSERT_EQUAL("Vector≺Outer꞉꞉Inner꞉꞉SomeClass≻", className.c_str());
|
143
|
+
|
144
|
+
typeName = detail::typeName(typeid(Outer::Inner::Map1));
|
145
|
+
className = detail::rubyClassName(typeName);
|
146
|
+
ASSERT_EQUAL("Map≺string‚ vector≺complex≺float≻≻≻", className.c_str());
|
147
|
+
|
148
|
+
typeName = detail::typeName(typeid(Outer::Inner::UnorderedMap1));
|
149
|
+
className = detail::rubyClassName(typeName);
|
150
|
+
ASSERT_EQUAL("UnorderedMap≺string‚ complex≺float≻≻", className.c_str());
|
151
|
+
}
|
152
|
+
|
153
|
+
TESTCASE(MakeRubyClass)
|
154
|
+
{
|
155
|
+
std::string typeName = detail::typeName(typeid(Outer::Inner::Vec1));
|
156
|
+
std::string rubyClassName = detail::rubyClassName(typeName);
|
157
|
+
|
158
|
+
Module module = define_module("Testing");
|
159
|
+
|
160
|
+
Identifier id(rubyClassName);
|
161
|
+
define_class_under<Outer::Inner::Vec1>(module, id);
|
162
|
+
|
163
|
+
std::string code = R"(Testing.constants.grep(/Vector/).sort)";
|
164
|
+
|
165
|
+
Array result = module.module_eval(code);
|
166
|
+
ASSERT_EQUAL(1, result.size());
|
167
|
+
|
168
|
+
// FIXME - fails compilation on GCC
|
169
|
+
// Symbol element = result[0];
|
170
|
+
// ASSERT_EQUAL("Vector≺complex≺float≻≻", element.c_str());
|
171
|
+
}
|
@@ -11,16 +11,21 @@ SETUP(GlobalFunction)
|
|
11
11
|
embed_ruby();
|
12
12
|
}
|
13
13
|
|
14
|
-
|
14
|
+
TEARDOWN(GlobalFunctions)
|
15
|
+
{
|
16
|
+
rb_gc_start();
|
17
|
+
}
|
15
18
|
|
19
|
+
namespace
|
20
|
+
{
|
16
21
|
bool no_args()
|
17
22
|
{
|
18
23
|
return true;
|
19
24
|
}
|
20
25
|
|
21
|
-
int int_arg(int
|
26
|
+
int int_arg(int value)
|
22
27
|
{
|
23
|
-
return 2 *
|
28
|
+
return 2 * value;
|
24
29
|
}
|
25
30
|
}
|
26
31
|
|
@@ -52,6 +57,28 @@ TESTCASE(int_arg)
|
|
52
57
|
ASSERT_EQUAL(20, detail::From_Ruby<int>().convert(result));
|
53
58
|
}
|
54
59
|
|
60
|
+
TESTCASE(int_kw_arg)
|
61
|
+
{
|
62
|
+
define_global_function("method_with_kw_args_1", &int_arg, Arg("value"));
|
63
|
+
Module m = Module(rb_mKernel);
|
64
|
+
std::string code = R"(method_with_kw_args_1(value: 15))";
|
65
|
+
Object result = m.instance_eval(code);
|
66
|
+
ASSERT_EQUAL(30, detail::From_Ruby<int>().convert(result));
|
67
|
+
}
|
68
|
+
|
69
|
+
TESTCASE(int_kw_arg_invalid)
|
70
|
+
{
|
71
|
+
define_global_function("method_with_kw_args_2", &int_arg, Arg("value"));
|
72
|
+
Module m = Module(rb_mKernel);
|
73
|
+
std::string code = R"(method_with_kw_args_2(wrong: 15))";
|
74
|
+
|
75
|
+
ASSERT_EXCEPTION_CHECK(
|
76
|
+
Exception,
|
77
|
+
m.instance_eval(code),
|
78
|
+
ASSERT_EQUAL("Unknown keyword: wrong", ex.what())
|
79
|
+
);
|
80
|
+
}
|
81
|
+
|
55
82
|
TESTCASE(int_arg_lambda)
|
56
83
|
{
|
57
84
|
define_global_function("method_with_args", [](int value)
|
@@ -85,7 +112,7 @@ namespace
|
|
85
112
|
|
86
113
|
TESTCASE(default_arguments_for_define_global_function)
|
87
114
|
{
|
88
|
-
define_global_function("foo", &defaults_method_one, Arg("arg1"), Arg("arg2") = (int)3, Arg("arg3") =
|
115
|
+
define_global_function("foo", &defaults_method_one, Arg("arg1"), Arg("arg2") = (int)3, Arg("arg3") = true);
|
89
116
|
Module m(rb_mKernel);
|
90
117
|
|
91
118
|
m.call("foo", 2);
|
@@ -107,7 +134,39 @@ TESTCASE(default_arguments_for_define_global_function)
|
|
107
134
|
ASSERT(!defaults_method_one_arg3);
|
108
135
|
}
|
109
136
|
|
110
|
-
TESTCASE(
|
137
|
+
TESTCASE(default_arguments_kw)
|
138
|
+
{
|
139
|
+
define_global_function("defaults_method_one_kw", &defaults_method_one,
|
140
|
+
Arg("arg1"), Arg("arg2") = 3, Arg("arg3") = true);
|
141
|
+
Module m = Module(rb_mKernel);
|
142
|
+
|
143
|
+
std::string code = R"(defaults_method_one_kw(4, arg2: 5))";
|
144
|
+
m.instance_eval(code);
|
145
|
+
ASSERT_EQUAL(4, defaults_method_one_arg1);
|
146
|
+
ASSERT_EQUAL(5, defaults_method_one_arg2);
|
147
|
+
ASSERT(defaults_method_one_arg3);
|
148
|
+
|
149
|
+
code = R"(defaults_method_one_kw(arg1: 9, arg2: 11, arg3: false))";
|
150
|
+
m.instance_eval(code);
|
151
|
+
ASSERT_EQUAL(9, defaults_method_one_arg1);
|
152
|
+
ASSERT_EQUAL(11, defaults_method_one_arg2);
|
153
|
+
ASSERT(!defaults_method_one_arg3);
|
154
|
+
|
155
|
+
code = R"(defaults_method_one_kw(4, arg3: false))";
|
156
|
+
m.instance_eval(code);
|
157
|
+
ASSERT_EQUAL(4, defaults_method_one_arg1);
|
158
|
+
ASSERT_EQUAL(3, defaults_method_one_arg2);
|
159
|
+
ASSERT_EQUAL(false, defaults_method_one_arg3);
|
160
|
+
|
161
|
+
code = R"(defaults_method_one_kw(arg2: 5))";
|
162
|
+
ASSERT_EXCEPTION_CHECK(
|
163
|
+
Exception,
|
164
|
+
m.instance_eval(code),
|
165
|
+
ASSERT_EQUAL("Missing argument. Name: arg1. Index: 0.", ex.what())
|
166
|
+
);
|
167
|
+
}
|
168
|
+
|
169
|
+
TESTCASE(default_arguments_and_returning)
|
111
170
|
{
|
112
171
|
define_global_function("foo_ret", &defaults_returns, Arg("arg1"), Arg("arg2") = (int)3);
|
113
172
|
Module m(rb_mKernel);
|
@@ -119,7 +178,8 @@ TESTCASE(default_arguments_for_define_global_function_and_returning)
|
|
119
178
|
ASSERT_EQUAL(INT2NUM(50), o.value());
|
120
179
|
}
|
121
180
|
|
122
|
-
namespace
|
181
|
+
namespace
|
182
|
+
{
|
123
183
|
int the_one_default_arg = 0;
|
124
184
|
void method_with_one_default_arg(int num = 4) {
|
125
185
|
the_one_default_arg = num;
|
@@ -132,4 +192,4 @@ TESTCASE(single_default_argument)
|
|
132
192
|
Module m(rb_mKernel);
|
133
193
|
m.call("foo");
|
134
194
|
ASSERT_EQUAL(4, the_one_default_arg);
|
135
|
-
}
|
195
|
+
}
|
data/test/unittest.cpp
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
#include <map>
|
4
4
|
#include "unittest.hpp"
|
5
5
|
|
6
|
+
#ifdef _WIN32
|
7
|
+
#include <windows.h>
|
8
|
+
#endif
|
9
|
+
|
6
10
|
size_t assertions;
|
7
11
|
|
8
12
|
namespace
|
@@ -98,6 +102,10 @@ char* findOption(char** begin, char** end, const std::string& option)
|
|
98
102
|
|
99
103
|
int main(int argc, char** argv)
|
100
104
|
{
|
105
|
+
#ifdef _WIN32
|
106
|
+
SetConsoleOutputCP(CP_UTF8);
|
107
|
+
#endif
|
108
|
+
|
101
109
|
std::vector<Test_Suite> suites;
|
102
110
|
|
103
111
|
char* moduleName = findOption(argv, argv + argc, "--suite");
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Brannan
|
8
8
|
- Jason Roelofs
|
9
9
|
- Charlie Savage
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: bundler
|
@@ -68,60 +67,106 @@ extra_rdoc_files:
|
|
68
67
|
- README.md
|
69
68
|
files:
|
70
69
|
- CHANGELOG.md
|
70
|
+
- CMakeLists.txt
|
71
|
+
- CMakePresets.json
|
71
72
|
- CONTRIBUTORS.md
|
72
73
|
- COPYING
|
74
|
+
- FindRuby.cmake
|
73
75
|
- Gemfile
|
74
76
|
- README.md
|
75
77
|
- Rakefile
|
76
78
|
- include/rice/rice.hpp
|
77
79
|
- include/rice/stl.hpp
|
80
|
+
- lib/make_rice_headers.rb
|
78
81
|
- lib/mkmf-rice.rb
|
79
|
-
- lib/
|
82
|
+
- lib/rice.rb
|
83
|
+
- lib/rice/version.rb
|
84
|
+
- lib/rubygems/builder.rb
|
85
|
+
- lib/rubygems/cmake_builder.rb
|
86
|
+
- lib/rubygems_plugin.rb
|
87
|
+
- rice.gemspec
|
80
88
|
- rice/Address_Registration_Guard.hpp
|
81
89
|
- rice/Address_Registration_Guard.ipp
|
82
|
-
- rice/Address_Registration_Guard_defn.hpp
|
83
90
|
- rice/Arg.hpp
|
84
91
|
- rice/Arg.ipp
|
92
|
+
- rice/Buffer.hpp
|
93
|
+
- rice/Buffer.ipp
|
94
|
+
- rice/Callback.hpp
|
95
|
+
- rice/Callback.ipp
|
85
96
|
- rice/Constructor.hpp
|
97
|
+
- rice/Constructor.ipp
|
86
98
|
- rice/Data_Object.hpp
|
87
99
|
- rice/Data_Object.ipp
|
88
|
-
- rice/Data_Object_defn.hpp
|
89
100
|
- rice/Data_Type.hpp
|
90
101
|
- rice/Data_Type.ipp
|
91
|
-
- rice/Data_Type_defn.hpp
|
92
102
|
- rice/Director.hpp
|
93
103
|
- rice/Enum.hpp
|
94
104
|
- rice/Enum.ipp
|
95
105
|
- rice/Exception.hpp
|
96
106
|
- rice/Exception.ipp
|
97
|
-
- rice/
|
98
|
-
- rice/
|
99
|
-
- rice/
|
100
|
-
- rice/
|
107
|
+
- rice/Init.hpp
|
108
|
+
- rice/Init.ipp
|
109
|
+
- rice/JumpException.hpp
|
110
|
+
- rice/JumpException.ipp
|
111
|
+
- rice/MemoryView.hpp
|
112
|
+
- rice/MemoryView.ipp
|
101
113
|
- rice/Return.hpp
|
102
114
|
- rice/Return.ipp
|
103
|
-
- rice/
|
104
|
-
- rice/
|
105
|
-
- rice/
|
115
|
+
- rice/cpp_api/Array.hpp
|
116
|
+
- rice/cpp_api/Array.ipp
|
117
|
+
- rice/cpp_api/Builtin_Object.hpp
|
118
|
+
- rice/cpp_api/Builtin_Object.ipp
|
119
|
+
- rice/cpp_api/Class.hpp
|
120
|
+
- rice/cpp_api/Class.ipp
|
121
|
+
- rice/cpp_api/Encoding.hpp
|
122
|
+
- rice/cpp_api/Encoding.ipp
|
123
|
+
- rice/cpp_api/Hash.hpp
|
124
|
+
- rice/cpp_api/Hash.ipp
|
125
|
+
- rice/cpp_api/Identifier.hpp
|
126
|
+
- rice/cpp_api/Identifier.ipp
|
127
|
+
- rice/cpp_api/Module.hpp
|
128
|
+
- rice/cpp_api/Module.ipp
|
129
|
+
- rice/cpp_api/Object.hpp
|
130
|
+
- rice/cpp_api/Object.ipp
|
131
|
+
- rice/cpp_api/String.hpp
|
132
|
+
- rice/cpp_api/String.ipp
|
133
|
+
- rice/cpp_api/Struct.hpp
|
134
|
+
- rice/cpp_api/Struct.ipp
|
135
|
+
- rice/cpp_api/Symbol.hpp
|
136
|
+
- rice/cpp_api/Symbol.ipp
|
137
|
+
- rice/cpp_api/shared_methods.hpp
|
138
|
+
- rice/detail/DefaultHandler.hpp
|
139
|
+
- rice/detail/DefaultHandler.ipp
|
106
140
|
- rice/detail/HandlerRegistry.hpp
|
107
141
|
- rice/detail/HandlerRegistry.ipp
|
108
142
|
- rice/detail/InstanceRegistry.hpp
|
109
143
|
- rice/detail/InstanceRegistry.ipp
|
110
|
-
- rice/detail/Jump_Tag.hpp
|
111
144
|
- rice/detail/MethodInfo.hpp
|
112
145
|
- rice/detail/MethodInfo.ipp
|
113
|
-
- rice/detail/
|
114
|
-
- rice/detail/
|
146
|
+
- rice/detail/Native.hpp
|
147
|
+
- rice/detail/Native.ipp
|
148
|
+
- rice/detail/NativeAttributeGet.hpp
|
149
|
+
- rice/detail/NativeAttributeGet.ipp
|
150
|
+
- rice/detail/NativeAttributeSet.hpp
|
151
|
+
- rice/detail/NativeAttributeSet.ipp
|
152
|
+
- rice/detail/NativeCallbackFFI.hpp
|
153
|
+
- rice/detail/NativeCallbackFFI.ipp
|
154
|
+
- rice/detail/NativeCallbackSimple.hpp
|
155
|
+
- rice/detail/NativeCallbackSimple.ipp
|
115
156
|
- rice/detail/NativeFunction.hpp
|
116
157
|
- rice/detail/NativeFunction.ipp
|
117
158
|
- rice/detail/NativeIterator.hpp
|
118
159
|
- rice/detail/NativeIterator.ipp
|
119
160
|
- rice/detail/NativeRegistry.hpp
|
120
161
|
- rice/detail/NativeRegistry.ipp
|
162
|
+
- rice/detail/Proc.hpp
|
163
|
+
- rice/detail/Proc.ipp
|
121
164
|
- rice/detail/Registries.hpp
|
122
165
|
- rice/detail/Registries.ipp
|
123
166
|
- rice/detail/RubyFunction.hpp
|
124
167
|
- rice/detail/RubyFunction.ipp
|
168
|
+
- rice/detail/RubyType.hpp
|
169
|
+
- rice/detail/RubyType.ipp
|
125
170
|
- rice/detail/Type.hpp
|
126
171
|
- rice/detail/Type.ipp
|
127
172
|
- rice/detail/TypeRegistry.hpp
|
@@ -133,17 +178,61 @@ files:
|
|
133
178
|
- rice/detail/default_allocation_func.ipp
|
134
179
|
- rice/detail/from_ruby.hpp
|
135
180
|
- rice/detail/from_ruby.ipp
|
136
|
-
- rice/detail/from_ruby_defn.hpp
|
137
181
|
- rice/detail/ruby.hpp
|
138
182
|
- rice/detail/to_ruby.hpp
|
139
183
|
- rice/detail/to_ruby.ipp
|
140
|
-
- rice/detail/to_ruby_defn.hpp
|
141
184
|
- rice/forward_declares.ipp
|
142
185
|
- rice/global_function.hpp
|
143
186
|
- rice/global_function.ipp
|
187
|
+
- rice/libc/file.hpp
|
188
|
+
- rice/libc/file.ipp
|
144
189
|
- rice/rice.hpp
|
145
190
|
- rice/ruby_mark.hpp
|
146
191
|
- rice/stl.hpp
|
192
|
+
- rice/stl/complex.hpp
|
193
|
+
- rice/stl/complex.ipp
|
194
|
+
- rice/stl/exception.hpp
|
195
|
+
- rice/stl/exception.ipp
|
196
|
+
- rice/stl/exception_ptr.hpp
|
197
|
+
- rice/stl/exception_ptr.ipp
|
198
|
+
- rice/stl/map.hpp
|
199
|
+
- rice/stl/map.ipp
|
200
|
+
- rice/stl/monostate.hpp
|
201
|
+
- rice/stl/monostate.ipp
|
202
|
+
- rice/stl/multimap.hpp
|
203
|
+
- rice/stl/multimap.ipp
|
204
|
+
- rice/stl/optional.hpp
|
205
|
+
- rice/stl/optional.ipp
|
206
|
+
- rice/stl/pair.hpp
|
207
|
+
- rice/stl/pair.ipp
|
208
|
+
- rice/stl/reference_wrapper.hpp
|
209
|
+
- rice/stl/reference_wrapper.ipp
|
210
|
+
- rice/stl/set.hpp
|
211
|
+
- rice/stl/set.ipp
|
212
|
+
- rice/stl/shared_ptr.hpp
|
213
|
+
- rice/stl/shared_ptr.ipp
|
214
|
+
- rice/stl/string.hpp
|
215
|
+
- rice/stl/string.ipp
|
216
|
+
- rice/stl/string_view.hpp
|
217
|
+
- rice/stl/string_view.ipp
|
218
|
+
- rice/stl/tuple.hpp
|
219
|
+
- rice/stl/tuple.ipp
|
220
|
+
- rice/stl/type_index.hpp
|
221
|
+
- rice/stl/type_index.ipp
|
222
|
+
- rice/stl/type_info.hpp
|
223
|
+
- rice/stl/type_info.ipp
|
224
|
+
- rice/stl/unique_ptr.hpp
|
225
|
+
- rice/stl/unique_ptr.ipp
|
226
|
+
- rice/stl/unordered_map.hpp
|
227
|
+
- rice/stl/unordered_map.ipp
|
228
|
+
- rice/stl/variant.hpp
|
229
|
+
- rice/stl/variant.ipp
|
230
|
+
- rice/stl/vector.hpp
|
231
|
+
- rice/stl/vector.ipp
|
232
|
+
- rice/traits/attribute_traits.hpp
|
233
|
+
- rice/traits/function_traits.hpp
|
234
|
+
- rice/traits/method_traits.hpp
|
235
|
+
- rice/traits/rice_traits.hpp
|
147
236
|
- sample/callbacks/extconf.rb
|
148
237
|
- sample/callbacks/sample_callbacks.cpp
|
149
238
|
- sample/callbacks/test.rb
|
@@ -171,7 +260,9 @@ files:
|
|
171
260
|
- test/test_Address_Registration_Guard.cpp
|
172
261
|
- test/test_Array.cpp
|
173
262
|
- test/test_Attribute.cpp
|
263
|
+
- test/test_Buffer.cpp
|
174
264
|
- test/test_Builtin_Object.cpp
|
265
|
+
- test/test_Callback.cpp
|
175
266
|
- test/test_Class.cpp
|
176
267
|
- test/test_Constructor.cpp
|
177
268
|
- test/test_Data_Object.cpp
|
@@ -179,34 +270,46 @@ files:
|
|
179
270
|
- test/test_Director.cpp
|
180
271
|
- test/test_Enum.cpp
|
181
272
|
- test/test_Exception.cpp
|
273
|
+
- test/test_File.cpp
|
274
|
+
- test/test_From_Ruby.cpp
|
182
275
|
- test/test_Hash.cpp
|
183
276
|
- test/test_Identifier.cpp
|
184
277
|
- test/test_Inheritance.cpp
|
185
278
|
- test/test_Iterator.cpp
|
186
|
-
- test/
|
279
|
+
- test/test_Jump_Exception.cpp
|
187
280
|
- test/test_Keep_Alive.cpp
|
188
281
|
- test/test_Keep_Alive_No_Wrapper.cpp
|
189
282
|
- test/test_Memory_Management.cpp
|
190
283
|
- test/test_Module.cpp
|
191
284
|
- test/test_Native_Registry.cpp
|
192
285
|
- test/test_Object.cpp
|
286
|
+
- test/test_Overloads.cpp
|
193
287
|
- test/test_Ownership.cpp
|
288
|
+
- test/test_Proc.cpp
|
194
289
|
- test/test_Self.cpp
|
290
|
+
- test/test_Stl_Exception.cpp
|
195
291
|
- test/test_Stl_Map.cpp
|
292
|
+
- test/test_Stl_Multimap.cpp
|
196
293
|
- test/test_Stl_Optional.cpp
|
197
294
|
- test/test_Stl_Pair.cpp
|
198
295
|
- test/test_Stl_Reference_Wrapper.cpp
|
199
|
-
- test/
|
296
|
+
- test/test_Stl_Set.cpp
|
297
|
+
- test/test_Stl_SharedPtr.cpp
|
200
298
|
- test/test_Stl_String.cpp
|
201
299
|
- test/test_Stl_String_View.cpp
|
300
|
+
- test/test_Stl_Tuple.cpp
|
301
|
+
- test/test_Stl_Type.cpp
|
302
|
+
- test/test_Stl_UniquePtr.cpp
|
202
303
|
- test/test_Stl_Unordered_Map.cpp
|
203
304
|
- test/test_Stl_Variant.cpp
|
204
305
|
- test/test_Stl_Vector.cpp
|
205
306
|
- test/test_String.cpp
|
206
307
|
- test/test_Struct.cpp
|
207
308
|
- test/test_Symbol.cpp
|
208
|
-
- test/
|
309
|
+
- test/test_Template.cpp
|
310
|
+
- test/test_To_Ruby.cpp
|
209
311
|
- test/test_Tracking.cpp
|
312
|
+
- test/test_Type.cpp
|
210
313
|
- test/test_global_functions.cpp
|
211
314
|
- test/unittest.cpp
|
212
315
|
- test/unittest.hpp
|
@@ -218,7 +321,6 @@ metadata:
|
|
218
321
|
changelog_uri: https://github.com/ruby-rice/rice/blob/master/CHANGELOG.md
|
219
322
|
documentation_uri: https://ruby-rice.github.io
|
220
323
|
source_code_uri: https://github.com/ruby-rice/rice
|
221
|
-
post_install_message:
|
222
324
|
rdoc_options: []
|
223
325
|
require_paths:
|
224
326
|
- lib
|
@@ -226,15 +328,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
328
|
requirements:
|
227
329
|
- - ">="
|
228
330
|
- !ruby/object:Gem::Version
|
229
|
-
version: '3.
|
331
|
+
version: '3.1'
|
230
332
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
333
|
requirements:
|
232
334
|
- - ">="
|
233
335
|
- !ruby/object:Gem::Version
|
234
336
|
version: '0'
|
235
337
|
requirements: []
|
236
|
-
rubygems_version: 3.
|
237
|
-
signing_key:
|
338
|
+
rubygems_version: 3.6.9
|
238
339
|
specification_version: 4
|
239
340
|
summary: Ruby Interface for C++ Extensions
|
240
341
|
test_files:
|
data/lib/version.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
#ifndef Rice__Address_Registration_Guard_defn__hpp_
|
2
|
-
#define Rice__Address_Registration_Guard_defn__hpp_
|
3
|
-
|
4
|
-
#include "cpp_api/Object_defn.hpp"
|
5
|
-
#include "detail/ruby.hpp"
|
6
|
-
|
7
|
-
namespace Rice
|
8
|
-
{
|
9
|
-
//! A guard to register a given address with the GC.
|
10
|
-
/*! Calls rb_gc_register_address upon construction and
|
11
|
-
* rb_gc_unregister_address upon destruction.
|
12
|
-
* For example:
|
13
|
-
* \code
|
14
|
-
* Class Foo
|
15
|
-
* {
|
16
|
-
* public:
|
17
|
-
* Foo()
|
18
|
-
* : string_(rb_str_new2())
|
19
|
-
* , guard_(&string_);
|
20
|
-
*
|
21
|
-
* private:
|
22
|
-
* VALUE string_;
|
23
|
-
* Address_Registration_Guard guard_;
|
24
|
-
* };
|
25
|
-
* \endcode
|
26
|
-
*/
|
27
|
-
class Address_Registration_Guard
|
28
|
-
{
|
29
|
-
public:
|
30
|
-
//! Register an address with the GC.
|
31
|
-
/* \param address The address to register with the GC. The address
|
32
|
-
* must point to a valid ruby object (RObject).
|
33
|
-
*/
|
34
|
-
Address_Registration_Guard(VALUE* address);
|
35
|
-
|
36
|
-
//! Register an Object with the GC.
|
37
|
-
/*! \param object The Object to register with the GC. The object must
|
38
|
-
* not be destroyed before the Address_Registration_Guard is
|
39
|
-
* destroyed.
|
40
|
-
*/
|
41
|
-
Address_Registration_Guard(Object* object);
|
42
|
-
|
43
|
-
//! Unregister an address/Object with the GC.
|
44
|
-
/*! Destruct an Address_Registration_Guard. The address registered
|
45
|
-
* with the Address_Registration_Guard when it was constructed will
|
46
|
-
* be unregistered from the GC.
|
47
|
-
*/
|
48
|
-
~Address_Registration_Guard();
|
49
|
-
|
50
|
-
// Disable copying
|
51
|
-
Address_Registration_Guard(Address_Registration_Guard const& other) = delete;
|
52
|
-
Address_Registration_Guard& operator=(Address_Registration_Guard const& other) = delete;
|
53
|
-
|
54
|
-
// Enable moving
|
55
|
-
Address_Registration_Guard(Address_Registration_Guard&& other);
|
56
|
-
Address_Registration_Guard& operator=(Address_Registration_Guard&& other);
|
57
|
-
|
58
|
-
//! Get the address that is registered with the GC.
|
59
|
-
VALUE* address() const;
|
60
|
-
|
61
|
-
/** Called during Ruby's exit process since we should not call
|
62
|
-
* rb_gc unregister_address there
|
63
|
-
*/
|
64
|
-
static void disable();
|
65
|
-
|
66
|
-
private:
|
67
|
-
inline static bool enabled = true;
|
68
|
-
inline static bool exit_handler_registered = false;
|
69
|
-
static void registerExitHandler();
|
70
|
-
|
71
|
-
private:
|
72
|
-
void registerAddress() const;
|
73
|
-
void unregisterAddress();
|
74
|
-
|
75
|
-
VALUE* address_ = nullptr;
|
76
|
-
};
|
77
|
-
} // namespace Rice
|
78
|
-
|
79
|
-
#endif // Rice__Address_Registration_Guard_defn__hpp_
|