MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / IndexRef

Class IndexRef

include/hx/FieldRef.h:152–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150
151
152class IndexRef
153{
154public:
155 explicit IndexRef(hx::Object *inObj,int inIndex) : mObject(inObj), mIndex(inIndex)
156 {
157 }
158
159 Dynamic operator=(const Dynamic &inRHS)
160 {
161 return mObject->__SetItem(mIndex,inRHS);
162 }
163 inline operator Dynamic() const { return mObject->__GetItem(mIndex); }
164 inline operator double() const { return mObject->__GetItem(mIndex); }
165 inline operator int() const { return mObject->__GetItem(mIndex); }
166
167 // post-increment
168 inline double operator++(int)
169 {
170 double d = mObject->__GetItem(mIndex)->__ToDouble();
171 mObject->__SetItem(mIndex,d+1);
172 return d;
173 }
174 // pre-increment
175 inline double operator++()
176 {
177 double d = mObject->__GetItem(mIndex)->__ToDouble() + 1;
178 mObject->__SetItem(mIndex,d);
179 return d;
180 }
181 // post-decrement
182 inline double operator--(int)
183 {
184 double d = mObject->__GetItem(mIndex)->__ToDouble();
185 mObject->__SetItem(mIndex,d-1);
186 return d;
187 }
188 // pre-decrement
189 inline double operator--()
190 {
191 double d = mObject->__GetItem(mIndex)->__ToDouble() - 1;
192 mObject->__SetItem(mIndex,d);
193 return d;
194 }
195 bool operator !() { return ! mObject->__GetItem(mIndex)->__ToInt(); }
196 int operator ~() { return ~ mObject->__GetItem(mIndex)->__ToInt(); }
197 double operator -() { return - mObject->__GetItem(mIndex)->__ToDouble(); }
198
199 inline bool operator==(const null &) const { return !mObject; }
200 inline bool operator!=(const null &) const { return mObject; }
201
202 HX_INDEX_REF_MEM_OP(==,bool)
203 HX_INDEX_REF_MEM_OP(!=,bool)
204 HX_INDEX_REF_MEM_OP(<,bool)
205 HX_INDEX_REF_MEM_OP(<=,bool)
206 HX_INDEX_REF_MEM_OP(>,bool)
207 HX_INDEX_REF_MEM_OP(>=,bool)
208
209 HX_INDEX_REF_MEM_OP(+,Dynamic)

Callers 1

IndexRefMethod · 0.70

Calls 1

__GetItemMethod · 0.45

Tested by

no test coverage detected