aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-22 09:20:43 +0200
committerLars Knoll <lars.knoll@qt.io>2018-06-26 10:04:11 +0000
commite9b3bdb96e008060a0e78815a3995015e5e4598d (patch)
treeb3213bc461329723e9fd119a65a5556c12209a21 /src/qml/jsruntime/qv4functionobject.cpp
parent046d1c5db44f409c67244bd70b13077cc03219b2 (diff)
Various fixes for class support
Add support for a default constructor if none is given. Fix support for computed method names, by unifying the handling between static and non static methods. Fix our table generation, so that we write UINT_MAX as the string index for undefined strings and not a reference to the empty string, as that can actually be a valid method name. Add support for getter and setter methods in classes. Change-Id: If52c57d6a67424b0218b86339b95aed9d0351e47 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 7fcb1c3536..589ed8fded 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -502,6 +502,22 @@ ReturnedValue ConstructorFunction::call(const FunctionObject *f, const Value *,
return f->engine()->throwTypeError(QStringLiteral("Cannot call a class constructor without |new|"));
}
+DEFINE_OBJECT_VTABLE(DefaultClassConstructorFunction);
+
+ReturnedValue DefaultClassConstructorFunction::callAsConstructor(const FunctionObject *f, const Value *, int)
+{
+ Scope scope(f);
+ ScopedObject proto(scope, f->get(scope.engine->id_prototype()));
+ ScopedObject c(scope, scope.engine->newObject());
+ c->setPrototypeUnchecked(proto);
+ return c->asReturnedValue();
+}
+
+ReturnedValue DefaultClassConstructorFunction::call(const FunctionObject *f, const Value *, const Value *, int)
+{
+ return f->engine()->throwTypeError(QStringLiteral("Cannot call a class constructor without |new|"));
+}
+
DEFINE_OBJECT_VTABLE(IndexedBuiltinFunction);
DEFINE_OBJECT_VTABLE(BoundFunction);