wurlinc-rice 1.4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/COPYING +23 -0
  2. data/Doxyfile +1253 -0
  3. data/Makefile.am +26 -0
  4. data/README +1119 -0
  5. data/README.mingw +8 -0
  6. data/Rakefile +33 -0
  7. data/bootstrap +9 -0
  8. data/configure.ac +52 -0
  9. data/doxygen.ac +314 -0
  10. data/doxygen.am +186 -0
  11. data/extconf.rb +41 -0
  12. data/post-autoconf.rb +22 -0
  13. data/post-automake.rb +28 -0
  14. data/rice/Address_Registration_Guard.hpp +7 -0
  15. data/rice/Address_Registration_Guard.ipp +34 -0
  16. data/rice/Address_Registration_Guard_defn.hpp +65 -0
  17. data/rice/Allocation_Strategies.hpp +37 -0
  18. data/rice/Arg.hpp +8 -0
  19. data/rice/Arg_impl.hpp +127 -0
  20. data/rice/Arg_operators.cpp +21 -0
  21. data/rice/Arg_operators.hpp +19 -0
  22. data/rice/Array.hpp +220 -0
  23. data/rice/Array.ipp +263 -0
  24. data/rice/Builtin_Object.hpp +8 -0
  25. data/rice/Builtin_Object.ipp +50 -0
  26. data/rice/Builtin_Object_defn.hpp +51 -0
  27. data/rice/Class.cpp +57 -0
  28. data/rice/Class.hpp +8 -0
  29. data/rice/Class.ipp +6 -0
  30. data/rice/Class_defn.hpp +83 -0
  31. data/rice/Constructor.hpp +367 -0
  32. data/rice/Critical_Guard.hpp +40 -0
  33. data/rice/Critical_Guard.ipp +26 -0
  34. data/rice/Data_Object.hpp +8 -0
  35. data/rice/Data_Object.ipp +133 -0
  36. data/rice/Data_Object_defn.hpp +132 -0
  37. data/rice/Data_Type.cpp +54 -0
  38. data/rice/Data_Type.hpp +8 -0
  39. data/rice/Data_Type.ipp +365 -0
  40. data/rice/Data_Type_defn.hpp +261 -0
  41. data/rice/Data_Type_fwd.hpp +12 -0
  42. data/rice/Director.cpp +13 -0
  43. data/rice/Director.hpp +39 -0
  44. data/rice/Enum.hpp +117 -0
  45. data/rice/Enum.ipp +246 -0
  46. data/rice/Exception.cpp +59 -0
  47. data/rice/Exception.hpp +9 -0
  48. data/rice/Exception_Base.hpp +8 -0
  49. data/rice/Exception_Base.ipp +13 -0
  50. data/rice/Exception_Base_defn.hpp +27 -0
  51. data/rice/Exception_defn.hpp +69 -0
  52. data/rice/Hash.hpp +210 -0
  53. data/rice/Hash.ipp +338 -0
  54. data/rice/Identifier.cpp +8 -0
  55. data/rice/Identifier.hpp +50 -0
  56. data/rice/Identifier.ipp +33 -0
  57. data/rice/Jump_Tag.hpp +24 -0
  58. data/rice/Makefile.am +129 -0
  59. data/rice/Module.cpp +84 -0
  60. data/rice/Module.hpp +8 -0
  61. data/rice/Module.ipp +6 -0
  62. data/rice/Module_defn.hpp +88 -0
  63. data/rice/Module_impl.hpp +281 -0
  64. data/rice/Module_impl.ipp +348 -0
  65. data/rice/Object.cpp +160 -0
  66. data/rice/Object.hpp +8 -0
  67. data/rice/Object.ipp +19 -0
  68. data/rice/Object_defn.hpp +191 -0
  69. data/rice/Require_Guard.hpp +21 -0
  70. data/rice/String.cpp +94 -0
  71. data/rice/String.hpp +89 -0
  72. data/rice/Struct.cpp +117 -0
  73. data/rice/Struct.hpp +162 -0
  74. data/rice/Struct.ipp +26 -0
  75. data/rice/Symbol.cpp +25 -0
  76. data/rice/Symbol.hpp +66 -0
  77. data/rice/Symbol.ipp +44 -0
  78. data/rice/VM.cpp +92 -0
  79. data/rice/VM.hpp +32 -0
  80. data/rice/config.hpp.in +40 -0
  81. data/rice/detail/Arguments.hpp +118 -0
  82. data/rice/detail/Auto_Function_Wrapper.hpp +829 -0
  83. data/rice/detail/Auto_Function_Wrapper.ipp +3391 -0
  84. data/rice/detail/Auto_Member_Function_Wrapper.hpp +828 -0
  85. data/rice/detail/Auto_Member_Function_Wrapper.ipp +2503 -0
  86. data/rice/detail/Caster.hpp +103 -0
  87. data/rice/detail/Exception_Handler.hpp +8 -0
  88. data/rice/detail/Exception_Handler.ipp +68 -0
  89. data/rice/detail/Exception_Handler_defn.hpp +96 -0
  90. data/rice/detail/Iterator.hpp +93 -0
  91. data/rice/detail/Not_Copyable.hpp +25 -0
  92. data/rice/detail/Wrapped_Function.hpp +33 -0
  93. data/rice/detail/cfp.hpp +24 -0
  94. data/rice/detail/cfp.ipp +51 -0
  95. data/rice/detail/check_ruby_type.cpp +27 -0
  96. data/rice/detail/check_ruby_type.hpp +23 -0
  97. data/rice/detail/creation_funcs.hpp +37 -0
  98. data/rice/detail/creation_funcs.ipp +36 -0
  99. data/rice/detail/default_allocation_func.hpp +23 -0
  100. data/rice/detail/default_allocation_func.ipp +11 -0
  101. data/rice/detail/define_method_and_auto_wrap.hpp +31 -0
  102. data/rice/detail/define_method_and_auto_wrap.ipp +30 -0
  103. data/rice/detail/demangle.cpp +56 -0
  104. data/rice/detail/demangle.hpp +19 -0
  105. data/rice/detail/env.hpp +19 -0
  106. data/rice/detail/from_ruby.hpp +43 -0
  107. data/rice/detail/from_ruby.ipp +60 -0
  108. data/rice/detail/method_data.cpp +159 -0
  109. data/rice/detail/method_data.hpp +21 -0
  110. data/rice/detail/mininode.cpp +1220 -0
  111. data/rice/detail/mininode.hpp +320 -0
  112. data/rice/detail/node.hpp +13 -0
  113. data/rice/detail/object_call.hpp +68 -0
  114. data/rice/detail/object_call.ipp +131 -0
  115. data/rice/detail/protect.cpp +29 -0
  116. data/rice/detail/protect.hpp +34 -0
  117. data/rice/detail/ruby.hpp +93 -0
  118. data/rice/detail/ruby_version_code.hpp.in +6 -0
  119. data/rice/detail/rubysig.hpp +19 -0
  120. data/rice/detail/st.hpp +60 -0
  121. data/rice/detail/to_ruby.hpp +22 -0
  122. data/rice/detail/to_ruby.ipp +36 -0
  123. data/rice/detail/traits.hpp +43 -0
  124. data/rice/detail/win32.hpp +16 -0
  125. data/rice/detail/wrap_function.hpp +341 -0
  126. data/rice/detail/wrap_function.ipp +514 -0
  127. data/rice/global_function.hpp +33 -0
  128. data/rice/global_function.ipp +22 -0
  129. data/rice/protect.hpp +91 -0
  130. data/rice/protect.ipp +1133 -0
  131. data/rice/ruby_mark.hpp +13 -0
  132. data/rice/ruby_try_catch.hpp +86 -0
  133. data/rice/rubypp.rb +97 -0
  134. data/rice/to_from_ruby.hpp +8 -0
  135. data/rice/to_from_ruby.ipp +297 -0
  136. data/rice/to_from_ruby_defn.hpp +71 -0
  137. data/ruby/Makefile.am +1 -0
  138. data/ruby/lib/Makefile.am +3 -0
  139. data/ruby/lib/mkmf-rice.rb.in +216 -0
  140. data/ruby/lib/version.rb +3 -0
  141. data/ruby.ac +136 -0
  142. data/sample/Makefile.am +47 -0
  143. data/sample/enum/extconf.rb +3 -0
  144. data/sample/enum/sample_enum.cpp +54 -0
  145. data/sample/enum/test.rb +8 -0
  146. data/sample/inheritance/animals.cpp +98 -0
  147. data/sample/inheritance/extconf.rb +3 -0
  148. data/sample/inheritance/test.rb +7 -0
  149. data/sample/map/extconf.rb +3 -0
  150. data/sample/map/map.cpp +81 -0
  151. data/sample/map/test.rb +7 -0
  152. data/test/Makefile.am +78 -0
  153. data/test/ext/Makefile.am +43 -0
  154. data/test/ext/t1/Foo.hpp +10 -0
  155. data/test/ext/t1/extconf.rb +2 -0
  156. data/test/ext/t1/t1.cpp +15 -0
  157. data/test/ext/t2/extconf.rb +2 -0
  158. data/test/ext/t2/t2.cpp +11 -0
  159. data/test/test_Address_Registration_Guard.cpp +43 -0
  160. data/test/test_Allocation_Strategies.cpp +77 -0
  161. data/test/test_Array.cpp +241 -0
  162. data/test/test_Builtin_Object.cpp +72 -0
  163. data/test/test_Class.cpp +498 -0
  164. data/test/test_Constructor.cpp +128 -0
  165. data/test/test_Critical_Guard.cpp +51 -0
  166. data/test/test_Data_Object.cpp +275 -0
  167. data/test/test_Data_Type.cpp +348 -0
  168. data/test/test_Director.cpp +301 -0
  169. data/test/test_Enum.cpp +195 -0
  170. data/test/test_Exception.cpp +46 -0
  171. data/test/test_Hash.cpp +195 -0
  172. data/test/test_Identifier.cpp +70 -0
  173. data/test/test_Jump_Tag.cpp +17 -0
  174. data/test/test_Memory_Management.cpp +50 -0
  175. data/test/test_Module.cpp +481 -0
  176. data/test/test_Object.cpp +148 -0
  177. data/test/test_String.cpp +94 -0
  178. data/test/test_Struct.cpp +192 -0
  179. data/test/test_Symbol.cpp +63 -0
  180. data/test/test_To_From_Ruby.cpp +263 -0
  181. data/test/test_VM.cpp +26 -0
  182. data/test/test_global_functions.cpp +114 -0
  183. data/test/test_rice.rb +43 -0
  184. data/test/unittest.cpp +136 -0
  185. data/test/unittest.hpp +292 -0
  186. metadata +276 -0
