rice 1.0.2 → 1.1.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.
- data/COPYING +2 -2
- data/Doxyfile +1 -1
- data/Makefile.in +8 -3
- data/Rakefile +3 -3
- data/config.guess +30 -49
- data/config.sub +4 -22
- data/configure +319 -104
- data/configure.ac +6 -2
- data/doxygen.ac +2 -2
- data/extconf.rb +22 -0
- data/post-autoconf.rb +3 -3
- data/post-automake.rb +2 -2
- data/rice/Array.ipp +7 -6
- data/rice/Critical_Guard.hpp +6 -0
- data/rice/Critical_Guard.ipp +6 -0
- data/rice/Data_Object.hpp +1 -120
- data/rice/Data_Object.ipp +5 -1
- data/rice/Data_Object_defn.hpp +132 -0
- data/rice/Data_Type.ipp +18 -2
- data/rice/Enum.ipp +3 -3
- data/rice/Exception.hpp +1 -61
- data/rice/Exception_Base.hpp +2 -24
- data/rice/Exception_Base.ipp +2 -0
- data/rice/Exception_Base_defn.hpp +27 -0
- data/rice/Exception_defn.hpp +69 -0
- data/rice/Hash.hpp +5 -1
- data/rice/Hash.ipp +7 -7
- data/rice/Makefile.am +20 -3
- data/rice/Makefile.in +39 -4
- data/rice/Module.cpp +11 -3
- data/rice/Module_impl.hpp +20 -9
- data/rice/Module_impl.ipp +84 -87
- data/rice/Object.cpp +1 -1
- data/rice/VM.cpp +14 -1
- data/rice/VM.hpp +6 -1
- data/rice/config.hpp +24 -3
- data/rice/config.hpp.in +21 -0
- data/rice/detail/Auto_Function_Wrapper.hpp +97 -65
- data/rice/detail/Auto_Function_Wrapper.ipp +160 -128
- data/rice/detail/Auto_Member_Function_Wrapper.hpp +96 -64
- data/rice/detail/Auto_Member_Function_Wrapper.ipp +160 -128
- data/rice/detail/Exception_Handler.hpp +2 -112
- 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/check_ruby_type.cpp +8 -2
- data/rice/detail/creation_funcs.ipp +2 -2
- data/rice/detail/define_method_and_auto_wrap.hpp +4 -2
- data/rice/detail/define_method_and_auto_wrap.ipp +14 -5
- data/rice/detail/env.hpp +4 -0
- data/rice/detail/method_data.cpp +362 -75
- data/rice/detail/method_data.cpp.rpp +301 -0
- data/rice/detail/method_data.hpp +6 -18
- data/rice/detail/mininode.cpp +1220 -0
- data/rice/detail/mininode.cpp.rpp +62 -0
- data/rice/detail/mininode.hpp +320 -0
- data/rice/detail/mininode.hpp.rpp +119 -0
- data/rice/detail/protect.cpp +4 -2
- data/rice/detail/ruby.hpp +44 -18
- data/rice/detail/ruby_version_code.hpp +6 -0
- data/rice/detail/ruby_version_code.hpp.in +6 -0
- data/rice/detail/rubysig.hpp +6 -0
- data/rice/detail/st.hpp +6 -2
- data/rice/detail/wrap_function.hpp +50 -48
- data/rice/detail/wrap_function.ipp +48 -48
- data/rice/generate_code.rb +43 -293
- data/rice/global_function.hpp +10 -4
- data/rice/global_function.ipp +1 -2
- data/rice/ruby_mark.hpp +13 -0
- data/rice/ruby_try_catch.hpp +1 -1
- data/rice/rubypp.rb +97 -0
- data/rice/to_from_ruby.ipp +3 -3
- data/ruby.ac +44 -8
- data/ruby/Makefile.in +2 -0
- data/ruby/lib/Makefile.in +2 -0
- data/ruby/lib/mkmf-rice.rb.in +4 -1
- data/ruby/lib/version.rb +3 -0
- data/sample/Makefile.am +2 -2
- data/sample/Makefile.in +4 -2
- data/test/Makefile.am +2 -1
- data/test/Makefile.in +7 -2
- data/test/test_Array.cpp +2 -2
- data/test/test_Class.cpp +4 -1
- data/test/test_Critical_Guard.cpp +4 -0
- data/test/test_Data_Object.cpp +43 -3
- data/test/test_Hash.cpp +3 -3
- data/test/test_String.cpp +8 -8
- data/test/test_VM.cpp +1 -1
- data/test/test_global_functions.cpp +45 -0
- data/test/test_rice.rb +5 -0
- metadata +115 -98
- data/rice/detail/Iterator_Definer.hpp +0 -98
data/configure.ac
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
AC_INIT(rice, 1.
|
1
|
+
AC_INIT(rice, 1.1)
|
2
2
|
AC_CONFIG_SRCDIR(rice)
|
3
3
|
AM_INIT_AUTOMAKE
|
4
4
|
|
@@ -40,8 +40,12 @@ DX_INIT_DOXYGEN(rice, Doxyfile, doc)
|
|
40
40
|
RICE_SAMPLES="enum map inheritance"
|
41
41
|
AC_SUBST(RICE_SAMPLES)
|
42
42
|
|
43
|
+
RICE_ROOT=`pwd`
|
44
|
+
AC_SUBST(RICE_ROOT)
|
45
|
+
|
43
46
|
AC_CONFIG_FILES(Makefile rice/Makefile test/Makefile sample/Makefile
|
44
|
-
ruby/Makefile ruby/lib/Makefile ruby/lib/mkmf-rice.rb
|
47
|
+
ruby/Makefile ruby/lib/Makefile ruby/lib/mkmf-rice.rb
|
48
|
+
rice/detail/ruby_version_code.hpp)
|
45
49
|
AC_OUTPUT
|
46
50
|
|
47
51
|
dnl Work around a bug in older versions of Rubygems
|
data/doxygen.ac
CHANGED
@@ -78,7 +78,7 @@ AC_DEFUN([DX_REQUIRE_PROG], [
|
|
78
78
|
AC_PATH_TOOL([$1], [$2])
|
79
79
|
if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then
|
80
80
|
AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
|
81
|
-
AC_SUBST([DX_FLAG_
|
81
|
+
AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
|
82
82
|
fi
|
83
83
|
])
|
84
84
|
|
@@ -101,7 +101,7 @@ test "$DX_FLAG_$1" = "$2" \
|
|
101
101
|
# ----------------------------------------------------------
|
102
102
|
# Turn off the DX_CURRENT_FEATURE if the required feature is off.
|
103
103
|
AC_DEFUN([DX_CLEAR_DEPEND], [
|
104
|
-
test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_
|
104
|
+
test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
|
105
105
|
])
|
106
106
|
|
107
107
|
# DX_FEATURE_ARG(FEATURE, DESCRIPTION,
|
data/extconf.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# To allow Rice to be installed on non-system installs of Ruby (say the user has
|
2
|
+
# 1.8.7 and 1.9.0 installed), the rice gem uses the extconf version of deployment
|
3
|
+
# rather than configure. This file will get the appropriate values from CONFIG
|
4
|
+
# for the Ruby that this library is being installed into and generate
|
5
|
+
# the proper arguments to ./configure.
|
6
|
+
#
|
7
|
+
# With this, installing on any of the Ruby versions installed on a machine is as
|
8
|
+
# easy as /path/to/the/gem install rice.
|
9
|
+
#
|
10
|
+
# This isn't actually an extconf.rb file, all it needs to do is create a Makefile
|
11
|
+
# for gem to continue 'make'-ing. It needs to be named 'extconf.rb' to fit Rubygem's
|
12
|
+
# expectations
|
13
|
+
|
14
|
+
require 'rbconfig'
|
15
|
+
require 'rubygems'
|
16
|
+
require 'ruby/lib/version.rb'
|
17
|
+
|
18
|
+
gem_name = "rice-#{Rice::VERSION}"
|
19
|
+
prefix_dir = File.join(Gem.default_dir, "gems", gem_name, "ruby", "lib")
|
20
|
+
with_ruby = File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])
|
21
|
+
|
22
|
+
system "./configure --with-ruby=#{with_ruby} --prefix=#{prefix_dir}"
|
data/post-autoconf.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'fileutils'
|
2
2
|
require 'find'
|
3
3
|
|
4
4
|
def process(file)
|
@@ -10,7 +10,7 @@ def process(file)
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
FileUtils.mv("#{file}.pp", "#{file}")
|
14
14
|
end
|
15
15
|
|
16
16
|
process("configure") do |out, line|
|
@@ -19,4 +19,4 @@ process("configure") do |out, line|
|
|
19
19
|
line.gsub!(/([^"'])(\$am_aux_dir)/, '\1\"\2\"')
|
20
20
|
out.puts line
|
21
21
|
end
|
22
|
-
|
22
|
+
FileUtils.chmod(0700, "configure")
|
data/post-automake.rb
CHANGED
data/rice/Array.ipp
CHANGED
@@ -46,13 +46,14 @@ Array(T const (& a)[n])
|
|
46
46
|
inline size_t Rice::Array::
|
47
47
|
size() const
|
48
48
|
{
|
49
|
-
return (
|
49
|
+
return RARRAY_LEN(this->value());
|
50
50
|
}
|
51
51
|
|
52
52
|
inline Rice::Object Rice::Array::
|
53
53
|
operator[](ptrdiff_t index) const
|
54
54
|
{
|
55
|
-
|
55
|
+
VALUE * ptr = RARRAY_PTR(this->value());
|
56
|
+
return ptr[position_of(index)];
|
56
57
|
}
|
57
58
|
|
58
59
|
inline Rice::Array::Proxy Rice::Array::
|
@@ -90,7 +91,7 @@ shift()
|
|
90
91
|
inline VALUE * Rice::Array::
|
91
92
|
to_c_array()
|
92
93
|
{
|
93
|
-
return (
|
94
|
+
return RARRAY_PTR(this->value());
|
94
95
|
}
|
95
96
|
|
96
97
|
inline size_t Rice::Array::
|
@@ -116,13 +117,13 @@ Proxy(Array array, size_t index)
|
|
116
117
|
inline Rice::Array::Proxy::
|
117
118
|
operator Rice::Object() const
|
118
119
|
{
|
119
|
-
return array_
|
120
|
+
return RARRAY_PTR(array_.value())[index_];
|
120
121
|
}
|
121
122
|
|
122
123
|
inline VALUE Rice::Array::Proxy::
|
123
124
|
value() const
|
124
125
|
{
|
125
|
-
return array_
|
126
|
+
return RARRAY_PTR(array_.value())[index_];
|
126
127
|
}
|
127
128
|
|
128
129
|
template<typename T>
|
@@ -130,7 +131,7 @@ Rice::Object Rice::Array::Proxy::
|
|
130
131
|
operator=(T const & value)
|
131
132
|
{
|
132
133
|
Object o = to_ruby(value);
|
133
|
-
array_
|
134
|
+
RARRAY_PTR(array_.value())[index_] = o.value();
|
134
135
|
return o;
|
135
136
|
}
|
136
137
|
|
data/rice/Critical_Guard.hpp
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
#ifndef Rice__ruby_Critical_Guard__hpp_
|
2
2
|
#define Rice__ruby_Critical_Guard__hpp_
|
3
3
|
|
4
|
+
#include "detail/ruby_version_code.hpp"
|
5
|
+
|
6
|
+
#if RICE__RUBY_VERSION_CODE < 190
|
7
|
+
|
4
8
|
namespace Rice
|
5
9
|
{
|
6
10
|
|
@@ -28,6 +32,8 @@ public:
|
|
28
32
|
|
29
33
|
}
|
30
34
|
|
35
|
+
#endif
|
36
|
+
|
31
37
|
#include "Critical_Guard.ipp"
|
32
38
|
|
33
39
|
#endif // Rice__ruby_Critical_Guard__hpp_
|
data/rice/Critical_Guard.ipp
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
#ifndef Rice__ruby_Critical_Guard__ipp_
|
2
2
|
#define Rice__ruby_Critical_Guard__ipp_
|
3
3
|
|
4
|
+
#include "detail/ruby_version_code.hpp"
|
5
|
+
|
6
|
+
#if RICE__RUBY_VERSION_CODE < 190
|
7
|
+
|
4
8
|
#include "detail/ruby.hpp"
|
5
9
|
#include "detail/rubysig.hpp"
|
6
10
|
|
@@ -16,5 +20,7 @@ inline Rice::Critical_Guard::
|
|
16
20
|
rb_thread_critical = 0;
|
17
21
|
}
|
18
22
|
|
23
|
+
#endif
|
24
|
+
|
19
25
|
#endif // Rice__ruby_Critical_Guard__ipp_
|
20
26
|
|
data/rice/Data_Object.hpp
CHANGED
@@ -1,126 +1,7 @@
|
|
1
1
|
#ifndef Rice__Data_Object__hpp_
|
2
2
|
#define Rice__Data_Object__hpp_
|
3
3
|
|
4
|
-
#include "
|
5
|
-
#include "Data_Type_fwd.hpp"
|
6
|
-
#include "Allocation_Strategies.hpp"
|
7
|
-
#include "detail/to_ruby.hpp"
|
8
|
-
#include "detail/ruby.hpp"
|
9
|
-
|
10
|
-
/*! \file
|
11
|
-
* \brief Provides a helper class for wrapping and unwrapping C++
|
12
|
-
* objects as Ruby objects.
|
13
|
-
*/
|
14
|
-
|
15
|
-
namespace Rice
|
16
|
-
{
|
17
|
-
|
18
|
-
//! A smartpointer-like wrapper for Ruby data objects.
|
19
|
-
/*! A data object is a ruby object of type T_DATA, which is usually
|
20
|
-
* created by using the Data_Wrap_Struct or Data_Make_Struct macro.
|
21
|
-
* This class wraps creation of the data structure, providing a
|
22
|
-
* type-safe object-oriented interface to the underlying C interface.
|
23
|
-
* This class works in conjunction with the Data_Type class to ensure
|
24
|
-
* type safety.
|
25
|
-
*
|
26
|
-
* Example:
|
27
|
-
* \code
|
28
|
-
* class Foo { };
|
29
|
-
* ...
|
30
|
-
* Data_Type<Foo> rb_cFoo = define_class("Foo");
|
31
|
-
* ...
|
32
|
-
* // Wrap:
|
33
|
-
* Data_Object<Foo> foo1(new Foo);
|
34
|
-
*
|
35
|
-
* // Get value to return:
|
36
|
-
* VALUE v = foo1.value()
|
37
|
-
*
|
38
|
-
* // Unwrap:
|
39
|
-
* Data_Object<Foo> foo2(v, rb_cFoo);
|
40
|
-
* \endcode
|
41
|
-
*/
|
42
|
-
template<typename T>
|
43
|
-
class Data_Object
|
44
|
-
: public Object
|
45
|
-
{
|
46
|
-
public:
|
47
|
-
//! A function that takes a T* and returns void.
|
48
|
-
typedef void (*Ruby_Data_Func)(T * obj);
|
49
|
-
|
50
|
-
//! Wrap a C++ object.
|
51
|
-
/*! This constructor is analgous to calling Data_Wrap_Struct. Be
|
52
|
-
* careful not to call this function more than once for the same
|
53
|
-
* pointer (in general, it should only be called for newly
|
54
|
-
* constructed objects that need to be managed by Ruby's garbage
|
55
|
-
* collector).
|
56
|
-
* \param obj the object to wrap.
|
57
|
-
* \param klass the Ruby class to use for the newly created Ruby
|
58
|
-
* object.
|
59
|
-
* \param mark_func a function that gets called by the garbage
|
60
|
-
* collector to mark the object's children.
|
61
|
-
* \param free_func a function that gets called by the garbage
|
62
|
-
* collector to free the object.
|
63
|
-
*/
|
64
|
-
Data_Object(
|
65
|
-
T * obj,
|
66
|
-
VALUE klass = Data_Type<T>::klass(),
|
67
|
-
Ruby_Data_Func mark_func = 0,
|
68
|
-
Ruby_Data_Func free_func = Default_Allocation_Strategy<T>::free);
|
69
|
-
|
70
|
-
//! Unwrap a Ruby object.
|
71
|
-
/*! This constructor is analgous to calling Data_Get_Struct. Uses
|
72
|
-
* Data_Type<T>::klass as the class of the object.
|
73
|
-
* \param value the Ruby object to unwrap.
|
74
|
-
*/
|
75
|
-
Data_Object(
|
76
|
-
Object value);
|
77
|
-
|
78
|
-
//! Unwrap a Ruby object.
|
79
|
-
/*! This constructor is analgous to calling Data_Get_Struct. Will
|
80
|
-
* throw an exception if the class of the object differs from the
|
81
|
-
* specified class.
|
82
|
-
* \param value the Ruby object to unwrap.
|
83
|
-
* \param klass the expected class of the object.
|
84
|
-
*/
|
85
|
-
template<typename U>
|
86
|
-
Data_Object(
|
87
|
-
Object value,
|
88
|
-
Data_Type<U> const & klass = Data_Type<T>::klass());
|
89
|
-
|
90
|
-
//! Make a copy of a Data_Object
|
91
|
-
/*! \param other the Data_Object to copy.
|
92
|
-
*/
|
93
|
-
Data_Object(Data_Object const & other);
|
94
|
-
|
95
|
-
T & operator*() const { return *obj_; } //!< Return a reference to obj_
|
96
|
-
T * operator->() const { return obj_; } //!< Return a pointer to obj_
|
97
|
-
T * get() const { return obj_; } //!< Return a pointer to obj_
|
98
|
-
|
99
|
-
//! Swap with another data object of the same type
|
100
|
-
/*! \param ref the object with which to swap.
|
101
|
-
*/
|
102
|
-
template<typename U>
|
103
|
-
void swap(Data_Object<U> & ref);
|
104
|
-
|
105
|
-
private:
|
106
|
-
static void check_cpp_type(Data_Type<T> const & klass);
|
107
|
-
|
108
|
-
private:
|
109
|
-
T * obj_;
|
110
|
-
};
|
111
|
-
|
112
|
-
namespace detail
|
113
|
-
{
|
114
|
-
template<typename T>
|
115
|
-
struct to_ruby_<Data_Object<T> >
|
116
|
-
{
|
117
|
-
static Rice::Object convert(Data_Object<T> const & x);
|
118
|
-
};
|
119
|
-
}
|
120
|
-
|
121
|
-
} // namespace Rice
|
122
|
-
|
123
|
-
#include "Object.hpp"
|
4
|
+
#include "Data_Object_defn.hpp"
|
124
5
|
#include "Data_Object.ipp"
|
125
6
|
|
126
7
|
#endif // Rice__Data_Object__hpp_
|
data/rice/Data_Object.ipp
CHANGED
@@ -6,6 +6,10 @@
|
|
6
6
|
|
7
7
|
#include <algorithm>
|
8
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
|
+
|
9
13
|
namespace Rice
|
10
14
|
{
|
11
15
|
|
@@ -109,7 +113,7 @@ inline void Rice::Data_Object<T>::
|
|
109
113
|
swap(Data_Object<U> & ref)
|
110
114
|
{
|
111
115
|
std::swap(obj_, ref.obj_);
|
112
|
-
Object::swap(
|
116
|
+
Object::swap(ref);
|
113
117
|
}
|
114
118
|
|
115
119
|
template<typename T>
|
@@ -0,0 +1,132 @@
|
|
1
|
+
#ifndef Rice__Data_Object_defn__hpp_
|
2
|
+
#define Rice__Data_Object_defn__hpp_
|
3
|
+
|
4
|
+
#include "Object_defn.hpp"
|
5
|
+
#include "Data_Type_fwd.hpp"
|
6
|
+
#include "Allocation_Strategies.hpp"
|
7
|
+
#include "ruby_mark.hpp"
|
8
|
+
#include "detail/to_ruby.hpp"
|
9
|
+
#include "detail/ruby.hpp"
|
10
|
+
|
11
|
+
/*! \file
|
12
|
+
* \brief Provides a helper class for wrapping and unwrapping C++
|
13
|
+
* objects as Ruby objects.
|
14
|
+
*/
|
15
|
+
|
16
|
+
namespace Rice
|
17
|
+
{
|
18
|
+
|
19
|
+
template<typename T>
|
20
|
+
struct Default_Mark_Function
|
21
|
+
{
|
22
|
+
typedef void (*Ruby_Data_Func)(T * obj);
|
23
|
+
static const Ruby_Data_Func mark;
|
24
|
+
};
|
25
|
+
|
26
|
+
//! A smartpointer-like wrapper for Ruby data objects.
|
27
|
+
/*! A data object is a ruby object of type T_DATA, which is usually
|
28
|
+
* created by using the Data_Wrap_Struct or Data_Make_Struct macro.
|
29
|
+
* This class wraps creation of the data structure, providing a
|
30
|
+
* type-safe object-oriented interface to the underlying C interface.
|
31
|
+
* This class works in conjunction with the Data_Type class to ensure
|
32
|
+
* type safety.
|
33
|
+
*
|
34
|
+
* Example:
|
35
|
+
* \code
|
36
|
+
* class Foo { };
|
37
|
+
* ...
|
38
|
+
* Data_Type<Foo> rb_cFoo = define_class("Foo");
|
39
|
+
* ...
|
40
|
+
* // Wrap:
|
41
|
+
* Data_Object<Foo> foo1(new Foo);
|
42
|
+
*
|
43
|
+
* // Get value to return:
|
44
|
+
* VALUE v = foo1.value()
|
45
|
+
*
|
46
|
+
* // Unwrap:
|
47
|
+
* Data_Object<Foo> foo2(v, rb_cFoo);
|
48
|
+
* \endcode
|
49
|
+
*/
|
50
|
+
template<typename T>
|
51
|
+
class Data_Object
|
52
|
+
: public Object
|
53
|
+
{
|
54
|
+
public:
|
55
|
+
//! A function that takes a T* and returns void.
|
56
|
+
typedef void (*Ruby_Data_Func)(T * obj);
|
57
|
+
|
58
|
+
//! Wrap a C++ object.
|
59
|
+
/*! This constructor is analgous to calling Data_Wrap_Struct. Be
|
60
|
+
* careful not to call this function more than once for the same
|
61
|
+
* pointer (in general, it should only be called for newly
|
62
|
+
* constructed objects that need to be managed by Ruby's garbage
|
63
|
+
* collector).
|
64
|
+
* \param obj the object to wrap.
|
65
|
+
* \param klass the Ruby class to use for the newly created Ruby
|
66
|
+
* object.
|
67
|
+
* \param mark_func a function that gets called by the garbage
|
68
|
+
* collector to mark the object's children.
|
69
|
+
* \param free_func a function that gets called by the garbage
|
70
|
+
* collector to free the object.
|
71
|
+
*/
|
72
|
+
Data_Object(
|
73
|
+
T * obj,
|
74
|
+
VALUE klass = Data_Type<T>::klass(),
|
75
|
+
Ruby_Data_Func mark_func = Default_Mark_Function<T>::mark,
|
76
|
+
Ruby_Data_Func free_func = Default_Allocation_Strategy<T>::free);
|
77
|
+
|
78
|
+
//! Unwrap a Ruby object.
|
79
|
+
/*! This constructor is analgous to calling Data_Get_Struct. Uses
|
80
|
+
* Data_Type<T>::klass as the class of the object.
|
81
|
+
* \param value the Ruby object to unwrap.
|
82
|
+
*/
|
83
|
+
Data_Object(
|
84
|
+
Object value);
|
85
|
+
|
86
|
+
//! Unwrap a Ruby object.
|
87
|
+
/*! This constructor is analgous to calling Data_Get_Struct. Will
|
88
|
+
* throw an exception if the class of the object differs from the
|
89
|
+
* specified class.
|
90
|
+
* \param value the Ruby object to unwrap.
|
91
|
+
* \param klass the expected class of the object.
|
92
|
+
*/
|
93
|
+
template<typename U>
|
94
|
+
Data_Object(
|
95
|
+
Object value,
|
96
|
+
Data_Type<U> const & klass = Data_Type<T>::klass());
|
97
|
+
|
98
|
+
//! Make a copy of a Data_Object
|
99
|
+
/*! \param other the Data_Object to copy.
|
100
|
+
*/
|
101
|
+
Data_Object(Data_Object const & other);
|
102
|
+
|
103
|
+
T & operator*() const { return *obj_; } //!< Return a reference to obj_
|
104
|
+
T * operator->() const { return obj_; } //!< Return a pointer to obj_
|
105
|
+
T * get() const { return obj_; } //!< Return a pointer to obj_
|
106
|
+
|
107
|
+
//! Swap with another data object of the same type
|
108
|
+
/*! \param ref the object with which to swap.
|
109
|
+
*/
|
110
|
+
template<typename U>
|
111
|
+
void swap(Data_Object<U> & ref);
|
112
|
+
|
113
|
+
private:
|
114
|
+
static void check_cpp_type(Data_Type<T> const & klass);
|
115
|
+
|
116
|
+
private:
|
117
|
+
T * obj_;
|
118
|
+
};
|
119
|
+
|
120
|
+
namespace detail
|
121
|
+
{
|
122
|
+
template<typename T>
|
123
|
+
struct to_ruby_<Data_Object<T> >
|
124
|
+
{
|
125
|
+
static Rice::Object convert(Data_Object<T> const & x);
|
126
|
+
};
|
127
|
+
}
|
128
|
+
|
129
|
+
} // namespace Rice
|
130
|
+
|
131
|
+
#endif // Rice__Data_Object_defn__hpp_
|
132
|
+
|