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/libc/file.ipp
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
#include <exception>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// so define it for Ruby if necessary
|
|
5
|
-
namespace Rice::libc
|
|
3
|
+
namespace Rice::Libc
|
|
6
4
|
{
|
|
7
5
|
inline Class rb_cLibcFile;
|
|
8
6
|
|
|
9
7
|
inline void define_libc_file()
|
|
10
8
|
{
|
|
11
|
-
Module
|
|
12
|
-
Module rb_mLibc = define_module_under(rb_mRice, "libc");
|
|
9
|
+
Module rb_mLibc = define_module("Libc");
|
|
13
10
|
rb_cLibcFile = define_class_under<FILE>(rb_mLibc, "File");
|
|
14
11
|
}
|
|
15
12
|
}
|
|
@@ -23,7 +20,7 @@ namespace Rice::detail
|
|
|
23
20
|
{
|
|
24
21
|
if (!Data_Type<FILE>::is_defined())
|
|
25
22
|
{
|
|
26
|
-
|
|
23
|
+
Libc::define_libc_file();
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
return true;
|
data/rice/rice.hpp
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
// Ruby
|
|
5
5
|
#include "detail/ruby.hpp"
|
|
6
6
|
|
|
7
|
-
// C++ headers
|
|
7
|
+
// C++ headers have to come after Ruby on MacOS for reasons I do not understand
|
|
8
8
|
#include <cstdio>
|
|
9
|
+
#include <cstring> // For std::memset
|
|
9
10
|
#include <string>
|
|
10
11
|
#include <typeinfo>
|
|
11
12
|
#include <typeindex>
|
|
@@ -21,22 +22,28 @@
|
|
|
21
22
|
#include "traits/method_traits.hpp"
|
|
22
23
|
#include "traits/attribute_traits.hpp"
|
|
23
24
|
|
|
25
|
+
// Wrap C++ objects as Ruby objects
|
|
26
|
+
#include "detail/Wrapper.hpp"
|
|
27
|
+
#include "detail/Type.hpp"
|
|
28
|
+
|
|
24
29
|
// Code for C++ to call Ruby
|
|
25
30
|
#include "Exception.hpp"
|
|
26
31
|
#include "JumpException.hpp"
|
|
27
32
|
#include "JumpException.ipp"
|
|
28
|
-
#include "detail/
|
|
29
|
-
#include "detail/
|
|
33
|
+
#include "detail/NativeInvoker.hpp"
|
|
34
|
+
#include "detail/NativeInvoker.ipp"
|
|
30
35
|
#include "detail/to_ruby.hpp"
|
|
31
36
|
|
|
32
37
|
// Code for Ruby to call C++
|
|
33
38
|
#include "Arg.hpp"
|
|
34
39
|
#include "Return.hpp"
|
|
40
|
+
#include "Function.hpp"
|
|
35
41
|
#include "detail/MethodInfo.hpp"
|
|
36
42
|
#include "detail/from_ruby.hpp"
|
|
43
|
+
#include "detail/RubyType.hpp"
|
|
44
|
+
#include "detail/Parameter.hpp"
|
|
37
45
|
|
|
38
46
|
// C++ API declarations
|
|
39
|
-
#include "detail/Type.hpp"
|
|
40
47
|
#include "cpp_api/Encoding.hpp"
|
|
41
48
|
#include "cpp_api/Identifier.hpp"
|
|
42
49
|
#include "cpp_api/Identifier.ipp"
|
|
@@ -55,26 +62,28 @@
|
|
|
55
62
|
#include "detail/NativeAttributeSet.hpp"
|
|
56
63
|
#include "Data_Type.hpp"
|
|
57
64
|
#include "Data_Object.hpp"
|
|
58
|
-
|
|
59
|
-
// Type Conversion declarations
|
|
60
|
-
#include "detail/RubyType.hpp"
|
|
61
65
|
#include "detail/RubyType.ipp"
|
|
62
|
-
#include "detail/Wrapper.hpp"
|
|
63
66
|
|
|
64
67
|
// Registries
|
|
65
68
|
#include "detail/TypeRegistry.hpp"
|
|
66
69
|
#include "detail/InstanceRegistry.hpp"
|
|
67
70
|
#include "detail/DefaultHandler.hpp"
|
|
68
71
|
#include "detail/HandlerRegistry.hpp"
|
|
72
|
+
#include "detail/ModuleRegistry.hpp"
|
|
69
73
|
#include "detail/NativeRegistry.hpp"
|
|
70
74
|
#include "detail/Registries.hpp"
|
|
71
75
|
|
|
72
76
|
// To / From Ruby
|
|
73
77
|
#include "Arg.ipp"
|
|
78
|
+
#include "detail/Parameter.ipp"
|
|
74
79
|
#include "Return.ipp"
|
|
80
|
+
#include "Function.ipp"
|
|
75
81
|
#include "Constructor.hpp"
|
|
76
82
|
#include "Buffer.hpp"
|
|
83
|
+
#include "Pointer.hpp"
|
|
77
84
|
#include "Buffer.ipp"
|
|
85
|
+
#include "Pointer.ipp"
|
|
86
|
+
#include "detail/Types.ipp"
|
|
78
87
|
#include "detail/to_ruby.ipp"
|
|
79
88
|
#include "detail/from_ruby.ipp"
|
|
80
89
|
#include "detail/Proc.hpp"
|
|
@@ -84,6 +93,7 @@
|
|
|
84
93
|
#include "detail/InstanceRegistry.ipp"
|
|
85
94
|
#include "detail/DefaultHandler.ipp"
|
|
86
95
|
#include "detail/HandlerRegistry.ipp"
|
|
96
|
+
#include "detail/ModuleRegistry.ipp"
|
|
87
97
|
#include "detail/NativeRegistry.ipp"
|
|
88
98
|
#include "detail/Registries.ipp"
|
|
89
99
|
|
|
@@ -101,6 +111,10 @@
|
|
|
101
111
|
#include "detail/NativeFunction.ipp"
|
|
102
112
|
#include "detail/NativeIterator.hpp"
|
|
103
113
|
#include "detail/NativeIterator.ipp"
|
|
114
|
+
#include "detail/NativeMethod.hpp"
|
|
115
|
+
#include "detail/NativeMethod.ipp"
|
|
116
|
+
#include "detail/NativeProc.hpp"
|
|
117
|
+
#include "detail/NativeProc.ipp"
|
|
104
118
|
#include "detail/NativeCallbackFFI.hpp"
|
|
105
119
|
#include "detail/NativeCallbackFFI.ipp"
|
|
106
120
|
#include "detail/NativeCallbackSimple.hpp"
|
|
@@ -147,8 +161,4 @@
|
|
|
147
161
|
// For now include libc support - maybe should be separate header file someday
|
|
148
162
|
#include "libc/file.hpp"
|
|
149
163
|
|
|
150
|
-
// Initialize Rice
|
|
151
|
-
#include "Init.hpp"
|
|
152
|
-
#include "Init.ipp"
|
|
153
|
-
|
|
154
164
|
#endif // Rice__hpp_
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
using namespace Rice;
|
|
2
|
+
|
|
3
|
+
extern "C"
|
|
4
|
+
void Init_Module_Registry()
|
|
5
|
+
{
|
|
6
|
+
Module rb_mRice = define_module("Rice");
|
|
7
|
+
|
|
8
|
+
Rice::define_class_under<detail::ModuleRegistry>(rb_mRice, "ModuleRegistry").
|
|
9
|
+
define_method("modules", &detail::ModuleRegistry::modules, Return().setValue());
|
|
10
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
using namespace Rice;
|
|
2
|
+
|
|
3
|
+
#include <ostream>
|
|
4
|
+
|
|
5
|
+
extern "C"
|
|
6
|
+
inline void Init_Native()
|
|
7
|
+
{
|
|
8
|
+
Module rb_mRice = define_module("Rice");
|
|
9
|
+
|
|
10
|
+
define_enum_under<detail::NativeKind>("NativeKind", rb_mRice)
|
|
11
|
+
.define_value("Function", detail::NativeKind::Function)
|
|
12
|
+
.define_value("Method", detail::NativeKind::Method)
|
|
13
|
+
.define_value("AttributeReader", detail::NativeKind::AttributeReader)
|
|
14
|
+
.define_value("AttributeWriter", detail::NativeKind::AttributeWriter)
|
|
15
|
+
.define_value("Proc", detail::NativeKind::Proc);
|
|
16
|
+
|
|
17
|
+
define_class_under<detail::Native>(rb_mRice, "Native").
|
|
18
|
+
define_method("name", &detail::Native::name).
|
|
19
|
+
define_method("kind", &detail::Native::kind).
|
|
20
|
+
define_method("return_klass", &detail::Native::returnKlass, Return().setValue()).
|
|
21
|
+
define_method("parameters", &detail::Native::parameters).
|
|
22
|
+
define_method("to_s", [](detail::Native& self) -> std::string
|
|
23
|
+
{
|
|
24
|
+
std::ostringstream stream;
|
|
25
|
+
stream << "Native";
|
|
26
|
+
|
|
27
|
+
switch (self.kind())
|
|
28
|
+
{
|
|
29
|
+
case detail::NativeKind::Function:
|
|
30
|
+
stream << "Function";
|
|
31
|
+
break;
|
|
32
|
+
case detail::NativeKind::Method:
|
|
33
|
+
stream << "Method";
|
|
34
|
+
break;
|
|
35
|
+
case detail::NativeKind::Iterator:
|
|
36
|
+
stream << "Iterator";
|
|
37
|
+
break;
|
|
38
|
+
case detail::NativeKind::AttributeReader:
|
|
39
|
+
stream << "AttributeReader";
|
|
40
|
+
break;
|
|
41
|
+
case detail::NativeKind::AttributeWriter:
|
|
42
|
+
stream << "AttributeWriter";
|
|
43
|
+
break;
|
|
44
|
+
case detail::NativeKind::Proc:
|
|
45
|
+
stream << "Proc";
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
stream << "<" << self.name() << "> ";
|
|
50
|
+
return stream.str();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
using namespace Rice;
|
|
2
|
+
|
|
3
|
+
extern "C"
|
|
4
|
+
inline void Init_Native_Registry()
|
|
5
|
+
{
|
|
6
|
+
Module rb_mRice = define_module("Rice");
|
|
7
|
+
|
|
8
|
+
Rice::define_class_under<detail::NativeRegistry>(rb_mRice, "NativeRegistry").
|
|
9
|
+
define_method("lookup", [](detail::NativeRegistry& self, VALUE klass) -> Array
|
|
10
|
+
{
|
|
11
|
+
Array result;
|
|
12
|
+
|
|
13
|
+
const std::vector<detail::Native*> natives = self.lookup(klass);
|
|
14
|
+
for (detail::Native* native : natives)
|
|
15
|
+
{
|
|
16
|
+
result.push(native, false);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return result;
|
|
20
|
+
}, Arg("klass").setValue());
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
using namespace Rice;
|
|
2
|
+
|
|
3
|
+
inline void Init_Parameter()
|
|
4
|
+
{
|
|
5
|
+
Module rb_mRice = define_module("Rice");
|
|
6
|
+
|
|
7
|
+
define_class_under<detail::ParameterAbstract>(rb_mRice, "Parameter").
|
|
8
|
+
define_attr("arg", &detail::ParameterAbstract::arg).
|
|
9
|
+
define_method("klass", &detail::ParameterAbstract::klass, Return().setValue()).
|
|
10
|
+
define_method("cpp_klass", &detail::ParameterAbstract::cppTypeName);
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
using namespace Rice;
|
|
2
|
+
|
|
3
|
+
inline void Init_Registries()
|
|
4
|
+
{
|
|
5
|
+
Module rb_mRice = define_module("Rice");
|
|
6
|
+
|
|
7
|
+
define_class_under<detail::Registries>(rb_mRice, "Registries").
|
|
8
|
+
define_singleton_attr("instance", &detail::Registries::instance, AttrAccess::Read).
|
|
9
|
+
define_attr("modules", &detail::Registries::modules, AttrAccess::Read).
|
|
10
|
+
define_attr("natives", &detail::Registries::natives, AttrAccess::Read).
|
|
11
|
+
define_attr("types", &detail::Registries::types, AttrAccess::Read);
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
using namespace Rice;
|
|
2
|
+
|
|
3
|
+
extern "C"
|
|
4
|
+
void Init_Type_Registry()
|
|
5
|
+
{
|
|
6
|
+
Module rb_mRice = define_module("Rice");
|
|
7
|
+
|
|
8
|
+
Rice::define_class_under<detail::TypeRegistry>(rb_mRice, "TypeRegistry").
|
|
9
|
+
define_method("klasses", &detail::TypeRegistry::klasses, Return().setValue());
|
|
10
|
+
}
|
data/rice/stl/complex.ipp
CHANGED
|
@@ -9,12 +9,23 @@ namespace Rice::detail
|
|
|
9
9
|
{
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
static VALUE rubyKlass()
|
|
14
|
+
{
|
|
15
|
+
return rb_cComplex;
|
|
16
|
+
}
|
|
12
17
|
};
|
|
13
18
|
|
|
14
19
|
template<typename T>
|
|
15
20
|
class To_Ruby<std::complex<T>>
|
|
16
21
|
{
|
|
17
22
|
public:
|
|
23
|
+
To_Ruby() = default;
|
|
24
|
+
|
|
25
|
+
explicit To_Ruby(Return* returnInfo) : returnInfo_(returnInfo)
|
|
26
|
+
{
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
VALUE convert(const std::complex<T>& data)
|
|
19
30
|
{
|
|
20
31
|
std::vector<VALUE> args(2);
|
|
@@ -22,12 +33,21 @@ namespace Rice::detail
|
|
|
22
33
|
args[1] = To_Ruby<T>().convert(data.imag());
|
|
23
34
|
return protect(rb_funcallv, rb_mKernel, rb_intern("Complex"), (int)args.size(), (const VALUE*)args.data());
|
|
24
35
|
}
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
Return* returnInfo_ = nullptr;
|
|
25
39
|
};
|
|
26
40
|
|
|
27
41
|
template<typename T>
|
|
28
42
|
class To_Ruby<std::complex<T>&>
|
|
29
43
|
{
|
|
30
44
|
public:
|
|
45
|
+
To_Ruby() = default;
|
|
46
|
+
|
|
47
|
+
explicit To_Ruby(Return* returnInfo) : returnInfo_(returnInfo)
|
|
48
|
+
{
|
|
49
|
+
}
|
|
50
|
+
|
|
31
51
|
VALUE convert(const std::complex<T>& data)
|
|
32
52
|
{
|
|
33
53
|
std::vector<VALUE> args(2);
|
|
@@ -35,12 +55,21 @@ namespace Rice::detail
|
|
|
35
55
|
args[1] = To_Ruby<T>().convert(data.imag());
|
|
36
56
|
return protect(rb_funcallv, rb_mKernel, rb_intern("Complex"), (int)args.size(), (const VALUE*)args.data());
|
|
37
57
|
}
|
|
58
|
+
|
|
59
|
+
private:
|
|
60
|
+
Return* returnInfo_ = nullptr;
|
|
38
61
|
};
|
|
39
62
|
|
|
40
63
|
template<typename T>
|
|
41
64
|
class From_Ruby<std::complex<T>>
|
|
42
65
|
{
|
|
43
66
|
public:
|
|
67
|
+
From_Ruby() = default;
|
|
68
|
+
|
|
69
|
+
explicit From_Ruby(Arg* arg)
|
|
70
|
+
{
|
|
71
|
+
}
|
|
72
|
+
|
|
44
73
|
Convertible is_convertible(VALUE value)
|
|
45
74
|
{
|
|
46
75
|
switch (rb_type(value))
|
|
@@ -66,6 +95,12 @@ namespace Rice::detail
|
|
|
66
95
|
class From_Ruby<std::complex<T>&>
|
|
67
96
|
{
|
|
68
97
|
public:
|
|
98
|
+
From_Ruby() = default;
|
|
99
|
+
|
|
100
|
+
explicit From_Ruby(Arg* arg)
|
|
101
|
+
{
|
|
102
|
+
}
|
|
103
|
+
|
|
69
104
|
Convertible is_convertible(VALUE value)
|
|
70
105
|
{
|
|
71
106
|
switch (rb_type(value))
|
data/rice/stl/exception.ipp
CHANGED
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
// so define it for Ruby if necessary
|
|
5
5
|
namespace Rice::stl
|
|
6
6
|
{
|
|
7
|
-
inline
|
|
8
|
-
|
|
9
|
-
inline void define_stl_exception()
|
|
7
|
+
inline void define_stl_exceptions()
|
|
10
8
|
{
|
|
11
9
|
Module rb_mStd = define_module("Std");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
|
|
11
|
+
define_class_under<std::exception>(rb_mStd, "Exception", rb_eStandardError).
|
|
12
|
+
define_constructor(Constructor<std::exception>()).
|
|
13
|
+
define_method("message", &std::exception::what);
|
|
14
|
+
|
|
15
|
+
define_class_under<std::runtime_error>(rb_mStd, "RuntimeError", rb_eRuntimeError).
|
|
16
|
+
define_constructor(Constructor<std::runtime_error, const char*>()).
|
|
17
|
+
define_method("message", &std::runtime_error::what);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
|
|
@@ -22,7 +25,17 @@ namespace Rice::detail
|
|
|
22
25
|
{
|
|
23
26
|
static bool verify()
|
|
24
27
|
{
|
|
25
|
-
Rice::stl::
|
|
28
|
+
Rice::stl::define_stl_exceptions();
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
template<>
|
|
34
|
+
struct Type<std::runtime_error>
|
|
35
|
+
{
|
|
36
|
+
static bool verify()
|
|
37
|
+
{
|
|
38
|
+
Rice::stl::define_stl_exceptions();
|
|
26
39
|
return true;
|
|
27
40
|
}
|
|
28
41
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include <filesystem>
|
|
2
|
+
|
|
3
|
+
namespace Rice
|
|
4
|
+
{
|
|
5
|
+
namespace stl
|
|
6
|
+
{
|
|
7
|
+
inline void define_filesystem_path()
|
|
8
|
+
{
|
|
9
|
+
Module rb_mStd = define_module("Std");
|
|
10
|
+
Module rb_mFileSystem = define_module_under(rb_mStd, "Filesystem");
|
|
11
|
+
|
|
12
|
+
define_class_under<std::filesystem::path>(rb_mFileSystem, "Path").
|
|
13
|
+
define_constructor(Constructor<std::filesystem::path>()).
|
|
14
|
+
define_constructor(Constructor<std::filesystem::path, std::string>());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
namespace Rice::detail
|
|
20
|
+
{
|
|
21
|
+
template<>
|
|
22
|
+
struct Type<std::filesystem::path>
|
|
23
|
+
{
|
|
24
|
+
static bool verify()
|
|
25
|
+
{
|
|
26
|
+
if (!Data_Type<std::filesystem::path>::is_defined())
|
|
27
|
+
{
|
|
28
|
+
Rice::stl::define_filesystem_path();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
data/rice/stl/map.ipp
CHANGED
|
@@ -19,8 +19,7 @@ namespace Rice
|
|
|
19
19
|
MapHelper(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();
|
|
@@ -37,27 +36,13 @@ namespace Rice
|
|
|
37
36
|
define_pair<const Key_T, Mapped_T>();
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
void
|
|
39
|
+
void define_constructors()
|
|
41
40
|
{
|
|
42
41
|
klass_.define_constructor(Constructor<T>());
|
|
43
|
-
}
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
if constexpr (std::is_copy_constructible_v<Value_T>)
|
|
48
|
-
{
|
|
49
|
-
klass_.define_method("copy", [](T& map) -> T
|
|
50
|
-
{
|
|
51
|
-
return map;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
else
|
|
43
|
+
if constexpr (std::is_copy_constructible_v<Key_T> && std::is_copy_constructible_v<Value_T>)
|
|
55
44
|
{
|
|
56
|
-
klass_.
|
|
57
|
-
{
|
|
58
|
-
throw std::runtime_error("Cannot copy maps with non-copy constructible types");
|
|
59
|
-
return map;
|
|
60
|
-
});
|
|
45
|
+
klass_.define_constructor(Constructor<T, const T&>());
|
|
61
46
|
}
|
|
62
47
|
}
|
|
63
48
|
|
|
@@ -240,8 +225,8 @@ namespace Rice
|
|
|
240
225
|
|
|
241
226
|
if (klassName.empty())
|
|
242
227
|
{
|
|
243
|
-
|
|
244
|
-
klassName =
|
|
228
|
+
detail::TypeMapper<Map_T> typeMapper;
|
|
229
|
+
klassName = typeMapper.rubyName();
|
|
245
230
|
}
|
|
246
231
|
|
|
247
232
|
Module rb_mStd = define_module("Std");
|
|
@@ -418,6 +403,12 @@ namespace Rice
|
|
|
418
403
|
class From_Ruby<std::map<T, U>*>
|
|
419
404
|
{
|
|
420
405
|
public:
|
|
406
|
+
From_Ruby() = default;
|
|
407
|
+
|
|
408
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
409
|
+
{
|
|
410
|
+
}
|
|
411
|
+
|
|
421
412
|
Convertible is_convertible(VALUE value)
|
|
422
413
|
{
|
|
423
414
|
switch (rb_type(value))
|
|
@@ -463,6 +454,7 @@ namespace Rice
|
|
|
463
454
|
}
|
|
464
455
|
|
|
465
456
|
private:
|
|
457
|
+
Arg* arg_;
|
|
466
458
|
std::map<T, U> converted_;
|
|
467
459
|
};
|
|
468
460
|
}
|
data/rice/stl/monostate.ipp
CHANGED
|
@@ -9,32 +9,62 @@ namespace Rice::detail
|
|
|
9
9
|
{
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
static VALUE rubyKlass()
|
|
14
|
+
{
|
|
15
|
+
return rb_cNilClass;
|
|
16
|
+
}
|
|
12
17
|
};
|
|
13
18
|
|
|
14
19
|
template<>
|
|
15
20
|
class To_Ruby<std::monostate>
|
|
16
21
|
{
|
|
17
22
|
public:
|
|
23
|
+
To_Ruby() = default;
|
|
24
|
+
|
|
25
|
+
explicit To_Ruby(Return* returnInfo) : returnInfo_(returnInfo)
|
|
26
|
+
{
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
VALUE convert(const std::monostate& _)
|
|
19
30
|
{
|
|
20
31
|
return Qnil;
|
|
21
32
|
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
private:
|
|
36
|
+
Return* returnInfo_ = nullptr;
|
|
22
37
|
};
|
|
23
38
|
|
|
24
39
|
template<>
|
|
25
40
|
class To_Ruby<std::monostate&>
|
|
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(const std::monostate& data)
|
|
29
50
|
{
|
|
30
51
|
return Qnil;
|
|
31
52
|
}
|
|
53
|
+
|
|
54
|
+
private:
|
|
55
|
+
Return* returnInfo_ = nullptr;
|
|
32
56
|
};
|
|
33
57
|
|
|
34
58
|
template<>
|
|
35
59
|
class From_Ruby<std::monostate>
|
|
36
60
|
{
|
|
37
61
|
public:
|
|
62
|
+
From_Ruby() = default;
|
|
63
|
+
|
|
64
|
+
explicit From_Ruby(Arg* arg)
|
|
65
|
+
{
|
|
66
|
+
}
|
|
67
|
+
|
|
38
68
|
Convertible is_convertible(VALUE value)
|
|
39
69
|
{
|
|
40
70
|
return value == Qnil ? Convertible::Exact : Convertible::None;
|
|
@@ -57,6 +87,12 @@ namespace Rice::detail
|
|
|
57
87
|
class From_Ruby<std::monostate&>
|
|
58
88
|
{
|
|
59
89
|
public:
|
|
90
|
+
From_Ruby() = default;
|
|
91
|
+
|
|
92
|
+
explicit From_Ruby(Arg* arg)
|
|
93
|
+
{
|
|
94
|
+
}
|
|
95
|
+
|
|
60
96
|
Convertible is_convertible(VALUE value)
|
|
61
97
|
{
|
|
62
98
|
return value == Qnil ? Convertible::Exact : Convertible::None;
|