rice2 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,92 @@
|
|
1
|
+
#include "method_data.hpp"
|
2
|
+
#include "ruby.hpp"
|
3
|
+
|
4
|
+
// TODO: This is silly, autoconf...
|
5
|
+
#undef PACKAGE_NAME
|
6
|
+
#undef PACKAGE_STRING
|
7
|
+
#undef PACKAGE_TARNAME
|
8
|
+
#undef PACKAGE_VERSION
|
9
|
+
#include "../config.hpp"
|
10
|
+
|
11
|
+
#define RICE_ID rb_intern("__rice__")
|
12
|
+
|
13
|
+
VALUE
|
14
|
+
Rice::detail::
|
15
|
+
method_data()
|
16
|
+
{
|
17
|
+
ID id;
|
18
|
+
VALUE klass;
|
19
|
+
if (!rb_frame_method_id_and_class(&id, &klass))
|
20
|
+
{
|
21
|
+
rb_raise(
|
22
|
+
rb_eRuntimeError,
|
23
|
+
"Cannot get method id and class for function");
|
24
|
+
}
|
25
|
+
|
26
|
+
if (rb_type(klass) == T_ICLASS) {
|
27
|
+
klass = rb_class_of(klass);
|
28
|
+
}
|
29
|
+
|
30
|
+
VALUE store = rb_ivar_get(klass, RICE_ID);
|
31
|
+
return (store == Qnil) ? Qnil : rb_ivar_get(store, id);
|
32
|
+
}
|
33
|
+
|
34
|
+
// Ruby 2.7 now includes a similarly named macro that uses templates to
|
35
|
+
// pick the right overload for the underlying function. That doesn't work
|
36
|
+
// for our cases because we are using this method dynamically and get a
|
37
|
+
// compilation error otherwise. This removes the macro and lets us fall
|
38
|
+
// back to the C-API underneath again.
|
39
|
+
#undef rb_define_method_id
|
40
|
+
|
41
|
+
// Define a method and attach data to it.
|
42
|
+
// The method looks to ruby like a normal aliased CFUNC, with a modified
|
43
|
+
// origin class.
|
44
|
+
//
|
45
|
+
// How this works:
|
46
|
+
//
|
47
|
+
// To store method data and have it registered with the GC, we need a
|
48
|
+
// "slot" to put it in. This "slot" must be recognized and marked by
|
49
|
+
// the garbage collector. There happens to be such a place we can put
|
50
|
+
// data, and it has to do with aliased methods. When Ruby creates an
|
51
|
+
// alias for a method, it stores a reference to the original class in
|
52
|
+
// the method entry. The form of the method entry differs from ruby
|
53
|
+
// version to ruby version, but the concept is the same across all of
|
54
|
+
// them.
|
55
|
+
//
|
56
|
+
// In Rice, we make use of this by attach the data to a dummy object
|
57
|
+
// (store) in the class variables table.
|
58
|
+
//
|
59
|
+
// When Ruby makes a method call, it stores the class Object and method
|
60
|
+
// ID in the current stack frame. When Ruby calls into Rice, we grab
|
61
|
+
// the class and method ID from the stack frame, then pull the data out
|
62
|
+
// of the class. The data item is then used to determine how to convert
|
63
|
+
// arguments and return type, how to handle exceptions, etc.
|
64
|
+
//
|
65
|
+
VALUE
|
66
|
+
Rice::detail::
|
67
|
+
define_method_with_data(
|
68
|
+
VALUE klass, ID id, VALUE (*cfunc)(ANYARGS), int arity, VALUE data)
|
69
|
+
{
|
70
|
+
VALUE store = rb_attr_get(klass, RICE_ID);
|
71
|
+
|
72
|
+
if (store == Qnil) {
|
73
|
+
store = rb_obj_alloc(rb_cObject);
|
74
|
+
// store is stored in the instance variables table with
|
75
|
+
// name "__rice__".
|
76
|
+
// since "__rice__" does not have the @ prefix,
|
77
|
+
// so it can never be read at the Ruby level.
|
78
|
+
rb_ivar_set(klass, RICE_ID, store);
|
79
|
+
}
|
80
|
+
|
81
|
+
rb_ivar_set(store, id, data);
|
82
|
+
|
83
|
+
// Create the aliased method on the origin class
|
84
|
+
rb_define_method_id(
|
85
|
+
klass,
|
86
|
+
id,
|
87
|
+
cfunc,
|
88
|
+
arity);
|
89
|
+
|
90
|
+
return Qnil;
|
91
|
+
}
|
92
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#ifndef Rice__detail__method_data__hpp
|
2
|
+
#define Rice__detail__method_data__hpp
|
3
|
+
|
4
|
+
#include "ruby.hpp"
|
5
|
+
|
6
|
+
namespace Rice
|
7
|
+
{
|
8
|
+
|
9
|
+
namespace detail
|
10
|
+
{
|
11
|
+
|
12
|
+
VALUE define_method_with_data(
|
13
|
+
VALUE klass, ID id, VALUE (*cfunc)(ANYARGS), int arity, VALUE data);
|
14
|
+
|
15
|
+
VALUE method_data();
|
16
|
+
|
17
|
+
} // namespace detail
|
18
|
+
|
19
|
+
} // namespace Rice
|
20
|
+
|
21
|
+
#endif // Rice__detail__method_data__hpp
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#include "protect.hpp"
|
2
|
+
#include "../Exception.hpp"
|
3
|
+
#include "../Jump_Tag.hpp"
|
4
|
+
|
5
|
+
#ifndef TAG_RAISE
|
6
|
+
#define TAG_RAISE 0x6
|
7
|
+
#endif
|
8
|
+
|
9
|
+
VALUE Rice::detail::
|
10
|
+
protect(
|
11
|
+
RUBY_VALUE_FUNC f,
|
12
|
+
VALUE arg)
|
13
|
+
{
|
14
|
+
int state = 0;
|
15
|
+
VALUE retval = rb_protect(f, arg, &state);
|
16
|
+
if(state != 0)
|
17
|
+
{
|
18
|
+
VALUE err = rb_errinfo();
|
19
|
+
if(state == TAG_RAISE && RTEST(err))
|
20
|
+
{
|
21
|
+
// TODO: convert NoMemoryError into bad_alloc?
|
22
|
+
rb_set_errinfo(Rice::Nil);
|
23
|
+
throw Rice::Exception(err);
|
24
|
+
}
|
25
|
+
throw Jump_Tag(state);
|
26
|
+
}
|
27
|
+
return retval;
|
28
|
+
}
|
29
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#ifndef Rice__detail__protect__hpp_
|
2
|
+
#define Rice__detail__protect__hpp_
|
3
|
+
|
4
|
+
#include "ruby.hpp"
|
5
|
+
|
6
|
+
/*! \file
|
7
|
+
* \brief Functions for making exception-safe calls into Ruby code.
|
8
|
+
* These are the building blocks for building other exception-safe
|
9
|
+
* helper functions.
|
10
|
+
*/
|
11
|
+
|
12
|
+
namespace Rice
|
13
|
+
{
|
14
|
+
|
15
|
+
namespace detail
|
16
|
+
{
|
17
|
+
|
18
|
+
//! Call the given function, converting Ruby exceptions to C++
|
19
|
+
//! exceptions.
|
20
|
+
/*! Call the function f with the parameter arg If f raises a Ruby
|
21
|
+
* exception, then the exception is re-thrown as an Exception. If f
|
22
|
+
* exits with any other non-zero tag (e.g. a Symbol is thrown), then the
|
23
|
+
* tag is re-thrown as a Jump_Tag.
|
24
|
+
*/
|
25
|
+
VALUE protect(
|
26
|
+
RUBY_VALUE_FUNC f,
|
27
|
+
VALUE arg);
|
28
|
+
|
29
|
+
} // namespace detail
|
30
|
+
|
31
|
+
} // namespace Rice
|
32
|
+
|
33
|
+
#endif // Rice__detail__protect__hpp_
|
34
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#ifndef Rice__detail__ruby__hpp_
|
2
|
+
#define Rice__detail__ruby__hpp_
|
3
|
+
|
4
|
+
/*! \file
|
5
|
+
* \brief Hacks for addressing incompatibilities between various Ruby
|
6
|
+
* versions.
|
7
|
+
*/
|
8
|
+
|
9
|
+
#include <cmath>
|
10
|
+
|
11
|
+
// missing.h that comes with the one-click installer doesn't properly
|
12
|
+
// check for double-definition of isinf
|
13
|
+
#ifdef isinf
|
14
|
+
#define HAVE_ISINF
|
15
|
+
#endif
|
16
|
+
|
17
|
+
#include "ruby_version_code.hpp"
|
18
|
+
#include "../config.hpp"
|
19
|
+
|
20
|
+
#include <ruby.h>
|
21
|
+
|
22
|
+
#ifdef WIN32
|
23
|
+
#include "win32.hpp"
|
24
|
+
#endif
|
25
|
+
|
26
|
+
// This causes problems with certain C++ libraries
|
27
|
+
#undef TYPE
|
28
|
+
|
29
|
+
//! A function that takes a VALUE as a parameter and returns a VALUE.
|
30
|
+
// TODO: Casting from a C++ function to an extern "C" function won't
|
31
|
+
// work on all platforms. I'm not sure what to do about this.
|
32
|
+
extern "C" typedef VALUE (*RUBY_VALUE_FUNC)(VALUE);
|
33
|
+
|
34
|
+
// Fix Ruby RUBY_METHOD_FUNC from macro to typedef
|
35
|
+
#if defined(RUBY_METHOD_FUNC)
|
36
|
+
# undef RUBY_METHOD_FUNC
|
37
|
+
extern "C" typedef VALUE (*RUBY_METHOD_FUNC)(ANYARGS);
|
38
|
+
#endif
|
39
|
+
|
40
|
+
#ifndef RSTRING_LEN
|
41
|
+
#define RSTRING_LEN(str) RSTRING(str)->len
|
42
|
+
#endif
|
43
|
+
|
44
|
+
#ifndef RSTRING_PTR
|
45
|
+
#define RSTRING_PTR(str) RSTRING(str)->ptr
|
46
|
+
#endif
|
47
|
+
|
48
|
+
#ifndef RARRAY_LEN
|
49
|
+
#define RARRAY_LEN(arr) RARRAY(arr)->len
|
50
|
+
#endif
|
51
|
+
|
52
|
+
#ifndef RARRAY_PTR
|
53
|
+
#define RARRAY_PTR(arr) RARRAY(arr)->ptr
|
54
|
+
#endif
|
55
|
+
|
56
|
+
#ifndef RHASH_TBL
|
57
|
+
#define RHASH_TBL(hsh) RHASH(hsh)->tbl
|
58
|
+
#endif
|
59
|
+
|
60
|
+
#ifndef RCLASS_M_TBL
|
61
|
+
#define RCLASS_M_TBL(c) RCLASS(c)->m_tbl
|
62
|
+
#endif
|
63
|
+
|
64
|
+
// ruby.h has a few defines that conflict with Visual Studio's STL
|
65
|
+
#if defined(_MSC_VER)
|
66
|
+
#undef write
|
67
|
+
#undef read
|
68
|
+
#undef bind
|
69
|
+
#endif
|
70
|
+
|
71
|
+
#define std_unique_ptr std::unique_ptr
|
72
|
+
|
73
|
+
#endif // Rice__detail__ruby__hpp_
|
74
|
+
|
data/rice/detail/st.hpp
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#ifndef Exc_Ruby___cpp__st__hpp_
|
2
|
+
#define Exc_Ruby___cpp__st__hpp_
|
3
|
+
|
4
|
+
/*! \file
|
5
|
+
* \brief Hacks to allow functions in st.h to be called from C++
|
6
|
+
* programs.
|
7
|
+
*/
|
8
|
+
|
9
|
+
#include "ruby.hpp"
|
10
|
+
|
11
|
+
// Ruby doesn't put extern "C" around st.h
|
12
|
+
|
13
|
+
extern "C"
|
14
|
+
{
|
15
|
+
#ifdef RUBY_VM
|
16
|
+
#include "ruby/st.h"
|
17
|
+
#else
|
18
|
+
#include "st.h"
|
19
|
+
#endif
|
20
|
+
}
|
21
|
+
|
22
|
+
#endif // Exc_Ruby___cpp__st__hpp_
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#ifndef Rice__detail__to_ruby__hpp_
|
2
|
+
#define Rice__detail__to_ruby__hpp_
|
3
|
+
|
4
|
+
namespace Rice
|
5
|
+
{
|
6
|
+
namespace detail
|
7
|
+
{
|
8
|
+
template<typename T>
|
9
|
+
struct to_ruby_
|
10
|
+
{
|
11
|
+
static Rice::Object convert(T const & x);
|
12
|
+
};
|
13
|
+
|
14
|
+
template<typename T>
|
15
|
+
struct to_ruby_<T *>
|
16
|
+
{
|
17
|
+
static Rice::Object convert(T * x);
|
18
|
+
};
|
19
|
+
} // detail
|
20
|
+
} // Rice
|
21
|
+
|
22
|
+
#endif // Rice__detail__to_ruby__hpp_
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#include "../Data_Object.hpp"
|
2
|
+
|
3
|
+
template<typename T>
|
4
|
+
Rice::Object
|
5
|
+
Rice::detail::to_ruby_<T>::
|
6
|
+
convert(T const & x)
|
7
|
+
{
|
8
|
+
if(Data_Type<T>::is_bound())
|
9
|
+
{
|
10
|
+
return Rice::Data_Object<T >(new T(x), Rice::Data_Type<T >::klass());
|
11
|
+
}
|
12
|
+
else
|
13
|
+
{
|
14
|
+
std::string s("Unable to convert ");
|
15
|
+
s += demangle(typeid(T *).name());
|
16
|
+
throw std::invalid_argument(s.c_str());
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
template<typename T>
|
21
|
+
Rice::Object
|
22
|
+
Rice::detail::to_ruby_<T *>::
|
23
|
+
convert(T * x)
|
24
|
+
{
|
25
|
+
if(Data_Type<T>::is_bound())
|
26
|
+
{
|
27
|
+
Data_Object<T> obj(x);
|
28
|
+
return obj;
|
29
|
+
}
|
30
|
+
else
|
31
|
+
{
|
32
|
+
std::string s("Unable to convert ");
|
33
|
+
s += demangle(typeid(T *).name());
|
34
|
+
throw std::invalid_argument(s.c_str());
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#ifndef Rice__detail__traits__hpp_
|
2
|
+
#define Rice__detail__traits__hpp_
|
3
|
+
|
4
|
+
namespace Rice
|
5
|
+
{
|
6
|
+
namespace detail
|
7
|
+
{
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Remove const from a type
|
11
|
+
*/
|
12
|
+
template<typename T>
|
13
|
+
struct remove_const { typedef T Type; };
|
14
|
+
|
15
|
+
template<typename T>
|
16
|
+
struct remove_const<const T> { typedef T Type; };
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Remove a reference from a type
|
20
|
+
*/
|
21
|
+
template<typename T>
|
22
|
+
struct remove_ref { typedef T Type; };
|
23
|
+
|
24
|
+
template<typename T>
|
25
|
+
struct remove_ref<T &> { typedef T Type; };
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Do both of the above in one easy step
|
29
|
+
*/
|
30
|
+
template<typename T>
|
31
|
+
struct sanitize
|
32
|
+
{
|
33
|
+
typedef T Type;
|
34
|
+
//typedef typename remove_const<
|
35
|
+
//typename remove_ref<T>::Type
|
36
|
+
//>::Type Type;
|
37
|
+
};
|
38
|
+
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
#endif // Rice__detail__traits__hpp_
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#ifndef Rice__detail__win32__hpp_
|
2
|
+
#define Rice__detail__win32__hpp_
|
3
|
+
|
4
|
+
/*! \file
|
5
|
+
* \brief Undefine all the evil macros that are defined in win32.h
|
6
|
+
*/
|
7
|
+
|
8
|
+
// None of these macros are used in Ruby header files
|
9
|
+
#undef bind
|
10
|
+
#undef read
|
11
|
+
#undef write
|
12
|
+
#undef send
|
13
|
+
#undef recv
|
14
|
+
#undef times
|
15
|
+
|
16
|
+
#endif // Rice__detail__win32__hpp_
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#ifndef Rice__detail__wrap_function__hpp_
|
2
|
+
#define Rice__detail__wrap_function__hpp_
|
3
|
+
|
4
|
+
// This causes problems with certain C++ libraries
|
5
|
+
#undef TYPE
|
6
|
+
|
7
|
+
#include "Exception_Handler.hpp"
|
8
|
+
#include "Wrapped_Function.hpp"
|
9
|
+
#include "../Object_defn.hpp"
|
10
|
+
#include "../Data_Object.hpp"
|
11
|
+
#include "Arguments.hpp"
|
12
|
+
#include "Auto_Function_Wrapper.hpp"
|
13
|
+
#include "Auto_Member_Function_Wrapper.hpp"
|
14
|
+
|
15
|
+
namespace Rice
|
16
|
+
{
|
17
|
+
|
18
|
+
namespace detail
|
19
|
+
{
|
20
|
+
|
21
|
+
template<typename Ret_T>
|
22
|
+
Wrapped_Function * wrap_function(
|
23
|
+
Ret_T (*func)(),
|
24
|
+
Data_Object<Exception_Handler> handler,
|
25
|
+
Arguments* arguments)
|
26
|
+
{
|
27
|
+
typedef Ret_T (*Func)();
|
28
|
+
return new Auto_Function_Wrapper<Func, Ret_T>(func, handler, arguments);
|
29
|
+
}
|
30
|
+
|
31
|
+
template<typename Ret_T, typename ...Arg_T>
|
32
|
+
Wrapped_Function * wrap_function(
|
33
|
+
Ret_T (*func)(Arg_T...),
|
34
|
+
Data_Object<Exception_Handler> handler,
|
35
|
+
Arguments* arguments)
|
36
|
+
{
|
37
|
+
typedef Ret_T (*Func)(Arg_T...);
|
38
|
+
return new Auto_Function_Wrapper<Func, Ret_T, Arg_T...>(func, handler, arguments);
|
39
|
+
}
|
40
|
+
|
41
|
+
template<typename Ret_T, typename Self_T, typename ...Arg_T>
|
42
|
+
Wrapped_Function * wrap_function(
|
43
|
+
Ret_T (Self_T::*func)(Arg_T...),
|
44
|
+
Data_Object<Exception_Handler> handler,
|
45
|
+
Arguments* arguments)
|
46
|
+
{
|
47
|
+
typedef Ret_T (Self_T::*Func)(Arg_T...);
|
48
|
+
return new Auto_Member_Function_Wrapper<Func, Ret_T, Self_T, Arg_T...>(func, handler, arguments);
|
49
|
+
}
|
50
|
+
|
51
|
+
template<typename Ret_T, typename Self_T, typename ...Arg_T>
|
52
|
+
Wrapped_Function * wrap_function(
|
53
|
+
Ret_T (Self_T::*func)(Arg_T...) const,
|
54
|
+
Data_Object<Exception_Handler> handler,
|
55
|
+
Arguments* arguments)
|
56
|
+
{
|
57
|
+
typedef Ret_T (Self_T::*Func)(Arg_T...) const;
|
58
|
+
return new Auto_Member_Function_Wrapper<Func, Ret_T, Self_T, Arg_T...>(func, handler, arguments);
|
59
|
+
}
|
60
|
+
|
61
|
+
} // namespace detail
|
62
|
+
|
63
|
+
} // namespace Rice
|
64
|
+
|
65
|
+
#endif // Rice__detail__wrap_function__hpp_
|
66
|
+
|