aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4reflect.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-19 13:28:26 +0200
committerLars Knoll <lars.knoll@qt.io>2018-06-25 07:36:48 +0000
commit1596112e146b28541bcee412ed159cdea7e692d0 (patch)
tree29e858041496256c9c9c700fca4fb7220d78d46e /src/qml/jsruntime/qv4reflect.cpp
parent3823e9b94f849f8344b81250fac708ac2eaccd16 (diff)
Add Proxy support for prototype handling
Cleanup get/setPrototypeOf and fix some smaller incompatibilities in the default implementation for Object. Add the methods to the vtable and reimplement them according to spec for ProxyObjects. Clean up the Object.prototype.get/setPrototypeOf/__proto__ methods and fix a smaller bug in the Reflect API for those methods. Change-Id: I6e438753332ec4db963d6cdcf86f340ff212777a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4reflect.cpp')
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
index 219e28b6e7..9b4a5a2375 100644
--- a/src/qml/jsruntime/qv4reflect.cpp
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -175,12 +175,14 @@ ReturnedValue Reflect::method_getOwnPropertyDescriptor(const FunctionObject *f,
return ObjectPrototype::method_getOwnPropertyDescriptor(f, thisObject, argv, argc);
}
-ReturnedValue Reflect::method_getPrototypeOf(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue Reflect::method_getPrototypeOf(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
if (!argc || !argv[0].isObject())
return f->engine()->throwTypeError();
- return ObjectPrototype::method_getPrototypeOf(f, thisObject, argv, argc);
+ const Object *o = static_cast<const Object *>(argv);
+ Heap::Object *p = o->getPrototypeOf();
+ return (p ? p->asReturnedValue() : Encode::null());
}
ReturnedValue Reflect::method_has(const FunctionObject *f, const Value *, const Value *argv, int argc)
@@ -260,10 +262,13 @@ ReturnedValue Reflect::method_set(const FunctionObject *f, const Value *, const
return Encode(result);
}
-ReturnedValue Reflect::method_setPrototypeOf(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue Reflect::method_setPrototypeOf(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
- if (argc < 2 || !argv[0].isObject())
+ if (argc < 2 || !argv[0].isObject() || (!argv[1].isNull() && !argv[1].isObject()))
return f->engine()->throwTypeError();
- return ObjectPrototype::method_setPrototypeOf(f, thisObject, argv, argc);
+ Scope scope(f);
+ ScopedObject o(scope, static_cast<const Object *>(argv));
+ const Object *proto = argv[1].isNull() ? nullptr : static_cast<const Object *>(argv + 1);
+ return Encode(o->setPrototypeOf(proto));
}