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 libraries/script-engine/src/ScriptEngine.cpp (1 of 170 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+16−16
@@ -20,36 +20,36 @@ ScriptEnginePointer newScriptEngine(ScriptManager* manager) { · 19 unmodified lines
2020 return QSharedPointer<ScriptEngineQtScript>(new ScriptEngineQtScript(manager));
2121 }
2222
23−ScriptValuePointer makeScopedHandlerObject(ScriptValuePointer scopeOrCallback, ScriptValuePointer methodOrName) {
24− auto engine = scopeOrCallback->engine();
23+ScriptValue makeScopedHandlerObject(const ScriptValue& scopeOrCallback, const ScriptValue& methodOrName) {
24+ auto engine = scopeOrCallback.engine();
2525 if (!engine) {
2626 return scopeOrCallback;
2727 }
28− ScriptValuePointer scope;
29− ScriptValuePointer callback = scopeOrCallback;
30− if (scopeOrCallback->isObject()) {
31− if (methodOrName->isString()) {
28+ ScriptValue scope;
29+ ScriptValue callback = scopeOrCallback;
30+ if (scopeOrCallback.isObject()) {
31+ if (methodOrName.isString()) {
3232 scope = scopeOrCallback;
33− callback = scope->property(methodOrName->toString());
34− } else if (methodOrName->isFunction()) {
33+ callback = scope.property(methodOrName.toString());
34+ } else if (methodOrName.isFunction()) {
3535 scope = scopeOrCallback;
3636 callback = methodOrName;
37− } else if (!methodOrName->isValid()) {
37+ } else if (!methodOrName.isValid()) {
3838 // instantiate from an existing scoped handler object
39− if (scopeOrCallback->property("callback")->isFunction()) {
40− scope = scopeOrCallback->property("scope");
41− callback = scopeOrCallback->property("callback");
39+ if (scopeOrCallback.property("callback").isFunction()) {
40+ scope = scopeOrCallback.property("scope");
41+ callback = scopeOrCallback.property("callback");
4242 }
4343 }
4444 }
4545 auto handler = engine->newObject();
46− handler->setProperty("scope", scope);
47− handler->setProperty("callback", callback);
46+ handler.setProperty("scope", scope);
47+ handler.setProperty("callback", callback);
4848 return handler;
4949 }
5050
51−ScriptValuePointer callScopedHandlerObject(ScriptValuePointer handler, ScriptValuePointer err, ScriptValuePointer result) {
52− return handler->property("callback")->call(handler->property("scope"), ScriptValueList({ err, result }));
51+ScriptValue callScopedHandlerObject(const ScriptValue& handler, const ScriptValue& err, const ScriptValue& result) {
52+ return handler.property("callback").call(handler.property("scope"), ScriptValueList({ err, result }));
5353 }
5454
5555 bool ScriptEngine::IS_THREADSAFE_INVOCATION(const QString& method) {