rice 4.3.3 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +63 -26
- data/README.md +7 -2
- data/Rakefile +7 -1
- data/include/rice/rice.hpp +7291 -4430
- data/include/rice/stl.hpp +769 -222
- data/lib/mkmf-rice.rb +37 -95
- data/rice/Address_Registration_Guard.hpp +72 -3
- data/rice/Arg.hpp +19 -5
- data/rice/Arg.ipp +24 -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 +74 -3
- data/rice/Data_Object.ipp +324 -32
- data/rice/Data_Type.hpp +215 -3
- data/rice/Data_Type.ipp +125 -64
- data/rice/Director.hpp +0 -2
- data/rice/Enum.hpp +4 -6
- data/rice/Enum.ipp +101 -57
- data/rice/Exception.hpp +62 -2
- data/rice/Exception.ipp +7 -12
- data/rice/JumpException.hpp +44 -0
- data/rice/JumpException.ipp +48 -0
- data/rice/MemoryView.hpp +11 -0
- data/rice/MemoryView.ipp +43 -0
- data/rice/Return.hpp +6 -26
- data/rice/Return.ipp +10 -16
- 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 +15 -5
- data/rice/detail/MethodInfo.ipp +78 -6
- data/rice/detail/Native.hpp +32 -0
- data/rice/detail/Native.ipp +129 -0
- data/rice/detail/NativeAttributeGet.hpp +51 -0
- data/rice/detail/NativeAttributeGet.ipp +51 -0
- data/rice/detail/NativeAttributeSet.hpp +43 -0
- data/rice/detail/NativeAttributeSet.ipp +82 -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 +20 -21
- data/rice/detail/NativeFunction.ipp +199 -64
- data/rice/detail/NativeIterator.hpp +8 -11
- data/rice/detail/NativeIterator.ipp +27 -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 +19 -0
- data/rice/detail/RubyType.ipp +187 -0
- data/rice/detail/TupleIterator.hpp +14 -0
- data/rice/detail/Type.hpp +5 -6
- data/rice/detail/Type.ipp +150 -33
- data/rice/detail/TypeRegistry.hpp +15 -7
- data/rice/detail/TypeRegistry.ipp +105 -12
- data/rice/detail/Wrapper.hpp +6 -5
- data/rice/detail/Wrapper.ipp +45 -23
- data/rice/detail/cpp_protect.hpp +5 -6
- data/rice/detail/default_allocation_func.ipp +0 -2
- data/rice/detail/from_ruby.hpp +37 -3
- data/rice/detail/from_ruby.ipp +911 -454
- data/rice/detail/ruby.hpp +18 -0
- data/rice/detail/to_ruby.hpp +41 -3
- data/rice/detail/to_ruby.ipp +437 -113
- data/rice/global_function.hpp +0 -4
- data/rice/global_function.ipp +1 -2
- data/rice/rice.hpp +105 -22
- data/rice/ruby_mark.hpp +4 -3
- data/rice/stl.hpp +4 -0
- data/test/embed_ruby.cpp +4 -1
- data/test/extconf.rb +2 -0
- data/test/ruby/test_multiple_extensions_same_class.rb +14 -14
- data/test/test_Address_Registration_Guard.cpp +5 -0
- data/test/test_Array.cpp +12 -1
- data/test/test_Attribute.cpp +103 -21
- data/test/test_Builtin_Object.cpp +5 -0
- data/test/test_Callback.cpp +231 -0
- data/test/test_Class.cpp +5 -31
- data/test/test_Constructor.cpp +69 -6
- data/test/test_Data_Object.cpp +9 -4
- data/test/test_Data_Type.cpp +428 -64
- data/test/test_Director.cpp +10 -5
- data/test/test_Enum.cpp +152 -40
- data/test/test_Exception.cpp +235 -0
- data/test/test_File.cpp +70 -0
- data/test/test_From_Ruby.cpp +542 -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 +5 -0
- data/test/test_JumpException.cpp +22 -0
- data/test/test_Keep_Alive.cpp +6 -1
- data/test/test_Keep_Alive_No_Wrapper.cpp +5 -0
- data/test/test_Memory_Management.cpp +5 -0
- data/test/test_Module.cpp +118 -64
- data/test/test_Native_Registry.cpp +2 -33
- data/test/test_Object.cpp +5 -0
- data/test/test_Overloads.cpp +631 -0
- data/test/test_Ownership.cpp +67 -4
- data/test/test_Proc.cpp +45 -0
- data/test/test_Self.cpp +5 -0
- data/test/test_Stl_Exception.cpp +109 -0
- data/test/test_Stl_Map.cpp +22 -8
- data/test/test_Stl_Optional.cpp +5 -0
- data/test/test_Stl_Pair.cpp +7 -2
- data/test/test_Stl_Reference_Wrapper.cpp +5 -0
- data/test/test_Stl_SmartPointer.cpp +210 -5
- data/test/test_Stl_String.cpp +5 -0
- data/test/test_Stl_String_View.cpp +5 -0
- data/test/test_Stl_Type.cpp +147 -0
- data/test/test_Stl_Unordered_Map.cpp +18 -7
- data/test/test_Stl_Variant.cpp +5 -0
- data/test/test_Stl_Vector.cpp +130 -8
- 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 +152 -0
- data/test/test_Tracking.cpp +1 -0
- data/test/test_Type.cpp +100 -0
- data/test/test_global_functions.cpp +53 -6
- data/test/unittest.cpp +8 -0
- metadata +37 -20
- 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/Identifier.hpp +0 -50
- data/rice/Identifier.ipp +0 -29
- 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_To_From_Ruby.cpp +0 -399
data/rice/detail/ruby.hpp
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
#include <cmath>
|
10
10
|
|
11
11
|
#include <ruby.h>
|
12
|
+
#include <ruby/encoding.h>
|
12
13
|
|
13
14
|
// ruby.h has a few defines that conflict with Visual Studio's STL
|
14
15
|
#if defined(_MSC_VER)
|
@@ -33,5 +34,22 @@ extern "C" typedef VALUE (*RUBY_VALUE_FUNC)(VALUE);
|
|
33
34
|
extern "C" typedef VALUE (*RUBY_METHOD_FUNC)(ANYARGS);
|
34
35
|
#endif
|
35
36
|
|
37
|
+
// This is a terrible hack for Ruby 3.1 and maybe earlier to avoid crashes when test_Attribute unit cases
|
38
|
+
// are run. If ruby_options is called to initialize the interpeter (previously it was not), when
|
39
|
+
// the attribute unit tests intentionally cause exceptions to happen, the exception is correctly processed.
|
40
|
+
// However any calls back to Ruby, for example to get the exception message, crash because the ruby
|
41
|
+
// execution context tag has been set to null. This does not happen in newer versions of Ruby. It is
|
42
|
+
// unknown if this happens in real life or just the test caes.
|
43
|
+
// Should be removed when Rice no longer supports Ruby 3.1
|
44
|
+
#if RUBY_API_VERSION_MAJOR == 3 && RUBY_API_VERSION_MINOR < 2
|
45
|
+
constexpr bool oldRuby = true;
|
46
|
+
#elif RUBY_API_VERSION_MAJOR < 3
|
47
|
+
constexpr bool oldRuby = true;
|
48
|
+
#else
|
49
|
+
constexpr bool oldRuby = false;
|
50
|
+
#endif
|
51
|
+
|
52
|
+
|
53
|
+
|
36
54
|
#endif // Rice__detail__ruby__hpp_
|
37
55
|
|
data/rice/detail/to_ruby.hpp
CHANGED
@@ -1,8 +1,46 @@
|
|
1
1
|
#ifndef Rice__detail__to_ruby__hpp_
|
2
2
|
#define Rice__detail__to_ruby__hpp_
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
namespace Rice
|
5
|
+
{
|
6
|
+
namespace detail
|
7
|
+
{
|
8
|
+
//! Convert a C++ object to Ruby.
|
9
|
+
/*! If x is a pointer, wraps the pointee as a Ruby object. If x is an
|
10
|
+
* Object, returns x.
|
11
|
+
*
|
12
|
+
* If no conversion exists a compile-time error is generated.
|
13
|
+
*
|
14
|
+
* \param x the object to convert.
|
15
|
+
* \return a Ruby representation of the C++ object.
|
16
|
+
*
|
17
|
+
* Example:
|
18
|
+
* \code
|
19
|
+
* rb_p(to_ruby(42));
|
20
|
+
*
|
21
|
+
* Foo * p_foo = new Foo();
|
22
|
+
* rb_p(to_ruby(p_foo));
|
23
|
+
* \endcode
|
24
|
+
*/
|
25
|
+
template <typename T>
|
26
|
+
class To_Ruby;
|
27
|
+
|
28
|
+
// Helper template function that let's users avoid having to specify the template type - its deduced
|
29
|
+
template <typename T>
|
30
|
+
VALUE to_ruby(T&& x)
|
31
|
+
{
|
32
|
+
using Unqualified_T = remove_cv_recursive_t<T>;
|
33
|
+
return To_Ruby<Unqualified_T>().convert(std::forward<T>(x));
|
34
|
+
}
|
6
35
|
|
7
|
-
|
36
|
+
// Helper template function that let's users avoid having to specify the template type - its deduced
|
37
|
+
template <typename T>
|
38
|
+
VALUE to_ruby(T* x)
|
39
|
+
{
|
40
|
+
using Unqualified_T = remove_cv_recursive_t<T>;
|
41
|
+
return To_Ruby<Unqualified_T*>().convert(x);
|
42
|
+
}
|
43
|
+
} // detail
|
44
|
+
} // Rice
|
8
45
|
|
46
|
+
#endif // Rice__detail__to_ruby__hpp_
|