rice2 2.2.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 +7 -0
- data/COPYING +23 -0
- data/Doxyfile +2268 -0
- data/Makefile.am +26 -0
- data/Makefile.in +929 -0
- data/README.md +1054 -0
- data/README.mingw +8 -0
- data/Rakefile +24 -0
- data/aclocal.m4 +1090 -0
- data/bootstrap +8 -0
- data/config.guess +1667 -0
- data/config.sub +1793 -0
- data/configure +8209 -0
- data/configure.ac +55 -0
- data/depcomp +791 -0
- data/doxygen.ac +314 -0
- data/doxygen.am +186 -0
- data/extconf.rb +66 -0
- data/install-sh +529 -0
- data/missing +215 -0
- data/post-autoconf.rb +22 -0
- data/post-automake.rb +28 -0
- data/rice/Address_Registration_Guard.cpp +22 -0
- data/rice/Address_Registration_Guard.hpp +7 -0
- data/rice/Address_Registration_Guard.ipp +37 -0
- data/rice/Address_Registration_Guard_defn.hpp +75 -0
- data/rice/Arg.hpp +8 -0
- data/rice/Arg_impl.hpp +129 -0
- data/rice/Arg_operators.cpp +21 -0
- data/rice/Arg_operators.hpp +19 -0
- data/rice/Array.hpp +214 -0
- data/rice/Array.ipp +256 -0
- data/rice/Builtin_Object.hpp +8 -0
- data/rice/Builtin_Object.ipp +50 -0
- data/rice/Builtin_Object_defn.hpp +50 -0
- data/rice/Class.cpp +57 -0
- data/rice/Class.hpp +8 -0
- data/rice/Class.ipp +6 -0
- data/rice/Class_defn.hpp +83 -0
- data/rice/Constructor.hpp +47 -0
- data/rice/Data_Object.hpp +8 -0
- data/rice/Data_Object.ipp +133 -0
- data/rice/Data_Object_defn.hpp +138 -0
- data/rice/Data_Type.cpp +54 -0
- data/rice/Data_Type.hpp +8 -0
- data/rice/Data_Type.ipp +365 -0
- data/rice/Data_Type_defn.hpp +261 -0
- data/rice/Data_Type_fwd.hpp +12 -0
- data/rice/Director.cpp +13 -0
- data/rice/Director.hpp +39 -0
- data/rice/Enum.hpp +117 -0
- data/rice/Enum.ipp +246 -0
- data/rice/Exception.cpp +59 -0
- data/rice/Exception.hpp +13 -0
- data/rice/Exception_Base.hpp +8 -0
- data/rice/Exception_Base.ipp +13 -0
- data/rice/Exception_Base_defn.hpp +27 -0
- data/rice/Exception_defn.hpp +69 -0
- data/rice/Hash.hpp +227 -0
- data/rice/Hash.ipp +329 -0
- data/rice/Identifier.cpp +8 -0
- data/rice/Identifier.hpp +50 -0
- data/rice/Identifier.ipp +33 -0
- data/rice/Jump_Tag.hpp +24 -0
- data/rice/Makefile.am +122 -0
- data/rice/Makefile.in +885 -0
- data/rice/Module.cpp +84 -0
- data/rice/Module.hpp +8 -0
- data/rice/Module.ipp +6 -0
- data/rice/Module_defn.hpp +88 -0
- data/rice/Module_impl.hpp +281 -0
- data/rice/Module_impl.ipp +345 -0
- data/rice/Object.cpp +169 -0
- data/rice/Object.hpp +8 -0
- data/rice/Object.ipp +33 -0
- data/rice/Object_defn.hpp +214 -0
- data/rice/Require_Guard.hpp +21 -0
- data/rice/String.cpp +94 -0
- data/rice/String.hpp +91 -0
- data/rice/Struct.cpp +117 -0
- data/rice/Struct.hpp +162 -0
- data/rice/Struct.ipp +26 -0
- data/rice/Symbol.cpp +25 -0
- data/rice/Symbol.hpp +66 -0
- data/rice/Symbol.ipp +44 -0
- data/rice/config.hpp +47 -0
- data/rice/config.hpp.in +46 -0
- data/rice/detail/Arguments.hpp +118 -0
- data/rice/detail/Auto_Function_Wrapper.hpp +898 -0
- data/rice/detail/Auto_Function_Wrapper.ipp +3694 -0
- data/rice/detail/Auto_Member_Function_Wrapper.hpp +897 -0
- data/rice/detail/Auto_Member_Function_Wrapper.ipp +2774 -0
- data/rice/detail/Caster.hpp +103 -0
- data/rice/detail/Exception_Handler.hpp +8 -0
- data/rice/detail/Exception_Handler.ipp +68 -0
- data/rice/detail/Exception_Handler_defn.hpp +96 -0
- data/rice/detail/Iterator.hpp +93 -0
- data/rice/detail/Not_Copyable.hpp +25 -0
- data/rice/detail/Wrapped_Function.hpp +33 -0
- data/rice/detail/cfp.hpp +24 -0
- data/rice/detail/cfp.ipp +51 -0
- data/rice/detail/check_ruby_type.cpp +27 -0
- data/rice/detail/check_ruby_type.hpp +23 -0
- data/rice/detail/creation_funcs.hpp +37 -0
- data/rice/detail/creation_funcs.ipp +36 -0
- data/rice/detail/default_allocation_func.hpp +23 -0
- data/rice/detail/default_allocation_func.ipp +11 -0
- data/rice/detail/define_method_and_auto_wrap.hpp +31 -0
- data/rice/detail/define_method_and_auto_wrap.ipp +30 -0
- data/rice/detail/demangle.cpp +56 -0
- data/rice/detail/demangle.hpp +19 -0
- data/rice/detail/env.hpp +11 -0
- data/rice/detail/from_ruby.hpp +43 -0
- data/rice/detail/from_ruby.ipp +60 -0
- data/rice/detail/method_data.cpp +92 -0
- data/rice/detail/method_data.hpp +21 -0
- data/rice/detail/node.hpp +13 -0
- data/rice/detail/protect.cpp +29 -0
- data/rice/detail/protect.hpp +34 -0
- data/rice/detail/ruby.hpp +74 -0
- data/rice/detail/ruby_version_code.hpp +6 -0
- data/rice/detail/ruby_version_code.hpp.in +6 -0
- data/rice/detail/st.hpp +22 -0
- data/rice/detail/to_ruby.hpp +22 -0
- data/rice/detail/to_ruby.ipp +36 -0
- data/rice/detail/traits.hpp +43 -0
- data/rice/detail/win32.hpp +16 -0
- data/rice/detail/wrap_function.hpp +66 -0
- data/rice/global_function.hpp +33 -0
- data/rice/global_function.ipp +22 -0
- data/rice/protect.hpp +38 -0
- data/rice/protect.ipp +1134 -0
- data/rice/ruby_mark.hpp +13 -0
- data/rice/ruby_try_catch.hpp +86 -0
- data/rice/rubypp.rb +97 -0
- data/rice/to_from_ruby.hpp +8 -0
- data/rice/to_from_ruby.ipp +418 -0
- data/rice/to_from_ruby_defn.hpp +70 -0
- data/ruby.ac +135 -0
- data/ruby/Makefile.am +1 -0
- data/ruby/Makefile.in +628 -0
- data/ruby/lib/Makefile.am +3 -0
- data/ruby/lib/Makefile.in +506 -0
- data/ruby/lib/mkmf-rice.rb.in +217 -0
- data/ruby/lib/version.rb +3 -0
- data/sample/Makefile.am +47 -0
- data/sample/Makefile.in +489 -0
- data/sample/enum/extconf.rb +3 -0
- data/sample/enum/sample_enum.cpp +54 -0
- data/sample/enum/test.rb +8 -0
- data/sample/inheritance/animals.cpp +98 -0
- data/sample/inheritance/extconf.rb +3 -0
- data/sample/inheritance/test.rb +7 -0
- data/sample/map/extconf.rb +3 -0
- data/sample/map/map.cpp +81 -0
- data/sample/map/test.rb +7 -0
- data/test/Makefile.am +72 -0
- data/test/Makefile.in +1213 -0
- data/test/ext/Makefile.am +41 -0
- data/test/ext/Makefile.in +483 -0
- data/test/ext/t1/Foo.hpp +10 -0
- data/test/ext/t1/extconf.rb +2 -0
- data/test/ext/t1/t1.cpp +15 -0
- data/test/ext/t2/extconf.rb +2 -0
- data/test/ext/t2/t2.cpp +11 -0
- data/test/test_Address_Registration_Guard.cpp +43 -0
- data/test/test_Array.cpp +248 -0
- data/test/test_Builtin_Object.cpp +71 -0
- data/test/test_Class.cpp +496 -0
- data/test/test_Constructor.cpp +128 -0
- data/test/test_Data_Object.cpp +275 -0
- data/test/test_Data_Type.cpp +348 -0
- data/test/test_Director.cpp +308 -0
- data/test/test_Enum.cpp +215 -0
- data/test/test_Exception.cpp +47 -0
- data/test/test_Hash.cpp +212 -0
- data/test/test_Identifier.cpp +70 -0
- data/test/test_Jump_Tag.cpp +17 -0
- data/test/test_Memory_Management.cpp +50 -0
- data/test/test_Module.cpp +497 -0
- data/test/test_Object.cpp +159 -0
- data/test/test_String.cpp +107 -0
- data/test/test_Struct.cpp +205 -0
- data/test/test_Symbol.cpp +63 -0
- data/test/test_To_From_Ruby.cpp +428 -0
- data/test/test_global_functions.cpp +114 -0
- data/test/test_rice.rb +41 -0
- data/test/unittest.cpp +136 -0
- data/test/unittest.hpp +294 -0
- metadata +297 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
#ifndef Rice__Builtin_Object__ipp_
|
2
|
+
#define Rice__Builtin_Object__ipp_
|
3
|
+
|
4
|
+
#include "Object.hpp"
|
5
|
+
#include "protect.hpp"
|
6
|
+
#include "detail/check_ruby_type.hpp"
|
7
|
+
|
8
|
+
#include <algorithm>
|
9
|
+
|
10
|
+
namespace Rice
|
11
|
+
{
|
12
|
+
|
13
|
+
namespace detail
|
14
|
+
{
|
15
|
+
inline VALUE check_type(Object value, int type)
|
16
|
+
{
|
17
|
+
rb_check_type(value, type);
|
18
|
+
return Qnil;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
template<int Builtin_Type>
|
23
|
+
inline Builtin_Object<Builtin_Type>::
|
24
|
+
Builtin_Object(Object value)
|
25
|
+
: Object(value)
|
26
|
+
, obj_((RObject*)(value.value()))
|
27
|
+
{
|
28
|
+
protect(detail::check_type, value, Builtin_Type);
|
29
|
+
}
|
30
|
+
|
31
|
+
template<int Builtin_Type>
|
32
|
+
inline Builtin_Object<Builtin_Type>::
|
33
|
+
Builtin_Object(Builtin_Object<Builtin_Type> const & other)
|
34
|
+
: Object(other.value())
|
35
|
+
, obj_(other.obj_)
|
36
|
+
{
|
37
|
+
}
|
38
|
+
|
39
|
+
template<int Builtin_Type>
|
40
|
+
inline void Builtin_Object<Builtin_Type>::
|
41
|
+
swap(Builtin_Object<Builtin_Type> & ref)
|
42
|
+
{
|
43
|
+
std::swap(obj_, ref.obj_);
|
44
|
+
Object::swap(ref);
|
45
|
+
}
|
46
|
+
|
47
|
+
} // namespace Rice
|
48
|
+
|
49
|
+
#endif // Rice__Builtin_Object__ipp_
|
50
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#ifndef Rice__Builtin_Object_defn__hpp_
|
2
|
+
#define Rice__Builtin_Object_defn__hpp_
|
3
|
+
|
4
|
+
#include "Object_defn.hpp"
|
5
|
+
#include "detail/ruby.hpp"
|
6
|
+
|
7
|
+
namespace Rice
|
8
|
+
{
|
9
|
+
|
10
|
+
//! A smartpointer-like wrapper for Ruby builtin objects.
|
11
|
+
/*! A builtin object is one of Ruby's internal types, e.g. RArray or
|
12
|
+
* RString. Every builtin type structure has a corresponding integer
|
13
|
+
* type number (e.g T_ARRAY for RArray or T_STRING for RString). This
|
14
|
+
* class is a wrapper for those types of objects, primarily useful as a
|
15
|
+
* base class for other wrapper classes like Array and Hash.
|
16
|
+
*/
|
17
|
+
template<int Builtin_Type>
|
18
|
+
class Builtin_Object
|
19
|
+
: public Object
|
20
|
+
{
|
21
|
+
public:
|
22
|
+
//! Wrap an already allocated Ruby object.
|
23
|
+
/*! Checks to see if the object is an object of type Builtin_Type; a
|
24
|
+
* C++ exception is thrown if this is not the case.
|
25
|
+
* \param value the object to be wrapped.
|
26
|
+
*/
|
27
|
+
Builtin_Object(Object value);
|
28
|
+
|
29
|
+
//! Make a copy of a Builtin_Object
|
30
|
+
/*! \param other the Builtin_Object to be copied.
|
31
|
+
*/
|
32
|
+
Builtin_Object(Builtin_Object const & other);
|
33
|
+
|
34
|
+
RObject & operator*() const { return *obj_; } //!< Return a reference to obj_
|
35
|
+
RObject * operator->() const { return obj_; } //!< Return a pointer to obj_
|
36
|
+
RObject * get() const { return obj_; } //!< Return a pointer to obj_
|
37
|
+
|
38
|
+
//! Swap with another builtin object of the same type
|
39
|
+
/*! \param ref the object with which to swap.
|
40
|
+
*/
|
41
|
+
void swap(Builtin_Object<Builtin_Type> & ref);
|
42
|
+
|
43
|
+
private:
|
44
|
+
RObject * obj_;
|
45
|
+
};
|
46
|
+
|
47
|
+
} // namespace Rice
|
48
|
+
|
49
|
+
#endif // Rice__Builtin_Object_defn__hpp_
|
50
|
+
|
data/rice/Class.cpp
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#include "Class.hpp"
|
2
|
+
#include "Exception.hpp"
|
3
|
+
#include "detail/creation_funcs.hpp"
|
4
|
+
|
5
|
+
Rice::Class::
|
6
|
+
Class()
|
7
|
+
: Module_impl<Module, Class>()
|
8
|
+
{
|
9
|
+
}
|
10
|
+
|
11
|
+
Rice::Class::
|
12
|
+
Class(VALUE v)
|
13
|
+
: Module_impl<Module, Class>(v)
|
14
|
+
{
|
15
|
+
if(::rb_type(v) != T_CLASS)
|
16
|
+
{
|
17
|
+
throw Exception(
|
18
|
+
rb_eTypeError,
|
19
|
+
"Expected a Class but got a %s",
|
20
|
+
rb_class2name(CLASS_OF(v))); // TODO: might raise an exception
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
Rice::Class & Rice::Class::
|
25
|
+
undef_creation_funcs()
|
26
|
+
{
|
27
|
+
detail::undef_creation_funcs(*this);
|
28
|
+
return *this;
|
29
|
+
}
|
30
|
+
|
31
|
+
Rice::Class Rice::
|
32
|
+
define_class_under(
|
33
|
+
Rice::Object module,
|
34
|
+
char const * name,
|
35
|
+
Rice::Object superclass)
|
36
|
+
{
|
37
|
+
VALUE v = rb_define_class_under(module, name, superclass);
|
38
|
+
return Class(v);
|
39
|
+
}
|
40
|
+
|
41
|
+
Rice::Class Rice::
|
42
|
+
define_class(
|
43
|
+
char const * name,
|
44
|
+
Rice::Object superclass)
|
45
|
+
{
|
46
|
+
VALUE v = rb_define_class(name, superclass);
|
47
|
+
return Class(v);
|
48
|
+
}
|
49
|
+
|
50
|
+
Rice::Class Rice::
|
51
|
+
anonymous_class(
|
52
|
+
Rice::Object superclass)
|
53
|
+
{
|
54
|
+
VALUE v = Class(rb_cClass).call("new");
|
55
|
+
return Class(v);
|
56
|
+
}
|
57
|
+
|
data/rice/Class.hpp
ADDED
data/rice/Class.ipp
ADDED
data/rice/Class_defn.hpp
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
#ifndef Rice__Class_defn__hpp_
|
2
|
+
#define Rice__Class_defn__hpp_
|
3
|
+
|
4
|
+
#include "Object_defn.hpp"
|
5
|
+
#include "Module_impl.hpp"
|
6
|
+
#include "Module_defn.hpp"
|
7
|
+
#include "to_from_ruby_defn.hpp"
|
8
|
+
#include "Identifier.hpp"
|
9
|
+
|
10
|
+
/*!
|
11
|
+
* \example inheritance/animals.cpp
|
12
|
+
*/
|
13
|
+
|
14
|
+
namespace Rice
|
15
|
+
{
|
16
|
+
|
17
|
+
//! A helper for defining a Class and its methods.
|
18
|
+
/*! This class provides a C++-style interface to ruby's Class class and
|
19
|
+
* for defining methods on that class.
|
20
|
+
*/
|
21
|
+
class Class
|
22
|
+
: public Module_impl<Module, Class>
|
23
|
+
{
|
24
|
+
public:
|
25
|
+
//! Default construct a new class wrapper and initialize it to
|
26
|
+
//! rb_cObject.
|
27
|
+
Class();
|
28
|
+
|
29
|
+
//! Construct a new class wrapper from a ruby object of type T_CLASS.
|
30
|
+
Class(VALUE v);
|
31
|
+
|
32
|
+
//! Disallow creation of an instance from Ruby code.
|
33
|
+
/*! Undefines the singleton method allocate (or new, if using a
|
34
|
+
* version of ruby prior to 1.7) and the instance method initialize.
|
35
|
+
*/
|
36
|
+
Class & undef_creation_funcs();
|
37
|
+
};
|
38
|
+
|
39
|
+
//! Define a new class in the namespace given by module.
|
40
|
+
/*! \param module the Module in which to define the class.
|
41
|
+
* \param name the name of the class.
|
42
|
+
* \param superclass the base class to use.
|
43
|
+
* \return the new class.
|
44
|
+
*/
|
45
|
+
Class define_class_under(
|
46
|
+
Object module,
|
47
|
+
char const * name,
|
48
|
+
Object superclass = rb_cObject);
|
49
|
+
|
50
|
+
//! Define a new class in the default namespace.
|
51
|
+
/*! \param name the name of the class.
|
52
|
+
* \param superclass the base class to use.
|
53
|
+
* \return the new class.
|
54
|
+
*/
|
55
|
+
Class define_class(
|
56
|
+
char const * name,
|
57
|
+
Object superclass = rb_cObject);
|
58
|
+
|
59
|
+
//! Create a new anonymous class.
|
60
|
+
/*! \param superclass the base class to use.
|
61
|
+
* \return the new class.
|
62
|
+
*/
|
63
|
+
Class anonymous_class(
|
64
|
+
Object superclass = rb_cObject);
|
65
|
+
|
66
|
+
} // namespace Rice
|
67
|
+
|
68
|
+
template<>
|
69
|
+
inline
|
70
|
+
Rice::Class from_ruby<Rice::Class>(Rice::Object x)
|
71
|
+
{
|
72
|
+
return Rice::Class(x);
|
73
|
+
}
|
74
|
+
|
75
|
+
template<>
|
76
|
+
inline
|
77
|
+
Rice::Object to_ruby<Rice::Class>(Rice::Class const & x)
|
78
|
+
{
|
79
|
+
return x;
|
80
|
+
}
|
81
|
+
|
82
|
+
#endif // Rice__Class_defn__hpp_
|
83
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#ifndef Rice__Constructor__hpp_
|
2
|
+
#define Rice__Constructor__hpp_
|
3
|
+
|
4
|
+
// This causes problems with certain C++ libraries
|
5
|
+
#undef TYPE
|
6
|
+
|
7
|
+
#include "to_from_ruby_defn.hpp"
|
8
|
+
|
9
|
+
namespace Rice
|
10
|
+
{
|
11
|
+
//! Define a Type's Constructor and it's arguments.
|
12
|
+
/*! E.g. for the default constructor on a Type:
|
13
|
+
\code
|
14
|
+
define_class<Test>()
|
15
|
+
.define_constructor(Constructor<Test>());
|
16
|
+
\endcode
|
17
|
+
*
|
18
|
+
* The first template type must be the type being wrapped.
|
19
|
+
* Afterwards any extra types must match the appropriate constructor
|
20
|
+
* to be used in C++ when constructing the object.
|
21
|
+
*
|
22
|
+
* For more information, see Rice::Data_Type::define_constructor.
|
23
|
+
*/
|
24
|
+
template<typename T, typename ...Arg_T>
|
25
|
+
class Constructor
|
26
|
+
{
|
27
|
+
public:
|
28
|
+
static void construct(Object self, Arg_T... args)
|
29
|
+
{
|
30
|
+
DATA_PTR(self.value()) = new T(args...);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
|
34
|
+
//! Special-case Constructor used when defining Directors.
|
35
|
+
template<typename T, typename ...Arg_T>
|
36
|
+
class Constructor<T, Object, Arg_T...>
|
37
|
+
{
|
38
|
+
public:
|
39
|
+
static void construct(Object self, Arg_T... args)
|
40
|
+
{
|
41
|
+
DATA_PTR(self.value()) = new T(self, args...);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
#endif
|
47
|
+
|
@@ -0,0 +1,133 @@
|
|
1
|
+
#ifndef Rice__Data_Object__ipp_
|
2
|
+
#define Rice__Data_Object__ipp_
|
3
|
+
|
4
|
+
#include "detail/check_ruby_type.hpp"
|
5
|
+
#include "protect.hpp"
|
6
|
+
|
7
|
+
#include <algorithm>
|
8
|
+
|
9
|
+
template<typename T>
|
10
|
+
const typename Rice::Default_Mark_Function<T>::Ruby_Data_Func
|
11
|
+
Rice::Default_Mark_Function<T>::mark = ruby_mark<T>;
|
12
|
+
|
13
|
+
namespace Rice
|
14
|
+
{
|
15
|
+
|
16
|
+
namespace detail
|
17
|
+
{
|
18
|
+
|
19
|
+
inline VALUE data_wrap_struct(
|
20
|
+
VALUE klass,
|
21
|
+
RUBY_DATA_FUNC mark,
|
22
|
+
RUBY_DATA_FUNC free,
|
23
|
+
void * obj)
|
24
|
+
{
|
25
|
+
return Data_Wrap_Struct(klass, mark, free, obj);
|
26
|
+
}
|
27
|
+
|
28
|
+
template<typename T>
|
29
|
+
inline VALUE wrap(
|
30
|
+
VALUE klass,
|
31
|
+
typename Data_Object<T>::Ruby_Data_Func mark,
|
32
|
+
typename Data_Object<T>::Ruby_Data_Func free,
|
33
|
+
T * obj)
|
34
|
+
{
|
35
|
+
// We cast to obj void* here before passing to Data_Wrap_Struct,
|
36
|
+
// becuase otherwise compilation will fail if obj is const. It's safe
|
37
|
+
// to do this, because unwrap() will always add the const back when
|
38
|
+
// the object is unwrapped.
|
39
|
+
return Rice::protect(data_wrap_struct,
|
40
|
+
klass,
|
41
|
+
reinterpret_cast<RUBY_DATA_FUNC>(mark),
|
42
|
+
reinterpret_cast<RUBY_DATA_FUNC>(free),
|
43
|
+
(void *)obj);
|
44
|
+
}
|
45
|
+
|
46
|
+
template<typename T>
|
47
|
+
inline VALUE data_get_struct(VALUE value, T * * obj)
|
48
|
+
{
|
49
|
+
Data_Get_Struct(value, T, *obj);
|
50
|
+
return Qnil;
|
51
|
+
}
|
52
|
+
|
53
|
+
template<typename T>
|
54
|
+
inline T * unwrap(VALUE value)
|
55
|
+
{
|
56
|
+
T * obj;
|
57
|
+
Rice::protect(data_get_struct<T>, value, &obj);
|
58
|
+
return obj;
|
59
|
+
}
|
60
|
+
|
61
|
+
} // namespace detail
|
62
|
+
|
63
|
+
} // namespace Rice
|
64
|
+
|
65
|
+
template<typename T>
|
66
|
+
inline Rice::Data_Object<T>::
|
67
|
+
Data_Object(
|
68
|
+
T * obj,
|
69
|
+
VALUE klass,
|
70
|
+
Ruby_Data_Func mark_func,
|
71
|
+
Ruby_Data_Func free_func)
|
72
|
+
: Object(detail::wrap(klass, mark_func, free_func, obj))
|
73
|
+
, obj_(obj)
|
74
|
+
{
|
75
|
+
}
|
76
|
+
|
77
|
+
template<typename T>
|
78
|
+
inline Rice::Data_Object<T>::
|
79
|
+
Data_Object(
|
80
|
+
Object value)
|
81
|
+
: Object(value)
|
82
|
+
, obj_(detail::unwrap<T>(value))
|
83
|
+
{
|
84
|
+
Data_Type<T> klass;
|
85
|
+
check_cpp_type(klass);
|
86
|
+
detail::check_ruby_type(value, klass, true);
|
87
|
+
}
|
88
|
+
|
89
|
+
template<typename T>
|
90
|
+
template<typename U>
|
91
|
+
inline Rice::Data_Object<T>::
|
92
|
+
Data_Object(
|
93
|
+
Object value,
|
94
|
+
Data_Type<U> const & klass)
|
95
|
+
: Object(value)
|
96
|
+
, obj_(detail::unwrap<T>(value))
|
97
|
+
{
|
98
|
+
check_cpp_type(klass);
|
99
|
+
detail::check_ruby_type(value, klass, true);
|
100
|
+
}
|
101
|
+
|
102
|
+
template<typename T>
|
103
|
+
inline Rice::Data_Object<T>::
|
104
|
+
Data_Object(Data_Object const & other)
|
105
|
+
: Object(other.value())
|
106
|
+
, obj_(other.obj_)
|
107
|
+
{
|
108
|
+
}
|
109
|
+
|
110
|
+
template<typename T>
|
111
|
+
template<typename U>
|
112
|
+
inline void Rice::Data_Object<T>::
|
113
|
+
swap(Data_Object<U> & ref)
|
114
|
+
{
|
115
|
+
std::swap(obj_, ref.obj_);
|
116
|
+
Object::swap(ref);
|
117
|
+
}
|
118
|
+
|
119
|
+
template<typename T>
|
120
|
+
inline void Rice::Data_Object<T>::
|
121
|
+
check_cpp_type(Data_Type<T> const & /* klass */)
|
122
|
+
{
|
123
|
+
}
|
124
|
+
|
125
|
+
template<typename T>
|
126
|
+
Rice::Object Rice::detail::to_ruby_<Rice::Data_Object<T> >::
|
127
|
+
convert(Rice::Data_Object<T> const & x)
|
128
|
+
{
|
129
|
+
return x;
|
130
|
+
}
|
131
|
+
|
132
|
+
#endif // Rice__Data_Object__ipp_
|
133
|
+
|