History

rework ScriptValue to act like a stack variable rather than a pointer

Heather Anderson committed 5 years ago

Commit 85810221 parent f209c51170 files · +2837 −2594Browse files

Showing the changes to interface/src/scripting/AccountServicesScriptingInterface.cpp (1 of 170 files). Show all

Unified · Split

interface/src/scripting/AccountServicesScriptingInterface.cpp+9−9
@@ -123,27 +123,27 @@ DownloadInfoResult::DownloadInfoResult() : · 122 unmodified lines
123 * @property {number[]} downloading - The download percentage remaining of each asset currently downloading.123 * @property {number[]} downloading - The download percentage remaining of each asset currently downloading.
124 * @property {number} pending - The number of assets pending download.124 * @property {number} pending - The number of assets pending download.
125 */125 */
126ScriptValuePointer DownloadInfoResultToScriptValue(ScriptEngine* engine, const DownloadInfoResult& result) {126ScriptValue DownloadInfoResultToScriptValue(ScriptEngine* engine, const DownloadInfoResult& result) {
127 ScriptValuePointer object = engine->newObject();127 ScriptValue object = engine->newObject();
128 128
129 ScriptValuePointer array = engine->newArray(result.downloading.count());129 ScriptValue array = engine->newArray(result.downloading.count());
130 for (int i = 0; i < result.downloading.count(); i += 1) {130 for (int i = 0; i < result.downloading.count(); i += 1) {
131 array->setProperty(i, result.downloading[i]);131 array.setProperty(i, result.downloading[i]);
132 }132 }
133 133
134 object->setProperty("downloading", array);134 object.setProperty("downloading", array);
135 object->setProperty("pending", result.pending);135 object.setProperty("pending", result.pending);
136 return object;136 return object;
137}137}
138 138
139void DownloadInfoResultFromScriptValue(const ScriptValuePointer& object, DownloadInfoResult& result) {139void DownloadInfoResultFromScriptValue(const ScriptValue& object, DownloadInfoResult& result) {
140 QList<QVariant> downloading = object->property("downloading")->toVariant().toList();140 QList<QVariant> downloading = object.property("downloading").toVariant().toList();
141 result.downloading.clear();141 result.downloading.clear();
142 for (int i = 0; i < downloading.count(); i += 1) {142 for (int i = 0; i < downloading.count(); i += 1) {
143 result.downloading.append(downloading[i].toFloat());143 result.downloading.append(downloading[i].toFloat());
144 }144 }
145 145
146 result.pending = object->property("pending")->toVariant().toFloat();146 result.pending = object.property("pending").toVariant().toFloat();
147}147}
148 148
149DownloadInfoResult AccountServicesScriptingInterface::getDownloadInfo() {149DownloadInfoResult AccountServicesScriptingInterface::getDownloadInfo() {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t