diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-08-30 09:18:03 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-02 17:27:36 +0200 |
commit | 3bf081203e713330aa1e5e92bc8b30fcc420e228 (patch) | |
tree | 1d9adea16f3b03964bd79a374f98b1d71b032502 /src | |
parent | d8e31c098dade7280f21ca9781ba11bee5e4f201 (diff) |
Remove more usages of Object::setPrototype()
Change-Id: I8c49f61bc85e3d98dea90bf05db1a3f22d08f7b1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 29 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 13 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4errorobject.cpp | 65 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4errorobject_p.h | 4 |
4 files changed, 49 insertions, 62 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 0d61dab0bc..b7215d06a2 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -140,7 +140,7 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) objectClass = emptyClass->changePrototype(objectPrototype); arrayClass = objectClass->addMember(id_length, Attr_NotConfigurable|Attr_NotEnumerable); - arrayPrototype = new (memoryManager) ArrayPrototype(arrayClass); + ArrayPrototype *arrayPrototype = new (memoryManager) ArrayPrototype(arrayClass); arrayClass = arrayClass->changePrototype(arrayPrototype); InternalClass *argsClass = objectClass->addMember(id_length, Attr_NotEnumerable); @@ -169,12 +169,18 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) ErrorPrototype *errorPrototype = new (memoryManager) ErrorPrototype(objectClass); errorClass = emptyClass->changePrototype(errorPrototype); - evalErrorPrototype = new (memoryManager) EvalErrorPrototype(errorClass); - rangeErrorPrototype = new (memoryManager) RangeErrorPrototype(errorClass); - referenceErrorPrototype = new (memoryManager) ReferenceErrorPrototype(errorClass); - syntaxErrorPrototype = new (memoryManager) SyntaxErrorPrototype(errorClass); - typeErrorPrototype = new (memoryManager) TypeErrorPrototype(errorClass); - uRIErrorPrototype = new (memoryManager) URIErrorPrototype(errorClass); + EvalErrorPrototype *evalErrorPrototype = new (memoryManager) EvalErrorPrototype(errorClass); + evalErrorClass = emptyClass->changePrototype(evalErrorPrototype); + RangeErrorPrototype *rangeErrorPrototype = new (memoryManager) RangeErrorPrototype(errorClass); + rangeErrorClass = emptyClass->changePrototype(rangeErrorPrototype); + ReferenceErrorPrototype *referenceErrorPrototype = new (memoryManager) ReferenceErrorPrototype(errorClass); + referenceErrorClass = emptyClass->changePrototype(referenceErrorPrototype); + SyntaxErrorPrototype *syntaxErrorPrototype = new (memoryManager) SyntaxErrorPrototype(errorClass); + syntaxErrorClass = emptyClass->changePrototype(syntaxErrorPrototype); + TypeErrorPrototype *typeErrorPrototype = new (memoryManager) TypeErrorPrototype(errorClass); + typeErrorClass = emptyClass->changePrototype(typeErrorPrototype); + URIErrorPrototype *uRIErrorPrototype = new (memoryManager) URIErrorPrototype(errorClass); + uriErrorClass = emptyClass->changePrototype(uRIErrorPrototype); variantPrototype = new (memoryManager) VariantPrototype(objectClass); sequencePrototype = new (memoryManager) SequencePrototype(arrayClass->changePrototype(arrayPrototype)); @@ -417,7 +423,7 @@ RegExpObject *ExecutionEngine::newRegExpObject(const QRegExp &re) Object *ExecutionEngine::newErrorObject(const Value &value) { - ErrorObject *object = new (memoryManager) ErrorObject(this, value); + ErrorObject *object = new (memoryManager) ErrorObject(errorClass, value); return object; } @@ -665,13 +671,6 @@ void ExecutionEngine::markObjects() uRIErrorCtor.mark(); objectPrototype->mark(); - arrayPrototype->mark(); - evalErrorPrototype->mark(); - rangeErrorPrototype->mark(); - referenceErrorPrototype->mark(); - syntaxErrorPrototype->mark(); - typeErrorPrototype->mark(); - uRIErrorPrototype->mark(); variantPrototype->mark(); sequencePrototype->mark(); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 17f92ce597..21763ca898 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -150,13 +150,6 @@ struct Q_QML_EXPORT ExecutionEngine Value uRIErrorCtor; ObjectPrototype *objectPrototype; - ArrayPrototype *arrayPrototype; - EvalErrorPrototype *evalErrorPrototype; - RangeErrorPrototype *rangeErrorPrototype; - ReferenceErrorPrototype *referenceErrorPrototype; - SyntaxErrorPrototype *syntaxErrorPrototype; - TypeErrorPrototype *typeErrorPrototype; - URIErrorPrototype *uRIErrorPrototype; VariantPrototype *variantPrototype; SequencePrototype *sequencePrototype; @@ -172,6 +165,12 @@ struct Q_QML_EXPORT ExecutionEngine InternalClass *functionClass; InternalClass *regExpClass; InternalClass *errorClass; + InternalClass *evalErrorClass; + InternalClass *rangeErrorClass; + InternalClass *referenceErrorClass; + InternalClass *syntaxErrorClass; + InternalClass *typeErrorClass; + InternalClass *uriErrorClass; InternalClass *argumentsObjectClass; InternalClass *strictArgumentsObjectClass; diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index 6b3607faec..04357c393a 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -81,38 +81,38 @@ ErrorObject::ErrorObject(InternalClass *ic) defineDefaultProperty(ic->engine, QStringLiteral("name"), Value::fromString(ic->engine, "Error")); } -ErrorObject::ErrorObject(ExecutionEngine *engine, const Value &message, ErrorType t) - : Object(engine->errorClass) +ErrorObject::ErrorObject(InternalClass *ic, const Value &message, ErrorType t) + : Object(ic) , stack(0) { type = Type_ErrorObject; vtbl = &static_vtbl; subtype = t; - defineAccessorProperty(engine, QStringLiteral("stack"), ErrorObject::method_get_stack, 0); + defineAccessorProperty(ic->engine, QStringLiteral("stack"), ErrorObject::method_get_stack, 0); if (!message.isUndefined()) - defineDefaultProperty(engine->newString(QStringLiteral("message")), message); - defineDefaultProperty(engine, QStringLiteral("name"), Value::fromString(engine, className())); + defineDefaultProperty(ic->engine->newString(QStringLiteral("message")), message); + defineDefaultProperty(ic->engine, QStringLiteral("name"), Value::fromString(ic->engine, className())); - stackTrace = engine->stackTrace(); + stackTrace = ic->engine->stackTrace(); if (!stackTrace.isEmpty()) { - defineDefaultProperty(engine, QStringLiteral("fileName"), Value::fromString(engine, stackTrace.at(0).source)); - defineDefaultProperty(engine, QStringLiteral("lineNumber"), Value::fromInt32(stackTrace.at(0).line)); + defineDefaultProperty(ic->engine, QStringLiteral("fileName"), Value::fromString(ic->engine, stackTrace.at(0).source)); + defineDefaultProperty(ic->engine, QStringLiteral("lineNumber"), Value::fromInt32(stackTrace.at(0).line)); } } -ErrorObject::ErrorObject(ExecutionEngine *engine, const QString &message, const QString &fileName, int line, int column, ErrorObject::ErrorType t) - : Object(engine->errorClass) +ErrorObject::ErrorObject(InternalClass *ic, const QString &message, const QString &fileName, int line, int column, ErrorObject::ErrorType t) + : Object(ic) , stack(0) { type = Type_ErrorObject; vtbl = &static_vtbl; subtype = t; - defineAccessorProperty(engine, QStringLiteral("stack"), ErrorObject::method_get_stack, 0); + defineAccessorProperty(ic->engine, QStringLiteral("stack"), ErrorObject::method_get_stack, 0); - defineDefaultProperty(engine, QStringLiteral("name"), Value::fromString(engine, className())); + defineDefaultProperty(ic->engine, QStringLiteral("name"), Value::fromString(ic->engine, className())); - stackTrace = engine->stackTrace(); + stackTrace = ic->engine->stackTrace(); ExecutionEngine::StackFrame frame; frame.source = fileName; frame.line = line; @@ -120,11 +120,11 @@ ErrorObject::ErrorObject(ExecutionEngine *engine, const QString &message, const stackTrace.prepend(frame); if (!stackTrace.isEmpty()) { - defineDefaultProperty(engine, QStringLiteral("fileName"), Value::fromString(engine, stackTrace.at(0).source)); - defineDefaultProperty(engine, QStringLiteral("lineNumber"), Value::fromInt32(stackTrace.at(0).line)); + defineDefaultProperty(ic->engine, QStringLiteral("fileName"), Value::fromString(ic->engine, stackTrace.at(0).source)); + defineDefaultProperty(ic->engine, QStringLiteral("lineNumber"), Value::fromInt32(stackTrace.at(0).line)); } - defineDefaultProperty(engine, QStringLiteral("message"), Value::fromString(engine->newString(message))); + defineDefaultProperty(ic->engine, QStringLiteral("message"), Value::fromString(ic->engine->newString(message))); } Value ErrorObject::method_get_stack(SimpleCallContext *ctx) @@ -164,71 +164,60 @@ DEFINE_MANAGED_VTABLE(ErrorObject); DEFINE_MANAGED_VTABLE(SyntaxErrorObject); SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const Value &msg) - : ErrorObject(engine, msg, SyntaxError) + : ErrorObject(engine->syntaxErrorClass, msg, SyntaxError) { vtbl = &static_vtbl; - setPrototype(engine->syntaxErrorPrototype); } SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const QString &msg, const QString &fileName, int lineNumber, int columnNumber) - : ErrorObject(engine, msg, fileName, lineNumber, columnNumber, SyntaxError) + : ErrorObject(engine->syntaxErrorClass, msg, fileName, lineNumber, columnNumber, SyntaxError) { vtbl = &static_vtbl; - setPrototype(engine->syntaxErrorPrototype); } EvalErrorObject::EvalErrorObject(ExecutionEngine *engine, const Value &message) - : ErrorObject(engine, message, EvalError) + : ErrorObject(engine->evalErrorClass, message, EvalError) { - setPrototype(engine->evalErrorPrototype); } RangeErrorObject::RangeErrorObject(ExecutionEngine *engine, const Value &message) - : ErrorObject(engine, message, RangeError) + : ErrorObject(engine->rangeErrorClass, message, RangeError) { - setPrototype(engine->rangeErrorPrototype); } RangeErrorObject::RangeErrorObject(ExecutionEngine *engine, const QString &message) - : ErrorObject(engine, Value::fromString(engine, message), RangeError) + : ErrorObject(engine->rangeErrorClass, Value::fromString(engine, message), RangeError) { - setPrototype(engine->rangeErrorPrototype); } ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const Value &message) - : ErrorObject(engine, message, ReferenceError) + : ErrorObject(engine->referenceErrorClass, message, ReferenceError) { - setPrototype(engine->referenceErrorPrototype); } ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const QString &message) - : ErrorObject(engine, Value::fromString(engine, message), ReferenceError) + : ErrorObject(engine->referenceErrorClass, Value::fromString(engine, message), ReferenceError) { - setPrototype(engine->referenceErrorPrototype); } ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const QString &msg, const QString &fileName, int lineNumber, int columnNumber) - : ErrorObject(engine, msg, fileName, lineNumber, columnNumber, ReferenceError) + : ErrorObject(engine->referenceErrorClass, msg, fileName, lineNumber, columnNumber, ReferenceError) { - setPrototype(engine->referenceErrorPrototype); } TypeErrorObject::TypeErrorObject(ExecutionEngine *engine, const Value &message) - : ErrorObject(engine, message, TypeError) + : ErrorObject(engine->typeErrorClass, message, TypeError) { - setPrototype(engine->typeErrorPrototype); } TypeErrorObject::TypeErrorObject(ExecutionEngine *engine, const QString &message) - : ErrorObject(engine, Value::fromString(engine, message), TypeError) + : ErrorObject(engine->typeErrorClass, Value::fromString(engine, message), TypeError) { - setPrototype(engine->typeErrorPrototype); } URIErrorObject::URIErrorObject(ExecutionEngine *engine, const Value &message) - : ErrorObject(engine, message, URIError) + : ErrorObject(engine->uriErrorClass, message, URIError) { - setPrototype(engine->uRIErrorPrototype); } DEFINE_MANAGED_VTABLE(ErrorCtor); diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h index e7bf995c53..f8aeae603c 100644 --- a/src/qml/jsruntime/qv4errorobject_p.h +++ b/src/qml/jsruntime/qv4errorobject_p.h @@ -64,8 +64,8 @@ struct ErrorObject: Object { }; ErrorObject(InternalClass *ic); - ErrorObject(ExecutionEngine *engine, const Value &message, ErrorType t = Error); - ErrorObject(ExecutionEngine *engine, const QString &message, const QString &fileName, int line, int column, ErrorType t = Error); + ErrorObject(InternalClass *ic, const Value &message, ErrorType t = Error); + ErrorObject(InternalClass *ic, const QString &message, const QString &fileName, int line, int column, ErrorType t = Error); SyntaxErrorObject *asSyntaxError(); |