rice2 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +7 -0
  2. data/COPYING +23 -0
  3. data/Doxyfile +2268 -0
  4. data/Makefile.am +26 -0
  5. data/Makefile.in +929 -0
  6. data/README.md +1054 -0
  7. data/README.mingw +8 -0
  8. data/Rakefile +24 -0
  9. data/aclocal.m4 +1090 -0
  10. data/bootstrap +8 -0
  11. data/config.guess +1667 -0
  12. data/config.sub +1793 -0
  13. data/configure +8209 -0
  14. data/configure.ac +55 -0
  15. data/depcomp +791 -0
  16. data/doxygen.ac +314 -0
  17. data/doxygen.am +186 -0
  18. data/extconf.rb +66 -0
  19. data/install-sh +529 -0
  20. data/missing +215 -0
  21. data/post-autoconf.rb +22 -0
  22. data/post-automake.rb +28 -0
  23. data/rice/Address_Registration_Guard.cpp +22 -0
  24. data/rice/Address_Registration_Guard.hpp +7 -0
  25. data/rice/Address_Registration_Guard.ipp +37 -0
  26. data/rice/Address_Registration_Guard_defn.hpp +75 -0
  27. data/rice/Arg.hpp +8 -0
  28. data/rice/Arg_impl.hpp +129 -0
  29. data/rice/Arg_operators.cpp +21 -0
  30. data/rice/Arg_operators.hpp +19 -0
  31. data/rice/Array.hpp +214 -0
  32. data/rice/Array.ipp +256 -0
  33. data/rice/Builtin_Object.hpp +8 -0
  34. data/rice/Builtin_Object.ipp +50 -0
  35. data/rice/Builtin_Object_defn.hpp +50 -0
  36. data/rice/Class.cpp +57 -0
  37. data/rice/Class.hpp +8 -0
  38. data/rice/Class.ipp +6 -0
  39. data/rice/Class_defn.hpp +83 -0
  40. data/rice/Constructor.hpp +47 -0
  41. data/rice/Data_Object.hpp +8 -0
  42. data/rice/Data_Object.ipp +133 -0
  43. data/rice/Data_Object_defn.hpp +138 -0
  44. data/rice/Data_Type.cpp +54 -0
  45. data/rice/Data_Type.hpp +8 -0
  46. data/rice/Data_Type.ipp +365 -0
  47. data/rice/Data_Type_defn.hpp +261 -0
  48. data/rice/Data_Type_fwd.hpp +12 -0
  49. data/rice/Director.cpp +13 -0
  50. data/rice/Director.hpp +39 -0
  51. data/rice/Enum.hpp +117 -0
  52. data/rice/Enum.ipp +246 -0
  53. data/rice/Exception.cpp +59 -0
  54. data/rice/Exception.hpp +13 -0
  55. data/rice/Exception_Base.hpp +8 -0
  56. data/rice/Exception_Base.ipp +13 -0
  57. data/rice/Exception_Base_defn.hpp +27 -0
  58. data/rice/Exception_defn.hpp +69 -0
  59. data/rice/Hash.hpp +227 -0
  60. data/rice/Hash.ipp +329 -0
  61. data/rice/Identifier.cpp +8 -0
  62. data/rice/Identifier.hpp +50 -0
  63. data/rice/Identifier.ipp +33 -0
  64. data/rice/Jump_Tag.hpp +24 -0
  65. data/rice/Makefile.am +122 -0
  66. data/rice/Makefile.in +885 -0
  67. data/rice/Module.cpp +84 -0
  68. data/rice/Module.hpp +8 -0
  69. data/rice/Module.ipp +6 -0
  70. data/rice/Module_defn.hpp +88 -0
  71. data/rice/Module_impl.hpp +281 -0
  72. data/rice/Module_impl.ipp +345 -0
  73. data/rice/Object.cpp +169 -0
  74. data/rice/Object.hpp +8 -0
  75. data/rice/Object.ipp +33 -0
  76. data/rice/Object_defn.hpp +214 -0
  77. data/rice/Require_Guard.hpp +21 -0
  78. data/rice/String.cpp +94 -0
  79. data/rice/String.hpp +91 -0
  80. data/rice/Struct.cpp +117 -0
  81. data/rice/Struct.hpp +162 -0
  82. data/rice/Struct.ipp +26 -0
  83. data/rice/Symbol.cpp +25 -0
  84. data/rice/Symbol.hpp +66 -0
  85. data/rice/Symbol.ipp +44 -0
  86. data/rice/config.hpp +47 -0
  87. data/rice/config.hpp.in +46 -0
  88. data/rice/detail/Arguments.hpp +118 -0
  89. data/rice/detail/Auto_Function_Wrapper.hpp +898 -0
  90. data/rice/detail/Auto_Function_Wrapper.ipp +3694 -0
  91. data/rice/detail/Auto_Member_Function_Wrapper.hpp +897 -0
  92. data/rice/detail/Auto_Member_Function_Wrapper.ipp +2774 -0
  93. data/rice/detail/Caster.hpp +103 -0
  94. data/rice/detail/Exception_Handler.hpp +8 -0
  95. data/rice/detail/Exception_Handler.ipp +68 -0
  96. data/rice/detail/Exception_Handler_defn.hpp +96 -0
  97. data/rice/detail/Iterator.hpp +93 -0
  98. data/rice/detail/Not_Copyable.hpp +25 -0
  99. data/rice/detail/Wrapped_Function.hpp +33 -0
  100. data/rice/detail/cfp.hpp +24 -0
  101. data/rice/detail/cfp.ipp +51 -0
  102. data/rice/detail/check_ruby_type.cpp +27 -0
  103. data/rice/detail/check_ruby_type.hpp +23 -0
  104. data/rice/detail/creation_funcs.hpp +37 -0
  105. data/rice/detail/creation_funcs.ipp +36 -0
  106. data/rice/detail/default_allocation_func.hpp +23 -0
  107. data/rice/detail/default_allocation_func.ipp +11 -0
  108. data/rice/detail/define_method_and_auto_wrap.hpp +31 -0
  109. data/rice/detail/define_method_and_auto_wrap.ipp +30 -0
  110. data/rice/detail/demangle.cpp +56 -0
  111. data/rice/detail/demangle.hpp +19 -0
  112. data/rice/detail/env.hpp +11 -0
  113. data/rice/detail/from_ruby.hpp +43 -0
  114. data/rice/detail/from_ruby.ipp +60 -0
  115. data/rice/detail/method_data.cpp +92 -0
  116. data/rice/detail/method_data.hpp +21 -0
  117. data/rice/detail/node.hpp +13 -0
  118. data/rice/detail/protect.cpp +29 -0
  119. data/rice/detail/protect.hpp +34 -0
  120. data/rice/detail/ruby.hpp +74 -0
  121. data/rice/detail/ruby_version_code.hpp +6 -0
  122. data/rice/detail/ruby_version_code.hpp.in +6 -0
  123. data/rice/detail/st.hpp +22 -0
  124. data/rice/detail/to_ruby.hpp +22 -0
  125. data/rice/detail/to_ruby.ipp +36 -0
  126. data/rice/detail/traits.hpp +43 -0
  127. data/rice/detail/win32.hpp +16 -0
  128. data/rice/detail/wrap_function.hpp +66 -0
  129. data/rice/global_function.hpp +33 -0
  130. data/rice/global_function.ipp +22 -0
  131. data/rice/protect.hpp +38 -0
  132. data/rice/protect.ipp +1134 -0
  133. data/rice/ruby_mark.hpp +13 -0
  134. data/rice/ruby_try_catch.hpp +86 -0
  135. data/rice/rubypp.rb +97 -0
  136. data/rice/to_from_ruby.hpp +8 -0
  137. data/rice/to_from_ruby.ipp +418 -0
  138. data/rice/to_from_ruby_defn.hpp +70 -0
  139. data/ruby.ac +135 -0
  140. data/ruby/Makefile.am +1 -0
  141. data/ruby/Makefile.in +628 -0
  142. data/ruby/lib/Makefile.am +3 -0
  143. data/ruby/lib/Makefile.in +506 -0
  144. data/ruby/lib/mkmf-rice.rb.in +217 -0
  145. data/ruby/lib/version.rb +3 -0
  146. data/sample/Makefile.am +47 -0
  147. data/sample/Makefile.in +489 -0
  148. data/sample/enum/extconf.rb +3 -0
  149. data/sample/enum/sample_enum.cpp +54 -0
  150. data/sample/enum/test.rb +8 -0
  151. data/sample/inheritance/animals.cpp +98 -0
  152. data/sample/inheritance/extconf.rb +3 -0
  153. data/sample/inheritance/test.rb +7 -0
  154. data/sample/map/extconf.rb +3 -0
  155. data/sample/map/map.cpp +81 -0
  156. data/sample/map/test.rb +7 -0
  157. data/test/Makefile.am +72 -0
  158. data/test/Makefile.in +1213 -0
  159. data/test/ext/Makefile.am +41 -0
  160. data/test/ext/Makefile.in +483 -0
  161. data/test/ext/t1/Foo.hpp +10 -0
  162. data/test/ext/t1/extconf.rb +2 -0
  163. data/test/ext/t1/t1.cpp +15 -0
  164. data/test/ext/t2/extconf.rb +2 -0
  165. data/test/ext/t2/t2.cpp +11 -0
  166. data/test/test_Address_Registration_Guard.cpp +43 -0
  167. data/test/test_Array.cpp +248 -0
  168. data/test/test_Builtin_Object.cpp +71 -0
  169. data/test/test_Class.cpp +496 -0
  170. data/test/test_Constructor.cpp +128 -0
  171. data/test/test_Data_Object.cpp +275 -0
  172. data/test/test_Data_Type.cpp +348 -0
  173. data/test/test_Director.cpp +308 -0
  174. data/test/test_Enum.cpp +215 -0
  175. data/test/test_Exception.cpp +47 -0
  176. data/test/test_Hash.cpp +212 -0
  177. data/test/test_Identifier.cpp +70 -0
  178. data/test/test_Jump_Tag.cpp +17 -0
  179. data/test/test_Memory_Management.cpp +50 -0
  180. data/test/test_Module.cpp +497 -0
  181. data/test/test_Object.cpp +159 -0
  182. data/test/test_String.cpp +107 -0
  183. data/test/test_Struct.cpp +205 -0
  184. data/test/test_Symbol.cpp +63 -0
  185. data/test/test_To_From_Ruby.cpp +428 -0
  186. data/test/test_global_functions.cpp +114 -0
  187. data/test/test_rice.rb +41 -0
  188. data/test/unittest.cpp +136 -0
  189. data/test/unittest.hpp +294 -0
  190. metadata +297 -0
