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,51 @@
1
+ namespace detail
2
+ {
3
+
4
+ struct rb_thread_struct
5
+ {
6
+ VALUE self;
7
+ void *vm;
8
+ VALUE *stack;
9
+ unsigned long stack_size;
10
+ VALUE *cfp;
11
+ /* ... */
12
+ };
13
+
14
+ typedef struct rb_thread_struct rb_thread_t;
15
+
16
+ } // namespace detail
17
+
18
+ extern "C" detail::rb_thread_t * ruby_current_thread;
19
+
20
+ inline
21
+ VALUE *
22
+ Rice::detail::
23
+ cfp()
24
+ {
25
+ return ruby_current_thread->cfp;
26
+ }
27
+
28
+ inline
29
+ VALUE &
30
+ Rice::detail::
31
+ cfp_data_memo_node_and_pc(VALUE * cfp)
32
+ {
33
+ return cfp[0];
34
+ }
35
+
36
+ inline
37
+ VALUE &
38
+ Rice::detail::
39
+ cfp_self(VALUE * cfp)
40
+ {
41
+ return cfp[5];
42
+ }
43
+
44
+ inline
45
+ VALUE &
46
+ Rice::detail::
47
+ cfp_method_class(VALUE * cfp)
48
+ {
49
+ return cfp[11];
50
+ }
51
+
@@ -0,0 +1,27 @@
1
+ #include "check_ruby_type.hpp"
2
+ #include "../Exception.hpp"
3
+
4
+ void Rice::detail::
5
+ check_ruby_type(
6
+ VALUE value,
7
+ VALUE klass,
8
+ bool include_super
9
+ )
10
+ {
11
+ if( !rb_obj_is_kind_of(value, klass) ||
12
+ (!include_super && rb_obj_class(value) != klass))
13
+ {
14
+ // Not sure why this stuff can't be chained
15
+ VALUE gotV = protect(rb_mod_name, rb_obj_class(value));
16
+ char* got = StringValuePtr(gotV);
17
+ VALUE exptV = protect(rb_mod_name, klass);
18
+ char* expected = StringValuePtr(exptV);
19
+
20
+ throw Exception(
21
+ rb_eTypeError,
22
+ "wrong argument type %s (expected %s)",
23
+ got, expected
24
+ );
25
+ }
26
+ }
27
+
@@ -0,0 +1,23 @@
1
+ #ifndef Rice__detail__check_ruby_type__hpp_
2
+ #define Rice__detail__check_ruby_type__hpp_
3
+
4
+ #include "ruby.hpp"
5
+
6
+ namespace Rice
7
+ {
8
+
9
+ namespace detail
10
+ {
11
+
12
+ // Throws an exception if the given object is not of type klass.
13
+ void check_ruby_type(
14
+ VALUE value,
15
+ VALUE klass,
16
+ bool include_super);
17
+
18
+ } // namespace detail
19
+
20
+ } // namespace Rice
21
+
22
+ #endif // Rice__detail__check_ruby_type__hpp_
23
+
@@ -0,0 +1,37 @@
1
+ #ifndef Rice__detail__creation_funcs__hpp_
2
+ #define Rice__detail__creation_funcs__hpp_
3
+
4
+ namespace Rice
5
+ {
6
+
7
+ class Class;
8
+
9
+ namespace detail
10
+ {
11
+
12
+ //! Like define_alloc_func, but allows the user to define an
13
+ //! "initialize" method too.
14
+ template<typename Initialize_Func_T>
15
+ void define_creation_funcs(
16
+ Class const & klass,
17
+ RUBY_VALUE_FUNC allocate_func,
18
+ Initialize_Func_T initialize_func);
19
+
20
+ //! This is just the opposite of define_alloc_func. It can be
21
+ //! used to create a class that cannot be instantiated by the user.
22
+ void undef_alloc_func(
23
+ Class const & klass);
24
+
25
+ //! This is just the opposite of define_creation_func. It can be
26
+ //! used to create a class that cannot be instantiated by the user.
27
+ void undef_creation_funcs(
28
+ Class const & klass);
29
+
30
+ } // namespace detail
31
+
32
+ } // namespace Rice
33
+
34
+ #include "creation_funcs.ipp"
35
+
36
+ #endif // Rice__detail__creation_funcs__hpp_
37
+
@@ -0,0 +1,36 @@
1
+ #ifndef Rice__detail__creation_funcs__ipp_
2
+ #define Rice__detail__creation_funcs__ipp_
3
+
4
+ namespace Rice
5
+ {
6
+
7
+ namespace detail
8
+ {
9
+
10
+ template<typename Initialize_Func_T>
11
+ inline void define_creation_funcs(
12
+ Class const & klass,
13
+ RUBY_VALUE_FUNC allocate_func,
14
+ Initialize_Func_T initialize_func)
15
+ {
16
+ rb_define_alloc_func(klass, allocate_func);
17
+ klass.define_method("initialize", initialize_func);
18
+ }
19
+
20
+ inline void undef_alloc_func(Class const & klass)
21
+ {
22
+ rb_undef_alloc_func(klass);
23
+ }
24
+
25
+ inline void undef_creation_funcs(Class const & klass)
26
+ {
27
+ undef_alloc_func(klass);
28
+ rb_undef_method(klass, "initialize");
29
+ }
30
+
31
+ } // namespace detail
32
+
33
+ } // namespace Rice
34
+
35
+ #endif // Rice__detail__creation_funcs__ipp_
36
+
@@ -0,0 +1,23 @@
1
+ #ifndef Rice__detail__default_allocation_func__hpp_
2
+ #define Rice__detail__default_allocation_func__hpp_
3
+
4
+ namespace Rice
5
+ {
6
+
7
+ namespace detail
8
+ {
9
+
10
+ //! A default implementation of an allocate_func. This function does no
11
+ //! actual allocation; the initialize_func can later do the real
12
+ //! allocation with: DATA_PTR(self) = new Type(arg1, arg2, ...)
13
+ template<typename T>
14
+ VALUE default_allocation_func(VALUE klass);
15
+
16
+ } // detail
17
+
18
+ } // Rice
19
+
20
+ #include "default_allocation_func.ipp"
21
+
22
+ #endif // Rice__detail__default_allocation_func__hpp_
23
+
@@ -0,0 +1,11 @@
1
+ #include "../Data_Object.hpp"
2
+
3
+ template<typename T>
4
+ VALUE Rice::detail::
5
+ default_allocation_func(VALUE klass)
6
+ {
7
+ Data_Object<T> m(static_cast<T*>(0), klass);
8
+ return m.value();
9
+ }
10
+
11
+
@@ -0,0 +1,31 @@
1
+ #ifndef Rice__detail__define_method_and_auto_wrap__hpp_
2
+ #define Rice__detail__define_method_and_auto_wrap__hpp_
3
+
4
+ #include "ruby.hpp"
5
+ #include "../Data_Object.hpp"
6
+ #include "../Identifier.hpp"
7
+ #include "Arguments.hpp"
8
+
9
+ namespace Rice
10
+ {
11
+
12
+ namespace detail
13
+ {
14
+
15
+ class Exception_Handler;
16
+
17
+ template<typename Fun_T>
18
+ void define_method_and_auto_wrap(
19
+ VALUE klass,
20
+ Identifier name,
21
+ Fun_T function,
22
+ Data_Object<Exception_Handler> handler,
23
+ Arguments* arguments = 0);
24
+
25
+ } // detail
26
+
27
+ } // Rice
28
+
29
+ #include "define_method_and_auto_wrap.ipp"
30
+
31
+ #endif // Rice__detail__define_method_and_auto_wrap__hpp_
@@ -0,0 +1,30 @@
1
+ #ifndef Rice__detail__define_method_and_auto_wrap__ipp_
2
+ #define Rice__detail__define_method_and_auto_wrap__ipp_
3
+
4
+ #include "wrap_function.hpp"
5
+ #include "method_data.hpp"
6
+ #include "Exception_Handler_defn.hpp"
7
+ #include "../protect.hpp"
8
+
9
+ template<typename Fun_T>
10
+ void Rice::detail::
11
+ define_method_and_auto_wrap(
12
+ VALUE klass,
13
+ Identifier name,
14
+ Fun_T function,
15
+ Data_Object<Exception_Handler> handler,
16
+ Arguments* arguments)
17
+ {
18
+ Data_Object<Wrapped_Function> f(
19
+ wrap_function(function, handler, arguments),
20
+ rb_cObject);
21
+ Rice::protect(
22
+ define_method_with_data,
23
+ klass,
24
+ name.id(),
25
+ f->func(),
26
+ -1,
27
+ f);
28
+ }
29
+
30
+ #endif // Rice__detail__define_method_and_auto_wrap__ipp_
@@ -0,0 +1,56 @@
1
+ #include "demangle.hpp"
2
+
3
+ #ifdef __GNUC__
4
+ #include <cxxabi.h>
5
+ #include <cstdlib>
6
+ #include <cstring>
7
+ #endif
8
+
9
+ std::string
10
+ Rice::detail::
11
+ demangle(char const * mangled_name)
12
+ {
13
+ #ifdef __GNUC__
14
+ struct Helper
15
+ {
16
+ Helper(
17
+ char const * mangled_name)
18
+ : name_(0)
19
+ {
20
+ int status = 0;
21
+ name_ = abi::__cxa_demangle(mangled_name, 0, 0, &status);
22
+ }
23
+
24
+ ~Helper()
25
+ {
26
+ std::free(name_);
27
+ }
28
+
29
+ char * name_;
30
+
31
+ private:
32
+ Helper(Helper const &);
33
+ void operator=(Helper const &);
34
+ };
35
+
36
+ Helper helper(mangled_name);
37
+ if(helper.name_)
38
+ {
39
+ return helper.name_;
40
+ }
41
+ else
42
+ {
43
+ return mangled_name;
44
+ }
45
+ #else
46
+ return mangled_name;
47
+ #endif
48
+ }
49
+
50
+
51
+ std::string
52
+ Rice::detail::
53
+ demangle(std::string const & mangled_name)
54
+ {
55
+ return demangle(mangled_name.c_str());
56
+ }
@@ -0,0 +1,19 @@
1
+ #ifndef Rice__detail__demangle__hpp_
2
+ #define Rice__detail__demangle__hpp_
3
+
4
+ #include <string>
5
+
6
+ namespace Rice
7
+ {
8
+
9
+ namespace detail
10
+ {
11
+
12
+ std::string demangle(char const * mangled_name);
13
+ std::string demangle(std::string const & mangled_name);
14
+
15
+ } // detail
16
+
17
+ } // Rice
18
+
19
+ #endif // Rice__detail__demangle__hpp_
@@ -0,0 +1,11 @@
1
+ #ifndef Rice__detail__env__hpp_
2
+ #define Rice__detail__env__hpp_
3
+
4
+ /**
5
+ * Helper header for the env.h ruby include file, which does
6
+ * not have extern "C"
7
+ */
8
+
9
+ #include "ruby_version_code.hpp"
10
+
11
+ #endif
@@ -0,0 +1,43 @@
1
+ #ifndef Rice__detail__from_ruby__hpp_
2
+ #define Rice__detail__from_ruby__hpp_
3
+
4
+ namespace Rice
5
+ {
6
+ namespace detail
7
+ {
8
+ template<typename T>
9
+ struct from_ruby_
10
+ {
11
+ typedef T Retval_T;
12
+
13
+ static T convert(Rice::Object x);
14
+ };
15
+
16
+ template<typename T>
17
+ struct from_ruby_<T *>
18
+ {
19
+ typedef T * Retval_T;
20
+
21
+ static T * convert(Rice::Object x);
22
+ };
23
+
24
+ template<typename T>
25
+ struct from_ruby_<T const *>
26
+ {
27
+ typedef T const * Retval_T;
28
+
29
+ static T const * convert(Rice::Object x);
30
+ };
31
+
32
+ template<typename T>
33
+ struct from_ruby_<T &>
34
+ {
35
+ typedef T & Retval_T;
36
+
37
+ static T & convert(Rice::Object x);
38
+ };
39
+ } // detail
40
+ } // Rice
41
+
42
+ #endif // Rice__detail__from_ruby__hpp_
43
+
@@ -0,0 +1,60 @@
1
+ #ifndef Rice__detail__from_ruby__ipp_
2
+ #define Rice__detail__from_ruby__ipp_
3
+
4
+ #include "../Data_Type.hpp"
5
+ #include "../String.hpp"
6
+ #include "demangle.hpp"
7
+ #include <typeinfo>
8
+
9
+ template<typename T>
10
+ T Rice::detail::from_ruby_<T>::
11
+ convert(Rice::Object x)
12
+ {
13
+ if(rb_type(x.value()) == T_DATA)
14
+ {
15
+ return *Data_Type<T>::from_ruby(x);
16
+ }
17
+ else
18
+ {
19
+ std::string s("Unable to convert ");
20
+ s += x.class_of().name().c_str();
21
+ s += " to ";
22
+ s += demangle(typeid(T).name());
23
+ throw std::invalid_argument(s.c_str());
24
+ }
25
+ }
26
+
27
+ template<typename T>
28
+ T * Rice::detail::from_ruby_<T *>::
29
+ convert(Rice::Object x)
30
+ {
31
+ if(rb_type(x.value()) == T_DATA)
32
+ {
33
+ return Data_Type<T>::from_ruby(x);
34
+ }
35
+ else
36
+ {
37
+ std::string s("Unable to convert ");
38
+ s += x.class_of().name().c_str();
39
+ s += " to ";
40
+ s += demangle(typeid(T *).name());
41
+ throw std::invalid_argument(s.c_str());
42
+ }
43
+ }
44
+
45
+ template<typename T>
46
+ T const * Rice::detail::from_ruby_<T const *>::
47
+ convert(Rice::Object x)
48
+ {
49
+ return from_ruby<T *>(x);
50
+ }
51
+
52
+ template<typename T>
53
+ T & Rice::detail::from_ruby_<T &>::
54
+ convert(Rice::Object x)
55
+ {
56
+ return *from_ruby<T *>(x);
57
+ }
58
+
59
+ #endif // Rice__detail__from_ruby__ipp_
60
+