keyme-rice 1.5.1.keyme

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.
Files changed (202) hide show
  1. checksums.yaml +15 -0
  2. data/COPYING +23 -0
  3. data/Doxyfile +1253 -0
  4. data/Makefile.am +26 -0
  5. data/Makefile.in +853 -0
  6. data/README +1124 -0
  7. data/README.mingw +8 -0
  8. data/Rakefile +34 -0
  9. data/aclocal.m4 +971 -0
  10. data/bootstrap +8 -0
  11. data/config.guess +1530 -0
  12. data/config.sub +1773 -0
  13. data/configure +7121 -0
  14. data/configure.ac +52 -0
  15. data/depcomp +688 -0
  16. data/doxygen.ac +314 -0
  17. data/doxygen.am +186 -0
  18. data/extconf.rb +51 -0
  19. data/install-sh +527 -0
  20. data/missing +331 -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 +127 -0
  29. data/rice/Arg_operators.cpp +21 -0
  30. data/rice/Arg_operators.hpp +19 -0
  31. data/rice/Array.hpp +220 -0
  32. data/rice/Array.ipp +263 -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 +368 -0
  41. data/rice/Critical_Guard.hpp +40 -0
  42. data/rice/Critical_Guard.ipp +26 -0
  43. data/rice/Data_Object.hpp +8 -0
  44. data/rice/Data_Object.ipp +133 -0
  45. data/rice/Data_Object_defn.hpp +138 -0
  46. data/rice/Data_Type.cpp +54 -0
  47. data/rice/Data_Type.hpp +8 -0
  48. data/rice/Data_Type.ipp +365 -0
  49. data/rice/Data_Type_defn.hpp +261 -0
  50. data/rice/Data_Type_fwd.hpp +12 -0
  51. data/rice/Director.cpp +13 -0
  52. data/rice/Director.hpp +39 -0
  53. data/rice/Enum.hpp +117 -0
  54. data/rice/Enum.ipp +246 -0
  55. data/rice/Exception.cpp +59 -0
  56. data/rice/Exception.hpp +9 -0
  57. data/rice/Exception_Base.hpp +8 -0
  58. data/rice/Exception_Base.ipp +13 -0
  59. data/rice/Exception_Base_defn.hpp +27 -0
  60. data/rice/Exception_defn.hpp +69 -0
  61. data/rice/Hash.hpp +227 -0
  62. data/rice/Hash.ipp +330 -0
  63. data/rice/Identifier.cpp +8 -0
  64. data/rice/Identifier.hpp +50 -0
  65. data/rice/Identifier.ipp +33 -0
  66. data/rice/Jump_Tag.hpp +24 -0
  67. data/rice/Makefile.am +129 -0
  68. data/rice/Makefile.in +769 -0
  69. data/rice/Module.cpp +84 -0
  70. data/rice/Module.hpp +8 -0
  71. data/rice/Module.ipp +6 -0
  72. data/rice/Module_defn.hpp +88 -0
  73. data/rice/Module_impl.hpp +281 -0
  74. data/rice/Module_impl.ipp +348 -0
  75. data/rice/Object.cpp +160 -0
  76. data/rice/Object.hpp +8 -0
  77. data/rice/Object.ipp +19 -0
  78. data/rice/Object_defn.hpp +191 -0
  79. data/rice/Require_Guard.hpp +21 -0
  80. data/rice/String.cpp +94 -0
  81. data/rice/String.hpp +89 -0
  82. data/rice/Struct.cpp +117 -0
  83. data/rice/Struct.hpp +162 -0
  84. data/rice/Struct.ipp +26 -0
  85. data/rice/Symbol.cpp +25 -0
  86. data/rice/Symbol.hpp +66 -0
  87. data/rice/Symbol.ipp +44 -0
  88. data/rice/VM.cpp +82 -0
  89. data/rice/VM.hpp +32 -0
  90. data/rice/config.hpp +44 -0
  91. data/rice/config.hpp.in +43 -0
  92. data/rice/detail/Arguments.hpp +118 -0
  93. data/rice/detail/Auto_Function_Wrapper.hpp +898 -0
  94. data/rice/detail/Auto_Function_Wrapper.ipp +3694 -0
  95. data/rice/detail/Auto_Member_Function_Wrapper.hpp +897 -0
  96. data/rice/detail/Auto_Member_Function_Wrapper.ipp +2774 -0
  97. data/rice/detail/Caster.hpp +103 -0
  98. data/rice/detail/Exception_Handler.hpp +8 -0
  99. data/rice/detail/Exception_Handler.ipp +68 -0
  100. data/rice/detail/Exception_Handler_defn.hpp +96 -0
  101. data/rice/detail/Iterator.hpp +93 -0
  102. data/rice/detail/Not_Copyable.hpp +25 -0
  103. data/rice/detail/Wrapped_Function.hpp +33 -0
  104. data/rice/detail/cfp.hpp +24 -0
  105. data/rice/detail/cfp.ipp +51 -0
  106. data/rice/detail/check_ruby_type.cpp +27 -0
  107. data/rice/detail/check_ruby_type.hpp +23 -0
  108. data/rice/detail/creation_funcs.hpp +37 -0
  109. data/rice/detail/creation_funcs.ipp +36 -0
  110. data/rice/detail/default_allocation_func.hpp +23 -0
  111. data/rice/detail/default_allocation_func.ipp +11 -0
  112. data/rice/detail/define_method_and_auto_wrap.hpp +31 -0
  113. data/rice/detail/define_method_and_auto_wrap.ipp +30 -0
  114. data/rice/detail/demangle.cpp +56 -0
  115. data/rice/detail/demangle.hpp +19 -0
  116. data/rice/detail/env.hpp +19 -0
  117. data/rice/detail/from_ruby.hpp +43 -0
  118. data/rice/detail/from_ruby.ipp +60 -0
  119. data/rice/detail/method_data.cpp +159 -0
  120. data/rice/detail/method_data.hpp +21 -0
  121. data/rice/detail/mininode.cpp +1220 -0
  122. data/rice/detail/mininode.hpp +320 -0
  123. data/rice/detail/node.hpp +13 -0
  124. data/rice/detail/object_call.hpp +69 -0
  125. data/rice/detail/object_call.ipp +131 -0
  126. data/rice/detail/protect.cpp +29 -0
  127. data/rice/detail/protect.hpp +34 -0
  128. data/rice/detail/ruby.hpp +84 -0
  129. data/rice/detail/ruby_version_code.hpp +6 -0
  130. data/rice/detail/ruby_version_code.hpp.in +6 -0
  131. data/rice/detail/rubysig.hpp +19 -0
  132. data/rice/detail/st.hpp +22 -0
  133. data/rice/detail/to_ruby.hpp +22 -0
  134. data/rice/detail/to_ruby.ipp +36 -0
  135. data/rice/detail/traits.hpp +43 -0
  136. data/rice/detail/win32.hpp +16 -0
  137. data/rice/detail/wrap_function.hpp +341 -0
  138. data/rice/detail/wrap_function.ipp +514 -0
  139. data/rice/global_function.hpp +33 -0
  140. data/rice/global_function.ipp +22 -0
  141. data/rice/protect.hpp +92 -0
  142. data/rice/protect.ipp +1134 -0
  143. data/rice/ruby_mark.hpp +13 -0
  144. data/rice/ruby_try_catch.hpp +86 -0
  145. data/rice/rubypp.rb +97 -0
  146. data/rice/to_from_ruby.hpp +8 -0
  147. data/rice/to_from_ruby.ipp +294 -0
  148. data/rice/to_from_ruby_defn.hpp +71 -0
  149. data/ruby/Makefile.am +1 -0
  150. data/ruby/Makefile.in +569 -0
  151. data/ruby/lib/Makefile.am +3 -0
  152. data/ruby/lib/Makefile.in +423 -0
  153. data/ruby/lib/mkmf-rice.rb.in +213 -0
  154. data/ruby/lib/version.rb +3 -0
  155. data/ruby.ac +136 -0
  156. data/sample/Makefile.am +47 -0
  157. data/sample/Makefile.in +408 -0
  158. data/sample/enum/extconf.rb +3 -0
  159. data/sample/enum/sample_enum.cpp +54 -0
  160. data/sample/enum/test.rb +8 -0
  161. data/sample/inheritance/animals.cpp +98 -0
  162. data/sample/inheritance/extconf.rb +3 -0
  163. data/sample/inheritance/test.rb +7 -0
  164. data/sample/map/extconf.rb +3 -0
  165. data/sample/map/map.cpp +81 -0
  166. data/sample/map/test.rb +7 -0
  167. data/test/Makefile.am +77 -0
  168. data/test/Makefile.in +820 -0
  169. data/test/ext/Makefile.am +43 -0
  170. data/test/ext/Makefile.in +404 -0
  171. data/test/ext/t1/Foo.hpp +10 -0
  172. data/test/ext/t1/extconf.rb +2 -0
  173. data/test/ext/t1/t1.cpp +15 -0
  174. data/test/ext/t2/extconf.rb +2 -0
  175. data/test/ext/t2/t2.cpp +11 -0
  176. data/test/test_Address_Registration_Guard.cpp +43 -0
  177. data/test/test_Array.cpp +241 -0
  178. data/test/test_Builtin_Object.cpp +72 -0
  179. data/test/test_Class.cpp +498 -0
  180. data/test/test_Constructor.cpp +128 -0
  181. data/test/test_Critical_Guard.cpp +51 -0
  182. data/test/test_Data_Object.cpp +275 -0
  183. data/test/test_Data_Type.cpp +348 -0
  184. data/test/test_Director.cpp +303 -0
  185. data/test/test_Enum.cpp +195 -0
  186. data/test/test_Exception.cpp +46 -0
  187. data/test/test_Hash.cpp +198 -0
  188. data/test/test_Identifier.cpp +70 -0
  189. data/test/test_Jump_Tag.cpp +17 -0
  190. data/test/test_Memory_Management.cpp +50 -0
  191. data/test/test_Module.cpp +497 -0
  192. data/test/test_Object.cpp +148 -0
  193. data/test/test_String.cpp +94 -0
  194. data/test/test_Struct.cpp +192 -0
  195. data/test/test_Symbol.cpp +63 -0
  196. data/test/test_To_From_Ruby.cpp +321 -0
  197. data/test/test_VM.cpp +26 -0
  198. data/test/test_global_functions.cpp +114 -0
  199. data/test/test_rice.rb +43 -0
  200. data/test/unittest.cpp +136 -0
  201. data/test/unittest.hpp +294 -0
  202. metadata +259 -0