@@ -0,0 +1,103 @@
1
+ #ifndef Rice__detail__Caster__hpp_
2
+ #define Rice__detail__Caster__hpp_
3
+
4
+ #include "../Module.hpp"
5
+ #include <stdexcept>
6
+
7
+ namespace Rice
8
+ {
9
+
10
+ namespace detail
11
+ {
12
+
13
+ class Abstract_Caster
14
+ {
15
+ public:
16
+ virtual void * cast_to_base(void * derived, Module type) const = 0;
17
+ virtual ~Abstract_Caster() { }
18
+ };
19
+
20
+ template<typename Derived_T, typename Base_T>
21
+ class Caster
22
+ : public Abstract_Caster
23
+ {
24
+ public:
25
+ Caster(Abstract_Caster * base_caster, Module type)
26
+ : base_caster_(base_caster)
27
+ , type_(type)
28
+ {
29
+ }
30
+
31
+ protected:
32
+ virtual void * cast_to_base(void * derived, Module type) const
33
+ {
34
+ if(type.value() == type_.value())
35
+ {
36
+ Derived_T * d(static_cast<Derived_T *>(derived));
37
+ return static_cast<Base_T *>(d);
38
+ }
39
+ else
40
+ {
41
+ if(base_caster_)
42
+ {
43
+ return base_caster_->cast_to_base(derived, type);
44
+ }
45
+ else
46
+ {
47
+ std::string s = "bad cast. No caster found for ";
48
+ s += type_.name().str();
49
+ throw std::runtime_error(s);
50
+ }
51
+ }
52
+ }
53
+
54
+ private:
55
+ Abstract_Caster * base_caster_;
56
+ Module type_;
57
+ };
58
+
59
+ template<typename To_T, typename From_T>
60
+ class Implicit_Caster
61
+ : public Abstract_Caster
62
+ {
63
+ public:
64
+ Implicit_Caster(Abstract_Caster * base_caster, Module type)
65
+ : base_caster_(base_caster)
66
+ , type_(type)
67
+ {
68
+ }
69
+
70
+ protected:
71
+ virtual void * cast_to_base(void * derived, Module type) const
72
+ {
73
+ if(type.value() == type_.value())
74
+ {
75
+ return new To_T( *static_cast<From_T*>(derived) );
76
+ }
77
+ else
78
+ {
79
+ if(base_caster_)
80
+ {
81
+ return base_caster_->cast_to_base(derived, type);
82
+ }
83
+ else
84
+ {
85
+ std::string s = "bad cast. No implicit caster found for ";
86
+ s += type_.name().str();
87
+ throw std::runtime_error(s);
88
+ }
89
+ }
90
+ }
91
+
92
+ private:
93
+ Abstract_Caster * base_caster_;
94
+ Module type_;
95
+ };
96
+
97
+
98
+
99
+ } // detail
100
+
101
+ } // Rice
102
+
103
+ #endif //Rice__detail__Caster__hpp_
@@ -0,0 +1,8 @@
1
+ #ifndef Rice__detail__Exception_Handler__hpp_
2
+ #define Rice__detail__Exception_Handler__hpp_
3
+
4
+ #include "Exception_Handler_defn.hpp"
5
+ #include "Exception_Handler.ipp"
6
+
7
+ #endif // Rice__detail__Exception_Handler__hpp_
8
+
@@ -0,0 +1,68 @@
1
+ #include "../Data_Type_defn.hpp"
2
+
3
+ inline
4
+ Rice::detail::Exception_Handler::
5
+ Exception_Handler(
6
+ Data_Object<Exception_Handler> next_exception_handler)
7
+ : next_exception_handler_(next_exception_handler)
8
+ , next_exception_handler_guard_(&next_exception_handler_)
9
+ {
10
+ }
11
+
12
+ inline
13
+ Rice::detail::Exception_Handler::
14
+ ~Exception_Handler()
15
+ {
16
+ }
17
+
18
+ inline
19
+ VALUE
20
+ Rice::detail::Exception_Handler::
21
+ call_next_exception_handler() const
22
+ {
23
+ return next_exception_handler_->handle_exception();
24
+ }
25
+
26
+ inline Rice::detail::Default_Exception_Handler::
27
+ Default_Exception_Handler()
28
+ : Exception_Handler(
29
+ Data_Object<Exception_Handler>(0, rb_cObject))
30
+ {
31
+ }
32
+
33
+ inline
34
+ VALUE
35
+ Rice::detail::Default_Exception_Handler::
36
+ handle_exception() const
37
+ {
38
+ throw;
39
+ }
40
+
41
+ template <typename Exception_T, typename Functor_T>
42
+ inline
43
+ Rice::detail::Functor_Exception_Handler<Exception_T, Functor_T>::
44
+ Functor_Exception_Handler(
45
+ Functor_T handler,
46
+ Data_Object<Exception_Handler> next_exception_handler)
47
+ : Exception_Handler(next_exception_handler)
48
+ , handler_(handler)
49
+ {
50
+ }
51
+
52
+ template <typename Exception_T, typename Functor_T>
53
+ inline
54
+ VALUE
55
+ Rice::detail::Functor_Exception_Handler<Exception_T, Functor_T>::
56
+ handle_exception() const
57
+ {
58
+ try
59
+ {
60
+ return call_next_exception_handler();
61
+ }
62
+ catch(Exception_T const & ex)
63
+ {
64
+ handler_(ex);
65
+ throw;
66
+ }
67
+ }
68
+
@@ -0,0 +1,96 @@
1
+ #ifndef Rice__detail__Exception_Handler_defn__hpp_
2
+ #define Rice__detail__Exception_Handler_defn__hpp_
3
+
4
+ #include "ruby.h"
5
+ #undef TYPE
6
+
7
+ #include "Not_Copyable.hpp"
8
+ #include "../Address_Registration_Guard_defn.hpp"
9
+ #include "../Data_Object_defn.hpp"
10
+
11
+ namespace Rice
12
+ {
13
+
14
+ namespace detail
15
+ {
16
+
17
+ // A class for converting C++ exceptions to ruby exceptions. It's used
18
+ // like this:
19
+ //
20
+ // try
21
+ // {
22
+ // }
23
+ // catch(...)
24
+ // {
25
+ // handler->handle_exception();
26
+ // }
27
+ //
28
+ // If an exception is thrown the handler will pass the exception up the
29
+ // chain, then the last handler in the chain will throw the exception
30
+ // down the chain until a lower handler can handle it, e.g.:
31
+ //
32
+ // try
33
+ // {
34
+ // return call_next_exception_handler();
35
+ // }
36
+ // catch(MyException const & ex)
37
+ // {
38
+ // throw Rice::Exception(rb_cMyException, "%s", ex.what());
39
+ // }
40
+ //
41
+ class Exception_Handler
42
+ : public Rice::detail::Not_Copyable
43
+ {
44
+ public:
45
+ Exception_Handler(
46
+ Data_Object<Exception_Handler> next_exception_handler);
47
+
48
+ virtual ~Exception_Handler();
49
+
50
+ virtual VALUE handle_exception() const = 0;
51
+
52
+ VALUE call_next_exception_handler() const;
53
+
54
+ private:
55
+ Data_Object<Exception_Handler> next_exception_handler_;
56
+ Address_Registration_Guard next_exception_handler_guard_;
57
+ };
58
+
59
+ // The default exception handler just rethrows the exception. If there
60
+ // are other handlers in the chain, they will try to handle the rethrown
61
+ // exception.
62
+ class Default_Exception_Handler
63
+ : public Exception_Handler
64
+ {
65
+ public:
66
+ Default_Exception_Handler();
67
+
68
+ virtual VALUE handle_exception() const;
69
+ };
70
+
71
+ // An exception handler that takes a functor as an argument. The
72
+ // functor should throw a Rice::Exception to handle the exception. If
73
+ // the functor does not handle the exception, the exception will be
74
+ // re-thrown.
75
+ template <typename Exception_T, typename Functor_T>
76
+ class Functor_Exception_Handler
77
+ : public Exception_Handler
78
+ {
79
+ public:
80
+ Functor_Exception_Handler(
81
+ Functor_T handler,
82
+ Data_Object<Exception_Handler> next_exception_handler);
83
+
84
+ private:
85
+ virtual VALUE handle_exception() const;
86
+
87
+ private:
88
+ Functor_T handler_;
89
+ };
90
+
91
+ } // namespace detail
92
+
93
+ } // namespace Rice
94
+
95
+ #endif // Rice__detail__Exception_Handler_defn__hpp_
96
+
@@ -0,0 +1,93 @@
1
+ #ifndef Rice__detail__Iterator__hpp_
2
+ #define Rice__detail__Iterator__hpp_
3
+
4
+ #include "method_data.hpp"
5
+ #include "ruby.hpp"
6
+ #include "../protect.hpp"
7
+ #include "../Data_Object.hpp"
8
+ #include "../Identifier.hpp"
9
+
10
+ namespace Rice
11
+ {
12
+
13
+ namespace detail
14
+ {
15
+
16
+ class Iterator
17
+ {
18
+ public:
19
+ virtual ~Iterator() { }
20
+
21
+ virtual VALUE call_impl(VALUE self) = 0;
22
+
23
+ static VALUE call(VALUE self)
24
+ {
25
+ VALUE data = (VALUE)method_data();
26
+ Data_Object<Iterator> iterator(
27
+ data,
28
+ Data_Type<Iterator>());
29
+ return iterator->call_impl(self);
30
+ }
31
+ };
32
+
33
+ template<typename T, typename Iterator_T>
34
+ class Iterator_Impl
35
+ : public Iterator
36
+ {
37
+ public:
38
+ Iterator_Impl(
39
+ Iterator_T (T::*begin)(),
40
+ Iterator_T (T::*end)(),
41
+ Data_Type<T> data_type)
42
+ : begin_(begin)
43
+ , end_(end)
44
+ , data_type_(data_type)
45
+ {
46
+ }
47
+
48
+ virtual VALUE call_impl(VALUE self)
49
+ {
50
+ Data_Object<T> obj(self, data_type_);
51
+ Iterator_T it = (*obj.*begin_)();
52
+ Iterator_T end = (*obj.*end_)();
53
+ for(; it != end; ++it)
54
+ {
55
+ Rice::protect(rb_yield, to_ruby(*it));
56
+ }
57
+ return self;
58
+ }
59
+
60
+ private:
61
+ Iterator_T (T::*begin_)();
62
+ Iterator_T (T::*end_)();
63
+ Data_Type<T> data_type_;
64
+ };
65
+
66
+ template<typename T, typename Iterator_T>
67
+ void define_iterator(
68
+ Module klass,
69
+ Identifier name,
70
+ Iterator_T (T::*begin)(),
71
+ Iterator_T (T::*end)())
72
+ {
73
+ Data_Type<Iterator> iterator_klass;
74
+ Data_Object<Iterator> iterator(
75
+ new Iterator_Impl<T, Iterator_T>(
76
+ begin,
77
+ end,
78
+ Data_Type<T>(klass)),
79
+ iterator_klass);
80
+ define_method_with_data(
81
+ klass,
82
+ name,
83
+ (RUBY_METHOD_FUNC)iterator->call,
84
+ 0,
85
+ iterator);
86
+ }
87
+
88
+ } // namespace detail
89
+
90
+ } // namespace Rice
91
+
92
+ #endif // Rice__detail__Iterator__hpp_
93
+
@@ -0,0 +1,25 @@
1
+ #ifndef Rice__Not_Copyable__hpp_
2
+ #define Rice__Not_Copyable__hpp_
3
+
4
+ namespace Rice
5
+ {
6
+
7
+ namespace detail
8
+ {
9
+
10
+ // Inherit from Not_Copyable to prevent copying instances of a class.
11
+ class Not_Copyable
12
+ {
13
+ public:
14
+ Not_Copyable() { }
15
+
16
+ private:
17
+ Not_Copyable(Not_Copyable const &);
18
+ Not_Copyable & operator=(Not_Copyable const &);
19
+ };
20
+
21
+ } // namespace detail
22
+
23
+ } // namespace Rice
24
+
25
+ #endif // Rice__Not_Copyable__hpp_
@@ -0,0 +1,33 @@
1
+ #ifndef Rice__detail__Wrapped_Function__hpp_
2
+ #define Rice__detail__Wrapped_Function__hpp_
3
+
4
+ #include "ruby.hpp"
5
+
6
+ namespace Rice
7
+ {
8
+
9
+ namespace detail
10
+ {
11
+
12
+ class Wrapped_Function
13
+ {
14
+ public:
15
+ Wrapped_Function(RUBY_METHOD_FUNC func, int arity)
16
+ : func_(func)
17
+ , arity_(arity)
18
+ {
19
+ }
20
+
21
+ RUBY_METHOD_FUNC func() const { return func_; }
22
+ int arity() const { return arity_; }
23
+
24
+ private:
25
+ RUBY_METHOD_FUNC func_;
26
+ int arity_;
27
+ };
28
+
29
+ } // detail
30
+
31
+ } // Rice
32
+
33
+ #endif // Rice__detail__Wrapped_Function__hpp_
@@ -0,0 +1,24 @@
1
+ #ifndef Rice__detail__cfp__hpp_
2
+ #define Rice__detail__cfp__hpp_
3
+
4
+ #include "ruby.hpp"
5
+
6
+ namespace Rice
7
+ {
8
+
9
+ namespace detail
10
+ {
11
+
12
+ VALUE * cfp();
13
+
14
+ VALUE & cfp_data_memo_node_and_pc(VALUE * cfp);
15
+ VALUE & cfp_self(VALUE * cfp);
16
+ VALUE & cfp_method_class(VALUE * cfp);
17
+
18
+ } // detail
19
+
20
+ } // Rice
21
+
22
+ #include "cfp.ipp"
23
+
24
+ #endif // Rice__detail__cfp__hpp_