MCPcopy Create free account
hub / github.com/anjo76/angelscript / ToString

Method ToString

sdk/add_on/debugger/debugger.cpp:24–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

ArrayToStringFunction · 0.45
DictionaryToStringFunction · 0.45

Calls 9

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

Tested by

no test coverage detected