data/rice/Hash.ipp ADDED
@@ -0,0 +1,338 @@
1
+ #ifndef Rice__Hash__ipp_
2
+ #define Rice__Hash__ipp_
3
+
4
+ #include "protect.hpp"
5
+ #include "to_from_ruby.hpp"
6
+ #include "Builtin_Object.hpp"
7
+ #include "Exception.hpp"
8
+ #include "Builtin_Object.hpp"
9
+ #include <algorithm>
10
+
11
+ // TODO: Evil hack
12
+ struct st_table_entry {
13
+ unsigned int hash;
14
+ st_data_t key;
15
+ st_data_t record;
16
+ st_table_entry *next;
17
+ };
18
+
19
+ inline Rice::Hash::
20
+ Hash()
21
+ : Builtin_Object<RHash, T_HASH>(protect(rb_hash_new))
22
+ {
23
+ }
24
+
25
+ inline Rice::Hash::
26
+ Hash(Object v)
27
+ : Builtin_Object<RHash, T_HASH>(v)
28
+ {
29
+ }
30
+
31
+ inline size_t Rice::Hash::
32
+ size() const
33
+ {
34
+ return RHASH_TBL(this->value())->num_entries;
35
+ }
36
+
37
+ inline Rice::Hash::Proxy::
38
+ Proxy(Hash hash, Object key)
39
+ : hash_(hash)
40
+ , key_(key)
41
+ {
42
+ }
43
+
44
+ /*
45
+ inline Rice::Hash::Proxy::
46
+ operator VALUE() const
47
+ {
48
+ return value();
49
+ }
50
+ */
51
+
52
+ inline Rice::Hash::Proxy::
53
+ operator Rice::Object() const
54
+ {
55
+ return value();
56
+ }
57
+
58
+ inline VALUE Rice::Hash::Proxy::
59
+ value() const
60
+ {
61
+ return protect(rb_hash_aref, hash_, key_);
62
+ }
63
+
64
+ template<typename T>
65
+ inline Rice::Object Rice::Hash::Proxy::
66
+ operator=(T const & value)
67
+ {
68
+ return protect(rb_hash_aset, hash_, key_, to_ruby(value));
69
+ }
70
+
71
+ inline void Rice::Hash::Proxy::
72
+ swap(Proxy & proxy)
73
+ {
74
+ hash_.swap(proxy.hash_);
75
+ key_.swap(proxy.key_);
76
+ }
77
+
78
+ template<typename Key_T>
79
+ inline Rice::Hash::Proxy const Rice::Hash::
80
+ operator[](Key_T const & key) const
81
+ {
82
+ return Proxy(*this, to_ruby(key));
83
+ }
84
+
85
+ template<typename Key_T>
86
+ inline Rice::Hash::Proxy Rice::Hash::
87
+ operator[](Key_T const & key)
88
+ {
89
+ return Proxy(*this, to_ruby(key));
90
+ }
91
+
92
+ template<typename Value_T, typename Key_T>
93
+ inline Value_T Rice::Hash::
94
+ get(Key_T const & key)
95
+ {
96
+ Object ruby_key(to_ruby(key));
97
+ Object value = operator[](ruby_key);
98
+ try
99
+ {
100
+ return from_ruby<Value_T>(value);
101
+ }
102
+ catch(Exception const & ex)
103
+ {
104
+ String s_key(ruby_key.to_s());
105
+ throw Exception(
106
+ ex,
107
+ "%s while converting value for key %s",
108
+ ex.what(),
109
+ s_key.c_str());
110
+ }
111
+ }
112
+
113
+ inline Rice::Hash::Entry::
114
+ Entry(Hash hash, Object key)
115
+ : key(key)
116
+ , first(Hash::Entry::key)
117
+ , value(hash, key)
118
+ , second(Hash::Entry::value)
119
+ {
120
+ }
121
+
122
+ inline Rice::Hash::Entry::
123
+ Entry(Entry const & entry)
124
+ : key(entry.key)
125
+ , first(Hash::Entry::key)
126
+ , value(entry.value)
127
+ , second(Hash::Entry::value)
128
+ {
129
+ }
130
+
131
+ inline Rice::Hash::Entry & Rice::Hash::Entry::
132
+ operator=(Rice::Hash::Entry const & rhs)
133
+ {
134
+ Entry tmp(rhs);
135
+ swap(tmp);
136
+ return *this;
137
+ }
138
+
139
+ inline void Rice::Hash::Entry::
140
+ swap(Rice::Hash::Entry & entry)
141
+ {
142
+ const_cast<Object &>(key).swap(const_cast<Object &>(entry.key));
143
+ value.swap(entry.value);
144
+ }
145
+
146
+ template<typename Hash_Ref_T, typename Value_T>
147
+ inline Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
148
+ Iterator(Hash_Ref_T hash, st_data_t bin, st_table_entry * ptr)
149
+ : hash_(hash)
150
+ , tbl_(RHASH_TBL(hash.value()))
151
+ , bin_(bin)
152
+ , ptr_(ptr)
153
+ , tmp_(hash, Qnil)
154
+ {
155
+ // If we aren't already at the end, then use the increment operator to
156
+ // point to the first element
157
+ if(!ptr_ && bin_ < tbl_->num_bins)
158
+ {
159
+ operator++();
160
+ }
161
+ }
162
+
163
+ template<typename Hash_Ref_T, typename Value_T>
164
+ inline Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
165
+ Iterator(Iterator const & iterator)
166
+ : hash_(iterator.hash_.value())
167
+ , tbl_(iterator.tbl_)
168
+ , bin_(iterator.bin_)
169
+ , ptr_(iterator.ptr_)
170
+ , tmp_(iterator.hash_, Qnil)
171
+ {
172
+ }
173
+
174
+ template<typename Hash_Ref_T, typename Value_T>
175
+ template<typename Iterator_T>
176
+ inline Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
177
+ Iterator(Iterator_T const & iterator)
178
+ : hash_(iterator.hash_.value())
179
+ , tbl_(iterator.tbl_)
180
+ , bin_(iterator.bin_)
181
+ , ptr_(iterator.ptr_)
182
+ , tmp_(iterator.hash_, Qnil)
183
+ {
184
+ }
185
+
186
+ template<typename Hash_Ref_T, typename Value_T>
187
+ inline Rice::Hash::Iterator<Hash_Ref_T, Value_T> &
188
+ Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
189
+ operator=(Iterator const & iterator)
190
+ {
191
+ Iterator tmp(iterator);
192
+
193
+ this->swap(tmp);
194
+
195
+ return *this;
196
+ }
197
+
198
+ template<typename Hash_Ref_T, typename Value_T>
199
+ inline Rice::Hash::Iterator<Hash_Ref_T, Value_T> &
200
+ Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
201
+ operator++()
202
+ {
203
+ // Go to the next element in the bin; this will be a no-op if we were
204
+ // called from the constructor, because ptr_ will be 0 (and if its
205
+ // not, this function won't get called).
206
+ if(ptr_)
207
+ {
208
+ ptr_ = ptr_->next;
209
+ }
210
+
211
+ // If we've reached the end of the bin, then try the next bin until
212
+ // we have run out of bins
213
+ while(ptr_ == 0)
214
+ {
215
+ ++bin_;
216
+ if(bin_ == tbl_->num_bins)
217
+ {
218
+ // At the end..
219
+ return *this;
220
+ }
221
+ ptr_ = tbl_->bins[bin_];
222
+ }
223
+
224
+ return *this;
225
+ }
226
+
227
+ template<typename Hash_Ref_T, typename Value_T>
228
+ inline Rice::Hash::Iterator<Hash_Ref_T, Value_T>
229
+ Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
230
+ operator++(int)
231
+ {
232
+ Iterator copy(*this);
233
+ ++(*this);
234
+ return copy;
235
+ }
236
+
237
+ template<typename Hash_Ref_T, typename Value_T>
238
+ inline Value_T
239
+ Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
240
+ operator*()
241
+ {
242
+ return Value_T(hash_, ptr_->key);
243
+ }
244
+
245
+ template<typename Hash_Ref_T, typename Value_T>
246
+ inline Value_T *
247
+ Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
248
+ operator->()
249
+ {
250
+ Entry tmp(hash_, ptr_->key);
251
+ this->tmp_.swap(tmp);
252
+ return &tmp_;
253
+ }
254
+
255
+ template<typename Hash_Ref_T, typename Value_T>
256
+ inline bool Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
257
+ operator==(Iterator const & rhs) const
258
+ {
259
+ return hash_.value() == rhs.hash_.value()
260
+ && tbl_ == rhs.tbl_
261
+ && bin_ == rhs.bin_
262
+ && ptr_ == rhs.ptr_;
263
+ }
264
+
265
+ template<typename Hash_Ref_T, typename Value_T>
266
+ inline bool Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
267
+ operator!=(Iterator const & rhs) const
268
+ {
269
+ return !(*this == rhs);
270
+ }
271
+
272
+ template<typename Hash_Ref_T, typename Value_T>
273
+ inline void
274
+ Rice::Hash::Iterator<Hash_Ref_T, Value_T>::
275
+ swap(Iterator& iterator)
276
+ {
277
+ using namespace std;
278
+
279
+ hash_.swap(iterator.hash_);
280
+ swap(tbl_, iterator.tbl_);
281
+ swap(bin_, iterator.bin_);
282
+ swap(ptr_, iterator.ptr_);
283
+ }
284
+
285
+ inline Rice::Hash::iterator Rice::Hash::
286
+ begin()
287
+ {
288
+ st_table * tbl(RHASH_TBL(value()));
289
+ return iterator(*this, 0, tbl->bins[0]);
290
+ }
291
+
292
+ inline Rice::Hash::const_iterator Rice::Hash::
293
+ begin() const
294
+ {
295
+ st_table * tbl(RHASH_TBL(value()));
296
+ return const_iterator(*this, 0, tbl->bins[0]);
297
+ }
298
+
299
+ inline Rice::Hash::iterator Rice::Hash::
300
+ end()
301
+ {
302
+ st_table * tbl(RHASH_TBL(value()));
303
+ return iterator(*this, tbl->num_bins, 0);
304
+ }
305
+
306
+ inline Rice::Hash::const_iterator Rice::Hash::
307
+ end() const
308
+ {
309
+ st_table * tbl(RHASH_TBL(value()));
310
+ return const_iterator(*this, tbl->num_bins, 0);
311
+ }
312
+
313
+ inline bool Rice::
314
+ operator<(
315
+ Hash::Entry const & lhs, Hash::Entry const & rhs)
316
+ {
317
+ Object lhs_key(lhs.key);
318
+ Object rhs_key(rhs.key);
319
+ if(lhs_key < rhs_key)
320
+ {
321
+ return true;
322
+ }
323
+ else if(lhs_key > rhs_key)
324
+ {
325
+ return false;
326
+ }
327
+ else if(Object(lhs.value.value()) < Object(rhs.value.value()))
328
+ {
329
+ return true;
330
+ }
331
+ else
332
+ {
333
+ return false;
334
+ }
335
+ }
336
+
337
+ #endif // Rice__Hash__ipp_
338
+
@@ -0,0 +1,8 @@
1
+ #include "Symbol.hpp"
2
+
3
+ Rice::Identifier::
4
+ Identifier(Symbol const & symbol)
5
+ : id_(SYM2ID(symbol.value()))
6
+ {
7
+ }
8
+
@@ -0,0 +1,50 @@
1
+ #ifndef Rice__Identifier__hpp_
2
+ #define Rice__Identifier__hpp_
3
+
4
+ #include "detail/ruby.hpp"
5
+ #include <string>
6
+
7
+ namespace Rice
8
+ {
9
+
10
+ class Symbol;
11
+
12
+ //! A wrapper for the ID type
13
+ /*! An ID is ruby's internal representation of a Symbol object.
14
+ */
15
+ class Identifier
16
+ {
17
+ public:
18
+ //! Construct a new Identifier from an ID.
19
+ Identifier(ID id);
20
+
21
+ //! Construct a new Identifier from a Symbol.
22
+ Identifier(Symbol const & symbol);
23
+
24
+ //! Construct a new Identifier from a string.
25
+ Identifier(char const * s = "");
26
+
27
+ //! Return a string representation of the Identifier.
28
+ char const * c_str() const;
29
+
30
+ //! Return a string representation of the Identifier.
31
+ std::string str() const;
32
+
33
+ //! Return the underlying ID
34
+ ID id() const { return id_; }
35
+
36
+ //! Return the underlying ID
37
+ operator ID() const { return id_; }
38
+
39
+ //! Return the ID as a Symbol
40
+ VALUE to_sym() const;
41
+
42
+ private:
43
+ ID id_;
44
+ };
45
+
46
+ } // namespace Rice
47
+
48
+ #include "Identifier.ipp"
49
+
50
+ #endif // Rice__Identifier__hpp_
@@ -0,0 +1,33 @@
1
+ inline Rice::Identifier::
2
+ Identifier(ID id)
3
+ : id_(id)
4
+ {
5
+ }
6
+
7
+ inline Rice::Identifier::
8
+ Identifier(char const * s)
9
+ : id_(rb_intern(s))
10
+ {
11
+ }
12
+
13
+ inline char const *
14
+ Rice::Identifier::
15
+ c_str() const
16
+ {
17
+ return rb_id2name(id_);
18
+ }
19
+
20
+ inline std::string
21
+ Rice::Identifier::
22
+ str() const
23
+ {
24
+ return c_str();
25
+ }
26
+
27
+ inline VALUE
28
+ Rice::Identifier::
29
+ to_sym() const
30
+ {
31
+ return ID2SYM(id_);
32
+ }
33
+
data/rice/Jump_Tag.hpp ADDED
@@ -0,0 +1,24 @@
1
+ #ifndef Rice__Jump_Tag__hpp_
2
+ #define Rice__Jump_Tag__hpp_
3
+
4
+ namespace Rice
5
+ {
6
+
7
+ //! A placeholder for Ruby longjmp data.
8
+ /*! When a Ruby exception is caught, the tag used for the longjmp is stored in
9
+ * a Jump_Tag, then later passed to rb_jump_tag() when there is no more
10
+ * C++ code to pass over.
11
+ */
12
+ struct Jump_Tag
13
+ {
14
+ //! Construct a Jump_Tag with tag t.
15
+ Jump_Tag(int t) : tag(t) { }
16
+
17
+ //! The tag being held.
18
+ int tag;
19
+ };
20
+
21
+ } // namespace Rice
22
+
23
+ #endif // Rice__Jump_Tag__hpp_
24
+
data/rice/Makefile.am ADDED
@@ -0,0 +1,129 @@
1
+ lib_LIBRARIES = librice.a
2
+
3
+ librice_a_SOURCES = \
4
+ Class.cpp \
5
+ Data_Type.cpp \
6
+ Director.cpp \
7
+ Exception.cpp \
8
+ Identifier.cpp \
9
+ Module.cpp \
10
+ Object.cpp \
11
+ String.cpp \
12
+ Struct.cpp \
13
+ Symbol.cpp \
14
+ VM.cpp \
15
+ Arg_operators.cpp \
16
+ detail/check_ruby_type.cpp \
17
+ detail/demangle.cpp \
18
+ detail/method_data.cpp \
19
+ detail/protect.cpp
20
+
21
+ nobase_include_HEADERS = \
22
+ Address_Registration_Guard.hpp \
23
+ Address_Registration_Guard.ipp \
24
+ Address_Registration_Guard_defn.hpp \
25
+ Allocation_Strategies.hpp \
26
+ Array.hpp \
27
+ Array.ipp \
28
+ Arg.hpp \
29
+ Arg_impl.hpp \
30
+ Arg_operators.hpp \
31
+ Builtin_Object.hpp \
32
+ Builtin_Object.ipp \
33
+ Builtin_Object_defn.hpp \
34
+ Class.hpp \
35
+ Class.ipp \
36
+ Class_defn.hpp \
37
+ Constructor.hpp \
38
+ Critical_Guard.hpp \
39
+ Critical_Guard.ipp \
40
+ Data_Object.hpp \
41
+ Data_Object.ipp \
42
+ Data_Object_defn.hpp \
43
+ Data_Type.hpp \
44
+ Data_Type.ipp \
45
+ Data_Type_defn.hpp \
46
+ Data_Type_fwd.hpp \
47
+ Director.hpp \
48
+ Enum.hpp \
49
+ Enum.ipp \
50
+ Exception.hpp \
51
+ Exception_defn.hpp \
52
+ Exception_Base.hpp \
53
+ Exception_Base.ipp \
54
+ Exception_Base_defn.hpp \
55
+ Hash.hpp \
56
+ Hash.ipp \
57
+ Identifier.hpp \
58
+ Identifier.ipp \
59
+ Jump_Tag.hpp \
60
+ Makefile \
61
+ Module.hpp \
62
+ Module.ipp \
63
+ Module_defn.hpp \
64
+ Module_impl.hpp \
65
+ Module_impl.ipp \
66
+ Object.hpp \
67
+ Object.ipp \
68
+ Object_defn.hpp \
69
+ Require_Guard.hpp \
70
+ String.hpp \
71
+ Struct.hpp \
72
+ Struct.ipp \
73
+ Symbol.hpp \
74
+ Symbol.ipp \
75
+ VM.hpp \
76
+ global_function.hpp \
77
+ global_function.ipp \
78
+ protect.hpp \
79
+ protect.ipp \
80
+ ruby_try_catch.hpp \
81
+ to_from_ruby.hpp \
82
+ to_from_ruby.ipp \
83
+ to_from_ruby_defn.hpp \
84
+ ruby_mark.hpp \
85
+ detail/Auto_Function_Wrapper.hpp \
86
+ detail/Auto_Function_Wrapper.ipp \
87
+ detail/Auto_Member_Function_Wrapper.hpp \
88
+ detail/Auto_Member_Function_Wrapper.ipp \
89
+ detail/Arguments.hpp \
90
+ detail/Caster.hpp \
91
+ detail/Exception_Handler.hpp \
92
+ detail/Exception_Handler.ipp \
93
+ detail/Exception_Handler_defn.hpp \
94
+ detail/Iterator.hpp \
95
+ detail/Not_Copyable.hpp \
96
+ detail/Wrapped_Function.hpp \
97
+ detail/check_ruby_type.hpp \
98
+ detail/creation_funcs.hpp \
99
+ detail/creation_funcs.ipp \
100
+ detail/default_allocation_func.hpp \
101
+ detail/default_allocation_func.ipp \
102
+ detail/define_method_and_auto_wrap.hpp \
103
+ detail/define_method_and_auto_wrap.ipp \
104
+ detail/demangle.hpp \
105
+ detail/env.hpp \
106
+ detail/from_ruby.hpp \
107
+ detail/from_ruby.ipp \
108
+ detail/method_data.hpp \
109
+ detail/node.hpp \
110
+ detail/object_call.hpp \
111
+ detail/object_call.ipp \
112
+ detail/protect.hpp \
113
+ detail/ruby.hpp \
114
+ detail/rubysig.hpp \
115
+ detail/st.hpp \
116
+ detail/traits.hpp \
117
+ detail/to_ruby.hpp \
118
+ detail/to_ruby.ipp \
119
+ detail/win32.hpp \
120
+ detail/wrap_function.hpp \
121
+ detail/wrap_function.ipp \
122
+ detail/ruby_version_code.hpp
123
+
124
+ includedir = ${prefix}/include/rice
125
+
126
+ AM_CPPFLAGS = @RUBY_CPPFLAGS@
127
+
128
+ AM_CXXFLAGS = @RUBY_CXXFLAGS@
129
+
data/rice/Module.cpp ADDED
@@ -0,0 +1,84 @@
1
+ #include "Module.hpp"
2
+ #include "Symbol.hpp"
3
+ #include "String.hpp"
4
+ #include "Array.hpp"
5
+ #include "Exception.hpp"
6
+ #include "protect.hpp"
7
+
8
+ Rice::Module::
9
+ Module()
10
+ : Module_impl<Module_base, Module>(rb_cObject)
11
+ {
12
+ }
13
+
14
+ Rice::Module::
15
+ Module(VALUE v)
16
+ : Module_impl<Module_base, Module>(v)
17
+ {
18
+ if(::rb_type(v) != T_CLASS && ::rb_type(v) != T_MODULE)
19
+ {
20
+ throw Exception(
21
+ rb_eTypeError,
22
+ "Expected a Module but got a %s",
23
+ rb_class2name(CLASS_OF(v))); // TODO: might raise an exception
24
+ }
25
+ }
26
+
27
+ Rice::String Rice::Module::
28
+ name() const
29
+ {
30
+ Object name = rb_mod_name(*this);
31
+ if(name.is_nil())
32
+ {
33
+ // 1.9
34
+ return String("");
35
+ }
36
+ else
37
+ {
38
+ return name;
39
+ }
40
+ }
41
+
42
+ Rice::Module Rice::
43
+ define_module_under(
44
+ Rice::Object module,
45
+ char const * name)
46
+ {
47
+ VALUE v = rb_define_module_under(module, name);
48
+ return Module(v);
49
+ }
50
+
51
+ Rice::Module Rice::
52
+ define_module(
53
+ char const * name)
54
+ {
55
+ VALUE v = rb_define_module(name);
56
+ return Module(v);
57
+ }
58
+
59
+ Rice::Module Rice::
60
+ anonymous_module()
61
+ {
62
+ return Module(protect(rb_module_new));
63
+ }
64
+
65
+ void Rice::Module::
66
+ swap(Rice::Module & other)
67
+ {
68
+ Module_base::swap(other);
69
+ }
70
+
71
+ Rice::Array
72
+ Rice::Module::
73
+ ancestors() const
74
+ {
75
+ return protect(rb_mod_ancestors, *this);
76
+ }
77
+
78
+ Rice::Class
79
+ Rice::Module::
80
+ singleton_class() const
81
+ {
82
+ return CLASS_OF(value());
83
+ }
84
+
data/rice/Module.hpp ADDED
@@ -0,0 +1,8 @@
1
+ #ifndef Rice__builtin__Module__hpp_
2
+ #define Rice__builtin__Module__hpp_
3
+
4
+ #include "Module_defn.hpp"
5
+ #include "Module.ipp"
6
+
7
+ #endif // Rice__builtin__Module__hpp_
8
+
data/rice/Module.ipp ADDED
@@ -0,0 +1,6 @@
1
+ #ifndef Rice__Module__ipp_
2
+ #define Rice__Module__ipp_
3
+
4
+ #include "Module_impl.ipp"
5
+
6
+ #endif // Rice__Module__ipp_