From c22fbac218f137a30920cad89431296d7d6dda66 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 13 Jan 2013 16:17:03 +0100 Subject: [PATCH] The prototype of Constructor objects is readonly Change-Id: I43449a964e003c444a42ad51639a22f9b0cb73c5 Reviewed-by: Simon Hausmann --- qmljs_objects.cpp | 8 +++----- qmljs_objects.h | 2 +- qv4ecmaobjects.cpp | 18 +++++++++--------- tests/TestExpectations | 36 +----------------------------------- 4 files changed, 14 insertions(+), 50 deletions(-) diff --git a/qmljs_objects.cpp b/qmljs_objects.cpp index d0e2bb7..fd4b07b 100644 --- a/qmljs_objects.cpp +++ b/qmljs_objects.cpp @@ -149,19 +149,17 @@ void Object::defineDefaultProperty(ExecutionContext *context, const QString &nam Q_UNUSED(argumentCount); String *s = context->engine->identifier(name); FunctionObject* function = context->engine->newNativeFunction(context, s, code); - function->defineReadonlyProperty(context->engine, context->engine->id_length, Value::fromInt32(argumentCount)); + function->defineReadonlyProperty(context->engine->id_length, Value::fromInt32(argumentCount)); defineDefaultProperty(s, Value::fromObject(function)); } void Object::defineReadonlyProperty(ExecutionEngine *engine, const QString &name, Value value) { - defineReadonlyProperty(engine, engine->identifier(name), value); + defineReadonlyProperty(engine->identifier(name), value); } -void Object::defineReadonlyProperty(ExecutionEngine *engine, String *name, Value value) +void Object::defineReadonlyProperty(String *name, Value value) { - Q_UNUSED(engine); - if (!members) members.reset(new PropertyTable()); PropertyDescriptor *pd = members->insert(name); diff --git a/qmljs_objects.h b/qmljs_objects.h index 384677c..65812e9 100644 --- a/qmljs_objects.h +++ b/qmljs_objects.h @@ -162,7 +162,7 @@ struct Object: Managed { void defineDefaultProperty(ExecutionContext *context, const QString &name, Value (*code)(ExecutionContext *), int count = 0); /* Fixed: Writable: false, Enumerable: false, Configurable: false */ void defineReadonlyProperty(ExecutionEngine *engine, const QString &name, Value value); - void defineReadonlyProperty(ExecutionEngine *engine, String *name, Value value); + void defineReadonlyProperty(String *name, Value value); protected: virtual void getCollectables(QVector &objects); diff --git a/qv4ecmaobjects.cpp b/qv4ecmaobjects.cpp index 48af470..6076b6d 100644 --- a/qv4ecmaobjects.cpp +++ b/qv4ecmaobjects.cpp @@ -554,7 +554,7 @@ Value ObjectCtor::__get__(ExecutionContext *ctx, String *name, bool *hasProperty void ObjectPrototype::init(ExecutionContext *ctx, const Value &ctor) { - ctor.objectValue()->defineDefaultProperty(ctx->engine->id_prototype, Value::fromObject(this)); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this)); ctor.objectValue()->defineDefaultProperty(ctx, QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1); ctor.objectValue()->defineDefaultProperty(ctx, QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 2); ctor.objectValue()->defineDefaultProperty(ctx, QStringLiteral("getOwnPropertyNames"), method_getOwnPropertyNames, 1); @@ -1032,7 +1032,7 @@ Value StringCtor::call(ExecutionContext *ctx) void StringPrototype::init(ExecutionContext *ctx, const Value &ctor) { - ctor.objectValue()->defineDefaultProperty(ctx->engine->id_prototype, Value::fromObject(this)); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this)); ctor.objectValue()->defineDefaultProperty(ctx, QStringLiteral("fromCharCode"), method_fromCharCode, 1); defineDefaultProperty(ctx, QStringLiteral("constructor"), ctor); @@ -1344,7 +1344,7 @@ Value NumberCtor::call(ExecutionContext *ctx) void NumberPrototype::init(ExecutionContext *ctx, const Value &ctor) { - ctor.objectValue()->defineDefaultProperty(ctx->engine->id_prototype, Value::fromObject(this)); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this)); ctor.objectValue()->defineReadonlyProperty(ctx->engine, QStringLiteral("NaN"), Value::fromDouble(qSNaN())); ctor.objectValue()->defineReadonlyProperty(ctx->engine, QStringLiteral("NEGATIVE_INFINITY"), Value::fromDouble(-qInf())); @@ -1522,7 +1522,7 @@ Value BooleanCtor::call(ExecutionContext *ctx) void BooleanPrototype::init(ExecutionContext *ctx, const Value &ctor) { - ctor.objectValue()->defineDefaultProperty(ctx->engine->id_prototype, Value::fromObject(this)); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this)); defineDefaultProperty(ctx, QStringLiteral("constructor"), ctor); defineDefaultProperty(ctx, QStringLiteral("toString"), method_toString); defineDefaultProperty(ctx, QStringLiteral("valueOf"), method_valueOf); @@ -1579,7 +1579,7 @@ Value ArrayCtor::call(ExecutionContext *ctx) void ArrayPrototype::init(ExecutionContext *ctx, const Value &ctor) { - ctor.objectValue()->defineDefaultProperty(ctx->engine->id_prototype, Value::fromObject(this)); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this)); defineDefaultProperty(ctx, QStringLiteral("constructor"), ctor); defineDefaultProperty(ctx, QStringLiteral("toString"), method_toString, 0); defineDefaultProperty(ctx, QStringLiteral("toLocalString"), method_toLocaleString, 0); @@ -2125,7 +2125,7 @@ Value FunctionCtor::call(ExecutionContext *ctx) void FunctionPrototype::init(ExecutionContext *ctx, const Value &ctor) { - ctor.objectValue()->defineDefaultProperty(ctx->engine->id_prototype, Value::fromObject(this)); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this)); defineDefaultProperty(ctx, QStringLiteral("constructor"), ctor); defineDefaultProperty(ctx, QStringLiteral("toString"), method_toString, 0); defineDefaultProperty(ctx, QStringLiteral("apply"), method_apply, 2); @@ -2246,7 +2246,7 @@ Value DateCtor::call(ExecutionContext *ctx) void DatePrototype::init(ExecutionContext *ctx, const Value &ctor) { - ctor.objectValue()->defineDefaultProperty(ctx->engine->id_prototype, Value::fromObject(this)); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this)); LocalTZA = getLocalTZA(); ctor.objectValue()->defineDefaultProperty(ctx, QStringLiteral("parse"), method_parse, 1); @@ -2851,7 +2851,7 @@ Value RegExpCtor::call(ExecutionContext *ctx) void RegExpPrototype::init(ExecutionContext *ctx, const Value &ctor) { - ctor.objectValue()->defineDefaultProperty(ctx->engine->id_prototype, Value::fromObject(this)); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this)); defineDefaultProperty(ctx, QStringLiteral("constructor"), ctor); defineDefaultProperty(ctx, QStringLiteral("exec"), method_exec, 1); defineDefaultProperty(ctx, QStringLiteral("test"), method_test, 1); @@ -2964,7 +2964,7 @@ Value URIErrorCtor::construct(ExecutionContext *ctx) void ErrorPrototype::init(ExecutionContext *ctx, const Value &ctor, Object *obj) { - ctor.objectValue()->defineDefaultProperty(ctx->engine->id_prototype, Value::fromObject(obj)); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(obj)); obj->defineDefaultProperty(ctx, QStringLiteral("constructor"), ctor); obj->defineDefaultProperty(ctx, QStringLiteral("toString"), method_toString, 0); } diff --git a/tests/TestExpectations b/tests/TestExpectations index ceb10c7..15161fa 100644 --- a/tests/TestExpectations +++ b/tests/TestExpectations @@ -565,8 +565,6 @@ S15.10.4.1_A9_T2 failing S15.10.4.1_A9_T3 failing 15.10.4.1-2 failing 15.10.4.1-3 failing -S15.10.5.1_A3 failing -S15.10.5.1_A4 failing S15.10.5_A1 failing S15.10.6.2_A1_T2 failing S15.10.6.2_A1_T6 failing @@ -605,8 +603,6 @@ S15.10.7.4_A9 failing 15.10.7.5-2 failing S15.10.7.5_A8 failing S15.10.7.5_A9 failing -S15.11.3.1_A1_T1 failing -S15.11.3.1_A3_T1 failing S15.11.3_A2_T1 failing S15.11.4.2_A1 failing S15.11.4.2_A2 failing @@ -700,8 +696,6 @@ S15.1.3.1_A2.1_T1 failing S15.2.3_A1 failing S15.2.3_A2 failing S15.2.3_A3 failing -15.2.3.1 failing -S15.2.3.1_A1 failing S15.2.3.1_A2 failing S15.2.3.1_A3 failing 15.2.3.10-3-12 failing @@ -885,31 +879,16 @@ S15.1.3.2_A5.3 failing 15.2.3.3-4-164 failing 15.2.3.3-4-176 failing 15.2.3.3-4-177 failing -15.2.3.3-4-182 failing -15.2.3.3-4-185 failing 15.2.3.3-4-186 failing 15.2.3.3-4-187 failing -15.2.3.3-4-189 failing -15.2.3.3-4-190 failing 15.2.3.3-4-191 failing 15.2.3.3-4-192 failing -15.2.3.3-4-193 failing 15.2.3.3-4-194 failing -15.2.3.3-4-195 failing 15.2.3.3-4-201 failing -15.2.3.3-4-210 failing -15.2.3.3-4-211 failing 15.2.3.3-4-212 failing 15.2.3.3-4-213 failing 15.2.3.3-4-214 failing 15.2.3.3-4-215 failing -15.2.3.3-4-216 failing -15.2.3.3-4-217 failing -15.2.3.3-4-218 failing -15.2.3.3-4-219 failing -15.2.3.3-4-220 failing -15.2.3.3-4-221 failing -15.2.3.3-4-222 failing 15.2.3.3-4-51 failing 15.2.3.3-4-82 failing 15.2.3.3-4-9 failing @@ -1190,8 +1169,6 @@ S15.1.3.2_A5.3 failing 15.2.4.2-2-2 failing S15.2.4.2_A12 failing S15.2.4.2_A13 failing -S15.3.3.1_A1 failing -S15.3.3.1_A3 failing 15.3.3.2-1 failing 15.3.4.3-1-s failing 15.3.4.3-2-s failing @@ -1317,8 +1294,6 @@ S15.3.5.3_A1_T8 failing S15.4.3_A2.2 failing S15.4.3_A2.3 failing S15.4.3_A2.4 failing -S15.4.3.1_A3 failing -S15.4.3.1_A4 failing 15.4.3.2-0-1 failing 15.4.3.2-0-2 failing 15.4.3.2-0-3 failing @@ -2760,8 +2735,6 @@ S15.4.4.7_A3 failing S15.4.4.7_A4_T2 failing S15.4.4.7_A4_T3 failing S15.4.4.7_A6.1 failing -S15.5.3.1_A3 failing -S15.5.3.1_A4 failing S15.5.3_A1 failing S15.5.4.10_A1_T1 failing S15.5.4.10_A1_T10 failing @@ -3125,12 +3098,7 @@ S15.5.5.1_A4 failing S15.5.5.1_A5 failing 15.5.5.5.2-7-4 failing S15.6.3_A3 failing -S15.6.3.1_A2 failing -S15.6.3.1_A3 failing S15.7.3_A8 failing -15.7.3.1-1 failing -S15.7.3.1_A1_T1 failing -S15.7.3.1_A1_T2 failing S15.7.4_A3.3 failing S15.7.4.5_A1.3_T01 failing S15.7.4.5_A1.3_T02 failing @@ -3138,8 +3106,6 @@ S15.7.4.5_A1.4_T01 failing S15.8.2.16_A4 failing S15.8.2.16_A5 failing S15.8.2.17_A2 failing -S15.9.4.1_A1_T1 failing -S15.9.4.1_A1_T2 failing 15.9.4.4-0-1 failing 15.9.4.4-0-2 failing 15.9.4.4-0-3 failing @@ -3429,4 +3395,4 @@ S15.4.4.7_A5_T1 failing 15.4.4.19-8-b-16 failing 15.4.4.20-9-b-16 failing 15.4.4.21-9-b-29 failing -15.4.4.22-9-b-16 failing +15.4.4.22-9-b-16 failing \ No newline at end of file -- 2.7.4