@@ -0,0 +1,59 @@
1
+ #include "Exception.hpp"
2
+ #include "protect.hpp"
3
+ #include "to_from_ruby.hpp"
4
+ #include "detail/ruby.hpp"
5
+
6
+ #ifdef HAVE_STDARG_PROTOTYPES
7
+ #include <stdarg.h>
8
+ #define va_init_list(a,b) va_start(a,b)
9
+ #else
10
+ #include <varargs.h>
11
+ #define va_init_list(a,b) va_start(a)
12
+ #endif
13
+
14
+ Rice::Exception::
15
+ Exception(VALUE e)
16
+ : Exception_Base(e)
17
+ , message_(Qnil)
18
+ , message_guard_(&message_)
19
+ {
20
+ }
21
+
22
+ Rice::Exception::
23
+ Exception(Exception const & other)
24
+ : Exception_Base(other)
25
+ , message_(other.message_)
26
+ , message_guard_(&message_)
27
+ {
28
+ }
29
+
30
+ Rice::Exception::
31
+ Exception(Object exc, char const * fmt, ...)
32
+ : Exception_Base(Qnil)
33
+ , message_(Qnil)
34
+ , message_guard_(&message_)
35
+ {
36
+ va_list args;
37
+ char buf[BUFSIZ];
38
+
39
+ va_init_list(args, fmt);
40
+ vsnprintf(buf, BUFSIZ, fmt, args);
41
+ buf[BUFSIZ - 1] = '\0';
42
+ va_end(args);
43
+
44
+ set_value(protect(rb_exc_new2, exc, buf));
45
+ }
46
+
47
+ Rice::String Rice::Exception::
48
+ message() const
49
+ {
50
+ return protect(rb_funcall, value(), rb_intern("message"), 0);
51
+ }
52
+
53
+ char const * Rice::Exception::
54
+ what() const throw()
55
+ {
56
+ message_ = message();
57
+ return from_ruby<char const *>(message_);
58
+ }
59
+
@@ -0,0 +1,9 @@
1
+ #ifndef Rice__Exception__hpp_
2
+ #define Rice__Exception__hpp_
3
+
4
+ #include "Exception_defn.hpp"
5
+ #include "Exception_Base.hpp"
6
+ #include "Address_Registration_Guard.hpp"
7
+
8
+ #endif // Rice__Exception__hpp_
9
+
@@ -0,0 +1,8 @@
1
+ #ifndef Rice__Exception_Base__hpp_
2
+ #define Rice__Exception_Base__hpp_
3
+
4
+ #include "Exception_Base_defn.hpp"
5
+ #include "Exception_Base.ipp"
6
+
7
+ #endif // Rice__Exception_Base__hpp_
8
+
@@ -0,0 +1,13 @@
1
+ #include "Object.hpp"
2
+
3
+ inline Rice::Exception_Base::
4
+ Exception_Base(VALUE v)
5
+ : Object(v)
6
+ {
7
+ }
8
+
9
+ inline Rice::Exception_Base::
10
+ ~Exception_Base() throw()
11
+ {
12
+ }
13
+
@@ -0,0 +1,27 @@
1
+ #ifndef Rice__Exception_Base_defn__hpp_
2
+ #define Rice__Exception_Base_defn__hpp_
3
+
4
+ #include "Object_defn.hpp"
5
+
6
+ namespace Rice
7
+ {
8
+
9
+ //! An abstract interface for Exception
10
+ /*! This class exists to prevent a circular reference between
11
+ * Exception.hpp and ruby_try_catch.hpp
12
+ */
13
+ class Exception_Base
14
+ : public std::exception
15
+ , public Object
16
+ {
17
+ public:
18
+ Exception_Base(VALUE v);
19
+
20
+ virtual ~Exception_Base() throw() = 0;
21
+
22
+ virtual char const * what() const throw() = 0;
23
+ };
24
+
25
+ } // Rice
26
+
27
+ #endif // Rice__Exception_Base_defn__hpp_
@@ -0,0 +1,69 @@
1
+ #ifndef Rice__Exception_defn__hpp_
2
+ #define Rice__Exception_defn__hpp_
3
+
4
+ #include "Exception_Base_defn.hpp"
5
+ #include "String.hpp"
6
+ #include "Address_Registration_Guard_defn.hpp"
7
+
8
+ #include <stdexcept>
9
+ #include "detail/ruby.hpp"
10
+
11
+ namespace Rice
12
+ {
13
+
14
+ //! A placeholder for Ruby exceptions.
15
+ /*! You can use this to safely throw a Ruby exception using C++ syntax:
16
+ * \code
17
+ * VALUE foo(VALUE self) {
18
+ * RUBY_TRY {
19
+ * throw Rice::Exception(rb_eMyException, "uh oh!");
20
+ * RUBY_CATCH
21
+ * }
22
+ * \endcode
23
+ */
24
+ class Exception
25
+ : public Exception_Base
26
+ {
27
+ public:
28
+ //! Construct a Exception with the exception e.
29
+ explicit Exception(VALUE e);
30
+
31
+ //! Copy constructor.
32
+ Exception(Exception const & other);
33
+
34
+ //! Construct a Exception with printf-style formatting.
35
+ /*! \param exc either an exception object or a class that inherits
36
+ * from Exception.
37
+ * \param fmt a printf-style format string
38
+ * \param ... the arguments to the format string.
39
+ */
40
+ Exception(Object exc, char const * fmt, ...);
41
+
42
+ //! Destructor
43
+ virtual ~Exception() throw() { }
44
+
45
+ //! Get the message the exception holds
46
+ /*! \return the result of calling message() on the underlying
47
+ * exception object.
48
+ */
49
+ String message() const;
50
+
51
+ //! Get message as a char const *.
52
+ /*! If message is a non-string object, then this function will attempt
53
+ * to throw an exception (which it can't do because of the no-throw
54
+ * specification).
55
+ * \return the underlying C pointer of the underlying message object.
56
+ */
57
+ virtual char const * what() const throw();
58
+
59
+ private:
60
+ // Keep message around in case someone calls what() and then the GC
61
+ // gets invoked.
62
+ mutable VALUE message_;
63
+ Address_Registration_Guard message_guard_;
64
+ };
65
+
66
+ } // namespace Rice
67
+
68
+ #endif // Rice__Exception_defn__hpp_
69
+
data/rice/Hash.hpp ADDED
@@ -0,0 +1,227 @@
1
+ #ifndef Rice__Hash__hpp_
2
+ #define Rice__Hash__hpp_
3
+
4
+ #include "Builtin_Object_defn.hpp"
5
+ #include "Array.hpp"
6
+ #include "to_from_ruby_defn.hpp"
7
+ #include "detail/ruby.hpp"
8
+ #include "detail/traits.hpp"
9
+ #include <iterator>
10
+
11
+ namespace Rice
12
+ {
13
+
14
+ //! A wrapper for the ruby Hash class.
15
+ //! This class provides a C++-style interface to ruby's Hash class and
16
+ //! its associated rb_hash_* functions.
17
+ //! Example:
18
+ //! \code
19
+ //! Hash h;
20
+ //! h[42] = String("foo");
21
+ //! h[10] = String("bar");
22
+ //! std::cout << String(h[42]) << std::endl;
23
+ //! \endcode
24
+ class Hash
25
+ : public Builtin_Object<RHash, T_HASH>
26
+ {
27
+ public:
28
+ //! Construct a new hash.
29
+ Hash();
30
+
31
+ //! Wrap an existing hash.
32
+ /*! \param v the hash to wrap.
33
+ */
34
+ Hash(Object v);
35
+
36
+ //! Return the number of elements in the hash.
37
+ size_t size() const;
38
+
39
+ private:
40
+ //! A helper class so hash[key]=value can work.
41
+ class Proxy;
42
+
43
+ public:
44
+ //! Get the value for the given key.
45
+ /*! \param key the key whose value should be retrieved from the hash.
46
+ * \return the value associated with the given key.
47
+ */
48
+ template<typename Key_T>
49
+ Proxy const operator[](Key_T const & key) const;
50
+
51
+ //! Get the value for the given key.
52
+ /*! \param key the key whose value should be retrieved from the hash.
53
+ * \return the value associated with the given key.
54
+ */
55
+ template<typename Key_T>
56
+ Proxy operator[](Key_T const & key);
57
+
58
+ //! Get the value for the given key
59
+ /*! The returned value is converted to the type given by Value_T.
60
+ * \param key the key whose value should be retrieved from the hash.
61
+ * \return the value associated with the given key, converted to C++
62
+ * type Value_T.
63
+ */
64
+ template<typename Value_T, typename Key_T>
65
+ Value_T get(Key_T const & key);
66
+
67
+ //! A helper class for dereferencing iterators
68
+ class Entry;
69
+
70
+ //! A helper class for implementing iterators for a Hash.
71
+ template<typename Hash_Ref_T, typename Value_T>
72
+ class Iterator;
73
+
74
+ public:
75
+ //! An iterator.
76
+ typedef Iterator<Hash &, Entry> iterator;
77
+
78
+ //! A const iterator.
79
+ typedef Iterator<Hash const &, Entry const> const_iterator;
80
+
81
+ public:
82
+ //! Return an iterator to the beginning of the hash.
83
+ iterator begin();
84
+
85
+ //! Return a const iterator to the beginning of the hash.
86
+ const_iterator begin() const;
87
+
88
+ //! Return an iterator to the end of the hash.
89
+ iterator end();
90
+
91
+ //! Return a const to the end of the hash.
92
+ const_iterator end() const;
93
+ };
94
+
95
+ //! A helper class so hash[key]=value can work.
96
+ class Hash::Proxy
97
+ {
98
+ public:
99
+ //! Construct a new Proxy.
100
+ Proxy(Hash hash, Object key);
101
+
102
+ //! Implicit conversion to Object.
103
+ operator Object() const;
104
+
105
+ //! Explicit conversion to VALUE.
106
+ VALUE value() const;
107
+
108
+ //! Assignment operator.
109
+ template<typename T>
110
+ Object operator=(T const & value);
111
+
112
+ void swap(Proxy & proxy);
113
+
114
+ private:
115
+ Hash hash_;
116
+ Object key_;
117
+ };
118
+
119
+ //! A helper class for dereferencing iterators
120
+ /*! This class is intended to look similar to an std::pair.
121
+ */
122
+ class Hash::Entry
123
+ {
124
+ public:
125
+ //! Construct a new Entry.
126
+ Entry(Hash hash, Object key);
127
+
128
+ //! Copy constructor.
129
+ Entry(Entry const & entry);
130
+
131
+ Object const key; //!< The key
132
+ Object const & first; //!< An alias for the key
133
+
134
+ Proxy value; //!< The value
135
+ Proxy & second; //!< An alias for the value
136
+
137
+ Entry & operator=(Entry const & rhs);
138
+
139
+ void swap(Entry & entry);
140
+
141
+ friend bool operator<(Entry const & lhs, Entry const & rhs);
142
+ };
143
+
144
+ bool operator<(Hash::Entry const & lhs, Hash::Entry const & rhs);
145
+
146
+ //! A helper class for implementing iterators for a Hash.
147
+ template<typename Hash_Ref_T, typename Value_T>
148
+ class Hash::Iterator
149
+ : public std::iterator<
150
+ std::input_iterator_tag,
151
+ Value_T>
152
+ {
153
+ public:
154
+ //! Construct a new Iterator.
155
+ Iterator(Hash_Ref_T hash);
156
+
157
+ //! Construct a new Iterator with a given start-at index point
158
+ Iterator(Hash_Ref_T hash, int start_at);
159
+
160
+ //! Copy construct an Iterator.
161
+ Iterator(Iterator const & iterator);
162
+
163
+ //! Construct an Iterator from another Iterator of a different const
164
+ //! qualification.
165
+ template<typename Iterator_T>
166
+ Iterator(Iterator_T const & iterator);
167
+
168
+ //! Assignment operator.
169
+ Iterator & operator=(Iterator const & rhs);
170
+
171
+ //! Preincrement operator.
172
+ Iterator & operator++();
173
+
174
+ //! Postincrement operator.
175
+ Iterator operator++(int);
176
+
177
+ //! Dereference operator.
178
+ Value_T operator*();
179
+
180
+ //! Dereference operator.
181
+ Value_T * operator->();
182
+
183
+ //! Equality operator.
184
+ bool operator==(Iterator const & rhs) const;
185
+
186
+ //! Inequality operator.
187
+ bool operator!=(Iterator const & rhs) const;
188
+
189
+ template<typename Hash_Ref_T_, typename Value_T_>
190
+ friend class Hash::Iterator;
191
+
192
+ //! Swap with another iterator of the same type.
193
+ void swap(Iterator & iterator);
194
+
195
+ protected:
196
+ Object current_key();
197
+
198
+ Array hash_keys();
199
+
200
+ private:
201
+ Hash hash_;
202
+ int current_index_;
203
+ VALUE keys_;
204
+
205
+ mutable typename detail::remove_const<Value_T>::Type tmp_;
206
+ };
207
+
208
+ } // namespace Rice
209
+
210
+ template<>
211
+ inline
212
+ Rice::Hash from_ruby<Rice::Hash>(Rice::Object x)
213
+ {
214
+ return Rice::Hash(x);
215
+ }
216
+
217
+ template<>
218
+ inline
219
+ Rice::Object to_ruby<Rice::Hash>(Rice::Hash const & x)
220
+ {
221
+ return x;
222
+ }
223
+
224
+ #include "Hash.ipp"
225
+
226
+ #endif // Rice__Hash__hpp_
227
+