Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/ProfileViewer.cpp
Show First 20 Lines • Show All 499 Lines • ▼ Show 20 Lines | struct DumpTable | ||||
} | } | ||||
void operator() (AbstractProfileTable* table) | void operator() (AbstractProfileTable* table) | ||||
{ | { | ||||
JSContext* cx = m_ScriptInterface.GetContext(); | JSContext* cx = m_ScriptInterface.GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
JS::RootedValue t(cx); | JS::RootedValue t(cx); | ||||
m_ScriptInterface.CreateObject( | ScriptInterface::CreateObject( | ||||
cx, | |||||
&t, | &t, | ||||
"cols", DumpCols(table), | "cols", DumpCols(table), | ||||
"data", DumpRows(table)); | "data", DumpRows(table)); | ||||
m_ScriptInterface.SetProperty(m_Root, table->GetTitle().c_str(), t); | m_ScriptInterface.SetProperty(m_Root, table->GetTitle().c_str(), t); | ||||
} | } | ||||
std::vector<std::string> DumpCols(AbstractProfileTable* table) | std::vector<std::string> DumpCols(AbstractProfileTable* table) | ||||
Show All 9 Lines | struct DumpTable | ||||
} | } | ||||
JS::Value DumpRows(AbstractProfileTable* table) | JS::Value DumpRows(AbstractProfileTable* table) | ||||
{ | { | ||||
JSContext* cx = m_ScriptInterface.GetContext(); | JSContext* cx = m_ScriptInterface.GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
JS::RootedValue data(cx); | JS::RootedValue data(cx); | ||||
m_ScriptInterface.CreateObject(&data); | ScriptInterface::CreateObject(cx, &data); | ||||
const std::vector<ProfileColumn>& columns = table->GetColumns(); | const std::vector<ProfileColumn>& columns = table->GetColumns(); | ||||
for (size_t r = 0; r < table->GetNumberRows(); ++r) | for (size_t r = 0; r < table->GetNumberRows(); ++r) | ||||
{ | { | ||||
JS::RootedValue row(cx); | JS::RootedValue row(cx); | ||||
m_ScriptInterface.CreateArray(&row); | ScriptInterface::CreateArray(cx, &row); | ||||
m_ScriptInterface.SetProperty(data, table->GetCellText(r, 0).c_str(), row); | m_ScriptInterface.SetProperty(data, table->GetCellText(r, 0).c_str(), row); | ||||
if (table->GetChild(r)) | if (table->GetChild(r)) | ||||
{ | { | ||||
JS::RootedValue childRows(cx, DumpRows(table->GetChild(r))); | JS::RootedValue childRows(cx, DumpRows(table->GetChild(r))); | ||||
m_ScriptInterface.SetPropertyInt(row, 0, childRows); | m_ScriptInterface.SetPropertyInt(row, 0, childRows); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator