rice 4.6.1 → 4.7.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 +31 -0
- data/CMakeLists.txt +0 -4
- data/Rakefile +2 -8
- data/bin/rice-doc.rb +212 -0
- data/bin/rice-rbs.rb +93 -0
- data/include/rice/rice.hpp +4972 -4015
- data/include/rice/stl.hpp +822 -294
- data/lib/rice/doc/cpp_reference.rb +166 -0
- data/lib/rice/doc/doxygen.rb +294 -0
- data/lib/rice/doc/mkdocs.rb +298 -0
- data/lib/rice/doc/rice.rb +29 -0
- data/lib/rice/doc/ruby.rb +37 -0
- data/lib/rice/doc.rb +5 -0
- data/lib/{make_rice_headers.rb → rice/make_rice_headers.rb} +3 -0
- data/lib/rice/native.rb +18 -0
- data/lib/rice/native_registry.rb +21 -0
- data/lib/rice/parameter.rb +7 -0
- data/lib/rice/rbs.rb +104 -0
- data/lib/rice/version.rb +1 -1
- data/lib/rice.rb +4 -0
- data/lib/rubygems/cmake_builder.rb +24 -27
- data/rice/Arg.hpp +4 -4
- data/rice/Arg.ipp +4 -4
- data/rice/Buffer.hpp +32 -28
- data/rice/Buffer.ipp +306 -178
- data/rice/Data_Object.ipp +101 -82
- data/rice/Data_Type.hpp +5 -7
- data/rice/Data_Type.ipp +48 -29
- data/rice/Enum.ipp +15 -21
- data/rice/Function.hpp +17 -0
- data/rice/Function.ipp +13 -0
- data/rice/Pointer.hpp +15 -0
- data/rice/Pointer.ipp +49 -0
- data/rice/Return.hpp +1 -1
- data/rice/Return.ipp +2 -2
- data/rice/api.hpp +30 -0
- data/rice/cpp_api/Array.hpp +2 -2
- data/rice/cpp_api/Array.ipp +50 -5
- data/rice/cpp_api/Class.hpp +0 -5
- data/rice/cpp_api/Class.ipp +19 -0
- data/rice/cpp_api/Hash.ipp +20 -0
- data/rice/cpp_api/Module.hpp +6 -3
- data/rice/cpp_api/Module.ipp +49 -11
- data/rice/cpp_api/Object.ipp +31 -2
- data/rice/cpp_api/String.hpp +1 -2
- data/rice/cpp_api/String.ipp +21 -1
- data/rice/cpp_api/Struct.ipp +5 -0
- data/rice/cpp_api/Symbol.ipp +34 -0
- data/rice/cpp_api/shared_methods.hpp +12 -12
- data/rice/detail/MethodInfo.hpp +4 -2
- data/rice/detail/MethodInfo.ipp +19 -3
- data/rice/detail/ModuleRegistry.hpp +18 -0
- data/rice/detail/ModuleRegistry.ipp +25 -0
- data/rice/detail/Native.hpp +45 -2
- data/rice/detail/Native.ipp +196 -2
- data/rice/detail/NativeAttributeGet.hpp +9 -4
- data/rice/detail/NativeAttributeGet.ipp +65 -11
- data/rice/detail/NativeAttributeSet.hpp +4 -0
- data/rice/detail/NativeAttributeSet.ipp +30 -2
- data/rice/detail/NativeCallbackFFI.ipp +2 -2
- data/rice/detail/NativeCallbackSimple.ipp +1 -1
- data/rice/detail/NativeFunction.hpp +11 -49
- data/rice/detail/NativeFunction.ipp +82 -379
- data/rice/detail/NativeInvoker.hpp +74 -0
- data/rice/detail/NativeInvoker.ipp +197 -0
- data/rice/detail/NativeIterator.hpp +4 -0
- data/rice/detail/NativeIterator.ipp +19 -0
- data/rice/detail/NativeMethod.hpp +97 -0
- data/rice/detail/NativeMethod.ipp +332 -0
- data/rice/detail/NativeProc.hpp +51 -0
- data/rice/detail/NativeProc.ipp +133 -0
- data/rice/detail/NativeRegistry.hpp +8 -0
- data/rice/detail/NativeRegistry.ipp +27 -0
- data/rice/detail/Parameter.hpp +47 -0
- data/rice/detail/Parameter.ipp +105 -0
- data/rice/detail/Proc.ipp +14 -13
- data/rice/detail/Registries.hpp +1 -0
- data/rice/detail/RubyType.hpp +0 -2
- data/rice/detail/RubyType.ipp +15 -33
- data/rice/detail/Type.hpp +44 -8
- data/rice/detail/Type.ipp +151 -49
- data/rice/detail/TypeRegistry.hpp +3 -0
- data/rice/detail/TypeRegistry.ipp +17 -27
- data/rice/detail/Types.ipp +430 -0
- data/rice/detail/Wrapper.hpp +12 -0
- data/rice/detail/Wrapper.ipp +45 -2
- data/rice/detail/from_ruby.ipp +567 -1073
- data/rice/detail/ruby.hpp +1 -0
- data/rice/detail/to_ruby.ipp +4 -635
- data/rice/libc/file.ipp +3 -6
- data/rice/rice.hpp +22 -12
- data/rice/rice_api/Arg.hpp +7 -0
- data/rice/rice_api/Arg.ipp +9 -0
- data/rice/rice_api/ModuleRegistry.hpp +7 -0
- data/rice/rice_api/ModuleRegistry.ipp +10 -0
- data/rice/rice_api/Native.hpp +7 -0
- data/rice/rice_api/Native.ipp +52 -0
- data/rice/rice_api/NativeRegistry.hpp +7 -0
- data/rice/rice_api/NativeRegistry.ipp +21 -0
- data/rice/rice_api/Parameter.hpp +7 -0
- data/rice/rice_api/Parameter.ipp +11 -0
- data/rice/rice_api/Registries.hpp +6 -0
- data/rice/rice_api/Registries.ipp +12 -0
- data/rice/rice_api/TypeRegistry.hpp +7 -0
- data/rice/rice_api/TypeRegistry.ipp +10 -0
- data/rice/stl/complex.ipp +35 -0
- data/rice/stl/exception.ipp +20 -7
- data/rice/stl/filesystem.hpp +6 -0
- data/rice/stl/filesystem.ipp +34 -0
- data/rice/stl/map.ipp +13 -21
- data/rice/stl/monostate.ipp +37 -1
- data/rice/stl/multimap.ipp +17 -24
- data/rice/stl/optional.ipp +47 -2
- data/rice/stl/pair.ipp +23 -58
- data/rice/stl/reference_wrapper.ipp +22 -1
- data/rice/stl/set.ipp +17 -9
- data/rice/stl/shared_ptr.ipp +44 -17
- data/rice/stl/string.ipp +175 -7
- data/rice/stl/string_view.ipp +5 -0
- data/rice/stl/tuple.ipp +38 -9
- data/rice/stl/unique_ptr.ipp +46 -2
- data/rice/stl/unordered_map.ipp +13 -21
- data/rice/stl/variant.ipp +47 -11
- data/rice/stl/vector.ipp +183 -104
- data/rice/stl.hpp +1 -0
- data/rice/traits/function_traits.hpp +2 -2
- data/rice/traits/method_traits.hpp +5 -16
- data/rice/traits/rice_traits.hpp +24 -4
- data/rice.gemspec +11 -22
- data/test/embed_ruby.cpp +0 -3
- data/test/test_Array.cpp +38 -38
- data/test/test_Attribute.cpp +187 -2
- data/test/test_Buffer.cpp +302 -26
- data/test/test_Callback.cpp +2 -3
- data/test/test_Class.cpp +5 -5
- data/test/test_Data_Object.cpp +0 -55
- data/test/test_Data_Type.cpp +19 -30
- data/test/test_Enum.cpp +4 -46
- data/test/test_From_Ruby.cpp +88 -81
- data/test/test_GVL.cpp +109 -0
- data/test/test_Iterator.cpp +1 -1
- data/test/test_Keep_Alive_No_Wrapper.cpp +5 -3
- data/test/test_Module.cpp +8 -9
- data/test/test_Object.cpp +1 -1
- data/test/test_Overloads.cpp +3 -3
- data/test/test_Stl_Map.cpp +8 -8
- data/test/test_Stl_Multimap.cpp +4 -4
- data/test/test_Stl_Pair.cpp +5 -3
- data/test/test_Stl_SharedPtr.cpp +24 -12
- data/test/test_Stl_Tuple.cpp +1 -1
- data/test/test_Stl_UniquePtr.cpp +8 -0
- data/test/test_Stl_Unordered_Map.cpp +9 -9
- data/test/test_Stl_Variant.cpp +9 -3
- data/test/test_Stl_Vector.cpp +118 -13
- data/test/test_To_Ruby.cpp +35 -28
- data/test/test_Type.cpp +256 -53
- data/test/unittest.hpp +35 -0
- metadata +66 -34
- data/rice/Init.hpp +0 -8
- data/rice/Init.ipp +0 -8
- data/rice/detail/RubyFunction.hpp +0 -31
- data/rice/detail/RubyFunction.ipp +0 -77
- data/sample/callbacks/extconf.rb +0 -5
- data/sample/callbacks/sample_callbacks.cpp +0 -35
- data/sample/callbacks/test.rb +0 -28
- data/sample/enum/extconf.rb +0 -5
- data/sample/enum/sample_enum.cpp +0 -40
- data/sample/enum/test.rb +0 -8
- data/sample/inheritance/animals.cpp +0 -82
- data/sample/inheritance/extconf.rb +0 -5
- data/sample/inheritance/test.rb +0 -7
- data/sample/map/extconf.rb +0 -5
- data/sample/map/map.cpp +0 -73
- data/sample/map/test.rb +0 -7
- data/test/ext/t1/Foo.hpp +0 -10
- data/test/ext/t1/extconf.rb +0 -4
- data/test/ext/t1/t1.cpp +0 -13
- data/test/ext/t2/extconf.rb +0 -4
- data/test/ext/t2/t2.cpp +0 -11
- data/test/ruby/test_callbacks_sample.rb +0 -28
- data/test/ruby/test_multiple_extensions.rb +0 -18
- data/test/ruby/test_multiple_extensions_same_class.rb +0 -14
- data/test/ruby/test_multiple_extensions_with_inheritance.rb +0 -20
- /data/test/{test_Stl_Type.cpp → test_Stl_Type_Info.cpp} +0 -0
data/rice/stl/multimap.ipp
CHANGED
|
@@ -19,8 +19,7 @@ namespace Rice
|
|
|
19
19
|
MultimapHelper(Data_Type<T> klass) : klass_(klass)
|
|
20
20
|
{
|
|
21
21
|
this->register_pair();
|
|
22
|
-
this->
|
|
23
|
-
this->define_copyable_methods();
|
|
22
|
+
this->define_constructors();
|
|
24
23
|
this->define_capacity_methods();
|
|
25
24
|
this->define_access_methods();
|
|
26
25
|
this->define_comparable_methods();
|
|
@@ -36,27 +35,13 @@ namespace Rice
|
|
|
36
35
|
define_pair<const Key_T, Mapped_T>();
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
void
|
|
38
|
+
void define_constructors()
|
|
40
39
|
{
|
|
41
40
|
klass_.define_constructor(Constructor<T>());
|
|
42
|
-
}
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
if constexpr (std::is_copy_constructible_v<Value_T>)
|
|
47
|
-
{
|
|
48
|
-
klass_.define_method("copy", [](T& multimap) -> T
|
|
49
|
-
{
|
|
50
|
-
return multimap;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
else
|
|
42
|
+
if constexpr (std::is_copy_constructible_v<Key_T> && std::is_copy_constructible_v<Value_T>)
|
|
54
43
|
{
|
|
55
|
-
klass_.
|
|
56
|
-
{
|
|
57
|
-
throw std::runtime_error("Cannot copy multimaps with non-copy constructible types");
|
|
58
|
-
return multimap;
|
|
59
|
-
});
|
|
44
|
+
klass_.define_constructor(Constructor<T, const T&>());
|
|
60
45
|
}
|
|
61
46
|
}
|
|
62
47
|
|
|
@@ -74,14 +59,14 @@ namespace Rice
|
|
|
74
59
|
{
|
|
75
60
|
// Access methods
|
|
76
61
|
klass_.
|
|
77
|
-
define_method("[]", [](
|
|
62
|
+
define_method("[]", [](T& multimap, const Key_T& key) -> Array
|
|
78
63
|
{
|
|
79
64
|
Array result;
|
|
80
65
|
auto range = multimap.equal_range(key);
|
|
81
66
|
|
|
82
67
|
for (auto iter = range.first; iter != range.second; iter++)
|
|
83
68
|
{
|
|
84
|
-
result.push
|
|
69
|
+
result.push(iter->second, false);
|
|
85
70
|
}
|
|
86
71
|
|
|
87
72
|
return result;
|
|
@@ -184,7 +169,8 @@ namespace Rice
|
|
|
184
169
|
auto iter = multimap.begin();
|
|
185
170
|
|
|
186
171
|
std::stringstream stream;
|
|
187
|
-
|
|
172
|
+
detail::TypeMapper<T> typeMapper;
|
|
173
|
+
stream << "<" << typeMapper.rubyName() << ":";
|
|
188
174
|
stream << "{";
|
|
189
175
|
|
|
190
176
|
for (; iter != multimap.end(); iter++)
|
|
@@ -222,8 +208,8 @@ namespace Rice
|
|
|
222
208
|
|
|
223
209
|
if (klassName.empty())
|
|
224
210
|
{
|
|
225
|
-
|
|
226
|
-
klassName =
|
|
211
|
+
detail::TypeMapper<MultiMap_T> typeMapper;
|
|
212
|
+
klassName = typeMapper.rubyName();
|
|
227
213
|
}
|
|
228
214
|
|
|
229
215
|
Module rb_mStd = define_module("Std");
|
|
@@ -397,6 +383,12 @@ namespace Rice
|
|
|
397
383
|
class From_Ruby<std::multimap<T, U>*>
|
|
398
384
|
{
|
|
399
385
|
public:
|
|
386
|
+
From_Ruby() = default;
|
|
387
|
+
|
|
388
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
389
|
+
{
|
|
390
|
+
}
|
|
391
|
+
|
|
400
392
|
Convertible is_convertible(VALUE value)
|
|
401
393
|
{
|
|
402
394
|
switch (rb_type(value))
|
|
@@ -442,6 +434,7 @@ namespace Rice
|
|
|
442
434
|
}
|
|
443
435
|
|
|
444
436
|
private:
|
|
437
|
+
Arg* arg_;
|
|
445
438
|
std::multimap<T, U> converted_;
|
|
446
439
|
};
|
|
447
440
|
}
|
data/rice/stl/optional.ipp
CHANGED
|
@@ -9,23 +9,44 @@ namespace Rice::detail
|
|
|
9
9
|
{
|
|
10
10
|
return Type<intrinsic_type<T>>::verify();
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
static VALUE rubyKlass()
|
|
14
|
+
{
|
|
15
|
+
TypeMapper<T> typeMapper;
|
|
16
|
+
return typeMapper.rubyKlass();
|
|
17
|
+
}
|
|
12
18
|
};
|
|
13
19
|
|
|
14
20
|
template<>
|
|
15
21
|
class To_Ruby<std::nullopt_t>
|
|
16
22
|
{
|
|
17
23
|
public:
|
|
24
|
+
To_Ruby() = default;
|
|
25
|
+
|
|
26
|
+
explicit To_Ruby(Return* returnInfo) : returnInfo_(returnInfo)
|
|
27
|
+
{
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
VALUE convert(const std::nullopt_t& _)
|
|
19
31
|
{
|
|
20
32
|
return Qnil;
|
|
21
33
|
}
|
|
34
|
+
|
|
35
|
+
private:
|
|
36
|
+
Return* returnInfo_ = nullptr;
|
|
22
37
|
};
|
|
23
38
|
|
|
24
39
|
template<typename T>
|
|
25
40
|
class To_Ruby<std::optional<T>>
|
|
26
41
|
{
|
|
27
42
|
public:
|
|
28
|
-
|
|
43
|
+
To_Ruby() = default;
|
|
44
|
+
|
|
45
|
+
explicit To_Ruby(Return* returnInfo) : returnInfo_(returnInfo)
|
|
46
|
+
{
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
VALUE convert(std::optional<T>& data)
|
|
29
50
|
{
|
|
30
51
|
if (data.has_value())
|
|
31
52
|
{
|
|
@@ -36,13 +57,22 @@ namespace Rice::detail
|
|
|
36
57
|
return Qnil;
|
|
37
58
|
}
|
|
38
59
|
}
|
|
60
|
+
|
|
61
|
+
private:
|
|
62
|
+
Return* returnInfo_ = nullptr;
|
|
39
63
|
};
|
|
40
64
|
|
|
41
65
|
template<typename T>
|
|
42
66
|
class To_Ruby<std::optional<T>&>
|
|
43
67
|
{
|
|
44
68
|
public:
|
|
45
|
-
|
|
69
|
+
To_Ruby() = default;
|
|
70
|
+
|
|
71
|
+
explicit To_Ruby(Return* returnInfo) : returnInfo_(returnInfo)
|
|
72
|
+
{
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
VALUE convert(const std::optional<T>& data)
|
|
46
76
|
{
|
|
47
77
|
if (data.has_value())
|
|
48
78
|
{
|
|
@@ -53,12 +83,21 @@ namespace Rice::detail
|
|
|
53
83
|
return Qnil;
|
|
54
84
|
}
|
|
55
85
|
}
|
|
86
|
+
|
|
87
|
+
private:
|
|
88
|
+
Return* returnInfo_ = nullptr;
|
|
56
89
|
};
|
|
57
90
|
|
|
58
91
|
template<typename T>
|
|
59
92
|
class From_Ruby<std::optional<T>>
|
|
60
93
|
{
|
|
61
94
|
public:
|
|
95
|
+
From_Ruby() = default;
|
|
96
|
+
|
|
97
|
+
explicit From_Ruby(Arg* arg)
|
|
98
|
+
{
|
|
99
|
+
}
|
|
100
|
+
|
|
62
101
|
Convertible is_convertible(VALUE value)
|
|
63
102
|
{
|
|
64
103
|
switch (rb_type(value))
|
|
@@ -88,6 +127,12 @@ namespace Rice::detail
|
|
|
88
127
|
class From_Ruby<std::optional<T>&>
|
|
89
128
|
{
|
|
90
129
|
public:
|
|
130
|
+
From_Ruby() = default;
|
|
131
|
+
|
|
132
|
+
explicit From_Ruby(Arg* arg)
|
|
133
|
+
{
|
|
134
|
+
}
|
|
135
|
+
|
|
91
136
|
Convertible is_convertible(VALUE value)
|
|
92
137
|
{
|
|
93
138
|
switch (rb_type(value))
|
data/rice/stl/pair.ipp
CHANGED
|
@@ -10,78 +10,43 @@ namespace Rice
|
|
|
10
10
|
public:
|
|
11
11
|
PairHelper(Data_Type<T> klass) : klass_(klass)
|
|
12
12
|
{
|
|
13
|
-
this->
|
|
14
|
-
this->
|
|
15
|
-
this->define_access_methods();
|
|
16
|
-
this->define_modify_methods();
|
|
13
|
+
this->define_constructors();
|
|
14
|
+
this->define_attributes();
|
|
17
15
|
this->define_to_s();
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
private:
|
|
21
|
-
void
|
|
19
|
+
void define_constructors()
|
|
22
20
|
{
|
|
23
|
-
klass_.define_constructor(Constructor<T
|
|
21
|
+
klass_.define_constructor(Constructor<T>())
|
|
22
|
+
.define_constructor(Constructor<T, typename T::first_type&, typename T::second_type&>());
|
|
23
|
+
|
|
24
|
+
if constexpr (std::is_copy_constructible_v<typename T::first_type> && std::is_copy_constructible_v<typename T::second_type>)
|
|
25
|
+
{
|
|
26
|
+
klass_.define_constructor(Constructor<T, const T&>());
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
void
|
|
30
|
+
void define_attributes()
|
|
27
31
|
{
|
|
28
|
-
|
|
32
|
+
// Access methods
|
|
33
|
+
if constexpr (std::is_const_v<std::remove_reference_t<std::remove_pointer_t<typename T::first_type>>>)
|
|
29
34
|
{
|
|
30
|
-
klass_.
|
|
31
|
-
{
|
|
32
|
-
return pair;
|
|
33
|
-
});
|
|
35
|
+
klass_.define_attr("first", &T::first, Rice::AttrAccess::Read);
|
|
34
36
|
}
|
|
35
37
|
else
|
|
36
38
|
{
|
|
37
|
-
klass_.
|
|
38
|
-
{
|
|
39
|
-
throw std::runtime_error("Cannot copy pair with non-copy constructible types");
|
|
40
|
-
return pair;
|
|
41
|
-
});
|
|
39
|
+
klass_.define_attr("first", &T::first, Rice::AttrAccess::ReadWrite);
|
|
42
40
|
}
|
|
43
|
-
}
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
// Access methods
|
|
48
|
-
klass_.define_method("first", [](T& pair) -> typename T::first_type&
|
|
49
|
-
{
|
|
50
|
-
return pair.first;
|
|
51
|
-
})
|
|
52
|
-
.define_method("second", [](T& pair) -> typename T::second_type&
|
|
53
|
-
{
|
|
54
|
-
return pair.second;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
void define_modify_methods()
|
|
59
|
-
{
|
|
60
|
-
// Access methods
|
|
61
|
-
klass_.define_method("first=", [](T& pair, typename T::first_type& value) -> typename T::first_type&
|
|
42
|
+
if constexpr (std::is_const_v<std::remove_reference_t<std::remove_pointer_t<typename T::second_type>>>)
|
|
62
43
|
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
else
|
|
68
|
-
{
|
|
69
|
-
pair.first = value;
|
|
70
|
-
return pair.first;
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
.define_method("second=", [](T& pair, typename T::second_type& value) -> typename T::second_type&
|
|
44
|
+
klass_.define_attr("second", &T::second, Rice::AttrAccess::Read);
|
|
45
|
+
}
|
|
46
|
+
else
|
|
74
47
|
{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
throw std::runtime_error("Cannot set pair.second since it is a constant");
|
|
78
|
-
}
|
|
79
|
-
else
|
|
80
|
-
{
|
|
81
|
-
pair.second = value;
|
|
82
|
-
return pair.second;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
48
|
+
klass_.define_attr("second", &T::second, Rice::AttrAccess::ReadWrite);
|
|
49
|
+
}
|
|
85
50
|
}
|
|
86
51
|
|
|
87
52
|
void define_to_s()
|
|
@@ -117,8 +82,8 @@ namespace Rice
|
|
|
117
82
|
|
|
118
83
|
if (klassName.empty())
|
|
119
84
|
{
|
|
120
|
-
|
|
121
|
-
klassName =
|
|
85
|
+
detail::TypeMapper<Pair_T> typeMapper;
|
|
86
|
+
klassName = typeMapper.rubyName();
|
|
122
87
|
}
|
|
123
88
|
|
|
124
89
|
Module rb_mStd = define_module("Std");
|
|
@@ -9,22 +9,43 @@ namespace Rice::detail
|
|
|
9
9
|
{
|
|
10
10
|
return Type<T>::verify();
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
static VALUE rubyKlass()
|
|
14
|
+
{
|
|
15
|
+
TypeMapper<T> typeMapper;
|
|
16
|
+
return typeMapper.rubyKlass();
|
|
17
|
+
}
|
|
12
18
|
};
|
|
13
19
|
|
|
14
20
|
template<typename T>
|
|
15
21
|
class To_Ruby<std::reference_wrapper<T>>
|
|
16
22
|
{
|
|
17
23
|
public:
|
|
18
|
-
|
|
24
|
+
To_Ruby() = default;
|
|
25
|
+
|
|
26
|
+
explicit To_Ruby(Return* returnInfo) : returnInfo_(returnInfo)
|
|
27
|
+
{
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
VALUE convert(const std::reference_wrapper<T>& data)
|
|
19
31
|
{
|
|
20
32
|
return To_Ruby<T&>().convert(data.get());
|
|
21
33
|
}
|
|
34
|
+
|
|
35
|
+
private:
|
|
36
|
+
Return* returnInfo_ = nullptr;
|
|
22
37
|
};
|
|
23
38
|
|
|
24
39
|
template<typename T>
|
|
25
40
|
class From_Ruby<std::reference_wrapper<T>>
|
|
26
41
|
{
|
|
27
42
|
public:
|
|
43
|
+
From_Ruby() = default;
|
|
44
|
+
|
|
45
|
+
explicit From_Ruby(Arg* arg)
|
|
46
|
+
{
|
|
47
|
+
}
|
|
48
|
+
|
|
28
49
|
Convertible is_convertible(VALUE value)
|
|
29
50
|
{
|
|
30
51
|
return this->converter_.is_convertible(value);
|
data/rice/stl/set.ipp
CHANGED
|
@@ -176,9 +176,9 @@ namespace Rice
|
|
|
176
176
|
klass_.define_method("to_a", [](T& self) -> VALUE
|
|
177
177
|
{
|
|
178
178
|
Array array;
|
|
179
|
-
for (
|
|
179
|
+
for (auto element: self)
|
|
180
180
|
{
|
|
181
|
-
array.push(element);
|
|
181
|
+
array.push(element, false);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
return array.value();
|
|
@@ -195,7 +195,8 @@ namespace Rice
|
|
|
195
195
|
auto finish = self.end();
|
|
196
196
|
|
|
197
197
|
std::stringstream stream;
|
|
198
|
-
|
|
198
|
+
detail::TypeMapper<T> typeMapper;
|
|
199
|
+
stream << "<" << typeMapper.rubyName() << ":";
|
|
199
200
|
stream << "{";
|
|
200
201
|
|
|
201
202
|
for (; iter != finish; iter++)
|
|
@@ -236,8 +237,8 @@ namespace Rice
|
|
|
236
237
|
|
|
237
238
|
if (klassName.empty())
|
|
238
239
|
{
|
|
239
|
-
|
|
240
|
-
klassName =
|
|
240
|
+
detail::TypeMapper<Set_T> typeMapper;
|
|
241
|
+
klassName = typeMapper.rubyName();
|
|
241
242
|
}
|
|
242
243
|
|
|
243
244
|
Module rb_mStd = define_module("Std");
|
|
@@ -268,11 +269,11 @@ namespace Rice
|
|
|
268
269
|
return Qnil;
|
|
269
270
|
};
|
|
270
271
|
|
|
271
|
-
using
|
|
272
|
+
using Proc_T = decltype(block);
|
|
273
|
+
using NativeProc_T = NativeProc<Proc_T>;
|
|
274
|
+
std::unique_ptr<NativeProc_T> proc(NativeProc_T::define(std::forward<Proc_T>(block)));
|
|
272
275
|
|
|
273
|
-
|
|
274
|
-
NativeFunction_T native(block);
|
|
275
|
-
detail::protect<Function_T>(rb_block_call, rubySet, identifier.id(), 0, nullptr, NativeFunction_T::procEntry, (VALUE)&native);
|
|
276
|
+
detail::protect<Function_T>(rb_block_call, rubySet, identifier.id(), 0, nullptr, NativeProc_T::resolve, (VALUE)proc.get());
|
|
276
277
|
|
|
277
278
|
return result;
|
|
278
279
|
}
|
|
@@ -433,6 +434,12 @@ namespace Rice
|
|
|
433
434
|
private:
|
|
434
435
|
static inline std::string setName = "Set";
|
|
435
436
|
public:
|
|
437
|
+
From_Ruby() = default;
|
|
438
|
+
|
|
439
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
440
|
+
{
|
|
441
|
+
}
|
|
442
|
+
|
|
436
443
|
Convertible is_convertible(VALUE value)
|
|
437
444
|
{
|
|
438
445
|
switch (rb_type(value))
|
|
@@ -489,6 +496,7 @@ namespace Rice
|
|
|
489
496
|
}
|
|
490
497
|
|
|
491
498
|
private:
|
|
499
|
+
Arg* arg_;
|
|
492
500
|
std::set<T> converted_;
|
|
493
501
|
};
|
|
494
502
|
}
|
data/rice/stl/shared_ptr.ipp
CHANGED
|
@@ -11,8 +11,8 @@ namespace Rice
|
|
|
11
11
|
|
|
12
12
|
if (klassName.empty())
|
|
13
13
|
{
|
|
14
|
-
|
|
15
|
-
klassName =
|
|
14
|
+
detail::TypeMapper<SharedPtr_T> typeMapper;
|
|
15
|
+
klassName = typeMapper.rubyName();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
Module rb_mStd = define_module("Std");
|
|
@@ -65,7 +65,29 @@ namespace Rice::detail
|
|
|
65
65
|
{
|
|
66
66
|
static bool verify()
|
|
67
67
|
{
|
|
68
|
-
|
|
68
|
+
if constexpr (std::is_fundamental_v<T>)
|
|
69
|
+
{
|
|
70
|
+
return Type<Pointer<T>>::verify();
|
|
71
|
+
return Type<Buffer<T>>::verify();
|
|
72
|
+
}
|
|
73
|
+
else
|
|
74
|
+
{
|
|
75
|
+
return Type<T>::verify();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static VALUE rubyKlass()
|
|
80
|
+
{
|
|
81
|
+
if (Data_Type<std::shared_ptr<T>>::is_defined())
|
|
82
|
+
{
|
|
83
|
+
std::pair<VALUE, rb_data_type_t*> pair = Registries::instance.types.getType<std::shared_ptr<T>>();
|
|
84
|
+
return pair.first;
|
|
85
|
+
}
|
|
86
|
+
else
|
|
87
|
+
{
|
|
88
|
+
TypeMapper<T> typeMapper;
|
|
89
|
+
return typeMapper.rubyKlass();
|
|
90
|
+
}
|
|
69
91
|
}
|
|
70
92
|
};
|
|
71
93
|
|
|
@@ -73,11 +95,17 @@ namespace Rice::detail
|
|
|
73
95
|
class To_Ruby<std::shared_ptr<T>>
|
|
74
96
|
{
|
|
75
97
|
public:
|
|
98
|
+
To_Ruby() = default;
|
|
99
|
+
|
|
100
|
+
explicit To_Ruby(Arg* arv)
|
|
101
|
+
{
|
|
102
|
+
}
|
|
103
|
+
|
|
76
104
|
VALUE convert(std::shared_ptr<T>& data)
|
|
77
105
|
{
|
|
78
106
|
if constexpr (std::is_fundamental_v<T>)
|
|
79
107
|
{
|
|
80
|
-
return detail::wrap(Data_Type<T
|
|
108
|
+
return detail::wrap<std::shared_ptr<T>>(Data_Type<Pointer<T>>::klass(), Data_Type<Pointer<T>>::ruby_data_type(), data, true);
|
|
81
109
|
}
|
|
82
110
|
else
|
|
83
111
|
{
|
|
@@ -89,7 +117,7 @@ namespace Rice::detail
|
|
|
89
117
|
{
|
|
90
118
|
if constexpr (std::is_fundamental_v<T>)
|
|
91
119
|
{
|
|
92
|
-
return detail::wrap(Data_Type<T
|
|
120
|
+
return detail::wrap<std::shared_ptr<T>>(Data_Type<Pointer<T>>::klass(), Data_Type<Pointer<T>>::ruby_data_type(), data, true);
|
|
93
121
|
}
|
|
94
122
|
else
|
|
95
123
|
{
|
|
@@ -134,10 +162,10 @@ namespace Rice::detail
|
|
|
134
162
|
std::shared_ptr<T>* ptr = unwrap<std::shared_ptr<T>>(value, Data_Type<std::shared_ptr<T>>::ruby_data_type(), false);
|
|
135
163
|
return *ptr;
|
|
136
164
|
}
|
|
137
|
-
else if
|
|
165
|
+
else if (std::is_fundamental_v<T>)
|
|
138
166
|
{
|
|
139
167
|
// Get the wrapper again to validate T's type
|
|
140
|
-
Wrapper<std::shared_ptr<T>>* wrapper = getWrapper<Wrapper<std::shared_ptr<T>>>(value, Data_Type<T
|
|
168
|
+
Wrapper<std::shared_ptr<T>>* wrapper = getWrapper<Wrapper<std::shared_ptr<T>>>(value, Data_Type<Pointer<T>>::ruby_data_type());
|
|
141
169
|
return wrapper->data();
|
|
142
170
|
}
|
|
143
171
|
else
|
|
@@ -155,16 +183,15 @@ namespace Rice::detail
|
|
|
155
183
|
class To_Ruby<std::shared_ptr<T>&>
|
|
156
184
|
{
|
|
157
185
|
public:
|
|
186
|
+
To_Ruby() = default;
|
|
187
|
+
|
|
188
|
+
explicit To_Ruby(Arg* arg)
|
|
189
|
+
{
|
|
190
|
+
}
|
|
191
|
+
|
|
158
192
|
VALUE convert(std::shared_ptr<T>& data)
|
|
159
193
|
{
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
return detail::wrap(Data_Type<T>::klass(), Data_Type<T>::ruby_data_type(), data, true);
|
|
163
|
-
}
|
|
164
|
-
else
|
|
165
|
-
{
|
|
166
|
-
return detail::wrap<std::shared_ptr<T>>(Data_Type<T>::klass(), Data_Type<T>::ruby_data_type(), data, true);
|
|
167
|
-
}
|
|
194
|
+
return detail::wrap(Data_Type<T>::klass(), Data_Type<T>::ruby_data_type(), data, true);
|
|
168
195
|
}
|
|
169
196
|
};
|
|
170
197
|
|
|
@@ -204,10 +231,10 @@ namespace Rice::detail
|
|
|
204
231
|
std::shared_ptr<T>* ptr = unwrap<std::shared_ptr<T>>(value, Data_Type<std::shared_ptr<T>>::ruby_data_type(), false);
|
|
205
232
|
return *ptr;
|
|
206
233
|
}
|
|
207
|
-
else if
|
|
234
|
+
else if (std::is_fundamental_v<T>)
|
|
208
235
|
{
|
|
209
236
|
// Get the wrapper again to validate T's type
|
|
210
|
-
Wrapper<std::shared_ptr<T>>* wrapper = getWrapper<Wrapper<std::shared_ptr<T>>>(value, Data_Type<T
|
|
237
|
+
Wrapper<std::shared_ptr<T>>* wrapper = getWrapper<Wrapper<std::shared_ptr<T>>>(value, Data_Type<Pointer<T>>::ruby_data_type());
|
|
211
238
|
return wrapper->data();
|
|
212
239
|
}
|
|
213
240
|
else
|