void CObjectsPage::AddPrivateVariableInspectItems() { // Inspecting private variables: if no pointer, get and update. We only need to get the pointer once. if (pCurrentVars == NULL) { pMyObject->DebuggerUpdateDisplay(pCurrentVars); // Still null: quit. if (pCurrentVars == NULL) return; } int numVars = pMyObject->pType->privateVars.size(); ExpStore* i = pCurrentVars; ExpStore* end = i + numVars; int index = 0; for ( ; i != end; i++, index++) { CString s; s.Format("'%s'", pMyObject->pType->privateVars[index].name); if (i->Type() == EXPTYPE_STRING) pRuntime->AddDebuggerItem(s, (const char*)*(i->GetStringPtr()), false); else pRuntime->AddDebuggerItem(s, i->GetString(), false); } }
inline void ExpArrayType::Free() { // Iterate and free ExpStore* ptr = pArray; ExpStore* end = pArray + size; for ( ; ptr != end; ptr++) ptr->Free(); // Delete my data delete[] pArray; }
CString ExpBase::GetString() const { switch (eType) { case EXPTYPE_INTEGER: { char strbuf[32]; _i64toa(eData.iVal, strbuf, 10); return strbuf; } case EXPTYPE_FLOAT: { char strbuf[32]; _gcvt(eData.fVal, DBL_DIG, strbuf); CString str = strbuf; if (str.Right(1) == ".") str.Delete(str.GetLength() - 1); return str; } case EXPTYPE_STRING: return (const char*)*(eData.str); case EXPTYPE_ARRAY: { // Build an expression style array string eg {1, 3, 5, 6} CString s = "{"; ExpStore* ptr = eData.arr.pArray; ExpStore* end = eData.arr.pArray + eData.arr.size; ExpStore* last = end - 1; for ( ; ptr != end; ptr++) { bool isString = (ptr->Type() == EXPTYPE_STRING); if (isString) s += '"'; s += (const char*)(ptr->GetString()); if (isString) s += '"'; if (ptr != last) s += ", "; } s += "}"; return s; } default: return ""; } }
inline long ReturnCustom(VRuntime* pRuntime, const ExpStore& r) { if (r.Type() == EXPTYPE_STRING) ReturnString(pRuntime, (const char*)*(r.eData.str)); else { // Bitwise copy eType = r.Type(); eData.iVal = r.eData.iVal; } return 0; }
ExpStore::ExpStore(const ExpStore& r) { switch (r.Type()) { case EXPTYPE_STRING: eData.str = new CString; *(eData.str) = (const char*)*(r.GetStringPtr()); break; case EXPTYPE_ARRAY: { const int size = eData.arr.size = r.eData.arr.size; eData.arr.pArray = new ExpStore[size]; for( int i = 0; i < eData.arr.size; i++) eData.arr.pArray[i] = ExpStore( r.eData.arr.pArray[i] ); } break; default: // Other types can simply copy the eData union content eData.iVal = r.eData.iVal; } eType = r.Type(); }