rice 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/COPYING +23 -0
  2. data/Doxyfile +1253 -0
  3. data/Makefile.am +26 -0
  4. data/Makefile.in +736 -0
  5. data/README +881 -0
  6. data/README.mingw +8 -0
  7. data/bootstrap +8 -0
  8. data/config.guess +1535 -0
  9. data/config.sub +1644 -0
  10. data/configure +7310 -0
  11. data/configure.ac +48 -0
  12. data/depcomp +584 -0
  13. data/doxygen.ac +314 -0
  14. data/doxygen.am +186 -0
  15. data/install-sh +507 -0
  16. data/missing +367 -0
  17. data/post-autoconf.rb +22 -0
  18. data/post-automake.rb +28 -0
  19. data/rice/Address_Registration_Guard.hpp +7 -0
  20. data/rice/Address_Registration_Guard.ipp +34 -0
  21. data/rice/Address_Registration_Guard_defn.hpp +65 -0
  22. data/rice/Allocation_Strategies.hpp +37 -0
  23. data/rice/Array.hpp +220 -0
  24. data/rice/Array.ipp +262 -0
  25. data/rice/Builtin_Object.hpp +8 -0
  26. data/rice/Builtin_Object.ipp +50 -0
  27. data/rice/Builtin_Object_defn.hpp +51 -0
  28. data/rice/Class.cpp +57 -0
  29. data/rice/Class.hpp +8 -0
  30. data/rice/Class.ipp +4 -0
  31. data/rice/Class_defn.hpp +83 -0
  32. data/rice/Constructor.hpp +189 -0
  33. data/rice/Critical_Guard.hpp +34 -0
  34. data/rice/Critical_Guard.ipp +20 -0
  35. data/rice/Data_Object.hpp +127 -0
  36. data/rice/Data_Object.ipp +129 -0
  37. data/rice/Data_Type.cpp +21 -0
  38. data/rice/Data_Type.hpp +8 -0
  39. data/rice/Data_Type.ipp +227 -0
  40. data/rice/Data_Type_defn.hpp +219 -0
  41. data/rice/Data_Type_fwd.hpp +12 -0
  42. data/rice/Enum.hpp +118 -0
  43. data/rice/Enum.ipp +246 -0
  44. data/rice/Exception.cpp +59 -0
  45. data/rice/Exception.hpp +69 -0
  46. data/rice/Exception_Base.hpp +30 -0
  47. data/rice/Exception_Base.ipp +11 -0
  48. data/rice/Hash.hpp +206 -0
  49. data/rice/Hash.ipp +336 -0
  50. data/rice/Identifier.cpp +8 -0
  51. data/rice/Identifier.hpp +50 -0
  52. data/rice/Identifier.ipp +33 -0
  53. data/rice/Jump_Tag.hpp +24 -0
  54. data/rice/Makefile.am +112 -0
  55. data/rice/Makefile.in +675 -0
  56. data/rice/Module.cpp +75 -0
  57. data/rice/Module.hpp +8 -0
  58. data/rice/Module.ipp +6 -0
  59. data/rice/Module_defn.hpp +87 -0
  60. data/rice/Module_impl.hpp +237 -0
  61. data/rice/Module_impl.ipp +302 -0
  62. data/rice/Object.cpp +153 -0
  63. data/rice/Object.hpp +8 -0
  64. data/rice/Object.ipp +19 -0
  65. data/rice/Object_defn.hpp +183 -0
  66. data/rice/Require_Guard.hpp +21 -0
  67. data/rice/String.cpp +93 -0
  68. data/rice/String.hpp +88 -0
  69. data/rice/Struct.cpp +117 -0
  70. data/rice/Struct.hpp +162 -0
  71. data/rice/Struct.ipp +26 -0
  72. data/rice/Symbol.cpp +25 -0
  73. data/rice/Symbol.hpp +66 -0
  74. data/rice/Symbol.ipp +44 -0
  75. data/rice/VM.cpp +79 -0
  76. data/rice/VM.hpp +27 -0
  77. data/rice/config.hpp +23 -0
  78. data/rice/config.hpp.in +22 -0
  79. data/rice/detail/Auto_Function_Wrapper.hpp +719 -0
  80. data/rice/detail/Auto_Function_Wrapper.ipp +1354 -0
  81. data/rice/detail/Auto_Member_Function_Wrapper.hpp +685 -0
  82. data/rice/detail/Auto_Member_Function_Wrapper.ipp +1435 -0
  83. data/rice/detail/Caster.hpp +61 -0
  84. data/rice/detail/Exception_Handler.hpp +118 -0
  85. data/rice/detail/Iterator_Definer.hpp +98 -0
  86. data/rice/detail/Not_Copyable.hpp +25 -0
  87. data/rice/detail/Wrapped_Function.hpp +33 -0
  88. data/rice/detail/check_ruby_type.cpp +21 -0
  89. data/rice/detail/check_ruby_type.hpp +23 -0
  90. data/rice/detail/creation_funcs.hpp +45 -0
  91. data/rice/detail/creation_funcs.ipp +62 -0
  92. data/rice/detail/default_allocation_func.hpp +23 -0
  93. data/rice/detail/default_allocation_func.ipp +11 -0
  94. data/rice/detail/define_method_and_auto_wrap.hpp +27 -0
  95. data/rice/detail/define_method_and_auto_wrap.ipp +20 -0
  96. data/rice/detail/env.hpp +13 -0
  97. data/rice/detail/from_ruby.hpp +43 -0
  98. data/rice/detail/from_ruby.ipp +74 -0
  99. data/rice/detail/method_data.cpp +105 -0
  100. data/rice/detail/method_data.hpp +33 -0
  101. data/rice/detail/node.hpp +13 -0
  102. data/rice/detail/object_call.hpp +85 -0
  103. data/rice/detail/object_call.ipp +147 -0
  104. data/rice/detail/protect.cpp +27 -0
  105. data/rice/detail/protect.hpp +34 -0
  106. data/rice/detail/remove_const.hpp +21 -0
  107. data/rice/detail/ruby.hpp +85 -0
  108. data/rice/detail/rubysig.hpp +13 -0
  109. data/rice/detail/st.hpp +56 -0
  110. data/rice/detail/to_ruby.hpp +16 -0
  111. data/rice/detail/to_ruby.ipp +10 -0
  112. data/rice/detail/win32.hpp +16 -0
  113. data/rice/detail/wrap_function.hpp +288 -0
  114. data/rice/detail/wrap_function.ipp +473 -0
  115. data/rice/generate_code.rb +1092 -0
  116. data/rice/global_function.hpp +16 -0
  117. data/rice/global_function.ipp +11 -0
  118. data/rice/protect.hpp +91 -0
  119. data/rice/protect.ipp +803 -0
  120. data/rice/ruby_try_catch.hpp +86 -0
  121. data/rice/to_from_ruby.hpp +8 -0
  122. data/rice/to_from_ruby.ipp +299 -0
  123. data/rice/to_from_ruby_defn.hpp +71 -0
  124. data/ruby.ac +105 -0
  125. data/ruby/Makefile.am +1 -0
  126. data/ruby/Makefile.in +493 -0
  127. data/ruby/lib/Makefile.am +3 -0
  128. data/ruby/lib/Makefile.in +369 -0
  129. data/ruby/lib/mkmf-rice.rb.in +199 -0
  130. data/sample/Makefile.am +47 -0
  131. data/sample/Makefile.in +375 -0
  132. data/sample/enum/extconf.rb +3 -0
  133. data/sample/enum/sample_enum.cpp +54 -0
  134. data/sample/enum/test.rb +8 -0
  135. data/sample/inheritance/animals.cpp +98 -0
  136. data/sample/inheritance/extconf.rb +3 -0
  137. data/sample/inheritance/test.rb +7 -0
  138. data/sample/map/extconf.rb +3 -0
  139. data/sample/map/map.cpp +81 -0
  140. data/sample/map/test.rb +7 -0
  141. data/test/Makefile.am +44 -0
  142. data/test/Makefile.in +575 -0
  143. data/test/test_Address_Registration_Guard.cpp +43 -0
  144. data/test/test_Allocation_Strategies.cpp +77 -0
  145. data/test/test_Array.cpp +241 -0
  146. data/test/test_Builtin_Object.cpp +72 -0
  147. data/test/test_Class.cpp +350 -0
  148. data/test/test_Constructor.cpp +30 -0
  149. data/test/test_Critical_Guard.cpp +47 -0
  150. data/test/test_Data_Object.cpp +235 -0
  151. data/test/test_Enum.cpp +162 -0
  152. data/test/test_Exception.cpp +46 -0
  153. data/test/test_Hash.cpp +195 -0
  154. data/test/test_Identifier.cpp +70 -0
  155. data/test/test_Jump_Tag.cpp +17 -0
  156. data/test/test_Module.cpp +253 -0
  157. data/test/test_Object.cpp +148 -0
  158. data/test/test_String.cpp +94 -0
  159. data/test/test_Struct.cpp +192 -0
  160. data/test/test_Symbol.cpp +63 -0
  161. data/test/test_To_From_Ruby.cpp +281 -0
  162. data/test/test_VM.cpp +26 -0
  163. data/test/test_rice.rb +30 -0
  164. data/test/unittest.cpp +136 -0
  165. data/test/unittest.hpp +292 -0
  166. metadata +209 -0
