rice 4.7.0 → 4.8.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 +36 -1
- data/CMakeLists.txt +14 -22
- data/CMakePresets.json +203 -75
- data/FindRuby.cmake +358 -123
- data/bin/rice-doc.rb +56 -142
- data/bin/rice-rbs.rb +1 -2
- data/include/rice/api.hpp +248 -0
- data/include/rice/rice.hpp +2281 -1668
- data/include/rice/stl.hpp +364 -443
- data/lib/rice/doc/config.rb +70 -0
- data/lib/rice/doc/cpp_reference.rb +1 -4
- data/lib/rice/doc/mkdocs.rb +58 -20
- data/lib/rice/doc/rice.rb +20 -0
- data/lib/rice/doc.rb +1 -0
- data/lib/rice/make_rice_headers.rb +7 -0
- data/lib/rice/native_registry.rb +2 -2
- data/lib/rice/rbs.rb +4 -4
- data/lib/rice/version.rb +1 -1
- data/lib/rubygems_plugin.rb +12 -9
- data/rice/Arg.hpp +12 -6
- data/rice/Arg.ipp +14 -7
- data/rice/Buffer.ipp +44 -40
- data/rice/Callback.hpp +1 -1
- data/rice/Callback.ipp +2 -7
- data/rice/Constructor.hpp +1 -1
- data/rice/Constructor.ipp +11 -11
- data/rice/Data_Object.ipp +59 -30
- data/rice/Data_Type.hpp +9 -10
- data/rice/Data_Type.ipp +22 -25
- data/rice/Director.hpp +1 -0
- data/rice/Enum.ipp +58 -39
- data/rice/Exception.hpp +4 -4
- data/rice/Exception.ipp +7 -7
- data/rice/NoGVL.hpp +13 -0
- data/rice/Reference.hpp +56 -0
- data/rice/Reference.ipp +96 -0
- data/rice/Return.hpp +4 -1
- data/rice/Return.ipp +0 -6
- data/rice/cpp_api/Array.hpp +44 -7
- data/rice/cpp_api/Array.ipp +105 -9
- data/rice/cpp_api/Class.hpp +2 -2
- data/rice/cpp_api/Class.ipp +4 -4
- data/rice/cpp_api/Hash.ipp +7 -4
- data/rice/cpp_api/Module.hpp +4 -4
- data/rice/cpp_api/Module.ipp +12 -10
- data/rice/cpp_api/Object.hpp +4 -4
- data/rice/cpp_api/Object.ipp +15 -12
- data/rice/cpp_api/String.hpp +2 -2
- data/rice/cpp_api/String.ipp +11 -8
- data/rice/cpp_api/Symbol.ipp +16 -7
- data/rice/cpp_api/shared_methods.hpp +5 -9
- data/rice/detail/InstanceRegistry.hpp +0 -2
- data/rice/detail/Native.hpp +31 -21
- data/rice/detail/Native.ipp +281 -133
- data/rice/detail/NativeAttributeGet.hpp +5 -7
- data/rice/detail/NativeAttributeGet.ipp +26 -26
- data/rice/detail/NativeAttributeSet.hpp +2 -4
- data/rice/detail/NativeAttributeSet.ipp +20 -16
- data/rice/detail/NativeCallback.hpp +77 -0
- data/rice/detail/NativeCallback.ipp +280 -0
- data/rice/detail/NativeFunction.hpp +11 -21
- data/rice/detail/NativeFunction.ipp +58 -119
- data/rice/detail/NativeInvoker.hpp +4 -4
- data/rice/detail/NativeInvoker.ipp +7 -7
- data/rice/detail/NativeIterator.hpp +2 -4
- data/rice/detail/NativeIterator.ipp +18 -14
- data/rice/detail/NativeMethod.hpp +10 -20
- data/rice/detail/NativeMethod.ipp +54 -114
- data/rice/detail/NativeProc.hpp +5 -7
- data/rice/detail/NativeProc.ipp +39 -28
- data/rice/detail/NativeRegistry.hpp +0 -1
- data/rice/detail/NativeRegistry.ipp +0 -1
- data/rice/detail/Parameter.hpp +15 -8
- data/rice/detail/Parameter.ipp +102 -43
- data/rice/detail/Proc.ipp +14 -28
- data/rice/detail/RubyType.ipp +2 -53
- data/rice/detail/Type.hpp +23 -7
- data/rice/detail/Type.ipp +73 -93
- data/rice/detail/TypeRegistry.ipp +5 -4
- data/rice/detail/Wrapper.hpp +1 -1
- data/rice/detail/Wrapper.ipp +18 -10
- data/rice/detail/from_ruby.hpp +8 -6
- data/rice/detail/from_ruby.ipp +306 -173
- data/rice/detail/ruby.hpp +23 -0
- data/rice/libc/file.hpp +4 -4
- data/rice/rice.hpp +6 -8
- data/rice/rice_api/Native.ipp +5 -1
- data/rice/rice_api/Parameter.ipp +1 -1
- data/rice/ruby_mark.hpp +2 -1
- data/rice/stl/complex.ipp +12 -8
- data/rice/stl/map.ipp +27 -22
- data/rice/stl/monostate.ipp +16 -12
- data/rice/stl/multimap.hpp +0 -2
- data/rice/stl/multimap.ipp +27 -22
- data/rice/stl/optional.ipp +27 -11
- data/rice/stl/pair.ipp +5 -5
- data/rice/stl/reference_wrapper.ipp +5 -4
- data/rice/stl/set.ipp +16 -16
- data/rice/stl/shared_ptr.hpp +0 -16
- data/rice/stl/shared_ptr.ipp +34 -190
- data/rice/stl/string.ipp +18 -18
- data/rice/stl/string_view.ipp +19 -1
- data/rice/stl/tuple.ipp +15 -36
- data/rice/stl/unique_ptr.ipp +18 -8
- data/rice/stl/unordered_map.ipp +20 -15
- data/rice/stl/variant.ipp +37 -21
- data/rice/stl/vector.ipp +41 -36
- data/rice/traits/function_traits.hpp +19 -19
- data/rice/traits/method_traits.hpp +4 -4
- data/rice/traits/rice_traits.hpp +162 -39
- data/rice.gemspec +1 -4
- data/test/test_Array.cpp +261 -3
- data/test/test_Attribute.cpp +6 -3
- data/test/test_Buffer.cpp +6 -42
- data/test/test_Callback.cpp +77 -23
- data/test/test_Data_Object.cpp +2 -2
- data/test/test_Data_Type.cpp +23 -23
- data/test/test_Director.cpp +2 -4
- data/test/test_Enum.cpp +34 -5
- data/test/test_File.cpp +9 -5
- data/test/test_From_Ruby.cpp +7 -6
- data/test/test_GVL.cpp +3 -3
- data/test/test_Hash.cpp +1 -1
- data/test/test_Iterator.cpp +54 -22
- data/test/test_Keep_Alive.cpp +1 -1
- data/test/test_Keep_Alive_No_Wrapper.cpp +1 -1
- data/test/test_Module.cpp +5 -5
- data/test/test_Overloads.cpp +395 -50
- data/test/test_Proc.cpp +54 -0
- data/test/test_Reference.cpp +181 -0
- data/test/test_Self.cpp +2 -2
- data/test/test_Stl_Set.cpp +6 -6
- data/test/test_Stl_SharedPtr.cpp +54 -30
- data/test/test_Stl_String_View.cpp +12 -0
- data/test/test_Stl_Tuple.cpp +1 -1
- data/test/test_Stl_Variant.cpp +6 -14
- data/test/test_Stl_Vector.cpp +61 -30
- data/test/test_String.cpp +4 -2
- data/test/test_Struct.cpp +1 -1
- data/test/test_Symbol.cpp +12 -0
- data/test/test_To_Ruby.cpp +1 -0
- data/test/test_Type.cpp +36 -35
- data/test/test_global_functions.cpp +1 -1
- data/test/unittest.cpp +1 -1
- data/test/unittest.hpp +5 -5
- metadata +10 -24
- data/rice/Function.hpp +0 -17
- data/rice/Function.ipp +0 -13
- data/rice/detail/MethodInfo.hpp +0 -48
- data/rice/detail/MethodInfo.ipp +0 -99
- data/rice/detail/NativeCallbackFFI.hpp +0 -55
- data/rice/detail/NativeCallbackFFI.ipp +0 -152
- data/rice/detail/NativeCallbackSimple.hpp +0 -30
- data/rice/detail/NativeCallbackSimple.ipp +0 -29
data/rice/stl/variant.ipp
CHANGED
|
@@ -8,7 +8,7 @@ namespace Rice::detail
|
|
|
8
8
|
using Tuple_T = std::tuple<Types...>;
|
|
9
9
|
|
|
10
10
|
template<std::size_t... I>
|
|
11
|
-
constexpr static bool verifyTypes(std::index_sequence<I...>&
|
|
11
|
+
constexpr static bool verifyTypes(std::index_sequence<I...>&)
|
|
12
12
|
{
|
|
13
13
|
return (Type<std::tuple_element_t<I, Tuple_T>>::verify() && ...);
|
|
14
14
|
}
|
|
@@ -32,18 +32,23 @@ namespace Rice::detail
|
|
|
32
32
|
public:
|
|
33
33
|
To_Ruby() = default;
|
|
34
34
|
|
|
35
|
-
explicit To_Ruby(
|
|
35
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
36
36
|
{
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
template<typename U, typename V>
|
|
40
40
|
VALUE convertElement(U& data, bool takeOwnership)
|
|
41
41
|
{
|
|
42
|
-
|
|
42
|
+
Arg arg("arg1");
|
|
43
|
+
if (takeOwnership)
|
|
44
|
+
{
|
|
45
|
+
arg.takeOwnership();
|
|
46
|
+
}
|
|
47
|
+
return To_Ruby<V>(&arg).convert(std::forward<V>(std::get<V>(data)));
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
template<typename U, std::size_t... I>
|
|
46
|
-
VALUE convertIterator(U& data, bool takeOwnership, std::index_sequence<I...>&
|
|
51
|
+
VALUE convertIterator(U& data, bool takeOwnership, std::index_sequence<I...>&)
|
|
47
52
|
{
|
|
48
53
|
// Create a tuple of the variant types so we can look over the tuple's types
|
|
49
54
|
using Tuple_T = std::tuple<Types...>;
|
|
@@ -101,7 +106,7 @@ namespace Rice::detail
|
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
private:
|
|
104
|
-
|
|
109
|
+
Arg* arg_ = nullptr;
|
|
105
110
|
};
|
|
106
111
|
|
|
107
112
|
template<typename...Types>
|
|
@@ -110,25 +115,31 @@ namespace Rice::detail
|
|
|
110
115
|
public:
|
|
111
116
|
To_Ruby() = default;
|
|
112
117
|
|
|
113
|
-
explicit To_Ruby(
|
|
118
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
114
119
|
{
|
|
115
120
|
}
|
|
116
121
|
|
|
117
122
|
template<typename U, typename V>
|
|
118
123
|
VALUE convertElement(U& data, bool takeOwnership)
|
|
119
124
|
{
|
|
125
|
+
Arg arg("arg1");
|
|
126
|
+
if (takeOwnership)
|
|
127
|
+
{
|
|
128
|
+
arg.takeOwnership();
|
|
129
|
+
}
|
|
130
|
+
|
|
120
131
|
if constexpr (std::is_const_v<U>)
|
|
121
132
|
{
|
|
122
|
-
return To_Ruby<V>().convert(std::get<V>(data));
|
|
133
|
+
return To_Ruby<V>(&arg).convert(std::get<V>(data));
|
|
123
134
|
}
|
|
124
135
|
else
|
|
125
136
|
{
|
|
126
|
-
return To_Ruby<V>().convert(std::forward<V>(std::get<V>(data)));
|
|
137
|
+
return To_Ruby<V>(&arg).convert(std::forward<V>(std::get<V>(data)));
|
|
127
138
|
}
|
|
128
139
|
}
|
|
129
140
|
|
|
130
141
|
template<typename U, std::size_t... I>
|
|
131
|
-
VALUE convertIterator(U& data, bool takeOwnership, std::index_sequence<I...>&
|
|
142
|
+
VALUE convertIterator(U& data, bool takeOwnership, std::index_sequence<I...>&)
|
|
132
143
|
{
|
|
133
144
|
// Create a tuple of the variant types so we can look over the tuple's types
|
|
134
145
|
using Tuple_T = std::tuple<Types...>;
|
|
@@ -154,13 +165,13 @@ namespace Rice::detail
|
|
|
154
165
|
template<typename U>
|
|
155
166
|
VALUE convert(U& data)
|
|
156
167
|
{
|
|
157
|
-
bool isOwner = (this->
|
|
168
|
+
bool isOwner = (this->arg_ && this->arg_->isOwner());
|
|
158
169
|
auto indices = std::make_index_sequence<std::variant_size_v<std::variant<Types...>>>{};
|
|
159
170
|
return convertIterator(data, isOwner, indices);
|
|
160
171
|
}
|
|
161
172
|
|
|
162
173
|
private:
|
|
163
|
-
|
|
174
|
+
Arg* arg_ = nullptr;
|
|
164
175
|
};
|
|
165
176
|
|
|
166
177
|
template<typename...Types>
|
|
@@ -169,18 +180,18 @@ namespace Rice::detail
|
|
|
169
180
|
public:
|
|
170
181
|
From_Ruby() = default;
|
|
171
182
|
|
|
172
|
-
explicit From_Ruby(Arg* arg)
|
|
183
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
173
184
|
{
|
|
174
185
|
}
|
|
175
186
|
|
|
176
|
-
|
|
187
|
+
double is_convertible(VALUE value)
|
|
177
188
|
{
|
|
178
|
-
|
|
189
|
+
double result = Convertible::None;
|
|
179
190
|
|
|
180
191
|
for_each_tuple(this->fromRubys_,
|
|
181
192
|
[&](auto& fromRuby)
|
|
182
193
|
{
|
|
183
|
-
result = result
|
|
194
|
+
result = (std::max)(result, fromRuby.is_convertible(value));
|
|
184
195
|
});
|
|
185
196
|
|
|
186
197
|
return result;
|
|
@@ -192,17 +203,17 @@ namespace Rice::detail
|
|
|
192
203
|
{
|
|
193
204
|
int i = 0;
|
|
194
205
|
int index = -1;
|
|
195
|
-
|
|
206
|
+
double foundScore = Convertible::None;
|
|
196
207
|
|
|
197
208
|
for_each_tuple(this->fromRubys_,
|
|
198
209
|
[&](auto& fromRuby)
|
|
199
210
|
{
|
|
200
|
-
|
|
211
|
+
double score = fromRuby.is_convertible(value);
|
|
201
212
|
|
|
202
|
-
if (
|
|
213
|
+
if (score > foundScore)
|
|
203
214
|
{
|
|
204
215
|
index = i;
|
|
205
|
-
|
|
216
|
+
foundScore = score;
|
|
206
217
|
}
|
|
207
218
|
i++;
|
|
208
219
|
});
|
|
@@ -240,7 +251,10 @@ namespace Rice::detail
|
|
|
240
251
|
return convertInternal<I + 1>(value, index);
|
|
241
252
|
}
|
|
242
253
|
}
|
|
243
|
-
|
|
254
|
+
else
|
|
255
|
+
{
|
|
256
|
+
rb_raise(rb_eArgError, "Could not find converter for variant");
|
|
257
|
+
}
|
|
244
258
|
}
|
|
245
259
|
|
|
246
260
|
std::variant<Types...> convert(VALUE value)
|
|
@@ -250,6 +264,7 @@ namespace Rice::detail
|
|
|
250
264
|
}
|
|
251
265
|
|
|
252
266
|
private:
|
|
267
|
+
Arg* arg_ = nullptr;
|
|
253
268
|
// Possible converters we could use for this variant
|
|
254
269
|
using From_Ruby_Ts = std::tuple<From_Ruby<Types>...>;
|
|
255
270
|
From_Ruby_Ts fromRubys_;
|
|
@@ -261,7 +276,7 @@ namespace Rice::detail
|
|
|
261
276
|
public:
|
|
262
277
|
From_Ruby() = default;
|
|
263
278
|
|
|
264
|
-
explicit From_Ruby(Arg* arg)
|
|
279
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
265
280
|
{
|
|
266
281
|
}
|
|
267
282
|
|
|
@@ -273,6 +288,7 @@ namespace Rice::detail
|
|
|
273
288
|
}
|
|
274
289
|
|
|
275
290
|
private:
|
|
291
|
+
Arg* arg_ = nullptr;
|
|
276
292
|
std::variant<Types...> converted_;
|
|
277
293
|
};
|
|
278
294
|
}
|
data/rice/stl/vector.ipp
CHANGED
|
@@ -39,7 +39,7 @@ namespace Rice
|
|
|
39
39
|
Difference_T normalizeIndex(Size_T size, Difference_T index, bool enforceBounds = false)
|
|
40
40
|
{
|
|
41
41
|
// Negative indices mean count from the right
|
|
42
|
-
if (index < 0 && (-index <= size))
|
|
42
|
+
if (index < 0 && ((Size_T)(-index) <= size))
|
|
43
43
|
{
|
|
44
44
|
index = size + index;
|
|
45
45
|
}
|
|
@@ -83,7 +83,7 @@ namespace Rice
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Wrap the vector
|
|
86
|
-
detail::wrapConstructed<T>(self, Data_Type<T>::ruby_data_type(), data
|
|
86
|
+
detail::wrapConstructed<T>(self, Data_Type<T>::ruby_data_type(), data);
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -99,10 +99,10 @@ namespace Rice
|
|
|
99
99
|
}
|
|
100
100
|
else
|
|
101
101
|
{
|
|
102
|
-
klass_.define_method("resize", [](const T
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
klass_.define_method("resize", [](const T&, Size_T)
|
|
103
|
+
{
|
|
104
|
+
// Do nothing
|
|
105
|
+
});
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -159,7 +159,7 @@ namespace Rice
|
|
|
159
159
|
return vector[index];
|
|
160
160
|
}
|
|
161
161
|
})
|
|
162
|
-
.template define_method<Value_T*(T::*)()>("data", &T::data,
|
|
162
|
+
.template define_method<Value_T*(T::*)()>("data", &T::data, ReturnBuffer());
|
|
163
163
|
}
|
|
164
164
|
else
|
|
165
165
|
{
|
|
@@ -240,7 +240,11 @@ namespace Rice
|
|
|
240
240
|
{
|
|
241
241
|
if constexpr (detail::is_comparable_v<T>)
|
|
242
242
|
{
|
|
243
|
-
klass_.define_method("
|
|
243
|
+
klass_.define_method("==", [](T& vector, T& other)->bool
|
|
244
|
+
{
|
|
245
|
+
return vector == other;
|
|
246
|
+
})
|
|
247
|
+
.define_method("delete", [](T& vector, Parameter_T element) -> std::optional<Value_T>
|
|
244
248
|
{
|
|
245
249
|
auto iter = std::find(vector.begin(), vector.end(), element);
|
|
246
250
|
if (iter == vector.end())
|
|
@@ -274,21 +278,22 @@ namespace Rice
|
|
|
274
278
|
return iter - vector.begin();
|
|
275
279
|
}
|
|
276
280
|
});
|
|
281
|
+
rb_define_alias(klass_, "eql?", "==");
|
|
277
282
|
}
|
|
278
283
|
else
|
|
279
284
|
{
|
|
280
|
-
klass_.define_method("delete", [](T
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
.define_method("include?", [](const T
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
.define_method("index", [](const T
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
285
|
+
klass_.define_method("delete", [](T&, Parameter_T) -> std::optional<Value_T>
|
|
286
|
+
{
|
|
287
|
+
return std::nullopt;
|
|
288
|
+
})
|
|
289
|
+
.define_method("include?", [](const T&, Parameter_T)
|
|
290
|
+
{
|
|
291
|
+
return false;
|
|
292
|
+
})
|
|
293
|
+
.define_method("index", [](const T&, Parameter_T) -> std::optional<Difference_T>
|
|
294
|
+
{
|
|
295
|
+
return std::nullopt;
|
|
296
|
+
});
|
|
292
297
|
}
|
|
293
298
|
}
|
|
294
299
|
|
|
@@ -313,7 +318,7 @@ namespace Rice
|
|
|
313
318
|
})
|
|
314
319
|
.define_method("insert", [this](T& vector, Difference_T index, Parameter_T element) -> T&
|
|
315
320
|
{
|
|
316
|
-
|
|
321
|
+
size_t normalized = normalizeIndex(vector.size(), index, true);
|
|
317
322
|
// For a Ruby array a positive index means insert the element before the index. But
|
|
318
323
|
// a negative index means insert the element *after* the index. std::vector
|
|
319
324
|
// inserts *before* the index. So add 1 if this is a negative index.
|
|
@@ -412,10 +417,10 @@ namespace Rice
|
|
|
412
417
|
}
|
|
413
418
|
else
|
|
414
419
|
{
|
|
415
|
-
klass_.define_method("to_s", [](const T&
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
420
|
+
klass_.define_method("to_s", [](const T&)
|
|
421
|
+
{
|
|
422
|
+
return "[Not printable]";
|
|
423
|
+
});
|
|
419
424
|
}
|
|
420
425
|
}
|
|
421
426
|
|
|
@@ -477,7 +482,7 @@ namespace Rice
|
|
|
477
482
|
{
|
|
478
483
|
}
|
|
479
484
|
|
|
480
|
-
|
|
485
|
+
double is_convertible(VALUE value)
|
|
481
486
|
{
|
|
482
487
|
switch (rb_type(value))
|
|
483
488
|
{
|
|
@@ -487,7 +492,7 @@ namespace Rice
|
|
|
487
492
|
case RUBY_T_ARRAY:
|
|
488
493
|
if constexpr (std::is_default_constructible_v<T>)
|
|
489
494
|
{
|
|
490
|
-
return Convertible::
|
|
495
|
+
return Convertible::Exact;
|
|
491
496
|
}
|
|
492
497
|
default:
|
|
493
498
|
return Convertible::None;
|
|
@@ -513,7 +518,7 @@ namespace Rice
|
|
|
513
518
|
}
|
|
514
519
|
default:
|
|
515
520
|
{
|
|
516
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
521
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
517
522
|
detail::protect(rb_obj_classname, value), "std::vector");
|
|
518
523
|
}
|
|
519
524
|
}
|
|
@@ -533,7 +538,7 @@ namespace Rice
|
|
|
533
538
|
{
|
|
534
539
|
}
|
|
535
540
|
|
|
536
|
-
|
|
541
|
+
double is_convertible(VALUE value)
|
|
537
542
|
{
|
|
538
543
|
switch (rb_type(value))
|
|
539
544
|
{
|
|
@@ -543,7 +548,7 @@ namespace Rice
|
|
|
543
548
|
case RUBY_T_ARRAY:
|
|
544
549
|
if constexpr (std::is_default_constructible_v<T>)
|
|
545
550
|
{
|
|
546
|
-
return Convertible::
|
|
551
|
+
return Convertible::Exact;
|
|
547
552
|
}
|
|
548
553
|
default:
|
|
549
554
|
return Convertible::None;
|
|
@@ -570,7 +575,7 @@ namespace Rice
|
|
|
570
575
|
}
|
|
571
576
|
default:
|
|
572
577
|
{
|
|
573
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
578
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
574
579
|
detail::protect(rb_obj_classname, value), "std::vector");
|
|
575
580
|
}
|
|
576
581
|
}
|
|
@@ -591,7 +596,7 @@ namespace Rice
|
|
|
591
596
|
{
|
|
592
597
|
}
|
|
593
598
|
|
|
594
|
-
|
|
599
|
+
double is_convertible(VALUE value)
|
|
595
600
|
{
|
|
596
601
|
switch (rb_type(value))
|
|
597
602
|
{
|
|
@@ -604,7 +609,7 @@ namespace Rice
|
|
|
604
609
|
case RUBY_T_ARRAY:
|
|
605
610
|
if constexpr (std::is_default_constructible_v<T>)
|
|
606
611
|
{
|
|
607
|
-
return Convertible::
|
|
612
|
+
return Convertible::Exact;
|
|
608
613
|
}
|
|
609
614
|
default:
|
|
610
615
|
return Convertible::None;
|
|
@@ -631,7 +636,7 @@ namespace Rice
|
|
|
631
636
|
}
|
|
632
637
|
default:
|
|
633
638
|
{
|
|
634
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
639
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
635
640
|
detail::protect(rb_obj_classname, value), "std::vector");
|
|
636
641
|
}
|
|
637
642
|
}
|
|
@@ -652,7 +657,7 @@ namespace Rice
|
|
|
652
657
|
public:
|
|
653
658
|
To_Ruby() = default;
|
|
654
659
|
|
|
655
|
-
explicit To_Ruby(
|
|
660
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
656
661
|
{
|
|
657
662
|
}
|
|
658
663
|
|
|
@@ -662,7 +667,7 @@ namespace Rice
|
|
|
662
667
|
}
|
|
663
668
|
|
|
664
669
|
private:
|
|
665
|
-
|
|
670
|
+
Arg* arg_ = nullptr;
|
|
666
671
|
};
|
|
667
672
|
}
|
|
668
673
|
}
|
|
@@ -9,12 +9,12 @@ namespace Rice::detail
|
|
|
9
9
|
template<typename Function_T>
|
|
10
10
|
struct function_traits;
|
|
11
11
|
|
|
12
|
-
template<typename Return_T, typename Class_T, typename...
|
|
13
|
-
struct function_traits<Return_T(Class_T,
|
|
12
|
+
template<typename Return_T, typename Class_T, typename...Parameter_Ts>
|
|
13
|
+
struct function_traits<Return_T(Class_T, Parameter_Ts...)>
|
|
14
14
|
{
|
|
15
|
-
using arg_types = std::tuple<
|
|
15
|
+
using arg_types = std::tuple<Parameter_Ts...>;
|
|
16
16
|
|
|
17
|
-
static constexpr std::size_t arity = sizeof...(
|
|
17
|
+
static constexpr std::size_t arity = sizeof...(Parameter_Ts);
|
|
18
18
|
|
|
19
19
|
template<std::size_t N>
|
|
20
20
|
using nth_arg = typename std::tuple_element_t<N, arg_types>;
|
|
@@ -37,47 +37,47 @@ namespace Rice::detail
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
// C functions and static member functions passed by pointer
|
|
40
|
-
template<typename Return_T, typename ...
|
|
41
|
-
struct function_traits<Return_T(*)(
|
|
40
|
+
template<typename Return_T, typename ...Parameter_Ts>
|
|
41
|
+
struct function_traits<Return_T(*)(Parameter_Ts...)> : public function_traits<Return_T(std::nullptr_t, Parameter_Ts...)>
|
|
42
42
|
{
|
|
43
|
-
using Function_T = Return_T(*)(
|
|
43
|
+
using Function_T = Return_T(*)(Parameter_Ts...);
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// C functions passed by pointer that take one or more defined parameter than a variable
|
|
47
47
|
// number of parameters (the second ...)
|
|
48
|
-
template<typename Return_T, typename ...
|
|
49
|
-
struct function_traits<Return_T(*)(
|
|
48
|
+
template<typename Return_T, typename ...Parameter_Ts>
|
|
49
|
+
struct function_traits<Return_T(*)(Parameter_Ts..., ...)> : public function_traits<Return_T(std::nullptr_t, Parameter_Ts...)>
|
|
50
50
|
{
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// C Functions or static member functions passed by reference
|
|
54
|
-
template<typename Return_T, typename ...
|
|
55
|
-
struct function_traits<Return_T(&)(
|
|
54
|
+
template<typename Return_T, typename ...Parameter_Ts>
|
|
55
|
+
struct function_traits<Return_T(&)(Parameter_Ts...)> : public function_traits<Return_T(std::nullptr_t, Parameter_Ts...)>
|
|
56
56
|
{
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// Member Functions on C++ classes
|
|
60
|
-
template<typename Return_T, typename Class_T, typename...
|
|
61
|
-
struct function_traits<Return_T(Class_T::*)(
|
|
60
|
+
template<typename Return_T, typename Class_T, typename...Parameter_Ts>
|
|
61
|
+
struct function_traits<Return_T(Class_T::*)(Parameter_Ts...)> : public function_traits<Return_T(Class_T*, Parameter_Ts...)>
|
|
62
62
|
{
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
// const member Functions on C++ classes
|
|
66
|
-
template<typename Return_T, typename Class_T, typename...
|
|
67
|
-
struct function_traits<Return_T(Class_T::*)(
|
|
66
|
+
template<typename Return_T, typename Class_T, typename...Parameter_Ts>
|
|
67
|
+
struct function_traits<Return_T(Class_T::*)(Parameter_Ts...) const> : public function_traits<Return_T(Class_T*, Parameter_Ts...)>
|
|
68
68
|
{
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
// noexcept member Functions on C++ classes
|
|
72
|
-
template<typename Return_T, typename Class_T, typename...
|
|
73
|
-
struct function_traits<Return_T(Class_T::*)(
|
|
72
|
+
template<typename Return_T, typename Class_T, typename...Parameter_Ts>
|
|
73
|
+
struct function_traits<Return_T(Class_T::*)(Parameter_Ts...) noexcept> : public function_traits<Return_T(Class_T*, Parameter_Ts...)>
|
|
74
74
|
{
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
// const noexcept member Functions on C++ classes
|
|
79
|
-
template<typename Return_T, typename Class_T, typename...
|
|
80
|
-
struct function_traits<Return_T(Class_T::*)(
|
|
79
|
+
template<typename Return_T, typename Class_T, typename...Parameter_Ts>
|
|
80
|
+
struct function_traits<Return_T(Class_T::*)(Parameter_Ts...) const noexcept> : public function_traits<Return_T(Class_T*, Parameter_Ts...)>
|
|
81
81
|
{
|
|
82
82
|
};
|
|
83
83
|
|
|
@@ -18,8 +18,8 @@ namespace Rice::detail
|
|
|
18
18
|
{
|
|
19
19
|
using Return_T = typename function_traits<Function_T>::return_type;
|
|
20
20
|
using Class_T = typename function_traits<Function_T>::template nth_arg<0>;
|
|
21
|
-
using
|
|
22
|
-
static constexpr std::size_t arity = std::tuple_size_v<
|
|
21
|
+
using Parameter_Ts = typename tuple_shift<typename function_traits<Function_T>::arg_types>::type;
|
|
22
|
+
static constexpr std::size_t arity = std::tuple_size_v<Parameter_Ts>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
// Member functions that have an implied self parameter of an object instance
|
|
@@ -29,8 +29,8 @@ namespace Rice::detail
|
|
|
29
29
|
{
|
|
30
30
|
using Return_T = typename function_traits<Function_T>::return_type;
|
|
31
31
|
using Class_T = typename function_traits<Function_T>::class_type;
|
|
32
|
-
using
|
|
33
|
-
static constexpr std::size_t arity = std::tuple_size_v<
|
|
32
|
+
using Parameter_Ts = typename function_traits<Function_T>::arg_types;
|
|
33
|
+
static constexpr std::size_t arity = std::tuple_size_v<Parameter_Ts>;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
#endif // Rice__detail__method_traits__hpp_
|