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

Method handler

include/cpp/Pointer.h:58–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56 static inline const char *getName() { return "unknown"; }
57 static inline String toString( const void *inValue ) { return HX_CSTRING("Struct"); }
58 static inline void handler(DynamicHandlerOp op, void *ioValue, int inSize, void *outResult)
59 {
60 if (op==dhoToString)
61 *(String *)outResult = toString(ioValue);
62 else if (op==dhoGetClassName)
63 *(const char **)outResult = getName();
64 else if (op==dhoToDynamic)
65 {
66 // Handle outsize..
67 *(hx::Object **)outResult = 0;
68 }
69 else if (op==dhoFromDynamic)
70 {
71 StructHandlerDynamicParams *params = (StructHandlerDynamicParams *)outResult;
72 hx::Object *ptr= params->inData;
73 void *data = (void *)ptr->__GetHandle();
74 int len = ptr->__length();
75 if (data && len>=inSize && ptr->__CStr()==params->inName)
76 {
77 memcpy(ioValue,data,inSize);
78 params->outProcessed = true;
79 }
80 }
81 else if (op==dhoIs)
82 {
83 StructHandlerDynamicParams *params = (StructHandlerDynamicParams *)outResult;
84 hx::Object *ptr= params->inData;
85 void *data = (void *)ptr->__GetHandle();
86 int len = ptr->__length();
87 params->outProcessed = data && len>=inSize && ptr->__CStr()==params->inName;
88 }
89 }
90};
91
92

Callers

nothing calls this directly

Calls 5

toStringFunction · 0.85
memcpyFunction · 0.85
__GetHandleMethod · 0.45
__lengthMethod · 0.45
__CStrMethod · 0.45

Tested by

no test coverage detected