diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-08-29 21:23:04 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-02 17:27:36 +0200 |
commit | d8e31c098dade7280f21ca9781ba11bee5e4f201 (patch) | |
tree | 793b7e5566e75b9c0ef45693d36cb57839a4233c /src | |
parent | edee5c3dc0d922ec3b6a44d66193e9a57b8a979e (diff) |
Cleanup calls to Object::setPrototype()
Rather use the correct internalClass directly when constructing
the objects.
Change-Id: I8e916f1ce8f83d291c08ca6332fe85b1f57b90b5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/localstorage/plugin.cpp | 1 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4dateobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4dateobject_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 77 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 14 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4errorobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4internalclass.cpp | 13 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexpobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexpobject_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringobject_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmllocale.cpp | 12 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 2 |
21 files changed, 86 insertions, 102 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 7c7303a7b8..578c388b44 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -99,7 +99,6 @@ public: : Object(QV8Engine::getV4(e)), type(Database), inTransaction(false), readonly(false), forwardOnly(false) { vtbl = &static_vtbl; - setPrototype(QV8Engine::getV4(e)->objectPrototype); } ~QQmlSqlDatabaseWrapper() { diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 696531fec3..bf1395822d 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -124,8 +124,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) for (int i = 0; i < data->jsClassTableSize; ++i) { int memberCount = 0; const CompiledData::JSClassMember *member = data->jsClassAt(i, &memberCount); - QV4::InternalClass *klass = engine->emptyClass; - klass = klass->changePrototype(engine->objectPrototype); + QV4::InternalClass *klass = engine->objectClass; for (int j = 0; j < memberCount; ++j, ++member) klass = klass->addMember(runtimeStrings[member->nameOffset], member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data); diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 87d93add6e..9f25b8dc40 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -640,7 +640,7 @@ static double getLocalTZA() } DateObject::DateObject(ExecutionEngine *engine, const QDateTime &date) - : Object(engine) + : Object(engine->dateClass) { type = Type_DateObject; value = Value::fromDouble(date.toMSecsSinceEpoch()); diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index 8c925d46e2..238d10849a 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -53,11 +53,13 @@ namespace QV4 { struct DateObject: Object { Value value; - DateObject(InternalClass *ic): Object(ic), value(Value::fromDouble(qSNaN())) { type = Type_DateObject; } - DateObject(ExecutionEngine *engine, const Value &value): Object(engine), value(value) { type = Type_DateObject; } + DateObject(ExecutionEngine *engine, const Value &value): Object(engine->dateClass), value(value) { type = Type_DateObject; } DateObject(ExecutionEngine *engine, const QDateTime &value); QDateTime toQDateTime() const; + +protected: + DateObject(InternalClass *ic): Object(ic), value(Value::fromDouble(qSNaN())) { type = Type_DateObject; } }; struct DateCtor: FunctionObject diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 00b7905a45..0d61dab0bc 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -149,20 +149,32 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) strictArgumentsObjectClass = strictArgumentsObjectClass->addMember(id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); initRootContext(); - stringPrototype = new (memoryManager) StringPrototype(objectClass); - numberPrototype = new (memoryManager) NumberPrototype(objectClass); - booleanPrototype = new (memoryManager) BooleanPrototype(objectClass); - datePrototype = new (memoryManager) DatePrototype(objectClass); - functionPrototype = new (memoryManager) FunctionPrototype(objectClass); - regExpPrototype = new (memoryManager) RegExpPrototype(objectClass); - errorPrototype = new (memoryManager) ErrorPrototype(objectClass); - InternalClass *errorProtoClass = emptyClass->changePrototype(errorPrototype); - evalErrorPrototype = new (memoryManager) EvalErrorPrototype(errorProtoClass); - rangeErrorPrototype = new (memoryManager) RangeErrorPrototype(errorProtoClass); - referenceErrorPrototype = new (memoryManager) ReferenceErrorPrototype(errorProtoClass); - syntaxErrorPrototype = new (memoryManager) SyntaxErrorPrototype(errorProtoClass); - typeErrorPrototype = new (memoryManager) TypeErrorPrototype(errorProtoClass); - uRIErrorPrototype = new (memoryManager) URIErrorPrototype(errorProtoClass); + StringPrototype *stringPrototype = new (memoryManager) StringPrototype(objectClass); + stringClass = emptyClass->changePrototype(stringPrototype); + + NumberPrototype *numberPrototype = new (memoryManager) NumberPrototype(objectClass); + numberClass = emptyClass->changePrototype(numberPrototype); + + BooleanPrototype *booleanPrototype = new (memoryManager) BooleanPrototype(objectClass); + booleanClass = emptyClass->changePrototype(booleanPrototype); + + DatePrototype *datePrototype = new (memoryManager) DatePrototype(objectClass); + dateClass = emptyClass->changePrototype(datePrototype); + + FunctionPrototype *functionPrototype = new (memoryManager) FunctionPrototype(objectClass); + functionClass = emptyClass->changePrototype(functionPrototype); + + RegExpPrototype *regExpPrototype = new (memoryManager) RegExpPrototype(objectClass); + regExpClass = emptyClass->changePrototype(regExpPrototype); + + 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); variantPrototype = new (memoryManager) VariantPrototype(objectClass); sequencePrototype = new (memoryManager) SequencePrototype(arrayClass->changePrototype(arrayPrototype)); @@ -183,22 +195,6 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) typeErrorCtor = Value::fromObject(new (memoryManager) TypeErrorCtor(rootContext)); uRIErrorCtor = Value::fromObject(new (memoryManager) URIErrorCtor(rootContext)); - objectCtor.objectValue()->setPrototype(functionPrototype); - stringCtor.objectValue()->setPrototype(functionPrototype); - numberCtor.objectValue()->setPrototype(functionPrototype); - booleanCtor.objectValue()->setPrototype(functionPrototype); - arrayCtor.objectValue()->setPrototype(functionPrototype); - functionCtor.objectValue()->setPrototype(functionPrototype); - dateCtor.objectValue()->setPrototype(functionPrototype); - regExpCtor.objectValue()->setPrototype(functionPrototype); - errorCtor.objectValue()->setPrototype(functionPrototype); - evalErrorCtor.objectValue()->setPrototype(functionPrototype); - rangeErrorCtor.objectValue()->setPrototype(functionPrototype); - referenceErrorCtor.objectValue()->setPrototype(functionPrototype); - syntaxErrorCtor.objectValue()->setPrototype(functionPrototype); - typeErrorCtor.objectValue()->setPrototype(functionPrototype); - uRIErrorCtor.objectValue()->setPrototype(functionPrototype); - objectPrototype->init(rootContext, objectCtor); stringPrototype->init(this, stringCtor); numberPrototype->init(rootContext, numberCtor); @@ -221,7 +217,7 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) // // set up the global object // - globalObject = newObject(/*rootContext*/); + globalObject = newObject(); rootContext->global = globalObject; rootContext->thisObject = Value::fromObject(globalObject); @@ -327,14 +323,12 @@ BoundFunction *ExecutionEngine::newBoundFunction(ExecutionContext *scope, Functi Object *ExecutionEngine::newObject() { Object *object = new (memoryManager) Object(this); - object->setPrototype(objectPrototype); return object; } Object *ExecutionEngine::newObject(InternalClass *internalClass) { Object *object = new (memoryManager) Object(internalClass); - object->setPrototype(objectPrototype); return object; } @@ -351,21 +345,18 @@ String *ExecutionEngine::newIdentifier(const QString &text) Object *ExecutionEngine::newStringObject(const Value &value) { StringObject *object = new (memoryManager) StringObject(this, value); - object->setPrototype(stringPrototype); return object; } Object *ExecutionEngine::newNumberObject(const Value &value) { NumberObject *object = new (memoryManager) NumberObject(this, value); - object->setPrototype(numberPrototype); return object; } Object *ExecutionEngine::newBooleanObject(const Value &value) { Object *object = new (memoryManager) BooleanObject(this, value); - object->setPrototype(booleanPrototype); return object; } @@ -390,14 +381,12 @@ ArrayObject *ExecutionEngine::newArrayObject(const QStringList &list) DateObject *ExecutionEngine::newDateObject(const Value &value) { DateObject *object = new (memoryManager) DateObject(this, value); - object->setPrototype(datePrototype); return object; } DateObject *ExecutionEngine::newDateObject(const QDateTime &dt) { DateObject *object = new (memoryManager) DateObject(this, dt); - object->setPrototype(datePrototype); return object; } @@ -417,21 +406,18 @@ RegExpObject *ExecutionEngine::newRegExpObject(const QString &pattern, int flags RegExpObject *ExecutionEngine::newRegExpObject(RegExp* re, bool global) { RegExpObject *object = new (memoryManager) RegExpObject(this, re, global); - object->setPrototype(regExpPrototype); return object; } RegExpObject *ExecutionEngine::newRegExpObject(const QRegExp &re) { RegExpObject *object = new (memoryManager) RegExpObject(this, re); - object->setPrototype(regExpPrototype); return object; } Object *ExecutionEngine::newErrorObject(const Value &value) { ErrorObject *object = new (memoryManager) ErrorObject(this, value); - object->setPrototype(errorPrototype); return object; } @@ -616,9 +602,7 @@ void ExecutionEngine::requireArgumentsAccessors(int n) argumentsAccessors.resize(n); for (int i = oldSize; i < n; ++i) { FunctionObject *get = new (memoryManager) ArgumentsGetterFunction(rootContext, i); - get->setPrototype(functionPrototype); FunctionObject *set = new (memoryManager) ArgumentsSetterFunction(rootContext, i); - set->setPrototype(functionPrototype); Property pd = Property::fromAccessor(get, set); argumentsAccessors[i] = pd; } @@ -681,14 +665,7 @@ void ExecutionEngine::markObjects() uRIErrorCtor.mark(); objectPrototype->mark(); - stringPrototype->mark(); - numberPrototype->mark(); - booleanPrototype->mark(); arrayPrototype->mark(); - functionPrototype->mark(); - datePrototype->mark(); - regExpPrototype->mark(); - errorPrototype->mark(); evalErrorPrototype->mark(); rangeErrorPrototype->mark(); referenceErrorPrototype->mark(); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index c368f4e81e..17f92ce597 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -150,14 +150,7 @@ struct Q_QML_EXPORT ExecutionEngine Value uRIErrorCtor; ObjectPrototype *objectPrototype; - StringPrototype *stringPrototype; - NumberPrototype *numberPrototype; - BooleanPrototype *booleanPrototype; ArrayPrototype *arrayPrototype; - FunctionPrototype *functionPrototype; - DatePrototype *datePrototype; - RegExpPrototype *regExpPrototype; - ErrorPrototype *errorPrototype; EvalErrorPrototype *evalErrorPrototype; RangeErrorPrototype *rangeErrorPrototype; ReferenceErrorPrototype *referenceErrorPrototype; @@ -172,6 +165,13 @@ struct Q_QML_EXPORT ExecutionEngine InternalClass *emptyClass; InternalClass *objectClass; InternalClass *arrayClass; + InternalClass *stringClass; + InternalClass *booleanClass; + InternalClass *numberClass; + InternalClass *dateClass; + InternalClass *functionClass; + InternalClass *regExpClass; + InternalClass *errorClass; InternalClass *argumentsObjectClass; InternalClass *strictArgumentsObjectClass; diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index f0d7d7205e..6b3607faec 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -82,7 +82,7 @@ ErrorObject::ErrorObject(InternalClass *ic) } ErrorObject::ErrorObject(ExecutionEngine *engine, const Value &message, ErrorType t) - : Object(engine) + : Object(engine->errorClass) , stack(0) { type = Type_ErrorObject; @@ -102,7 +102,7 @@ ErrorObject::ErrorObject(ExecutionEngine *engine, const Value &message, ErrorTyp } ErrorObject::ErrorObject(ExecutionEngine *engine, const QString &message, const QString &fileName, int line, int column, ErrorObject::ErrorType t) - : Object(engine) + : Object(engine->errorClass) , stack(0) { type = Type_ErrorObject; diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 59892033c4..94c4b81b40 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -70,7 +70,7 @@ using namespace QV4; DEFINE_MANAGED_VTABLE(FunctionObject); FunctionObject::FunctionObject(ExecutionContext *scope, String *name) - : Object(scope->engine) + : Object(scope->engine->functionClass) , scope(scope) , name(name) , formalParameterList(0) @@ -80,7 +80,6 @@ FunctionObject::FunctionObject(ExecutionContext *scope, String *name) , function(0) { vtbl = &static_vtbl; - setPrototype(scope->engine->functionPrototype); type = Type_FunctionObject; needsActivation = true; diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 8b900db55d..09a91138cb 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -108,7 +108,6 @@ struct Q_QML_EXPORT FunctionObject: Object { Function *function; FunctionObject(ExecutionContext *scope, String *name = 0); - FunctionObject(InternalClass *ic); ~FunctionObject(); Value newInstance(); @@ -125,6 +124,8 @@ struct Q_QML_EXPORT FunctionObject: Object { static FunctionObject *creatScriptFunction(ExecutionContext *scope, Function *function); protected: + FunctionObject(InternalClass *ic); + static const ManagedVTable static_vtbl; static void markObjects(Managed *that); static bool hasInstance(Managed *that, const Value &value); diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index 59b1989e72..16038b0b68 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -331,11 +331,16 @@ void InternalClass::destroy() void InternalClass::markObjects() { - if (prototype) - prototype->mark(); + // all prototype changes are done on the empty class + Q_ASSERT(!prototype); + for (QHash<Transition, InternalClass *>::ConstIterator it = transitions.begin(), end = transitions.end(); - it != end; ++it) - it.value()->markObjects(); + it != end; ++it) { + if (it.key().flags == Transition::ProtoChange) { + Q_ASSERT(it.value()->prototype); + it.value()->prototype->mark(); + } + } } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index fd4c03160e..c3c444b7b9 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -69,7 +69,7 @@ using namespace QV4; DEFINE_MANAGED_VTABLE(Object); Object::Object(ExecutionEngine *engine) - : Managed(engine->emptyClass) + : Managed(engine->objectClass) , memberDataAlloc(InlinePropertySize), memberData(inlineProperties) , arrayOffset(0), arrayDataLen(0), arrayAlloc(0), arrayAttributes(0), arrayData(0), sparseArray(0) { @@ -1422,7 +1422,7 @@ void Object::markArrayObjects() const } ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list) - : Object(engine) + : Object(engine->arrayClass) { init(engine); @@ -1441,8 +1441,6 @@ ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list) void ArrayObject::init(ExecutionEngine *engine) { type = Type_ArrayObject; - internalClass = engine->arrayClass; - memberData[LengthPropertyIndex].value = Value::fromInt32(0); } diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 7d4aae5aa7..09476c9009 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -352,14 +352,16 @@ protected: struct BooleanObject: Object { Value value; + BooleanObject(ExecutionEngine *engine, const Value &value): Object(engine->booleanClass), value(value) { type = Type_BooleanObject; } +protected: BooleanObject(InternalClass *ic): Object(ic), value(Value::fromBoolean(false)) { type = Type_BooleanObject; } - BooleanObject(ExecutionEngine *engine, const Value &value): Object(engine), value(value) { type = Type_BooleanObject; } }; struct NumberObject: Object { Value value; + NumberObject(ExecutionEngine *engine, const Value &value): Object(engine->numberClass), value(value) { type = Type_NumberObject; } +protected: NumberObject(InternalClass *ic): Object(ic), value(Value::fromInt32(0)) { type = Type_NumberObject; } - NumberObject(ExecutionEngine *engine, const Value &value): Object(engine), value(value) { type = Type_NumberObject; } }; struct ArrayObject: Object { @@ -367,12 +369,14 @@ struct ArrayObject: Object { LengthPropertyIndex = 0 }; - ArrayObject(InternalClass *ic) : Object(ic) { init(ic->engine); } - ArrayObject(ExecutionEngine *engine) : Object(engine) { init(engine); } + ArrayObject(ExecutionEngine *engine) : Object(engine->arrayClass) { init(engine); } ArrayObject(ExecutionEngine *engine, const QStringList &list); void init(ExecutionEngine *engine); QStringList toQStringList() const; + +protected: + ArrayObject(InternalClass *ic) : Object(ic) { init(ic->engine); } }; inline uint Object::arrayLength() const diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index fe821928b5..1c160edd7a 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -254,8 +254,8 @@ QObjectWrapper::QObjectWrapper(ExecutionEngine *engine, QObject *object) void QObjectWrapper::initializeBindings(ExecutionEngine *engine) { - engine->functionPrototype->defineDefaultProperty(engine, QStringLiteral("connect"), method_connect); - engine->functionPrototype->defineDefaultProperty(engine, QStringLiteral("disconnect"), method_disconnect); + engine->functionClass->prototype->defineDefaultProperty(engine, QStringLiteral("connect"), method_connect); + engine->functionClass->prototype->defineDefaultProperty(engine, QStringLiteral("disconnect"), method_disconnect); } QQmlPropertyData *QObjectWrapper::findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const @@ -340,8 +340,8 @@ Value QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextData *qml QV4::String *connect = ctx->engine->newIdentifier(QStringLiteral("connect")); QV4::String *disconnect = ctx->engine->newIdentifier(QStringLiteral("disconnect")); - handler->put(connect, ctx->engine->functionPrototype->get(connect)); - handler->put(disconnect, ctx->engine->functionPrototype->get(disconnect)); + handler->put(connect, ctx->engine->functionClass->prototype->get(connect)); + handler->put(disconnect, ctx->engine->functionClass->prototype->get(disconnect)); return QV4::Value::fromObject(handler); } else { diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 05829b4e94..cd104c0a71 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -79,7 +79,7 @@ RegExpObject::RegExpObject(InternalClass *ic) } RegExpObject::RegExpObject(ExecutionEngine *engine, RegExp* value, bool global) - : Object(engine) + : Object(engine->regExpClass) , value(value) , global(global) { @@ -90,7 +90,7 @@ RegExpObject::RegExpObject(ExecutionEngine *engine, RegExp* value, bool global) // The conversion is not 100% exact since ECMA regexp and QRegExp // have different semantics/flags, but we try to do our best. RegExpObject::RegExpObject(ExecutionEngine *engine, const QRegExp &re) - : Object(engine) + : Object(engine->regExpClass) , value(0) , global(false) { diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index 6c4f12c1e4..c95c00bbf6 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -78,7 +78,6 @@ struct RegExpObject: Object { Property *lastIndexProperty(ExecutionContext *ctx); bool global; - RegExpObject(InternalClass *ic); RegExpObject(ExecutionEngine *engine, RegExp* value, bool global); RegExpObject(ExecutionEngine *engine, const QRegExp &re); ~RegExpObject() {} @@ -91,6 +90,7 @@ struct RegExpObject: Object { uint flags() const; protected: + RegExpObject(InternalClass *ic); static void destroy(Managed *that); static void markObjects(Managed *that); }; diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index a9095ffcf7..b1ae59f648 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -814,7 +814,7 @@ void __qmljs_call_property_lookup(ExecutionContext *context, Value *result, cons if (thisObject.isObject()) baseObject = thisObject.objectValue(); else if (thisObject.isString()) - baseObject = context->engine->stringPrototype; + baseObject = context->engine->stringClass->prototype; else baseObject = __qmljs_convert_to_object(context, thisObject); diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 8b78c40129..11d3100180 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -139,7 +139,7 @@ Value String::get(Managed *m, String *name, bool *hasProperty) return Value::fromInt32(that->_text.length()); } PropertyAttributes attrs; - Property *pd = v4->stringPrototype->__getPropertyDescriptor__(name, &attrs); + Property *pd = v4->stringClass->prototype->__getPropertyDescriptor__(name, &attrs); if (!pd || attrs.isGeneric()) { if (hasProperty) *hasProperty = false; @@ -147,7 +147,7 @@ Value String::get(Managed *m, String *name, bool *hasProperty) } if (hasProperty) *hasProperty = true; - return v4->stringPrototype->getValue(Value::fromString(that), pd, attrs); + return v4->stringClass->prototype->getValue(Value::fromString(that), pd, attrs); } Value String::getIndexed(Managed *m, uint index, bool *hasProperty) @@ -160,7 +160,7 @@ Value String::getIndexed(Managed *m, uint index, bool *hasProperty) return Value::fromString(engine->newString(that->toQString().mid(index, 1))); } PropertyAttributes attrs; - Property *pd = engine->stringPrototype->__getPropertyDescriptor__(index, &attrs); + Property *pd = engine->stringClass->prototype->__getPropertyDescriptor__(index, &attrs); if (!pd || attrs.isGeneric()) { if (hasProperty) *hasProperty = false; @@ -168,7 +168,7 @@ Value String::getIndexed(Managed *m, uint index, bool *hasProperty) } if (hasProperty) *hasProperty = true; - return engine->stringPrototype->getValue(Value::fromString(that), pd, attrs); + return engine->stringClass->prototype->getValue(Value::fromString(that), pd, attrs); } void String::put(Managed *m, String *name, const Value &value) diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 6fd312ab24..442297ffe0 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -88,7 +88,7 @@ StringObject::StringObject(InternalClass *ic) } StringObject::StringObject(ExecutionEngine *engine, const Value &value) - : Object(engine), value(value) + : Object(engine->stringClass), value(value) { vtbl = &static_vtbl; type = Type_StringObject; @@ -364,7 +364,7 @@ Value StringPrototype::method_match(SimpleCallContext *context) bool global = rx->global; // ### use the standard builtin function, not the one that might be redefined in the proto - FunctionObject *exec = context->engine->regExpPrototype->get(context->engine->newString(QStringLiteral("exec")), 0).asFunctionObject(); + FunctionObject *exec = context->engine->regExpClass->prototype->get(context->engine->newString(QStringLiteral("exec")), 0).asFunctionObject(); CALLDATA(1); d.thisObject = Value::fromObject(rx); diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h index 6d2ccce641..38d6eeeac5 100644 --- a/src/qml/jsruntime/qv4stringobject_p.h +++ b/src/qml/jsruntime/qv4stringobject_p.h @@ -54,7 +54,6 @@ struct StringObject: Object { Value value; mutable Property tmpProperty; - StringObject(InternalClass *ic); StringObject(ExecutionEngine *engine, const Value &value); Property *getIndex(uint index) const; @@ -62,6 +61,7 @@ struct StringObject: Object { static bool deleteIndexedProperty(Managed *m, uint index); protected: + StringObject(InternalClass *ic); static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attrs); static void markObjects(Managed *that); }; diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index f248b8b495..7f68ccc324 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -126,9 +126,9 @@ static bool isLocaleObject(const QV4::Value &val) void QQmlDateExtension::registerExtension(QV4::ExecutionEngine *engine) { - engine->datePrototype->defineDefaultProperty(engine, QStringLiteral("toLocaleString"), toLocaleString); - engine->datePrototype->defineDefaultProperty(engine, QStringLiteral("toLocaleTimeString"), toLocaleTimeString); - engine->datePrototype->defineDefaultProperty(engine, QStringLiteral("toLocaleDateString"), toLocaleDateString); + engine->dateClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleString"), toLocaleString); + engine->dateClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleTimeString"), toLocaleTimeString); + engine->dateClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleDateString"), toLocaleDateString); engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleString"), fromLocaleString); engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleTimeString"), fromLocaleTimeString); engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleDateString"), fromLocaleDateString); @@ -393,8 +393,8 @@ QV4::Value QQmlDateExtension::timeZoneUpdated(QV4::SimpleCallContext *ctx) void QQmlNumberExtension::registerExtension(QV4::ExecutionEngine *engine) { - engine->numberPrototype->defineDefaultProperty(engine, QStringLiteral("toLocaleString"), toLocaleString); - engine->numberPrototype->defineDefaultProperty(engine, QStringLiteral("toLocaleCurrencyString"), toLocaleCurrencyString); + engine->numberClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleString"), toLocaleString); + engine->numberClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleCurrencyString"), toLocaleCurrencyString); engine->numberCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleString"), fromLocaleString); } @@ -820,7 +820,7 @@ QV4::Value QQmlLocale::locale(QV8Engine *v8engine, const QString &locale) void QQmlLocale::registerStringLocaleCompare(QV4::ExecutionEngine *engine) { - engine->stringPrototype->defineDefaultProperty(engine, QStringLiteral("localeCompare"), localeCompare); + engine->stringClass->prototype->defineDefaultProperty(engine, QStringLiteral("localeCompare"), localeCompare); } QV4::Value QQmlLocale::localeCompare(QV4::SimpleCallContext *ctx) diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 3f67de2782..35b0b84f46 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1595,7 +1595,7 @@ void QV4::GlobalExtensions::init(QQmlEngine *qmlEngine, Object *globalObject) globalObject->defineDefaultProperty(v4, QStringLiteral("Qt"), qt); // string prototype extension - QV4::Object *stringProto = v4->stringPrototype; + QV4::Object *stringProto = v4->stringClass->prototype; stringProto->defineDefaultProperty(v4, QStringLiteral("arg"), string_arg); } |