MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / ToString

Method ToString

src/server/angelscript/add_on/debugger/debugger.cpp:23–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

ArrayToStringFunction · 0.80
DictionaryToStringFunction · 0.80

Calls 9

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

Tested by

no test coverage detected