rice 4.6.1 → 4.7.1
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 +38 -0
- data/CMakeLists.txt +0 -4
- data/Rakefile +2 -8
- data/bin/rice-doc.rb +211 -0
- data/bin/rice-rbs.rb +92 -0
- data/include/rice/rice.hpp +4694 -3704
- data/include/rice/stl.hpp +840 -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 +136 -88
- 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 +4 -4
- 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 +43 -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 -6
- 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 +26 -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 +23 -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 +10 -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 +1 -56
- data/test/test_Data_Type.cpp +20 -30
- data/test/test_Enum.cpp +4 -46
- data/test/test_From_Ruby.cpp +89 -82
- 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 +58 -10
- 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_String_View.cpp +10 -0
- 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_Symbol.cpp +12 -0
- data/test/test_To_Ruby.cpp +35 -28
- data/test/test_Type.cpp +256 -53
- data/test/unittest.hpp +35 -0
- metadata +52 -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
|
@@ -52,7 +52,16 @@ namespace Rice::detail
|
|
|
52
52
|
if constexpr (!std::is_null_pointer_v<Receiver_T>)
|
|
53
53
|
{
|
|
54
54
|
Receiver_T* nativeSelf = From_Ruby<Receiver_T*>().convert(self);
|
|
55
|
-
|
|
55
|
+
|
|
56
|
+
// Deal with pointers to pointes, see Parameter::convertToNative commment
|
|
57
|
+
if constexpr (is_pointer_pointer_v<Attr_T> && !std::is_convertible_v<remove_cv_recursive_t<Attr_T>, Attr_T>)
|
|
58
|
+
{
|
|
59
|
+
nativeSelf->*attribute_ = (Attr_T)From_Ruby<T_Unqualified>().convert(value);
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
{
|
|
63
|
+
nativeSelf->*attribute_ = From_Ruby<T_Unqualified>().convert(value);
|
|
64
|
+
}
|
|
56
65
|
}
|
|
57
66
|
else
|
|
58
67
|
{
|
|
@@ -67,4 +76,23 @@ namespace Rice::detail
|
|
|
67
76
|
{
|
|
68
77
|
return "";
|
|
69
78
|
}
|
|
70
|
-
|
|
79
|
+
|
|
80
|
+
template<typename Attribute_T>
|
|
81
|
+
inline std::string NativeAttributeSet<Attribute_T>::name()
|
|
82
|
+
{
|
|
83
|
+
return this->name_;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
template<typename Attribute_T>
|
|
87
|
+
inline NativeKind NativeAttributeSet<Attribute_T>::kind()
|
|
88
|
+
{
|
|
89
|
+
return NativeKind::AttributeWriter;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
template<typename Attribute_T>
|
|
93
|
+
inline VALUE NativeAttributeSet<Attribute_T>::returnKlass()
|
|
94
|
+
{
|
|
95
|
+
TypeMapper<Attr_T> typeMapper;
|
|
96
|
+
return typeMapper.rubyKlass();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -64,7 +64,7 @@ namespace Rice::detail
|
|
|
64
64
|
on the arguments (Arg_Ts) required by the C++ function. Arg_T may have const/volatile while
|
|
65
65
|
the associated From_Ruby<T> template parameter will not. Thus From_Ruby produces non-const values
|
|
66
66
|
which we let the compiler convert to const values as needed. This works except for
|
|
67
|
-
T** -> const T**, see comment in
|
|
67
|
+
T** -> const T**, see comment in convertToNative method. */
|
|
68
68
|
return std::forward_as_tuple(*(std::tuple_element_t<I, Tuple_T>*)(args[I])...);
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -137,7 +137,7 @@ namespace Rice::detail
|
|
|
137
137
|
VALUE result = detail::protect(rb_funcallv, this->proc_, id.id(), (int)sizeof...(Arg_Ts), values.data());
|
|
138
138
|
if constexpr (!std::is_void_v<Return_T>)
|
|
139
139
|
{
|
|
140
|
-
static From_Ruby<Return_T> fromRuby(dynamic_cast<Arg*>(
|
|
140
|
+
static From_Ruby<Return_T> fromRuby(dynamic_cast<Arg*>(methodInfo_->returnInfo()));
|
|
141
141
|
return fromRuby.convert(result);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -15,7 +15,7 @@ namespace Rice::detail
|
|
|
15
15
|
VALUE result = detail::protect(rb_funcallv, proc, id.id(), (int)sizeof...(Arg_Ts), values.data());
|
|
16
16
|
if constexpr (!std::is_void_v<Return_T>)
|
|
17
17
|
{
|
|
18
|
-
static From_Ruby<Return_T> fromRuby(dynamic_cast<Arg*>(
|
|
18
|
+
static From_Ruby<Return_T> fromRuby(dynamic_cast<Arg*>(methodInfo_->returnInfo()));
|
|
19
19
|
return fromRuby.convert(result);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -35,77 +35,40 @@ namespace Rice::detail
|
|
|
35
35
|
* calling them methods (self) or functions (no self).
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
-
template<typename
|
|
38
|
+
template<typename Function_T>
|
|
39
39
|
class NativeFunction: Native
|
|
40
40
|
{
|
|
41
41
|
public:
|
|
42
|
-
using NativeFunction_T = NativeFunction<
|
|
42
|
+
using NativeFunction_T = NativeFunction<Function_T>;
|
|
43
43
|
|
|
44
44
|
// We remove const to avoid an explosion of To_Ruby specializations and Ruby doesn't
|
|
45
45
|
// have the concept of constants anyways
|
|
46
46
|
using Return_T = typename function_traits<Function_T>::return_type;
|
|
47
|
-
using
|
|
48
|
-
using Arg_Ts = typename
|
|
49
|
-
static constexpr std::size_t arity = method_traits<Function_T, IsMethod>::arity;
|
|
50
|
-
using From_Ruby_Args_Ts = typename tuple_map<From_Ruby, Arg_Ts>::type;
|
|
47
|
+
using Class_T = typename function_traits<Function_T>::class_type;
|
|
48
|
+
using Arg_Ts = typename function_traits<Function_T>::arg_types;
|
|
51
49
|
using To_Ruby_T = remove_cv_recursive_t<Return_T>;
|
|
52
50
|
|
|
53
51
|
// Register function with Ruby
|
|
54
52
|
static void define(VALUE klass, std::string method_name, Function_T function, MethodInfo* methodInfo);
|
|
55
53
|
|
|
56
|
-
// Proc entry
|
|
57
|
-
static VALUE procEntry(VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE* argv, VALUE blockarg);
|
|
58
|
-
static VALUE finalizerCallback(VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE* argv, VALUE blockarg);
|
|
59
54
|
public:
|
|
60
|
-
|
|
61
|
-
NativeFunction() = delete;
|
|
62
|
-
NativeFunction(const NativeFunction_T&) = delete;
|
|
63
|
-
NativeFunction(NativeFunction_T&&) = delete;
|
|
64
|
-
void operator=(const NativeFunction_T&) = delete;
|
|
65
|
-
void operator=(NativeFunction_T&&) = delete;
|
|
55
|
+
NativeFunction(VALUE klass, std::string method_name, Function_T function, MethodInfo* methodInfo);
|
|
66
56
|
|
|
67
|
-
Resolved matches(size_t argc, const VALUE* argv, VALUE self) override;
|
|
68
57
|
VALUE operator()(size_t argc, const VALUE* argv, VALUE self) override;
|
|
69
58
|
std::string toString() override;
|
|
70
59
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
protected:
|
|
60
|
+
std::string name() override;
|
|
61
|
+
NativeKind kind() override;
|
|
62
|
+
VALUE returnKlass() override;
|
|
75
63
|
|
|
76
64
|
private:
|
|
77
|
-
template<int I>
|
|
78
|
-
Convertible matchParameter(std::vector<std::optional<VALUE>>& value);
|
|
79
|
-
|
|
80
|
-
template<std::size_t...I>
|
|
81
|
-
Convertible matchParameters(std::vector<std::optional<VALUE>>& values, std::index_sequence<I...>& indices);
|
|
82
|
-
|
|
83
65
|
template<std::size_t...I>
|
|
84
66
|
std::vector<std::string> argTypeNames(std::ostringstream& stream, std::index_sequence<I...>& indices);
|
|
85
67
|
|
|
86
|
-
template<typename T, std::size_t I>
|
|
87
|
-
From_Ruby<T> createFromRuby();
|
|
88
|
-
|
|
89
|
-
// Create NativeArgs which are used to convert values from Ruby to C++
|
|
90
|
-
template<std::size_t...I>
|
|
91
|
-
From_Ruby_Args_Ts createFromRuby(std::index_sequence<I...>& indices);
|
|
92
|
-
|
|
93
|
-
// Convert C++ value to Ruby
|
|
94
|
-
To_Ruby<To_Ruby_T> createToRuby();
|
|
95
|
-
|
|
96
|
-
// Convert Ruby argv pointer to Ruby values
|
|
97
|
-
std::vector<std::optional<VALUE>> getRubyValues(size_t argc, const VALUE* argv, bool validate);
|
|
98
|
-
|
|
99
|
-
template<typename Arg_T, int I>
|
|
100
|
-
Arg_T getNativeValue(std::vector<std::optional<VALUE>>& values);
|
|
101
|
-
|
|
102
68
|
// Convert Ruby values to C++ values
|
|
103
69
|
template<typename std::size_t...I>
|
|
104
70
|
Arg_Ts getNativeValues(std::vector<std::optional<VALUE>>& values, std::index_sequence<I...>& indices);
|
|
105
71
|
|
|
106
|
-
// Figure out what self is
|
|
107
|
-
Receiver_T getReceiver(VALUE self);
|
|
108
|
-
|
|
109
72
|
// Throw an exception when wrapper cannot be extracted
|
|
110
73
|
[[noreturn]] void noWrapper(const VALUE klass, const std::string& wrapper);
|
|
111
74
|
|
|
@@ -113,16 +76,15 @@ namespace Rice::detail
|
|
|
113
76
|
void checkKeepAlive(VALUE self, VALUE returnValue, std::vector<std::optional<VALUE>>& rubyValues);
|
|
114
77
|
|
|
115
78
|
// Call the underlying C++ function
|
|
116
|
-
VALUE
|
|
117
|
-
VALUE
|
|
79
|
+
VALUE invoke(Arg_Ts&& nativeArgs);
|
|
80
|
+
VALUE invokeNoGVL(Arg_Ts&& nativeArgs);
|
|
118
81
|
|
|
119
82
|
private:
|
|
120
83
|
VALUE klass_;
|
|
121
84
|
std::string method_name_;
|
|
122
85
|
Function_T function_;
|
|
123
|
-
From_Ruby_Args_Ts fromRubys_;
|
|
124
|
-
To_Ruby<To_Ruby_T> toRuby_;
|
|
125
86
|
std::unique_ptr<MethodInfo> methodInfo_;
|
|
87
|
+
To_Ruby<To_Ruby_T> toRuby_;
|
|
126
88
|
};
|
|
127
89
|
}
|
|
128
90
|
|