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

Class StructData

src/Dynamic.cpp:236–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234
235
236class StructData : public hx::Object
237{
238public:
239 inline void *operator new( size_t inSize, hx::NewObjectType inAlloc=NewObjContainer,const char *inName="cpp.Struct")
240 { return hx::Object::operator new(inSize,inAlloc,inName); }
241
242 StructData(const void *inValue,int inLength, cpp::DynamicHandlerFunc inHandler)
243 {
244 mLength= inLength;
245 mValue = InternalNew(inLength,false);
246 HX_OBJ_WB_GET(this, mValue);
247 memcpy(mValue, inValue, inLength);
248 mHandler = inHandler;
249 }
250
251 HX_IS_INSTANCE_OF enum { _hx_ClassId = hx::clsIdStruct };
252
253 hx::Class __GetClass() const HXCPP_OVERRIDE { return __PointerClass; }
254
255 // k_cpp_struct
256 int __GetType() const HXCPP_OVERRIDE { return vtAbstractBase + 3; }
257 void * __GetHandle() const HXCPP_OVERRIDE { return mValue; }
258 String toString() HXCPP_OVERRIDE
259 {
260 return __ToString();
261 }
262 String __ToString() const HXCPP_OVERRIDE
263 {
264 String result;
265 mHandler(cpp::dhoToString, mValue, 0, &result );
266 return result;
267 }
268 const char *__CStr() const HXCPP_OVERRIDE
269 {
270 const char *result = "unknown";
271 mHandler(cpp::dhoGetClassName, mValue, 0, &result );
272 return result;
273 }
274
275 int __Compare(const hx::Object *inRHS) const HXCPP_OVERRIDE
276 {
277 if (!inRHS)
278 return 1;
279
280 int diff = __length() - inRHS->__length();
281 if (diff==0)
282 diff = __GetType() - inRHS->__GetType();
283 if (diff==0)
284 diff = memcmp( mValue, inRHS->__GetHandle(), mLength );
285
286 if (diff<0) return -1;
287 if (diff>0) return 1;
288 return 0;
289 }
290
291 int __length() const HXCPP_OVERRIDE { return mLength; }
292
293 void __Mark(hx::MarkContext *__inCtx) HXCPP_OVERRIDE

Callers

nothing calls this directly

Calls 1

__ToStringFunction · 0.85

Tested by

no test coverage detected