Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/ProfileViewer.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 516 Lines • ▼ Show 20 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.Eval("({})", &data); | m_ScriptInterface.CreateObject(&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.Eval("([])", &row); | m_ScriptInterface.CreateArray(&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 73 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator