| 22 | } |
| 23 | |
| 24 | string 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; |
no test coverage detected