@@ -0,0 +1,65 @@
1
+ #ifndef Rice__Address_Registration_Guard_defn__hpp_
2
+ #define Rice__Address_Registration_Guard_defn__hpp_
3
+
4
+ #include "Object_defn.hpp"
5
+ #include "detail/ruby.hpp"
6
+ #include "detail/Not_Copyable.hpp"
7
+
8
+ namespace Rice
9
+ {
10
+
11
+ //! A guard to register a given address with the GC.
12
+ /*! Calls rb_gc_register_address upon construction and
13
+ * rb_gc_unregister_address upon destruction.
14
+ * For example:
15
+ * \code
16
+ * Class Foo
17
+ * {
18
+ * public:
19
+ * Foo()
20
+ * : string_(rb_str_new2())
21
+ * , guard_(&string_);
22
+ *
23
+ * private:
24
+ * VALUE string_;
25
+ * Address_Registration_Guard guard_;
26
+ * };
27
+ * \endcode
28
+ */
29
+ class Address_Registration_Guard
30
+ : private detail::Not_Copyable
31
+ {
32
+ public:
33
+ //! Register an address with the GC.
34
+ /* \param address The address to register with the GC. The address
35
+ * must point to a valid ruby object (RObject).
36
+ */
37
+ Address_Registration_Guard(VALUE * address);
38
+
39
+ //! Register an Object with the GC.
40
+ /*! \param object The Object to register with the GC. The object must
41
+ * not be destroyed before the Address_Registration_Guard is
42
+ * destroyed.
43
+ */
44
+ Address_Registration_Guard(Object * object);
45
+
46
+ //! Unregister an address/Object with the GC.
47
+ /*! Destruct an Address_Registration_Guard. The address registered
48
+ * with the Address_Registration_Guard when it was constructed will
49
+ * be unregistered from the GC.
50
+ */
51
+ ~Address_Registration_Guard();
52
+
53
+ //! Get the address that is registered with the GC.
54
+ VALUE * address() const;
55
+
56
+ //! Swap with another Address_Registration_Guard.
57
+ void swap(Address_Registration_Guard & other);
58
+
59
+ private:
60
+ VALUE * address_;
61
+ };
62
+
63
+ } // namespace Rice
64
+
65
+ #endif // Rice__Address_Registration_Guard_defn__hpp_
@@ -0,0 +1,37 @@
1
+ #ifndef Rice__Default_Allocation_Strategy__hpp_
2
+ #define Rice__Default_Allocation_Strategy__hpp_
3
+
4
+ #include "detail/ruby.hpp"
5
+
6
+ /*! \file
7
+ * \brief Strategies for allocation/deallocation of objects.
8
+ */
9
+
10
+ namespace Rice
11
+ {
12
+
13
+ template<typename T>
14
+ struct Default_Allocation_Strategy
15
+ {
16
+ //! Allocate an object using operator new.
17
+ static T * allocate() { return new T; }
18
+
19
+ //! Delete obj using the delete operator.
20
+ static void free(T * obj) { delete obj; }
21
+ };
22
+
23
+ template<typename T>
24
+ struct Xmalloc_Allocation_Strategy
25
+ {
26
+ //! Allocate an array of objects using operator new and xmalloc.
27
+ static T * allocate() { T * obj = static_cast<T *>(::xmalloc(sizeof(T))); new(obj) T; return obj; }
28
+
29
+ //! Delete obj by calling the destructor explicitly and calling xfree.
30
+ static void free(T * obj) { obj->~T(); ::xfree(obj); }
31
+ };
32
+
33
+ // TODO: array allocation
34
+
35
+ } // namespace Rice
36
+
37
+ #endif // Rice__Default_Allocation_Strategy__hpp_
data/rice/Array.hpp ADDED
@@ -0,0 +1,220 @@
1
+ #ifndef Rice__Array__hpp_
2
+ #define Rice__Array__hpp_
3
+
4
+ #include "Builtin_Object.hpp"
5
+ #include "to_from_ruby_defn.hpp"
6
+ #include "detail/ruby.hpp"
7
+ #include <iterator>
8
+
9
+ namespace Rice
10
+ {
11
+
12
+ //! A wrapper for the ruby Array class.
13
+ /*! This class provides a C++-style interface to ruby's Array class and
14
+ * its associated rb_ary_* functions.
15
+ * Example:
16
+ * \code
17
+ * Array a;
18
+ * a.push(String("some string"));
19
+ * a.push(42);
20
+ * \endcode
21
+ */
22
+ class Array
23
+ : public Builtin_Object<RArray, T_ARRAY>
24
+ {
25
+ public:
26
+ //! Construct a new array
27
+ Array();
28
+
29
+ //! Wrap an existing array
30
+ /*! \param v a ruby object, which must be of type T_ARRAY.
31
+ */
32
+ Array(Object v);
33
+
34
+ //! Wrap an existing array
35
+ /*! \param v a ruby object, which must be of type T_ARRAY.
36
+ */
37
+ Array(VALUE v);
38
+
39
+ //! Construct an array from a sequence.
40
+ /*! \param begin an iterator to the beginning of the sequence.
41
+ * \param end an iterator to the end of the sequence.
42
+ */
43
+ template<typename Iter_T>
44
+ Array(Iter_T begin, Iter_T end);
45
+
46
+ //! Construct an Array from a C array.
47
+ /*! \param a a C array of type T and size n.
48
+ */
49
+ template<typename T, size_t n>
50
+ Array(T const (& a)[n]);
51
+
52
+ public:
53
+ //! Return the size of the array.
54
+ size_t size() const;
55
+
56
+ //! Return the element at the given index.
57
+ /*! \param index The index of the desired element. The index may be
58
+ * negative, to indicate an offset from the end of the array. If the
59
+ * index is out of bounds, this function has undefined behavior.
60
+ * \return the element at the given index.
61
+ */
62
+ Object operator[](ptrdiff_t index) const;
63
+
64
+ private:
65
+ //! A helper class so array[index]=value can work.
66
+ class Proxy;
67
+
68
+ public:
69
+ //! Return a reference to the element at the given index.
70
+ /*! \param index The index of the desired element. The index may be
71
+ * negative, to indicate an offset from the end of the array. If the
72
+ * index is out of bounds, this function has undefined behavior.
73
+ * \return the element at the given index.
74
+ */
75
+ Proxy operator[](ptrdiff_t index);
76
+
77
+ //! Push an element onto the end of the array
78
+ /*! \param v an object to push onto the array.
79
+ * \return the object which was pushed onto the array.
80
+ */
81
+ template<typename T>
82
+ Object push(T const & obj);
83
+
84
+ //! Pop an element from the end of the array
85
+ /*! \return the object which was popped from the array, or Qnil if
86
+ * the array was empty.
87
+ */
88
+ Object pop();
89
+
90
+ //! Unshift an element onto the beginning of the array
91
+ /*! \param v an object to unshift onto the array.
92
+ * \return the object which was unshifted onto the array.
93
+ */
94
+ template<typename T>
95
+ Object unshift(T const & obj);
96
+
97
+ //! Shift an element from the beginning of the array
98
+ /*! \return the object which was shifted from the array.
99
+ */
100
+ Object shift();
101
+
102
+ //! Return a pointer to the beginning of the underlying C array.
103
+ //! Use with caution!
104
+ /*! \return a pointer to the beginning of the array.
105
+ */
106
+ VALUE * to_c_array();
107
+
108
+ private:
109
+ template<typename Array_Ref_T, typename Value_T>
110
+ class Iterator;
111
+
112
+ size_t position_of(ptrdiff_t index) const;
113
+
114
+ public:
115
+ //! An iterator.
116
+ typedef Iterator<Array &, Proxy> iterator;
117
+
118
+ //! A const iterator.
119
+ typedef Iterator<Array const &, Object> const_iterator;
120
+
121
+ //! Return an iterator to the beginning of the array.
122
+ iterator begin();
123
+
124
+ //! Return a const iterator to the beginning of the array.
125
+ const_iterator begin() const;
126
+
127
+ //! Return an iterator to the end of the array.
128
+ iterator end();
129
+
130
+ //! Return a const iterator to the end of the array.
131
+ const_iterator end() const;
132
+ };
133
+
134
+ //! A helper class so array[index]=value can work.
135
+ class Array::Proxy
136
+ {
137
+ public:
138
+ //! Construct a new Proxy
139
+ Proxy(Array array, size_t index);
140
+
141
+ //! Implicit conversion to Object.
142
+ operator Object() const;
143
+
144
+ //! Explicit conversion to VALUE.
145
+ VALUE value() const;
146
+
147
+ //! Assignment operator.
148
+ template<typename T>
149
+ Object operator=(T const & value);
150
+
151
+ private:
152
+ Array array_;
153
+ size_t index_;
154
+ };
155
+
156
+ //! A helper class for implementing iterators for a Array.
157
+ // TODO: This really should be a random-access iterator.
158
+ template<typename Array_Ref_T, typename Value_T>
159
+ class Array::Iterator
160
+ : public std::iterator<
161
+ std::forward_iterator_tag,
162
+ Value_T, // Type
163
+ ptrdiff_t, // Distance type
164
+ Object *, // Pointer type
165
+ Value_T &> // Reference type
166
+ {
167
+ public:
168
+ Iterator(Array_Ref_T array, size_t index);
169
+
170
+ template<typename Array_Ref_T_, typename Value_T_>
171
+ Iterator(Iterator<Array_Ref_T_, Value_T_> const & rhs);
172
+
173
+ template<typename Array_Ref_T_, typename Value_T_>
174
+ Iterator & operator=(Iterator<Array_Ref_T_, Value_T_> const & rhs);
175
+
176
+ Iterator & operator++();
177
+ Iterator operator++(int);
178
+ Value_T operator*();
179
+ Object * operator->();
180
+
181
+ template<typename Array_Ref_T_, typename Value_T_>
182
+ bool operator==(Iterator<Array_Ref_T_, Value_T_> const & rhs) const;
183
+
184
+ template<typename Array_Ref_T_, typename Value_T_>
185
+ bool operator!=(Iterator<Array_Ref_T_, Value_T_> const & rhs) const;
186
+
187
+ // Causes ICE on g++ 3.3.3
188
+ // template<typename Array_Ref_T_, typename Value_T_>
189
+ // friend class Iterator;
190
+
191
+ Array_Ref_T array() const;
192
+ size_t index() const;
193
+
194
+ private:
195
+ Array_Ref_T array_;
196
+ size_t index_;
197
+
198
+ Object tmp_;
199
+ };
200
+
201
+ } // namespace Rice
202
+
203
+ template<>
204
+ inline
205
+ Rice::Array from_ruby<Rice::Array>(Rice::Object x)
206
+ {
207
+ return Rice::Array(x);
208
+ }
209
+
210
+ template<>
211
+ inline
212
+ Rice::Object to_ruby<Rice::Array>(Rice::Array const & x)
213
+ {
214
+ return x;
215
+ }
216
+
217
+ #include "Array.ipp"
218
+
219
+ #endif // Rice__Array__hpp_
220
+
data/rice/Array.ipp ADDED
@@ -0,0 +1,262 @@
1
+ #ifndef Rice__Array__ipp_
2
+ #define Rice__Array__ipp_
3
+
4
+ #include "protect.hpp"
5
+
6
+ inline Rice::Array::
7
+ Array()
8
+ : Builtin_Object<RArray, T_ARRAY>(protect(rb_ary_new))
9
+ {
10
+ }
11
+
12
+ inline Rice::Array::
13
+ Array(Object v)
14
+ : Builtin_Object<RArray, T_ARRAY>(v)
15
+ {
16
+ }
17
+
18
+ inline Rice::Array::
19
+ Array(VALUE v)
20
+ : Builtin_Object<RArray, T_ARRAY>(v)
21
+ {
22
+ }
23
+
24
+ template<typename Iter_T>
25
+ inline Rice::Array::
26
+ Array(Iter_T it, Iter_T end)
27
+ : Builtin_Object<RArray, T_ARRAY>(protect(rb_ary_new))
28
+ {
29
+ for(; it != end; ++it)
30
+ {
31
+ push(*it);
32
+ }
33
+ }
34
+
35
+ template<typename T, size_t n>
36
+ inline Rice::Array::
37
+ Array(T const (& a)[n])
38
+ : Builtin_Object<RArray, T_ARRAY>(protect(rb_ary_new))
39
+ {
40
+ for(size_t j = 0; j < n; ++j)
41
+ {
42
+ push(a[j]);
43
+ }
44
+ }
45
+
46
+ inline size_t Rice::Array::
47
+ size() const
48
+ {
49
+ return (*this)->len;
50
+ }
51
+
52
+ inline Rice::Object Rice::Array::
53
+ operator[](ptrdiff_t index) const
54
+ {
55
+ return (*this)->ptr[position_of(index)];
56
+ }
57
+
58
+ inline Rice::Array::Proxy Rice::Array::
59
+ operator[](ptrdiff_t index)
60
+ {
61
+ return Proxy(*this, position_of(index));
62
+ }
63
+
64
+ template<typename T>
65
+ inline Rice::Object Rice::Array::
66
+ push(T const & obj)
67
+ {
68
+ return protect(rb_ary_push, value(), to_ruby(obj));
69
+ }
70
+
71
+ inline Rice::Object Rice::Array::
72
+ pop()
73
+ {
74
+ return protect(rb_ary_pop, value());
75
+ }
76
+
77
+ template<typename T>
78
+ inline Rice::Object Rice::Array::
79
+ unshift(T const & obj)
80
+ {
81
+ return protect(rb_ary_unshift, value(), to_ruby(obj));
82
+ }
83
+
84
+ inline Rice::Object Rice::Array::
85
+ shift()
86
+ {
87
+ return protect(rb_ary_shift, value());
88
+ }
89
+
90
+ inline VALUE * Rice::Array::
91
+ to_c_array()
92
+ {
93
+ return (*this)->ptr;
94
+ }
95
+
96
+ inline size_t Rice::Array::
97
+ position_of(ptrdiff_t index) const
98
+ {
99
+ if(index < 0)
100
+ {
101
+ return size() + index;
102
+ }
103
+ else
104
+ {
105
+ return static_cast<size_t>(index);
106
+ }
107
+ }
108
+
109
+ inline Rice::Array::Proxy::
110
+ Proxy(Array array, size_t index)
111
+ : array_(array)
112
+ , index_(index)
113
+ {
114
+ }
115
+
116
+ inline Rice::Array::Proxy::
117
+ operator Rice::Object() const
118
+ {
119
+ return array_->ptr[index_];
120
+ }
121
+
122
+ inline VALUE Rice::Array::Proxy::
123
+ value() const
124
+ {
125
+ return array_->ptr[index_];
126
+ }
127
+
128
+ template<typename T>
129
+ Rice::Object Rice::Array::Proxy::
130
+ operator=(T const & value)
131
+ {
132
+ Object o = to_ruby(value);
133
+ array_->ptr[index_] = o.value();
134
+ return o;
135
+ }
136
+
137
+ template<typename Array_Ref_T, typename Value_T>
138
+ inline Rice::Array::Iterator<Array_Ref_T, Value_T>::
139
+ Iterator(Array_Ref_T array, size_t index)
140
+ : array_(array)
141
+ , index_(index)
142
+ {
143
+ }
144
+
145
+ template<typename Array_Ref_T, typename Value_T>
146
+ template<typename Array_Ref_T_, typename Value_T_>
147
+ inline
148
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
149
+ Iterator(Iterator<Array_Ref_T_, Value_T_> const & rhs)
150
+ : array_(rhs.array())
151
+ , index_(rhs.index())
152
+ , tmp_()
153
+ {
154
+ }
155
+
156
+ template<typename Array_Ref_T, typename Value_T>
157
+ template<typename Array_Ref_T_, typename Value_T_>
158
+ inline Rice::Array::Iterator<Array_Ref_T, Value_T> &
159
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
160
+ operator=(Iterator<Array_Ref_T_, Value_T_> const & rhs)
161
+ {
162
+ array_ = rhs.array_;
163
+ index_ = rhs.index_;
164
+ return *this;
165
+ }
166
+
167
+ template<typename Array_Ref_T, typename Value_T>
168
+ inline Rice::Array::Iterator<Array_Ref_T, Value_T> &
169
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
170
+ operator++()
171
+ {
172
+ ++index_;
173
+ return *this;
174
+ }
175
+
176
+ template<typename Array_Ref_T, typename Value_T>
177
+ inline Rice::Array::Iterator<Array_Ref_T, Value_T>
178
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
179
+ operator++(int)
180
+ {
181
+ Array copy(*this);
182
+ ++(*this);
183
+ return *this;
184
+ }
185
+
186
+ template<typename Array_Ref_T, typename Value_T>
187
+ inline Value_T
188
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
189
+ operator*()
190
+ {
191
+ return array_[index_];
192
+ }
193
+
194
+ template<typename Array_Ref_T, typename Value_T>
195
+ inline Rice::Object *
196
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
197
+ operator->()
198
+ {
199
+ tmp_ = array_[index_];
200
+ return &tmp_;
201
+ }
202
+
203
+ template<typename Array_Ref_T, typename Value_T>
204
+ template<typename Array_Ref_T_, typename Value_T_>
205
+ inline bool
206
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
207
+ operator==(Iterator<Array_Ref_T_, Value_T_> const & rhs) const
208
+ {
209
+ return array_.value() == rhs.array_.value() && index_ == rhs.index_;
210
+ }
211
+
212
+ template<typename Array_Ref_T, typename Value_T>
213
+ template<typename Array_Ref_T_, typename Value_T_>
214
+ inline bool
215
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
216
+ operator!=(Iterator<Array_Ref_T_, Value_T_> const & rhs) const
217
+ {
218
+ return !(*this == rhs);
219
+ }
220
+
221
+ template<typename Array_Ref_T, typename Value_T>
222
+ Array_Ref_T
223
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
224
+ array() const
225
+ {
226
+ return array_;
227
+ }
228
+
229
+ template<typename Array_Ref_T, typename Value_T>
230
+ size_t
231
+ Rice::Array::Iterator<Array_Ref_T, Value_T>::
232
+ index() const
233
+ {
234
+ return index_;
235
+ }
236
+
237
+ inline Rice::Array::iterator Rice::Array::
238
+ begin()
239
+ {
240
+ return iterator(*this, 0);
241
+ }
242
+
243
+ inline Rice::Array::const_iterator Rice::Array::
244
+ begin() const
245
+ {
246
+ return const_iterator(*this, 0);
247
+ }
248
+
249
+ inline Rice::Array::iterator Rice::Array::
250
+ end()
251
+ {
252
+ return iterator(*this, size());
253
+ }
254
+
255
+ inline Rice::Array::const_iterator Rice::Array::
256
+ end() const
257
+ {
258
+ return const_iterator(*this, size());
259
+ }
260
+
261
+ #endif // Rice__Array__ipp_
262
+