| 19 | } |
| 20 | |
| 21 | string CDebugger::ToString(void *value, asUINT typeId, int expandMembers, asIScriptEngine *engine) { |
| 22 | if (value == 0) |
| 23 | return "<null>"; |
| 24 | |
| 25 | // If no engine pointer was provided use the default |
| 26 | if (engine == 0) |
| 27 | engine = m_engine; |
| 28 | |
| 29 | stringstream s; |
| 30 | if (typeId == asTYPEID_VOID) |
| 31 | return "<void>"; |
| 32 | else if (typeId == asTYPEID_BOOL) |
| 33 | return *(bool *)value ? "true" : "false"; |
| 34 | else if (typeId == asTYPEID_INT8) |
| 35 | s << (int)*(signed char *)value; |
| 36 | else if (typeId == asTYPEID_INT16) |
| 37 | s << (int)*(signed short *)value; |
| 38 | else if (typeId == asTYPEID_INT32) |
| 39 | s << *(signed int *)value; |
| 40 | else if (typeId == asTYPEID_INT64) |
| 41 | #if defined(_MSC_VER) && _MSC_VER <= 1200 |
| 42 | s << "{...}"; // MSVC6 doesn't like the << operator for 64bit integer |
| 43 | #else |
| 44 | s << *(asINT64 *)value; |
| 45 | #endif |
| 46 | else if (typeId == asTYPEID_UINT8) |
| 47 | s << (unsigned int)*(unsigned char *)value; |
| 48 | else if (typeId == asTYPEID_UINT16) |
| 49 | s << (unsigned int)*(unsigned short *)value; |
| 50 | else if (typeId == asTYPEID_UINT32) |
| 51 | s << *(unsigned int *)value; |
| 52 | else if (typeId == asTYPEID_UINT64) |
| 53 | #if defined(_MSC_VER) && _MSC_VER <= 1200 |
| 54 | s << "{...}"; // MSVC6 doesn't like the << operator for 64bit integer |
| 55 | #else |
| 56 | s << *(asQWORD *)value; |
| 57 | #endif |
| 58 | else if (typeId == asTYPEID_FLOAT) |
| 59 | s << *(float *)value; |
| 60 | else if (typeId == asTYPEID_DOUBLE) |
| 61 | s << *(double *)value; |
| 62 | else if ((typeId & asTYPEID_MASK_OBJECT) == 0) { |
| 63 | // The type is an enum |
| 64 | s << *(asUINT *)value; |
| 65 | |
| 66 | // Check if the value matches one of the defined enums |
| 67 | if (engine) { |
| 68 | asITypeInfo *t = engine->GetTypeInfoById(typeId); |
| 69 | for (int n = t->GetEnumValueCount(); n-- > 0;) { |
| 70 | int enumVal; |
| 71 | const char *enumName = t->GetEnumValueByIndex(n, &enumVal); |
| 72 | if (enumVal == *(int *)value) { |
| 73 | s << ", " << enumName; |
| 74 | break; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } else if (typeId & asTYPEID_SCRIPTOBJECT) { |
nothing calls this directly
no test coverage detected