MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ToString

Method ToString

Source/Scripting/angelscript/add_on/debugger/debugger.cpp:21–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21string 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) {

Callers

nothing calls this directly

Calls 10

GetTypeInfoByIdMethod · 0.80
secondMethod · 0.80
ifFunction · 0.70
GetEnumValueCountMethod · 0.45
GetEnumValueByIndexMethod · 0.45
GetFlagsMethod · 0.45
findMethod · 0.45
endMethod · 0.45
GetTypeInfoByNameMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected