diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-05-07 13:33:24 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-07-22 13:49:12 +0200 |
commit | 33593f00e84e6fb05191e9bb88000566c0c96426 (patch) | |
tree | 127877f1719689659a8ec6cea669ad5d38ec0903 /src/qml/jsruntime | |
parent | 9afc7d9a53ad86e548e2d239ff012bed15eb52ba (diff) |
Get rid of StringRef
Remove the Ref classes, as they won't be required
anymore once Managed and Managed::Data are separated.
Change-Id: Ic6bec2d5b4ecf2595ce129dbb45bbf6a385138a5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
36 files changed, 240 insertions, 250 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 88700e17d0..e65ec2c019 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -133,7 +133,7 @@ ReturnedValue ArrayPrototype::method_toString(CallContext *ctx) if (ctx->d()->engine->hasException) return Encode::undefined(); ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("join"))); - ScopedFunctionObject f(scope, o->get(s)); + ScopedFunctionObject f(scope, o->get(s.getPointer())); if (!!f) { ScopedCallData d(scope, 0); d->thisObject = ctx->d()->callData->thisObject; @@ -224,7 +224,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx) // crazy! // ScopedString name(scope, ctx->d()->engine->newString(QStringLiteral("0"))); - ScopedValue r6(scope, self->get(name)); + ScopedValue r6(scope, self->get(name.getPointer())); if (!r6->isNullOrUndefined()) R = r6->toString(ctx)->toQString(); @@ -233,7 +233,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx) R += r4; name = Primitive::fromDouble(k).toString(ctx); - r12 = self->get(name); + r12 = self->get(name.getPointer()); if (scope.hasException()) return Encode::undefined(); @@ -290,7 +290,7 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx) ScopedString s(scope); for (int i = 0; i < ctx->d()->callData->argc; ++i) { s = Primitive::fromDouble(l + i).toString(ctx); - instance->put(s, ctx->d()->callData->args[i]); + instance->put(s.getPointer(), ctx->d()->callData->args[i]); } double newLen = l + ctx->d()->callData->argc; if (!instance->isArrayObject()) diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index a49fd8ad71..91fdfc8554 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -92,7 +92,7 @@ WithContext *ExecutionContext::newWithContext(ObjectRef with) return w; } -CatchContext *ExecutionContext::newCatchContext(const StringRef exceptionVarName, const ValueRef exceptionValue) +CatchContext *ExecutionContext::newCatchContext(String *exceptionVarName, const ValueRef exceptionValue) { CatchContext *c = new (d()->engine->memoryManager) CatchContext(d()->engine, exceptionVarName, exceptionValue); return c; @@ -107,7 +107,7 @@ CallContext *ExecutionContext::newQmlContext(FunctionObject *f, ObjectRef qml) -void ExecutionContext::createMutableBinding(const StringRef name, bool deletable) +void ExecutionContext::createMutableBinding(String *name, bool deletable) { Scope scope(this); @@ -151,7 +151,7 @@ WithContext::WithContext(ExecutionEngine *engine, ObjectRef with) d()->withObject = with.getPointer(); } -CatchContext::CatchContext(ExecutionEngine *engine, const StringRef exceptionVarName, const ValueRef exceptionValue) +CatchContext::CatchContext(ExecutionEngine *engine, String *exceptionVarName, const ValueRef exceptionValue) : ExecutionContext(engine, Type_CatchContext) { d()->strictMode = d()->parent->d()->strictMode; @@ -210,7 +210,7 @@ unsigned int CallContext::variableCount() const -bool ExecutionContext::deleteProperty(const StringRef name) +bool ExecutionContext::deleteProperty(String *name) { Scope scope(this); bool hasWith = false; @@ -284,7 +284,7 @@ void ExecutionContext::markObjects(Managed *m, ExecutionEngine *engine) } } -void ExecutionContext::setProperty(const StringRef name, const ValueRef value) +void ExecutionContext::setProperty(String *name, const ValueRef value) { Scope scope(this); for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { @@ -332,21 +332,21 @@ void ExecutionContext::setProperty(const StringRef name, const ValueRef value) } } } - if (d()->strictMode || name->equals(d()->engine->id_this)) { - ScopedValue n(scope, name.asReturnedValue()); + if (d()->strictMode || name->equals(d()->engine->id_this.getPointer())) { + ScopedValue n(scope, name->asReturnedValue()); throwReferenceError(n); return; } d()->engine->globalObject->put(name, value); } -ReturnedValue ExecutionContext::getProperty(const StringRef name) +ReturnedValue ExecutionContext::getProperty(String *name) { Scope scope(this); ScopedValue v(scope); name->makeIdentifier(); - if (name->equals(d()->engine->id_this)) + if (name->equals(d()->engine->id_this.getPointer())) return d()->callData->thisObject.asReturnedValue(); bool hasWith = false; @@ -400,18 +400,18 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name) return v.asReturnedValue(); } } - ScopedValue n(scope, name.asReturnedValue()); + ScopedValue n(scope, name); return throwReferenceError(n); } -ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectRef base) +ReturnedValue ExecutionContext::getPropertyAndBase(String *name, ObjectRef base) { Scope scope(this); ScopedValue v(scope); base = (Object *)0; name->makeIdentifier(); - if (name->equals(d()->engine->id_this)) + if (name->equals(d()->engine->id_this.getPointer())) return d()->callData->thisObject.asReturnedValue(); bool hasWith = false; @@ -469,7 +469,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR return v.asReturnedValue(); } } - ScopedValue n(scope, name.asReturnedValue()); + ScopedValue n(scope, name); return throwReferenceError(n); } diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index a713a38141..cea6499f00 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -139,10 +139,10 @@ struct Q_QML_EXPORT ExecutionContext : public Managed CallContext *newCallContext(FunctionObject *f, CallData *callData); WithContext *newWithContext(ObjectRef with); - CatchContext *newCatchContext(const StringRef exceptionVarName, const ValueRef exceptionValue); + CatchContext *newCatchContext(String *exceptionVarName, const ValueRef exceptionValue); CallContext *newQmlContext(FunctionObject *f, ObjectRef qml); - void createMutableBinding(const StringRef name, bool deletable); + void createMutableBinding(String *name, bool deletable); ReturnedValue throwError(const QV4::ValueRef value); ReturnedValue throwError(const QString &message); @@ -157,10 +157,10 @@ struct Q_QML_EXPORT ExecutionContext : public Managed ReturnedValue throwURIError(const ValueRef msg); ReturnedValue throwUnimplemented(const QString &message); - void setProperty(const StringRef name, const ValueRef value); - ReturnedValue getProperty(const StringRef name); - ReturnedValue getPropertyAndBase(const StringRef name, ObjectRef base); - bool deleteProperty(const StringRef name); + void setProperty(String *name, const ValueRef value); + ReturnedValue getProperty(String *name); + ReturnedValue getPropertyAndBase(String *name, ObjectRef base); + bool deleteProperty(String *name); // Can only be called from within catch(...), rethrows if no JS exception. ReturnedValue catchException(StackTrace *trace = 0); @@ -226,7 +226,7 @@ struct CatchContext : public ExecutionContext } __data; V4_MANAGED - CatchContext(ExecutionEngine *engine, const StringRef exceptionVarName, const ValueRef exceptionValue); + CatchContext(ExecutionEngine *engine, String *exceptionVarName, const ValueRef exceptionValue); }; struct WithContext : public ExecutionContext diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 6c485200c9..13e6bda8e5 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -1314,7 +1314,7 @@ ReturnedValue DatePrototype::method_toJSON(CallContext *ctx) return Encode::null(); ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toISOString"))); - ScopedValue v(scope, O->objectValue()->get(s)); + ScopedValue v(scope, O->objectValue()->get(s.getPointer())); FunctionObject *toIso = v->asFunctionObject(); if (!toIso) diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index f1b6ecd9d6..a1c2b2042a 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -412,7 +412,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) globalObject->defineDefaultProperty(QStringLiteral("unescape"), GlobalFunctions::method_unescape, 1); Scoped<String> name(scope, newString(QStringLiteral("thrower"))); - thrower = newBuiltinFunction(rootContext, name, throwTypeError)->getPointer(); + thrower = newBuiltinFunction(rootContext, name.getPointer(), throwTypeError)->getPointer(); } ExecutionEngine::~ExecutionEngine() @@ -481,7 +481,7 @@ ExecutionContext *ExecutionEngine::pushGlobalContext() return g; } -Returned<FunctionObject> *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *)) +Returned<FunctionObject> *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)) { BuiltinFunction *f = new (memoryManager) BuiltinFunction(scope, name, code); return f->asReturned<FunctionObject>(); @@ -969,7 +969,7 @@ QQmlError ExecutionEngine::catchExceptionAsQmlError(ExecutionContext *context) QV4::Scoped<QV4::ErrorObject> errorObj(scope, exception); if (!!errorObj && errorObj->asSyntaxError()) { QV4::ScopedString m(scope, errorObj->engine()->newString(QStringLiteral("message"))); - QV4::ScopedValue v(scope, errorObj->get(m)); + QV4::ScopedValue v(scope, errorObj->get(m.getPointer())); error.setDescription(v->toQStringNoThrow()); } else error.setDescription(exception->toQStringNoThrow()); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 8e8f40ee91..6ff10ae6b8 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -307,7 +307,7 @@ public: void pushContext(CallContext *context); ExecutionContext *popContext(); - Returned<FunctionObject> *newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *)); + Returned<FunctionObject> *newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)); Returned<BoundFunction> *newBoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QV4::Members &boundArgs); Returned<Object> *newObject(); diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index f8fbbf09cb..5b3ffdec76 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -383,7 +383,7 @@ ReturnedValue ErrorPrototype::method_toString(CallContext *ctx) qname = name->toQString(); ScopedString s(scope, ctx->d()->engine->newString(QString::fromLatin1("message"))); - ScopedValue message(scope, o->get(s)); + ScopedValue message(scope, o->get(s.getPointer())); QString qmessage; if (!message->isUndefined()) qmessage = message->toQString(); diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index e6385d861c..482f247319 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -94,8 +94,8 @@ struct Q_QML_EXPORT Function { ReturnedValue (*codePtr)(ExecutionContext *, const uchar *)); ~Function(); - inline StringRef name() { - return compilationUnit->runtimeStrings[compiledFunction->nameIndex]; + inline String *name() { + return compilationUnit->runtimeStrings[compiledFunction->nameIndex].getPointer(); } inline QString sourceFile() const { return compilationUnit->fileName(); } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 236e4be219..bc6cd45f13 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -74,7 +74,7 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(FunctionObject); -FunctionObject::FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto) +FunctionObject::FunctionObject(ExecutionContext *scope, String *name, bool createProto) : Object(scope->d()->engine->functionClass) { d()->scope = scope; @@ -91,7 +91,7 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, boo Scope s(scope); ScopedValue protectThis(s, this); ScopedString n(s, s.engine->newString(name)); - init(n, createProto); + init(n.getPointer(), createProto); } FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name) @@ -103,7 +103,7 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name Scope s(scope); ScopedValue protectThis(s, this); ScopedString n(s, name); - init(n, false); + init(n.getPointer(), false); } FunctionObject::FunctionObject(InternalClass *ic) @@ -123,7 +123,7 @@ FunctionObject::~FunctionObject() function()->compilationUnit->deref(); } -void FunctionObject::init(const StringRef n, bool createProto) +void FunctionObject::init(String *n, bool createProto) { Scope s(internalClass()->engine); ScopedValue protectThis(s, this); @@ -139,7 +139,7 @@ void FunctionObject::init(const StringRef n, bool createProto) memberData()[Index_Prototype] = Encode::undefined(); } - ScopedValue v(s, n.asReturnedValue()); + ScopedValue v(s, n); defineReadonlyProperty(scope()->d()->engine->id_name, v); } @@ -555,7 +555,7 @@ InternalClass *SimpleScriptFunction::internalClassForConstructor() DEFINE_OBJECT_VTABLE(BuiltinFunction); -BuiltinFunction::BuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *)) +BuiltinFunction::BuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)) : FunctionObject(scope, name) { d()->code = code; diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index ff57e27419..ad1ebb468c 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -129,12 +129,12 @@ struct Q_QML_EXPORT FunctionObject: Object { unsigned int formalParameterCount() { return function() ? function()->compiledFunction->nFormals : 0; } unsigned int varCount() { return function() ? function()->compiledFunction->nLocals : 0; } - FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto = false); + FunctionObject(ExecutionContext *scope, String *name, bool createProto = false); FunctionObject(ExecutionContext *scope, const QString &name = QString(), bool createProto = false); FunctionObject(ExecutionContext *scope, const ReturnedValue name); ~FunctionObject(); - void init(const StringRef name, bool createProto); + void init(String *name, bool createProto); ReturnedValue newInstance(); @@ -197,7 +197,7 @@ struct BuiltinFunction: FunctionObject { } __data; V4_OBJECT - BuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *)); + BuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)); static ReturnedValue construct(Managed *, CallData *); static ReturnedValue call(Managed *that, CallData *callData); diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index b6172a79a5..105ad93157 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -164,7 +164,6 @@ typedef Returned<String> ReturnedString; typedef Returned<Object> ReturnedObject; typedef Returned<FunctionObject> ReturnedFunctionObject; struct ManagedRef; -struct StringRef; struct ObjectRef; struct ArrayObjectRef; struct FunctionObjectRef; diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 6b382b53fa..b9576e1bee 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -89,11 +89,11 @@ QV4::ReturnedValue QV4Include::resultValue(QV4::ExecutionEngine *v4, Status stat QV4::ScopedObject o(scope, v4->newObject()); QV4::ScopedString s(scope); QV4::ScopedValue v(scope); - o->put((s = v4->newString(QStringLiteral("OK"))), (v = QV4::Primitive::fromInt32(Ok))); - o->put((s = v4->newString(QStringLiteral("LOADING"))), (v = QV4::Primitive::fromInt32(Loading))); - o->put((s = v4->newString(QStringLiteral("NETWORK_ERROR"))), (v = QV4::Primitive::fromInt32(NetworkError))); - o->put((s = v4->newString(QStringLiteral("EXCEPTION"))), (v = QV4::Primitive::fromInt32(Exception))); - o->put((s = v4->newString(QStringLiteral("status"))), (v = QV4::Primitive::fromInt32(status))); + o->put((s = v4->newString(QStringLiteral("OK"))).getPointer(), (v = QV4::Primitive::fromInt32(Ok))); + o->put((s = v4->newString(QStringLiteral("LOADING"))).getPointer(), (v = QV4::Primitive::fromInt32(Loading))); + o->put((s = v4->newString(QStringLiteral("NETWORK_ERROR"))).getPointer(), (v = QV4::Primitive::fromInt32(NetworkError))); + o->put((s = v4->newString(QStringLiteral("EXCEPTION"))).getPointer(), (v = QV4::Primitive::fromInt32(Exception))); + o->put((s = v4->newString(QStringLiteral("status"))).getPointer(), (v = QV4::Primitive::fromInt32(status))); return o.asReturnedValue(); } @@ -160,13 +160,13 @@ void QV4Include::finished() script.run(); if (scope.engine->hasException) { QV4::ScopedValue ex(scope, ctx->catchException()); - resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Exception))); - resultObj->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("exception"))), ex); + resultObj->put(status.getPointer(), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Exception))); + resultObj->put(v4->newString(QStringLiteral("exception"))->getPointer(), ex); } else { - resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Ok))); + resultObj->put(status.getPointer(), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Ok))); } } else { - resultObj->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("status"))), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError))); + resultObj->put(v4->newString(QStringLiteral("status"))->getPointer(), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError))); } QV4::ScopedValue cb(scope, m_callbackFunction.value()); @@ -226,7 +226,7 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx) if (scope.engine->hasException) { QV4::ScopedValue ex(scope, ctx->catchException()); result = resultValue(scope.engine, Exception); - result->asObject()->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("exception"))), ex); + result->asObject()->put(scope.engine->newString(QStringLiteral("exception"))->getPointer(), ex); } else { result = resultValue(scope.engine, Ok); } diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index 35efd3c022..2edaf6fe96 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -271,11 +271,6 @@ InternalClass *InternalClass::changeVTable(const ManagedVTable *vt) return newClass; } -void InternalClass::addMember(Object *object, StringRef string, PropertyAttributes data, uint *index) -{ - return addMember(object, string.getPointer(), data, index); -} - void InternalClass::addMember(Object *object, String *string, PropertyAttributes data, uint *index) { data.resolve(); @@ -294,11 +289,6 @@ void InternalClass::addMember(Object *object, String *string, PropertyAttributes } -InternalClass *InternalClass::addMember(StringRef string, PropertyAttributes data, uint *index) -{ - return addMember(string.getPointer(), data, index); -} - InternalClass *InternalClass::addMember(String *string, PropertyAttributes data, uint *index) { data.resolve(); @@ -374,11 +364,6 @@ void InternalClass::removeMember(Object *object, Identifier *id) oldClass->transitions.insert(t, object->internalClass()); } -uint InternalClass::find(const StringRef string) -{ - return find(string.getPointer()); -} - uint InternalClass::find(const String *string) { engine->identifierTable->identifier(string); diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index bd1828a146..830d5f792f 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -234,14 +234,11 @@ struct InternalClass : public QQmlJS::Managed { static InternalClass *create(ExecutionEngine *engine, const ManagedVTable *vtable, Object *proto); InternalClass *changePrototype(Object *proto); InternalClass *changeVTable(const ManagedVTable *vt); - static void addMember(Object *object, StringRef string, PropertyAttributes data, uint *index); static void addMember(Object *object, String *string, PropertyAttributes data, uint *index); - InternalClass *addMember(StringRef string, PropertyAttributes data, uint *index = 0); InternalClass *addMember(String *string, PropertyAttributes data, uint *index = 0); InternalClass *changeMember(String *string, PropertyAttributes data, uint *index = 0); static void changeMember(Object *object, String *string, PropertyAttributes data, uint *index = 0); static void removeMember(Object *object, Identifier *id); - uint find(const StringRef string); uint find(const String *s); InternalClass *sealed(); diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 8552936663..f0f71523b7 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -290,7 +290,7 @@ bool JsonParser::parseMember(ObjectRef o) if (idx < UINT_MAX) { o->putIndexed(idx, val); } else { - o->insertMember(s, val); + o->insertMember(s.getPointer(), val); } END; @@ -711,7 +711,7 @@ QString Stringify::Str(const QString &key, ValueRef v) ScopedObject o(scope, value); if (o) { ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toJSON"))); - Scoped<FunctionObject> toJSON(scope, o->get(s)); + Scoped<FunctionObject> toJSON(scope, o->get(s.getPointer())); if (!!toJSON) { ScopedCallData callData(scope, 1); callData->thisObject = value; @@ -814,7 +814,7 @@ QString Stringify::JO(ObjectRef o) for (int i = 0; i < propertyList.size(); ++i) { bool exists; s = propertyList.at(i); - ScopedValue v(scope, o->get(s, &exists)); + ScopedValue v(scope, o->get(s.getPointer(), &exists)); if (!exists) continue; QString member = makeMember(s->toQString(), v); @@ -1008,7 +1008,7 @@ QV4::ReturnedValue JsonObject::fromJsonObject(ExecutionEngine *engine, const QJs ScopedValue v(scope); for (QJsonObject::const_iterator it = object.begin(); it != object.end(); ++it) { v = fromJsonValue(engine, it.value()); - o->put((s = engine->newString(it.key())), v); + o->put((s = engine->newString(it.key())).getPointer(), v); } return o.asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index ed555b7763..d2ddec560b 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -159,7 +159,7 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const ValueRef object, co ScopedString name(scope, index->toString(ctx)); if (scope.hasException()) return Encode::undefined(); - return o->get(name); + return o->get(name.getPointer()); } @@ -215,7 +215,7 @@ void Lookup::indexedSetterFallback(Lookup *l, const ValueRef object, const Value } ScopedString name(scope, index->toString(ctx)); - o->put(name, value); + o->put(name.getPointer(), value); } void Lookup::indexedSetterObjectInt(Lookup *l, const ValueRef object, const ValueRef index, const ValueRef v) @@ -254,7 +254,7 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const ValueRef object) case Value::Managed_Type: Q_ASSERT(object->isString()); proto = engine->stringObjectClass->prototype; - if (l->name->equals(engine->id_length)) { + if (l->name->equals(engine->id_length.getPointer())) { // special case, as the property is on the object itself l->getter = stringLengthGetter; return stringLengthGetter(l, object); @@ -331,7 +331,7 @@ ReturnedValue Lookup::getterFallback(Lookup *l, const ValueRef object) if (!o) return Encode::undefined(); QV4::ScopedString s(scope, l->name); - return o->get(s); + return o->get(s.getPointer()); } ReturnedValue Lookup::getter0(Lookup *l, const ValueRef object) @@ -712,7 +712,7 @@ void Lookup::setterGeneric(Lookup *l, const ValueRef object, const ValueRef valu if (!o) // type error return; ScopedString s(scope, l->name); - o->put(s, value); + o->put(s.getPointer(), value); return; } o->setLookup(l, value); @@ -743,7 +743,7 @@ void Lookup::setterFallback(Lookup *l, const ValueRef object, const ValueRef val QV4::ScopedObject o(scope, object->toObject(scope.engine->currentContext())); if (o) { QV4::ScopedString s(scope, l->name); - o->put(s, value); + o->put(s.getPointer(), value); } } diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 69e08bdab3..271fad7255 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -121,18 +121,18 @@ struct ObjectVTable ManagedVTable managedVTable; ReturnedValue (*call)(Managed *, CallData *data); ReturnedValue (*construct)(Managed *, CallData *data); - ReturnedValue (*get)(Managed *, const StringRef name, bool *hasProperty); + ReturnedValue (*get)(Managed *, String *name, bool *hasProperty); ReturnedValue (*getIndexed)(Managed *, uint index, bool *hasProperty); - void (*put)(Managed *, const StringRef name, const ValueRef value); + void (*put)(Managed *, String *name, const ValueRef value); void (*putIndexed)(Managed *, uint index, const ValueRef value); - PropertyAttributes (*query)(const Managed *, StringRef name); + PropertyAttributes (*query)(const Managed *, String *name); PropertyAttributes (*queryIndexed)(const Managed *, uint index); - bool (*deleteProperty)(Managed *m, const StringRef name); + bool (*deleteProperty)(Managed *m, String *name); bool (*deleteIndexedProperty)(Managed *m, uint index); ReturnedValue (*getLookup)(Managed *m, Lookup *l); void (*setLookup)(Managed *m, Lookup *l, const ValueRef v); uint (*getLength)(const Managed *m); - void (*advanceIterator)(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attributes); + void (*advanceIterator)(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes); }; diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index d24ae97d41..a9218cad35 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -104,7 +104,7 @@ void Object::put(ExecutionContext *ctx, const QString &name, const ValueRef valu { Scope scope(ctx); ScopedString n(scope, ctx->d()->engine->newString(name)); - put(n, value); + put(n.getPointer(), value); } ReturnedValue Object::getValue(const ValueRef thisObject, const Property *p, PropertyAttributes attrs) @@ -154,7 +154,7 @@ void Object::defineDefaultProperty(const QString &name, ValueRef value) ExecutionEngine *e = engine(); Scope scope(e); ScopedString s(scope, e->newIdentifier(name)); - defineDefaultProperty(s, value); + defineDefaultProperty(s.getPointer(), value); } void Object::defineDefaultProperty(const QString &name, ReturnedValue (*code)(CallContext *), int argumentCount) @@ -162,12 +162,12 @@ void Object::defineDefaultProperty(const QString &name, ReturnedValue (*code)(Ca ExecutionEngine *e = engine(); Scope scope(e); ScopedString s(scope, e->newIdentifier(name)); - Scoped<FunctionObject> function(scope, e->newBuiltinFunction(e->rootContext, s, code)); + Scoped<FunctionObject> function(scope, e->newBuiltinFunction(e->rootContext, s.getPointer(), code)); function->defineReadonlyProperty(e->id_length, Primitive::fromInt32(argumentCount)); - defineDefaultProperty(s, function); + defineDefaultProperty(s.getPointer(), function); } -void Object::defineDefaultProperty(const StringRef name, ReturnedValue (*code)(CallContext *), int argumentCount) +void Object::defineDefaultProperty(String *name, ReturnedValue (*code)(CallContext *), int argumentCount) { ExecutionEngine *e = engine(); Scope scope(e); @@ -181,10 +181,10 @@ void Object::defineAccessorProperty(const QString &name, ReturnedValue (*getter) ExecutionEngine *e = engine(); Scope scope(e); Scoped<String> s(scope, e->newIdentifier(name)); - defineAccessorProperty(s, getter, setter); + defineAccessorProperty(s.getPointer(), getter, setter); } -void Object::defineAccessorProperty(const StringRef name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)) +void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)) { ExecutionEngine *v4 = engine(); QV4::Scope scope(v4); @@ -199,10 +199,10 @@ void Object::defineReadonlyProperty(const QString &name, ValueRef value) QV4::ExecutionEngine *e = engine(); Scope scope(e); ScopedString s(scope, e->newIdentifier(name)); - defineReadonlyProperty(s, value); + defineReadonlyProperty(s.getPointer(), value); } -void Object::defineReadonlyProperty(const StringRef name, ValueRef value) +void Object::defineReadonlyProperty(String *name, ValueRef value) { insertMember(name, value, Attr_ReadOnly); } @@ -221,10 +221,10 @@ void Object::ensureMemberIndex(uint idx) memberData().ensureIndex(engine(), idx); } -void Object::insertMember(const StringRef s, const Property &p, PropertyAttributes attributes) +void Object::insertMember(String *s, const Property &p, PropertyAttributes attributes) { uint idx; - InternalClass::addMember(this, s.getPointer(), attributes, &idx); + InternalClass::addMember(this, s, attributes, &idx); ensureMemberIndex(internalClass()->size); @@ -240,7 +240,7 @@ void Object::insertMember(const StringRef s, const Property &p, PropertyAttribut } // Section 8.12.1 -Property *Object::__getOwnProperty__(const StringRef name, PropertyAttributes *attrs) +Property *Object::__getOwnProperty__(String *name, PropertyAttributes *attrs) { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) @@ -278,7 +278,7 @@ Property *Object::__getOwnProperty__(uint index, PropertyAttributes *attrs) } // Section 8.12.2 -Property *Object::__getPropertyDescriptor__(const StringRef name, PropertyAttributes *attrs) const +Property *Object::__getPropertyDescriptor__(String *name, PropertyAttributes *attrs) const { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) @@ -287,7 +287,7 @@ Property *Object::__getPropertyDescriptor__(const StringRef name, PropertyAttrib const Object *o = this; while (o) { - uint idx = o->internalClass()->find(name.getPointer()); + uint idx = o->internalClass()->find(name); if (idx < UINT_MAX) { if (attrs) *attrs = o->internalClass()->propertyData[idx]; @@ -326,7 +326,7 @@ Property *Object::__getPropertyDescriptor__(uint index, PropertyAttributes *attr return 0; } -bool Object::hasProperty(const StringRef name) const +bool Object::hasProperty(String *name) const { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) @@ -356,7 +356,7 @@ bool Object::hasProperty(uint index) const return false; } -bool Object::hasOwnProperty(const StringRef name) const +bool Object::hasOwnProperty(String *name) const { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) @@ -393,7 +393,7 @@ ReturnedValue Object::call(Managed *m, CallData *) return m->engine()->currentContext()->throwTypeError(); } -ReturnedValue Object::get(Managed *m, const StringRef name, bool *hasProperty) +ReturnedValue Object::get(Managed *m, String *name, bool *hasProperty) { return static_cast<Object *>(m)->internalGet(name, hasProperty); } @@ -403,7 +403,7 @@ ReturnedValue Object::getIndexed(Managed *m, uint index, bool *hasProperty) return static_cast<Object *>(m)->internalGetIndexed(index, hasProperty); } -void Object::put(Managed *m, const StringRef name, const ValueRef value) +void Object::put(Managed *m, String *name, const ValueRef value) { static_cast<Object *>(m)->internalPut(name, value); } @@ -413,14 +413,14 @@ void Object::putIndexed(Managed *m, uint index, const ValueRef value) static_cast<Object *>(m)->internalPutIndexed(index, value); } -PropertyAttributes Object::query(const Managed *m, StringRef name) +PropertyAttributes Object::query(const Managed *m, String *name) { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) return queryIndexed(m, idx); const Object *o = static_cast<const Object *>(m); - idx = o->internalClass()->find(name.getPointer()); + idx = o->internalClass()->find(name); if (idx < UINT_MAX) return o->internalClass()->propertyData[idx]; @@ -441,7 +441,7 @@ PropertyAttributes Object::queryIndexed(const Managed *m, uint index) return Attr_Invalid; } -bool Object::deleteProperty(Managed *m, const StringRef name) +bool Object::deleteProperty(Managed *m, String *name) { return static_cast<Object *>(m)->internalDeleteProperty(name); } @@ -505,7 +505,7 @@ void Object::setLookup(Managed *m, Lookup *l, const ValueRef value) } ScopedString s(scope, l->name); - o->put(s, value); + o->put(s.getPointer(), value); if (o->internalClass() == c) return; @@ -534,7 +534,7 @@ void Object::setLookup(Managed *m, Lookup *l, const ValueRef value) l->setter = Lookup::setterGeneric; } -void Object::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *pd, PropertyAttributes *attrs) +void Object::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *pd, PropertyAttributes *attrs) { Object *o = static_cast<Object *>(m); name = (String *)0; @@ -601,7 +601,7 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uin } // Section 8.12.3 -ReturnedValue Object::internalGet(const StringRef name, bool *hasProperty) +ReturnedValue Object::internalGet(String *name, bool *hasProperty) { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) @@ -611,7 +611,7 @@ ReturnedValue Object::internalGet(const StringRef name, bool *hasProperty) Object *o = this; while (o) { - uint idx = o->internalClass()->find(name.getPointer()); + uint idx = o->internalClass()->find(name); if (idx < UINT_MAX) { if (hasProperty) *hasProperty = true; @@ -661,7 +661,7 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) // Section 8.12.5 -void Object::internalPut(const StringRef name, const ValueRef value) +void Object::internalPut(String *name, const ValueRef value) { if (internalClass()->engine->hasException) return; @@ -672,7 +672,7 @@ void Object::internalPut(const StringRef name, const ValueRef value) name->makeIdentifier(); - uint member = internalClass()->find(name.getPointer()); + uint member = internalClass()->find(name); Property *pd = 0; PropertyAttributes attrs; if (member < UINT_MAX) { @@ -814,7 +814,7 @@ void Object::internalPutIndexed(uint index, const ValueRef value) } // Section 8.12.7 -bool Object::internalDeleteProperty(const StringRef name) +bool Object::internalDeleteProperty(String *name) { if (internalClass()->engine->hasException) return false; @@ -853,7 +853,7 @@ bool Object::internalDeleteIndexedProperty(uint index) } // Section 8.12.9 -bool Object::__defineOwnProperty__(ExecutionContext *ctx, const StringRef name, const Property &p, PropertyAttributes attrs) +bool Object::__defineOwnProperty__(ExecutionContext *ctx, String *name, const Property &p, PropertyAttributes attrs) { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) @@ -895,7 +895,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, const StringRef name, } // Clause 1 - memberIndex = internalClass()->find(name.getPointer()); + memberIndex = internalClass()->find(name); current = (memberIndex < UINT_MAX) ? propertyAt(memberIndex) : 0; cattrs = internalClass()->propertyData.constData() + memberIndex; @@ -963,14 +963,14 @@ bool Object::defineOwnProperty2(ExecutionContext *ctx, uint index, const Propert return true; } - return __defineOwnProperty__(ctx, index, StringRef::null(), p, attrs); + return __defineOwnProperty__(ctx, index, 0, p, attrs); reject: if (ctx->d()->strictMode) ctx->throwTypeError(); return false; } -bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const StringRef member, const Property &p, PropertyAttributes attrs) +bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, String *member, const Property &p, PropertyAttributes attrs) { // clause 5 if (attrs.isEmpty()) @@ -978,7 +978,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri Property *current; PropertyAttributes cattrs; - if (!member.isNull()) { + if (member) { current = propertyAt(index); cattrs = internalClass()->propertyData[index]; } else { @@ -1011,7 +1011,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri // 9b cattrs.setType(PropertyAttributes::Accessor); cattrs.clearWritable(); - if (member.isNull()) { + if (!member) { // need to convert the array and the slot initSparseArray(); setArrayAttributes(index, cattrs); @@ -1023,7 +1023,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri // 9c cattrs.setType(PropertyAttributes::Data); cattrs.setWritable(false); - if (member.isNull()) { + if (!member) { // need to convert the array and the slot setArrayAttributes(index, cattrs); current = arrayData()->getProperty(index); @@ -1048,8 +1048,8 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri accept: current->merge(cattrs, p, attrs); - if (!member.isNull()) { - InternalClass::changeMember(this, member.getPointer(), cattrs); + if (member) { + InternalClass::changeMember(this, member, cattrs); } else { setArrayAttributes(index, cattrs); } @@ -1067,7 +1067,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, const QString &name, c { Scope scope(ctx); ScopedString s(scope, ctx->d()->engine->newString(name)); - return __defineOwnProperty__(ctx, s, p, attrs); + return __defineOwnProperty__(ctx, s.getPointer(), p, attrs); } diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index f4b23d8cb3..3be5039548 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -133,20 +133,20 @@ struct Q_QML_EXPORT Object: Managed { Object *prototype() const { return internalClass()->prototype; } bool setPrototype(Object *proto); - Property *__getOwnProperty__(const StringRef name, PropertyAttributes *attrs = 0); + Property *__getOwnProperty__(String *name, PropertyAttributes *attrs = 0); Property *__getOwnProperty__(uint index, PropertyAttributes *attrs = 0); - Property *__getPropertyDescriptor__(const StringRef name, PropertyAttributes *attrs = 0) const; + Property *__getPropertyDescriptor__(String *name, PropertyAttributes *attrs = 0) const; Property *__getPropertyDescriptor__(uint index, PropertyAttributes *attrs = 0) const; - bool hasProperty(const StringRef name) const; + bool hasProperty(String *name) const; bool hasProperty(uint index) const; - bool hasOwnProperty(const StringRef name) const; + bool hasOwnProperty(String *name) const; bool hasOwnProperty(uint index) const; - bool __defineOwnProperty__(ExecutionContext *ctx, uint index, const StringRef member, const Property &p, PropertyAttributes attrs); - bool __defineOwnProperty__(ExecutionContext *ctx, const StringRef name, const Property &p, PropertyAttributes attrs); + bool __defineOwnProperty__(ExecutionContext *ctx, uint index, String *member, const Property &p, PropertyAttributes attrs); + bool __defineOwnProperty__(ExecutionContext *ctx, String *name, const Property &p, PropertyAttributes attrs); bool __defineOwnProperty__(ExecutionContext *ctx, uint index, const Property &p, PropertyAttributes attrs); bool __defineOwnProperty__(ExecutionContext *ctx, const QString &name, const Property &p, PropertyAttributes attrs); bool defineOwnProperty2(ExecutionContext *ctx, uint index, const Property &p, PropertyAttributes attrs); @@ -166,23 +166,23 @@ struct Q_QML_EXPORT Object: Managed { void putValue(Property *pd, PropertyAttributes attrs, const ValueRef value); /* The spec default: Writable: true, Enumerable: false, Configurable: true */ - void defineDefaultProperty(const StringRef name, ValueRef value) { + void defineDefaultProperty(String *name, ValueRef value) { insertMember(name, value, Attr_Data|Attr_NotEnumerable); } void defineDefaultProperty(const QString &name, ValueRef value); void defineDefaultProperty(const QString &name, ReturnedValue (*code)(CallContext *), int argumentCount = 0); - void defineDefaultProperty(const StringRef name, ReturnedValue (*code)(CallContext *), int argumentCount = 0); + void defineDefaultProperty(String *name, ReturnedValue (*code)(CallContext *), int argumentCount = 0); void defineAccessorProperty(const QString &name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)); - void defineAccessorProperty(const StringRef name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)); + void defineAccessorProperty(String *name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)); /* Fixed: Writable: false, Enumerable: false, Configurable: false */ void defineReadonlyProperty(const QString &name, ValueRef value); - void defineReadonlyProperty(const StringRef name, ValueRef value); + void defineReadonlyProperty(String *name, ValueRef value); - void insertMember(const StringRef s, const ValueRef v, PropertyAttributes attributes = Attr_Data) { + void insertMember(String *s, const ValueRef v, PropertyAttributes attributes = Attr_Data) { Property p(*v); insertMember(s, p, attributes); } - void insertMember(const StringRef s, const Property &p, PropertyAttributes attributes); + void insertMember(String *s, const Property &p, PropertyAttributes attributes); inline ExecutionEngine *engine() const { return internalClass()->engine; } @@ -258,19 +258,19 @@ public: } void ensureMemberIndex(uint idx); - inline ReturnedValue get(const StringRef name, bool *hasProperty = 0) + inline ReturnedValue get(String *name, bool *hasProperty = 0) { return vtable()->get(this, name, hasProperty); } inline ReturnedValue getIndexed(uint idx, bool *hasProperty = 0) { return vtable()->getIndexed(this, idx, hasProperty); } - inline void put(const StringRef name, const ValueRef v) + inline void put(String *name, const ValueRef v) { vtable()->put(this, name, v); } inline void putIndexed(uint idx, const ValueRef v) { vtable()->putIndexed(this, idx, v); } - PropertyAttributes query(StringRef name) const + PropertyAttributes query(String *name) const { return vtable()->query(this, name); } PropertyAttributes queryIndexed(uint index) const { return vtable()->queryIndexed(this, index); } - bool deleteProperty(const StringRef name) + bool deleteProperty(String *name) { return vtable()->deleteProperty(this, name); } bool deleteIndexedProperty(uint index) { return vtable()->deleteIndexedProperty(this, index); } @@ -278,7 +278,7 @@ public: { return vtable()->getLookup(this, l); } void setLookup(Lookup *l, const ValueRef v) { vtable()->setLookup(this, l, v); } - void advanceIterator(ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attributes) + void advanceIterator(ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes) { vtable()->advanceIterator(this, it, name, index, p, attributes); } uint getLength() const { return vtable()->getLength(this); } @@ -290,25 +290,25 @@ protected: static void markObjects(Managed *that, ExecutionEngine *e); static ReturnedValue construct(Managed *m, CallData *); static ReturnedValue call(Managed *m, CallData *); - static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty); + static ReturnedValue get(Managed *m, String *name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, const StringRef name, const ValueRef value); + static void put(Managed *m, String *name, const ValueRef value); static void putIndexed(Managed *m, uint index, const ValueRef value); - static PropertyAttributes query(const Managed *m, StringRef name); + static PropertyAttributes query(const Managed *m, String *name); static PropertyAttributes queryIndexed(const Managed *m, uint index); - static bool deleteProperty(Managed *m, const StringRef name); + static bool deleteProperty(Managed *m, String *name); static bool deleteIndexedProperty(Managed *m, uint index); static ReturnedValue getLookup(Managed *m, Lookup *l); static void setLookup(Managed *m, Lookup *l, const ValueRef v); - static void advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attributes); + static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes); static uint getLength(const Managed *m); private: - ReturnedValue internalGet(const StringRef name, bool *hasProperty); + ReturnedValue internalGet(String *name, bool *hasProperty); ReturnedValue internalGetIndexed(uint index, bool *hasProperty); - void internalPut(const StringRef name, const ValueRef value); + void internalPut(String *name, const ValueRef value); void internalPutIndexed(uint index, const ValueRef value); - bool internalDeleteProperty(const StringRef name); + bool internalDeleteProperty(String *name); bool internalDeleteIndexedProperty(uint index); friend struct ObjectIterator; diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index b0219cdff4..ff17d8fb20 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -80,7 +80,7 @@ ObjectIterator::ObjectIterator(Scope &scope, const ObjectRef o, uint flags) } } -void ObjectIterator::next(StringRef name, uint *index, Property *pd, PropertyAttributes *attrs) +void ObjectIterator::next(String *&name, uint *index, Property *pd, PropertyAttributes *attrs) { name = (String *)0; *index = UINT_MAX; @@ -137,7 +137,9 @@ ReturnedValue ObjectIterator::nextPropertyName(ValueRef value) uint index; Scope scope(object->engine()); ScopedString name(scope); - next(name, &index, &p, &attrs); + String *n; + next(n, &index, &p, &attrs); + name = n; if (attrs.isEmpty()) return Encode::null(); @@ -159,7 +161,9 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString(ValueRef value) uint index; Scope scope(object->engine()); ScopedString name(scope); - next(name, &index, &p, &attrs); + String *n; + next(n, &index, &p, &attrs); + name = n; if (attrs.isEmpty()) return Encode::null(); @@ -181,7 +185,9 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString() uint index; Scope scope(object->engine()); ScopedString name(scope); - next(name, &index, &p, &attrs); + String *n; + next(n, &index, &p, &attrs); + name = n; if (attrs.isEmpty()) return Encode::null(); diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index 9a212df5a5..8ee2ae4e4f 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -76,7 +76,7 @@ struct Q_QML_EXPORT ObjectIterator ObjectIterator(Value *scratch1, Value *scratch2, const ObjectRef o, uint flags); ObjectIterator(Scope &scope, const ObjectRef o, uint flags); - void next(StringRef name, uint *index, Property *pd, PropertyAttributes *attributes = 0); + void next(String *&name, uint *index, Property *pd, PropertyAttributes *attributes = 0); ReturnedValue nextPropertyName(ValueRef value); ReturnedValue nextPropertyNameAsString(ValueRef value); ReturnedValue nextPropertyNameAsString(); diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 48fea0d0bf..05ad95b400 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -133,10 +133,9 @@ void ObjectPrototype::init(ExecutionEngine *v4, ObjectRef ctor) defineDefaultProperty(QStringLiteral("__defineGetter__"), method_defineGetter, 2); defineDefaultProperty(QStringLiteral("__defineSetter__"), method_defineSetter, 2); - Scoped<String> id_proto(scope, v4->id___proto__); - Property p(v4->newBuiltinFunction(v4->rootContext, id_proto, method_get_proto)->getPointer(), - v4->newBuiltinFunction(v4->rootContext, id_proto, method_set_proto)->getPointer()); - insertMember(StringRef(v4->id___proto__), p, Attr_Accessor|Attr_NotEnumerable); + Property p(v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_get_proto)->getPointer(), + v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_set_proto)->getPointer()); + insertMember(v4->id___proto__, p, Attr_Accessor|Attr_NotEnumerable); } ReturnedValue ObjectPrototype::method_getPrototypeOf(CallContext *ctx) @@ -165,7 +164,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(CallContext *ctx) if (scope.hasException()) return Encode::undefined(); PropertyAttributes attrs; - Property *desc = O->__getOwnProperty__(name, &attrs); + Property *desc = O->__getOwnProperty__(name.getPointer(), &attrs); return fromPropertyDescriptor(ctx, desc, attrs); } @@ -216,7 +215,7 @@ ReturnedValue ObjectPrototype::method_defineProperty(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); - if (!O->__defineOwnProperty__(ctx, name, pd, attrs)) + if (!O->__defineOwnProperty__(ctx, name.getPointer(), pd, attrs)) return ctx->throwTypeError(); return O.asReturnedValue(); @@ -240,7 +239,9 @@ ReturnedValue ObjectPrototype::method_defineProperties(CallContext *ctx) uint index; PropertyAttributes attrs; Property pd; - it.next(name, &index, &pd, &attrs); + String *nm; + it.next(nm, &index, &pd, &attrs); + name = nm; if (attrs.isEmpty()) break; Property n; @@ -251,7 +252,7 @@ ReturnedValue ObjectPrototype::method_defineProperties(CallContext *ctx) return Encode::undefined(); bool ok; if (name) - ok = O->__defineOwnProperty__(ctx, name, n, nattrs); + ok = O->__defineOwnProperty__(ctx, name.getPointer(), n, nattrs); else ok = O->__defineOwnProperty__(ctx, index, n, nattrs); if (!ok) @@ -455,9 +456,9 @@ ReturnedValue ObjectPrototype::method_hasOwnProperty(CallContext *ctx) Scoped<Object> O(scope, ctx->d()->callData->thisObject, Scoped<Object>::Convert); if (scope.engine->hasException) return Encode::undefined(); - bool r = O->hasOwnProperty(P); + bool r = O->hasOwnProperty(P.getPointer()); if (!r) - r = !O->query(P).isEmpty(); + r = !O->query(P.getPointer()).isEmpty(); return Encode(r); } @@ -491,7 +492,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); PropertyAttributes attrs; - o->__getOwnProperty__(p, &attrs); + o->__getOwnProperty__(p.getPointer(), &attrs); return Encode(attrs.isEnumerable()); } @@ -519,7 +520,7 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx) Property pd; pd.value = f; pd.set = Primitive::emptyValue(); - o->__defineOwnProperty__(ctx, prop, pd, Attr_Accessor); + o->__defineOwnProperty__(ctx, prop.getPointer(), pd, Attr_Accessor); return Encode::undefined(); } @@ -547,7 +548,7 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx) Property pd; pd.value = Primitive::emptyValue(); pd.set = f; - o->__defineOwnProperty__(ctx, prop, pd, Attr_Accessor); + o->__defineOwnProperty__(ctx, prop.getPointer(), pd, Attr_Accessor); return Encode::undefined(); } @@ -671,24 +672,24 @@ ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionContext *ctx, con if (attrs.isData()) { pd.value = desc->value; s = engine->newString(QStringLiteral("value")); - o->__defineOwnProperty__(ctx, s, pd, Attr_Data); + o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data); pd.value = Primitive::fromBoolean(attrs.isWritable()); s = engine->newString(QStringLiteral("writable")); - o->__defineOwnProperty__(ctx, s, pd, Attr_Data); + o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data); } else { pd.value = desc->getter() ? desc->getter()->asReturnedValue() : Encode::undefined(); s = engine->newString(QStringLiteral("get")); - o->__defineOwnProperty__(ctx, s, pd, Attr_Data); + o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data); pd.value = desc->setter() ? desc->setter()->asReturnedValue() : Encode::undefined(); s = engine->newString(QStringLiteral("set")); - o->__defineOwnProperty__(ctx, s, pd, Attr_Data); + o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data); } pd.value = Primitive::fromBoolean(attrs.isEnumerable()); s = engine->newString(QStringLiteral("enumerable")); - o->__defineOwnProperty__(ctx, s, pd, Attr_Data); + o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data); pd.value = Primitive::fromBoolean(attrs.isConfigurable()); s = engine->newString(QStringLiteral("configurable")); - o->__defineOwnProperty__(ctx, s, pd, Attr_Data); + o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data); return o.asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index a731eee624..791ea0efc9 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -314,7 +314,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD } } } - return QV4::Object::get(this, name, hasProperty); + return QV4::Object::get(this, name.getPointer(), hasProperty); } QQmlData *ddata = QQmlData::get(d()->object, false); @@ -352,8 +352,8 @@ ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx QV4::ScopedString connect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("connect"))); QV4::ScopedString disconnect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("disconnect"))); - handler->put(connect, QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(connect))); - handler->put(disconnect, QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(disconnect))); + handler->put(connect.getPointer(), QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(connect.getPointer()))); + handler->put(disconnect.getPointer(), QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(disconnect.getPointer()))); return handler.asReturnedValue(); } else { @@ -664,15 +664,15 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object) return (new (engine->memoryManager) QV4::QObjectWrapper(engine, object))->asReturnedValue(); } -QV4::ReturnedValue QObjectWrapper::get(Managed *m, const StringRef name, bool *hasProperty) +QV4::ReturnedValue QObjectWrapper::get(Managed *m, String *name, bool *hasProperty) { QObjectWrapper *that = static_cast<QObjectWrapper*>(m); ExecutionEngine *v4 = m->engine(); QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4); - return that->getQmlProperty(v4->currentContext(), qmlContext, name.getPointer(), IgnoreRevision, hasProperty, /*includeImports*/ true); + return that->getQmlProperty(v4->currentContext(), qmlContext, name, IgnoreRevision, hasProperty, /*includeImports*/ true); } -void QObjectWrapper::put(Managed *m, const StringRef name, const ValueRef value) +void QObjectWrapper::put(Managed *m, String *name, const ValueRef value) { QObjectWrapper *that = static_cast<QObjectWrapper*>(m); ExecutionEngine *v4 = m->engine(); @@ -681,7 +681,7 @@ void QObjectWrapper::put(Managed *m, const StringRef name, const ValueRef value) return; QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4); - if (!setQmlProperty(v4->currentContext(), qmlContext, that->d()->object, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value)) { + if (!setQmlProperty(v4->currentContext(), qmlContext, that->d()->object, name, QV4::QObjectWrapper::IgnoreRevision, value)) { QQmlData *ddata = QQmlData::get(that->d()->object); // Types created by QML are not extensible at run-time, but for other QObjects we can store them // as regular JavaScript properties, like on JavaScript objects. @@ -695,7 +695,7 @@ void QObjectWrapper::put(Managed *m, const StringRef name, const ValueRef value) } } -PropertyAttributes QObjectWrapper::query(const Managed *m, StringRef name) +PropertyAttributes QObjectWrapper::query(const Managed *m, String *name) { const QObjectWrapper *that = static_cast<const QObjectWrapper*>(m); ExecutionEngine *engine = that->engine(); @@ -708,7 +708,7 @@ PropertyAttributes QObjectWrapper::query(const Managed *m, StringRef name) return QV4::Object::query(m, name); } -void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attributes) +void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes) { // Used to block access to QObject::destroyed() and QObject::deleteLater() from QML static const int destroyedIdx1 = QObject::staticMetaObject.indexOfSignal("destroyed(QObject*)"); @@ -724,7 +724,7 @@ void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, StringRef n const QMetaObject *mo = that->d()->object->metaObject(); const int propertyCount = mo->propertyCount(); if (it->arrayIndex < static_cast<uint>(propertyCount)) { - name = that->engine()->newString(QString::fromUtf8(mo->property(it->arrayIndex).name())); + name = that->engine()->newString(QString::fromUtf8(mo->property(it->arrayIndex).name()))->getPointer(); ++it->arrayIndex; *attributes = QV4::Attr_Data; p->value = that->get(name); @@ -737,7 +737,7 @@ void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, StringRef n ++it->arrayIndex; if (method.access() == QMetaMethod::Private || index == deleteLaterIdx || index == destroyedIdx1 || index == destroyedIdx2) continue; - name = that->engine()->newString(QString::fromUtf8(method.name())); + name = that->engine()->newString(QString::fromUtf8(method.name()))->getPointer(); *attributes = QV4::Attr_Data; p->value = that->get(name); return; diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index e1ec5be03a..3164eb78f3 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -117,10 +117,10 @@ private: QQmlPropertyData *findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const; - static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty); - static void put(Managed *m, const StringRef name, const ValueRef value); - static PropertyAttributes query(const Managed *, StringRef name); - static void advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attributes); + static ReturnedValue get(Managed *m, String *name, bool *hasProperty); + static void put(Managed *m, String *name, const ValueRef value); + static PropertyAttributes query(const Managed *, String *name); + static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes); static void markObjects(Managed *that, QV4::ExecutionEngine *e); static void destroy(Managed *that); diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 7e3400d4a6..ab51ac7abd 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -151,7 +151,7 @@ void RegExpObject::init(ExecutionEngine *engine) ScopedString lastIndex(scope, engine->newIdentifier(QStringLiteral("lastIndex"))); ScopedValue v(scope, Primitive::fromInt32(0)); - insertMember(lastIndex, v, Attr_NotEnumerable|Attr_NotConfigurable); + insertMember(lastIndex.getPointer(), v, Attr_NotEnumerable|Attr_NotConfigurable); if (!this->value()) return; @@ -211,7 +211,7 @@ QString RegExpObject::source() const { Scope scope(engine()); ScopedString source(scope, scope.engine->newIdentifier(QStringLiteral("source"))); - ScopedValue s(scope, const_cast<RegExpObject *>(this)->get(source)); + ScopedValue s(scope, const_cast<RegExpObject *>(this)->get(source.getPointer())); return s->toQString(); } diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 3fa8db9098..3aca34e086 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -283,10 +283,10 @@ ReturnedValue Runtime::deleteElement(ExecutionContext *ctx, const ValueRef base, } ScopedString name(scope, index->toString(ctx)); - return Runtime::deleteMember(ctx, base, name); + return Runtime::deleteMember(ctx, base, name.getPointer()); } -ReturnedValue Runtime::deleteMember(ExecutionContext *ctx, const ValueRef base, const StringRef name) +ReturnedValue Runtime::deleteMember(ExecutionContext *ctx, const ValueRef base, String *name) { Scope scope(ctx); ScopedObject obj(scope, base->toObject(ctx)); @@ -295,7 +295,7 @@ ReturnedValue Runtime::deleteMember(ExecutionContext *ctx, const ValueRef base, return Encode(obj->deleteProperty(name)); } -ReturnedValue Runtime::deleteName(ExecutionContext *ctx, const StringRef name) +ReturnedValue Runtime::deleteName(ExecutionContext *ctx, String *name) { Scope scope(ctx); return Encode(ctx->deleteProperty(name)); @@ -341,7 +341,7 @@ QV4::ReturnedValue Runtime::in(ExecutionContext *ctx, const ValueRef left, const ScopedString s(scope, left->toString(ctx)); if (scope.hasException()) return Encode::undefined(); - bool r = right->objectValue()->hasProperty(s); + bool r = right->objectValue()->hasProperty(s.getPointer()); return Encode(r); } @@ -551,7 +551,7 @@ QV4::ReturnedValue Runtime::addString(QV4::ExecutionContext *ctx, const QV4::Val return (new (ctx->engine()->memoryManager) String(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue(); } -void Runtime::setProperty(ExecutionContext *ctx, const ValueRef object, const StringRef name, const ValueRef value) +void Runtime::setProperty(ExecutionContext *ctx, const ValueRef object, String *name, const ValueRef value) { Scope scope(ctx); ScopedObject o(scope, object->toObject(ctx)); @@ -600,7 +600,7 @@ ReturnedValue Runtime::getElement(ExecutionContext *ctx, const ValueRef object, ScopedString name(scope, index->toString(ctx)); if (scope.hasException()) return Encode::undefined(); - return o->get(name); + return o->get(name.getPointer()); } void Runtime::setElement(ExecutionContext *ctx, const ValueRef object, const ValueRef index, const ValueRef value) @@ -624,7 +624,7 @@ void Runtime::setElement(ExecutionContext *ctx, const ValueRef object, const Val } ScopedString name(scope, index->toString(ctx)); - o->put(name, value); + o->put(name.getPointer(), value); } ReturnedValue Runtime::foreachIterator(ExecutionContext *ctx, const ValueRef in) @@ -648,12 +648,12 @@ ReturnedValue Runtime::foreachNextPropertyName(const ValueRef foreach_iterator) } -void Runtime::setActivationProperty(ExecutionContext *ctx, const StringRef name, const ValueRef value) +void Runtime::setActivationProperty(ExecutionContext *ctx, String *name, const ValueRef value) { ctx->setProperty(name, value); } -ReturnedValue Runtime::getProperty(ExecutionContext *ctx, const ValueRef object, const StringRef name) +ReturnedValue Runtime::getProperty(ExecutionContext *ctx, const ValueRef object, String *name) { Scope scope(ctx); @@ -672,7 +672,7 @@ ReturnedValue Runtime::getProperty(ExecutionContext *ctx, const ValueRef object, return o->get(name); } -ReturnedValue Runtime::getActivationProperty(ExecutionContext *ctx, const StringRef name) +ReturnedValue Runtime::getActivationProperty(ExecutionContext *ctx, String *name) { return ctx->getProperty(name); } @@ -883,7 +883,7 @@ ReturnedValue Runtime::callGlobalLookup(ExecutionContext *context, uint index, C } -ReturnedValue Runtime::callActivationProperty(ExecutionContext *context, const StringRef name, CallDataRef callData) +ReturnedValue Runtime::callActivationProperty(ExecutionContext *context, String *name, CallDataRef callData) { Q_ASSERT(callData->thisObject.isUndefined()); Scope scope(context); @@ -912,7 +912,7 @@ ReturnedValue Runtime::callActivationProperty(ExecutionContext *context, const S return o->call(callData); } -ReturnedValue Runtime::callProperty(ExecutionContext *context, const StringRef name, CallDataRef callData) +ReturnedValue Runtime::callProperty(ExecutionContext *context, String *name, CallDataRef callData) { Scope scope(context); Scoped<Object> baseObject(scope, callData->thisObject); @@ -959,7 +959,7 @@ ReturnedValue Runtime::callElement(ExecutionContext *context, const ValueRef ind return Encode::undefined(); callData->thisObject = baseObject; - ScopedObject o(scope, baseObject->get(s)); + ScopedObject o(scope, baseObject->get(s.getPointer())); if (!o) return context->throwTypeError(); @@ -989,7 +989,7 @@ ReturnedValue Runtime::constructGlobalLookup(ExecutionContext *context, uint ind } -ReturnedValue Runtime::constructActivationProperty(ExecutionContext *context, const StringRef name, CallDataRef callData) +ReturnedValue Runtime::constructActivationProperty(ExecutionContext *context, String *name, CallDataRef callData) { Scope scope(context); ScopedValue func(scope, context->getProperty(name)); @@ -1012,7 +1012,7 @@ ReturnedValue Runtime::constructValue(ExecutionContext *context, const ValueRef return f->construct(callData); } -ReturnedValue Runtime::constructProperty(ExecutionContext *context, const StringRef name, CallDataRef callData) +ReturnedValue Runtime::constructProperty(ExecutionContext *context, String *name, CallDataRef callData) { Scope scope(context); ScopedObject thisObject(scope, callData->thisObject.toObject(context)); @@ -1073,7 +1073,7 @@ ReturnedValue Runtime::typeofValue(ExecutionContext *ctx, const ValueRef value) return res.asReturnedValue(); } -QV4::ReturnedValue Runtime::typeofName(ExecutionContext *context, const StringRef name) +QV4::ReturnedValue Runtime::typeofName(ExecutionContext *context, String *name) { Scope scope(context); ScopedValue prop(scope, context->getProperty(name)); @@ -1082,7 +1082,7 @@ QV4::ReturnedValue Runtime::typeofName(ExecutionContext *context, const StringRe return Runtime::typeofValue(context, prop); } -QV4::ReturnedValue Runtime::typeofMember(ExecutionContext *context, const ValueRef base, const StringRef name) +QV4::ReturnedValue Runtime::typeofMember(ExecutionContext *context, const ValueRef base, String *name) { Scope scope(context); ScopedObject obj(scope, base->toObject(context)); @@ -1099,7 +1099,7 @@ QV4::ReturnedValue Runtime::typeofElement(ExecutionContext *context, const Value ScopedObject obj(scope, base->toObject(context)); if (scope.engine->hasException) return Encode::undefined(); - ScopedValue prop(scope, obj->get(name)); + ScopedValue prop(scope, obj->get(name.getPointer())); return Runtime::typeofValue(context, prop); } @@ -1117,7 +1117,7 @@ ReturnedValue Runtime::unwindException(ExecutionContext *ctx) return ctx->engine()->catchException(ctx, 0); } -ExecutionContext *Runtime::pushCatchScope(ExecutionContext *ctx, const StringRef exceptionVarName) +ExecutionContext *Runtime::pushCatchScope(ExecutionContext *ctx, String *exceptionVarName) { Scope scope(ctx); ScopedValue v(scope, ctx->engine()->catchException(ctx, 0)); @@ -1129,7 +1129,7 @@ ExecutionContext *Runtime::popScope(ExecutionContext *ctx) return ctx->engine()->popContext(); } -void Runtime::declareVar(ExecutionContext *ctx, bool deletable, const StringRef name) +void Runtime::declareVar(ExecutionContext *ctx, bool deletable, String *name) { ctx->createMutableBinding(name, deletable); } @@ -1344,7 +1344,7 @@ ReturnedValue Runtime::getQmlImportedScripts(NoThrowContext *ctx) return context->importedScripts.value(); } -QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowContext *ctx, const QV4::StringRef name) +QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowContext *ctx, String *name) { return ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->qmlSingletonWrapper(ctx->engine()->v8Engine, name); } diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 0979105680..b4417bd13e 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -106,50 +106,50 @@ struct NoThrowContext : public ExecutionContext struct Q_QML_PRIVATE_EXPORT Runtime { // call static ReturnedValue callGlobalLookup(ExecutionContext *context, uint index, CallDataRef callData); - static ReturnedValue callActivationProperty(ExecutionContext *, const StringRef name, CallDataRef callData); - static ReturnedValue callProperty(ExecutionContext *context, const StringRef name, CallDataRef callData); + static ReturnedValue callActivationProperty(ExecutionContext *, String *name, CallDataRef callData); + static ReturnedValue callProperty(ExecutionContext *context, String *name, CallDataRef callData); static ReturnedValue callPropertyLookup(ExecutionContext *context, uint index, CallDataRef callData); static ReturnedValue callElement(ExecutionContext *context, const ValueRef index, CallDataRef callData); static ReturnedValue callValue(ExecutionContext *context, const ValueRef func, CallDataRef callData); // construct static ReturnedValue constructGlobalLookup(ExecutionContext *context, uint index, CallDataRef callData); - static ReturnedValue constructActivationProperty(ExecutionContext *, const StringRef name, CallDataRef callData); - static ReturnedValue constructProperty(ExecutionContext *context, const StringRef name, CallDataRef callData); + static ReturnedValue constructActivationProperty(ExecutionContext *, String *name, CallDataRef callData); + static ReturnedValue constructProperty(ExecutionContext *context, String *name, CallDataRef callData); static ReturnedValue constructPropertyLookup(ExecutionContext *context, uint index, CallDataRef callData); static ReturnedValue constructValue(ExecutionContext *context, const ValueRef func, CallDataRef callData); // set & get - static void setActivationProperty(ExecutionContext *ctx, const StringRef name, const ValueRef value); - static void setProperty(ExecutionContext *ctx, const ValueRef object, const StringRef name, const ValueRef value); + static void setActivationProperty(ExecutionContext *ctx, String *name, const ValueRef value); + static void setProperty(ExecutionContext *ctx, const ValueRef object, String *name, const ValueRef value); static void setElement(ExecutionContext *ctx, const ValueRef object, const ValueRef index, const ValueRef value); - static ReturnedValue getProperty(ExecutionContext *ctx, const ValueRef object, const StringRef name); - static ReturnedValue getActivationProperty(ExecutionContext *ctx, const StringRef name); + static ReturnedValue getProperty(ExecutionContext *ctx, const ValueRef object, String *name); + static ReturnedValue getActivationProperty(ExecutionContext *ctx, String *name); static ReturnedValue getElement(ExecutionContext *ctx, const ValueRef object, const ValueRef index); // typeof static ReturnedValue typeofValue(ExecutionContext *ctx, const ValueRef val); - static ReturnedValue typeofName(ExecutionContext *context, const StringRef name); - static ReturnedValue typeofMember(ExecutionContext* context, const ValueRef base, const StringRef name); + static ReturnedValue typeofName(ExecutionContext *context, String *name); + static ReturnedValue typeofMember(ExecutionContext* context, const ValueRef base, String *name); static ReturnedValue typeofElement(ExecutionContext* context, const ValueRef base, const ValueRef index); // delete static ReturnedValue deleteElement(ExecutionContext *ctx, const ValueRef base, const ValueRef index); - static ReturnedValue deleteMember(ExecutionContext *ctx, const ValueRef base, const StringRef name); - static ReturnedValue deleteName(ExecutionContext *ctx, const StringRef name); + static ReturnedValue deleteMember(ExecutionContext *ctx, const ValueRef base, String *name); + static ReturnedValue deleteName(ExecutionContext *ctx, String *name); // exceptions & scopes static void throwException(ExecutionContext*, const ValueRef value); static ReturnedValue unwindException(ExecutionContext *ctx); static ExecutionContext *pushWithScope(const ValueRef o, ExecutionContext *ctx); - static ExecutionContext *pushCatchScope(ExecutionContext *ctx, const StringRef exceptionVarName); + static ExecutionContext *pushCatchScope(ExecutionContext *ctx, String *exceptionVarName); static ExecutionContext *popScope(ExecutionContext *ctx); // closures static ReturnedValue closure(ExecutionContext *ctx, int functionId); // function header - static void declareVar(ExecutionContext *ctx, bool deletable, const StringRef name); + static void declareVar(ExecutionContext *ctx, bool deletable, String *name); static ReturnedValue setupArgumentsObject(ExecutionContext *ctx); static void convertThisToObject(ExecutionContext *ctx); @@ -226,7 +226,7 @@ struct Q_QML_PRIVATE_EXPORT Runtime { static ReturnedValue getQmlImportedScripts(NoThrowContext *ctx); static ReturnedValue getQmlContextObject(NoThrowContext *ctx); static ReturnedValue getQmlScopeObject(NoThrowContext *ctx); - static ReturnedValue getQmlSingleton(NoThrowContext *ctx, const StringRef name); + static ReturnedValue getQmlSingleton(NoThrowContext *ctx, String *name); static ReturnedValue getQmlAttachedProperty(ExecutionContext *ctx, int attachedPropertiesId, int propertyIndex); static ReturnedValue getQmlQObjectProperty(ExecutionContext *ctx, const ValueRef object, int propertyIndex, bool captureRequired); static void setQmlQObjectProperty(ExecutionContext *ctx, const ValueRef object, int propertyIndex, const ValueRef value); diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 23fc091d73..97ad97b45f 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -308,6 +308,9 @@ struct Scoped return *this; } + operator T *() { + return static_cast<T *>(ptr->managed()); + } T *operator->() { return static_cast<T *>(ptr->managed()); @@ -379,7 +382,6 @@ struct ScopedCallData { }; -struct StringRef; struct ObjectRef; struct FunctionObjectRef; diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index fa856be6a2..a7d3845d41 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -155,7 +155,7 @@ Returned<FunctionObject> *QmlBindingWrapper::createQmlCallableForFunction(QQmlCo p->setGetter(new (engine->memoryManager) QV4::IndexedBuiltinFunction(wrapper->context(), index++, signalParameterGetter)); p->setSetter(0); s = engine->newString(QString::fromUtf8(param)); - qmlScopeObject->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable); + qmlScopeObject->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable); } } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 6dbe787ab5..6c964adfe4 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -300,7 +300,7 @@ public: return (signedIdx < d()->container.count()) ? QV4::Attr_Data : QV4::Attr_Invalid; } - void containerAdvanceIterator(ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attrs) + void containerAdvanceIterator(ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs) { name = (String *)0; *index = UINT_MAX; @@ -519,7 +519,7 @@ private: { return static_cast<QQmlSequence<Container> *>(that)->containerDeleteIndexedProperty(index); } static bool isEqualTo(Managed *that, Managed *other) { return static_cast<QQmlSequence<Container> *>(that)->containerIsEqualTo(other); } - static void advanceIterator(Managed *that, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attrs) + static void advanceIterator(Managed *that, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs) { return static_cast<QQmlSequence<Container> *>(that)->containerAdvanceIterator(it, name, index, p, attrs); } static void destroy(Managed *that) diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index 244ca73efa..4e88a331a4 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -281,7 +281,7 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, QV8Engine *en QV4::ExecutionContext *ctx = v4->currentContext(); str = s; - val = o->get(str); + val = o->get(str.getPointer()); if (scope.hasException()) ctx->catchException(); @@ -342,7 +342,7 @@ ReturnedValue Serialize::deserialize(const char *&data, QV8Engine *engine) name = deserialize(data, engine); value = deserialize(data, engine); n = name.asReturnedValue(); - o->put(n, value); + o->put(n.getPointer(), value); } return o.asReturnedValue(); } @@ -372,7 +372,7 @@ ReturnedValue Serialize::deserialize(const char *&data, QV8Engine *engine) QVariant var = qVariantFromValue(ref); QV4::ScopedValue v(scope, engine->fromVariant((var))); QV4::ScopedString s(scope, v4->newString(QStringLiteral("__qml:hidden:ref"))); - rv->asObject()->defineReadonlyProperty(s, v); + rv->asObject()->defineReadonlyProperty(s.getPointer(), v); agent->release(); agent->setV8Engine(engine); diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index f489699b2a..588c79496c 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -139,7 +139,7 @@ void String::markObjects(Managed *that, ExecutionEngine *e) } } -ReturnedValue String::get(Managed *m, const StringRef name, bool *hasProperty) +ReturnedValue String::get(Managed *m, String *name, bool *hasProperty) { ExecutionEngine *v4 = m->engine(); Scope scope(v4); @@ -185,7 +185,7 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty) return engine->stringObjectClass->prototype->getValue(that, pd, attrs); } -void String::put(Managed *m, const StringRef name, const ValueRef value) +void String::put(Managed *m, String *name, const ValueRef value) { Scope scope(m->engine()); if (scope.hasException()) @@ -206,7 +206,7 @@ void String::putIndexed(Managed *m, uint index, const ValueRef value) o->putIndexed(index, value); } -PropertyAttributes String::query(const Managed *m, StringRef name) +PropertyAttributes String::query(const Managed *m, String *name) { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) @@ -220,7 +220,7 @@ PropertyAttributes String::queryIndexed(const Managed *m, uint index) return (index < static_cast<uint>(that->d()->text->size)) ? Attr_NotConfigurable|Attr_NotWritable : Attr_Invalid; } -bool String::deleteProperty(Managed *, const StringRef) +bool String::deleteProperty(Managed *, String *) { return false; } @@ -304,9 +304,9 @@ uint String::toUInt(bool *ok) const return UINT_MAX; } -bool String::equals(const StringRef other) const +bool String::equals(String *other) const { - if (this == other.getPointer()) + if (this == other) return true; if (hashValue() != other->hashValue()) return false; diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 1ad869d09f..7af6ff5947 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -100,7 +100,7 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed { QStringData::deallocate(d()->text); } - bool equals(const StringRef other) const; + bool equals(String *other) const; inline bool isEqualTo(const String *other) const { if (this == other) return true; @@ -176,13 +176,13 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed { protected: static void destroy(Managed *); static void markObjects(Managed *that, ExecutionEngine *e); - static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty); + static ReturnedValue get(Managed *m, String *name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, const StringRef name, const ValueRef value); + static void put(Managed *m, String *name, const ValueRef value); static void putIndexed(Managed *m, uint index, const ValueRef value); - static PropertyAttributes query(const Managed *m, StringRef name); + static PropertyAttributes query(const Managed *m, String *name); static PropertyAttributes queryIndexed(const Managed *m, uint index); - static bool deleteProperty(Managed *, const StringRef); + static bool deleteProperty(Managed *, String *); static bool deleteIndexedProperty(Managed *m, uint index); static bool isEqualTo(Managed *that, Managed *o); static uint getLength(const Managed *m); @@ -207,7 +207,6 @@ inline ReturnedValue value_convert<String>(ExecutionEngine *e, const Value &v) return v.toString(e)->asReturnedValue(); } -DEFINE_REF(String, Managed); #endif } diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 5cc1b13c4f..42c5e8f16a 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -135,7 +135,7 @@ bool StringObject::deleteIndexedProperty(Managed *m, uint index) return true; } -void StringObject::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attrs) +void StringObject::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs) { name = (String *)0; StringObject *s = static_cast<StringObject *>(m); @@ -400,7 +400,7 @@ ReturnedValue StringPrototype::method_match(CallContext *context) // ### use the standard builtin function, not the one that might be redefined in the proto ScopedString execString(scope, context->d()->engine->newString(QStringLiteral("exec"))); - Scoped<FunctionObject> exec(scope, context->d()->engine->regExpClass->prototype->get(execString)); + Scoped<FunctionObject> exec(scope, context->d()->engine->regExpClass->prototype->get(execString.getPointer())); ScopedCallData callData(scope, 1); callData->thisObject = rx; @@ -409,7 +409,7 @@ ReturnedValue StringPrototype::method_match(CallContext *context) return exec->call(callData); ScopedString lastIndex(scope, context->d()->engine->newString(QStringLiteral("lastIndex"))); - rx->put(lastIndex, ScopedValue(scope, Primitive::fromInt32(0))); + rx->put(lastIndex.getPointer(), ScopedValue(scope, Primitive::fromInt32(0))); Scoped<ArrayObject> a(scope, context->d()->engine->newArrayObject()); double previousLastIndex = 0; @@ -422,11 +422,11 @@ ReturnedValue StringPrototype::method_match(CallContext *context) if (result->isNull()) break; assert(result->isObject()); - index = rx->get(lastIndex, 0); + index = rx->get(lastIndex.getPointer(), 0); double thisIndex = index->toInteger(); if (previousLastIndex == thisIndex) { previousLastIndex = thisIndex + 1; - rx->put(lastIndex, ScopedValue(scope, Primitive::fromDouble(previousLastIndex))); + rx->put(lastIndex.getPointer(), ScopedValue(scope, Primitive::fromDouble(previousLastIndex))); } else { previousLastIndex = thisIndex; } diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h index 37090cf96a..cc852ba88b 100644 --- a/src/qml/jsruntime/qv4stringobject_p.h +++ b/src/qml/jsruntime/qv4stringobject_p.h @@ -70,7 +70,7 @@ struct StringObject: Object { protected: StringObject(InternalClass *ic); - static void advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attrs); + static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs); static void markObjects(Managed *that, ExecutionEngine *e); }; diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index c0d0f8b484..7c4f3ec2b1 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -444,6 +444,7 @@ struct TypedValue : public Value bool operator!() const { return !managed(); } + operator T *() { return static_cast<T *>(managed()); } T *operator->() { return static_cast<T *>(managed()); } const T *operator->() const { return static_cast<T *>(managed()); } T *getPointer() const { return static_cast<T *>(managed()); } |