From: Lars Knoll Date: Wed, 7 May 2014 11:33:24 +0000 (+0200) Subject: Get rid of StringRef X-Git-Tag: v5.3.99+beta1~284 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33593f00e84e6fb05191e9bb88000566c0c96426;p=platform%2Fupstream%2Fqtdeclarative.git 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 --- diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index eeb835d..03175fd 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -66,7 +66,7 @@ using namespace QV4; #define V4THROW_SQL(error, desc) { \ QV4::Scoped v(scope, scope.engine->newString(desc)); \ QV4::Scoped ex(scope, scope.engine->newErrorObject(v)); \ - ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \ + ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \ ctx->throwError(ex); \ return Encode::undefined(); \ } @@ -74,7 +74,7 @@ using namespace QV4; #define V4THROW_SQL2(error, desc) { \ QV4::Scoped v(scope, scope.engine->newString(desc)); \ QV4::Scoped ex(scope, scope.engine->newErrorObject(v)); \ - ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \ + ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \ args->setReturnValue(ctx->throwError(ex)); \ return; \ } @@ -238,7 +238,7 @@ static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapperRef r, Exec QVariant v = record.value(ii); ScopedString s(scope, v4->newIdentifier(record.fieldName(ii))); ScopedValue val(scope, v.isNull() ? Encode::null() : v8->fromVariant(v)); - row->put(s, val); + row->put(s.getPointer(), val); } if (hasProperty) *hasProperty = true; @@ -338,9 +338,9 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) // XXX optimize ScopedString s(scope); ScopedValue v(scope); - resultObject->put((s = scope.engine->newIdentifier("rowsAffected")), (v = Primitive::fromInt32(query.numRowsAffected()))); - resultObject->put((s = scope.engine->newIdentifier("insertId")), (v = engine->toString(query.lastInsertId().toString()))); - resultObject->put((s = scope.engine->newIdentifier("rows")), rows); + resultObject->put((s = scope.engine->newIdentifier("rowsAffected")).getPointer(), (v = Primitive::fromInt32(query.numRowsAffected()))); + resultObject->put((s = scope.engine->newIdentifier("insertId")).getPointer(), (v = engine->toString(query.lastInsertId().toString()))); + resultObject->put((s = scope.engine->newIdentifier("rows")).getPointer(), rows); } else { err = true; } diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp index d5be42c..5cc97f0 100644 --- a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp +++ b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp @@ -934,7 +934,7 @@ QQmlV4Handle QQuickXmlListModel::get(int index) const for (int ii = 0; ii < d->roleObjects.count(); ++ii) { name = v4engine->newIdentifier(d->roleObjects[ii]->name()); value = v8engine->fromVariant(d->data.value(ii).value(index)); - o->insertMember(name, value); + o->insertMember(name.getPointer(), value); } return QQmlV4Handle(o); diff --git a/src/qml/jit/qv4assembler.cpp b/src/qml/jit/qv4assembler.cpp index 4539714..707b53f 100644 --- a/src/qml/jit/qv4assembler.cpp +++ b/src/qml/jit/qv4assembler.cpp @@ -232,7 +232,7 @@ void Assembler::loadStringRef(RegisterID reg, const QString &string) loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, compilationUnit)), reg); loadPtr(Address(reg, qOffsetOf(QV4::CompiledData::CompilationUnit, runtimeStrings)), reg); const int id = _isel->registerString(string); - addPtr(TrustedImmPtr(id * sizeof(QV4::StringValue)), reg); + loadPtr(Address(reg, id * sizeof(QV4::StringValue)), reg); } void Assembler::storeValue(QV4::Primitive value, IR::Expr *destination) diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index 6091a53..353a294 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -389,8 +389,7 @@ void InstructionSelection::callBuiltinUnwindException(IR::Expr *result) void InstructionSelection::callBuiltinPushCatchScope(const QString &exceptionName) { - Assembler::Pointer s = _as->loadStringAddress(Assembler::ScratchRegister, exceptionName); - generateFunctionCall(Assembler::ContextRegister, Runtime::pushCatchScope, Assembler::ContextRegister, s); + generateFunctionCall(Assembler::ContextRegister, Runtime::pushCatchScope, Assembler::ContextRegister, Assembler::PointerToString(exceptionName)); } void InstructionSelection::callBuiltinForeachIteratorObject(IR::Expr *arg, IR::Expr *result) diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index 04e2d28..ec45ce9 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -861,7 +861,7 @@ QJSValue QJSValue::property(const QString& name) const s->makeIdentifier(); QV4::ExecutionContext *ctx = engine->currentContext(); QV4::ScopedValue result(scope); - result = o->get(s); + result = o->get(s.getPointer()); if (scope.hasException()) result = ctx->catchException(); @@ -893,7 +893,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const QV4::ExecutionContext *ctx = engine->currentContext(); QV4::ScopedValue result(scope); - result = arrayIndex == UINT_MAX ? o->get(engine->id_uintMax) : o->getIndexed(arrayIndex); + result = arrayIndex == UINT_MAX ? o->get(engine->id_uintMax.getPointer()) : o->getIndexed(arrayIndex); if (scope.hasException()) result = ctx->catchException(); return new QJSValuePrivate(engine, result); @@ -936,7 +936,7 @@ void QJSValue::setProperty(const QString& name, const QJSValue& value) QV4::ExecutionContext *ctx = engine->currentContext(); s->makeIdentifier(); QV4::ScopedValue v(scope, value.d->getValue(engine)); - o->put(s, v); + o->put(s.getPointer(), v); if (scope.hasException()) ctx->catchException(); } @@ -969,7 +969,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value) if (arrayIndex != UINT_MAX) o->putIndexed(arrayIndex, v); else - o->put(engine->id_uintMax, v); + o->put(engine->id_uintMax.getPointer(), v); if (scope.hasException()) ctx->catchException(); } @@ -1004,7 +1004,7 @@ bool QJSValue::deleteProperty(const QString &name) return false; ScopedString s(scope, engine->newString(name)); - bool b = o->deleteProperty(s); + bool b = o->deleteProperty(s.getPointer()); if (scope.hasException()) ctx->catchException(); return b; @@ -1028,7 +1028,7 @@ bool QJSValue::hasProperty(const QString &name) const return false; ScopedString s(scope, engine->newIdentifier(name)); - return o->hasProperty(s); + return o->hasProperty(s.getPointer()); } /*! @@ -1049,7 +1049,7 @@ bool QJSValue::hasOwnProperty(const QString &name) const return false; ScopedString s(scope, engine->newIdentifier(name)); - return o->hasOwnProperty(s); + return o->hasOwnProperty(s.getPointer()); } /*! diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp index 7e2ea5d..449fb82 100644 --- a/src/qml/jsapi/qjsvalueiterator.cpp +++ b/src/qml/jsapi/qjsvalueiterator.cpp @@ -109,7 +109,9 @@ QJSValueIterator::QJSValueIterator(const QJSValue& object) QV4::Scope scope(v4); QV4::Scoped it(scope, d_ptr->iterator.value()); it->d()->it.flags = QV4::ObjectIterator::NoFlags; - it->d()->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); + QV4::String *nm = 0; + it->d()->it.next(nm, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); + d_ptr->nextName = nm; } /*! @@ -155,7 +157,9 @@ bool QJSValueIterator::next() return false; QV4::Scope scope(v4); QV4::Scoped it(scope, d_ptr->iterator.value()); - it->d()->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); + QV4::String *nm = 0; + it->d()->it.next(nm, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); + d_ptr->nextName = nm; return !!d_ptr->currentName || d_ptr->currentIndex != UINT_MAX; } @@ -230,7 +234,9 @@ QJSValueIterator& QJSValueIterator::operator=(QJSValue& object) d_ptr->iterator = v4->newForEachIteratorObject(v4->currentContext(), o)->asReturnedValue(); QV4::Scoped it(scope, d_ptr->iterator.value()); it->d()->it.flags = QV4::ObjectIterator::NoFlags; - it->d()->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); + QV4::String *nm = 0; + it->d()->it.next(nm, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); + d_ptr->nextName = nm; return *this; } diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 88700e1..e65ec2c 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 a49fd8a..91fdfc8 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 a713a38..cea6499 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 6c48520..13e6bda 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 f1b6ecd..a1c2b20 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 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 *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *)) +Returned *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)) { BuiltinFunction *f = new (memoryManager) BuiltinFunction(scope, name, code); return f->asReturned(); @@ -969,7 +969,7 @@ QQmlError ExecutionEngine::catchExceptionAsQmlError(ExecutionContext *context) QV4::Scoped 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 8e8f40e..6ff10ae 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 *newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *)); + Returned *newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)); Returned *newBoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QV4::Members &boundArgs); Returned *newObject(); diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index f8fbbf0..5b3ffde 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 e6385d8..482f247 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 236e4be..bc6cd45 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 ff57e27..ad1ebb4 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 b6172a7..105ad93 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -164,7 +164,6 @@ typedef Returned ReturnedString; typedef Returned ReturnedObject; typedef Returned 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 6b382b5..b9576e1 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 35efd3c..2edaf6f 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 bd1828a..830d5f7 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 8552936..f0f7152 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 toJSON(scope, o->get(s)); + Scoped 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 ed555b7..d2ddec5 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 69e08bd..271fad7 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 d24ae97..a9218ca 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 function(scope, e->newBuiltinFunction(e->rootContext, s, code)); + Scoped 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 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(m)->internalGet(name, hasProperty); } @@ -403,7 +403,7 @@ ReturnedValue Object::getIndexed(Managed *m, uint index, bool *hasProperty) return static_cast(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(m)->internalPut(name, value); } @@ -413,14 +413,14 @@ void Object::putIndexed(Managed *m, uint index, const ValueRef value) static_cast(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(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(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(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 f4b23d8..3be5039 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 b0219cd..ff17d8f 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 9a212df..8ee2ae4 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 48fea0d..05ad95b 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 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 O(scope, ctx->d()->callData->thisObject, Scoped::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 a731eee..791ea0e 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(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(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(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(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 e1ec5be..3164eb7 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 7e3400d..ab51ac7 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(this)->get(source)); + ScopedValue s(scope, const_cast(this)->get(source.getPointer())); return s->toQString(); } diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 3fa8db9..3aca34e 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 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()->qmlSingletonWrapper(ctx->engine()->v8Engine, name); } diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 0979105..b4417bd 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 23fc091..97ad97b 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(ptr->managed()); + } T *operator->() { return static_cast(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 fa856be..a7d3845 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -155,7 +155,7 @@ Returned *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 6dbe787..6c964ad 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 *>(that)->containerDeleteIndexedProperty(index); } static bool isEqualTo(Managed *that, Managed *other) { return static_cast *>(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 *>(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 244ca73..4e88a33 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 f489699..588c794 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(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 1ad869d..7af6ff5 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(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 5cc1b13..42c5e8f 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(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 exec(scope, context->d()->engine->regExpClass->prototype->get(execString)); + Scoped 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 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 37090cf..cc852ba 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 c0d0f8b..7c4f3ec 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(managed()); } T *operator->() { return static_cast(managed()); } const T *operator->() const { return static_cast(managed()); } T *getPointer() const { return static_cast(managed()); } diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 46f9483..f94d70f 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -135,7 +135,7 @@ void QmlContextWrapper::takeContextOwnership(const ValueRef qmlglobal) } -ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *hasProperty) +ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty) { QV4::ExecutionEngine *v4 = m->engine(); QV4::Scope scope(v4); @@ -215,7 +215,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has while (context) { // Search context properties if (context->propertyNames.count()) { - int propertyIdx = context->propertyNames.value(name.getPointer()); + int propertyIdx = context->propertyNames.value(name); if (propertyIdx != -1) { @@ -251,7 +251,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has if (scopeObject) { bool hasProp = false; QV4::ScopedValue result(scope, QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, scopeObject, - name.getPointer(), QV4::QObjectWrapper::CheckRevision, &hasProp)); + name, QV4::QObjectWrapper::CheckRevision, &hasProp)); if (hasProp) { if (hasProperty) *hasProperty = true; @@ -264,7 +264,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has // Search context object if (context->contextObject) { bool hasProp = false; - result = QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, context->contextObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, &hasProp); + result = QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp); if (hasProp) { if (hasProperty) *hasProperty = true; @@ -280,7 +280,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has return Primitive::undefinedValue().asReturnedValue(); } -void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef value) +void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value) { ExecutionEngine *v4 = m->engine(); QV4::Scope scope(v4); @@ -326,18 +326,18 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val while (context) { // Search context properties - if (context->propertyNames.count() && -1 != context->propertyNames.value(name.getPointer())) + if (context->propertyNames.count() && -1 != context->propertyNames.value(name)) return; // Search scope object if (scopeObject && - QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, scopeObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, value)) + QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, scopeObject, name, QV4::QObjectWrapper::CheckRevision, value)) return; scopeObject = 0; // Search context object if (context->contextObject && - QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, context->contextObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, value)) + QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, value)) return; context = context->parent; @@ -420,7 +420,7 @@ ReturnedValue QmlContextWrapper::idObjectsArray() return d()->idObjectsWrapper->asReturnedValue(); } -ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, const StringRef &name) +ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, String *name) { if (!d()->context->imports) return Encode::undefined(); diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h index 2b2a19e..297d2d0 100644 --- a/src/qml/qml/qqmlcontextwrapper_p.h +++ b/src/qml/qml/qqmlcontextwrapper_p.h @@ -108,15 +108,15 @@ struct Q_QML_EXPORT QmlContextWrapper : Object void setReadOnly(bool b) { d()->readOnly = b; } - static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty); - static void put(Managed *m, const StringRef name, const ValueRef value); + static ReturnedValue get(Managed *m, String *name, bool *hasProperty); + static void put(Managed *m, String *name, const ValueRef value); static void destroy(Managed *that); static void markObjects(Managed *m, ExecutionEngine *engine); static void registerQmlDependencies(ExecutionEngine *context, const CompiledData::Function *compiledFunction); ReturnedValue idObjectsArray(); - ReturnedValue qmlSingletonWrapper(QV8Engine *e, const StringRef &name); + ReturnedValue qmlSingletonWrapper(QV8Engine *e, String *name); }; diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index e4e79f5..055fd3e 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -105,7 +105,7 @@ QVariant QmlListWrapper::toVariant() const } -ReturnedValue QmlListWrapper::get(Managed *m, const StringRef name, bool *hasProperty) +ReturnedValue QmlListWrapper::get(Managed *m, String *name, bool *hasProperty) { QV4::ExecutionEngine *v4 = m->engine(); QmlListWrapper *w = m->as(); @@ -148,7 +148,7 @@ ReturnedValue QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProper return Primitive::undefinedValue().asReturnedValue(); } -void QmlListWrapper::put(Managed *m, const StringRef name, const ValueRef value) +void QmlListWrapper::put(Managed *m, String *name, const ValueRef value) { // doesn't do anything. Should we throw? Q_UNUSED(m); @@ -162,7 +162,7 @@ void QmlListWrapper::destroy(Managed *that) w->~QmlListWrapper(); } -void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attrs) +void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs) { name = (String *)0; *index = UINT_MAX; diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h index 3369902..da8f990 100644 --- a/src/qml/qml/qqmllistwrapper_p.h +++ b/src/qml/qml/qqmllistwrapper_p.h @@ -94,10 +94,10 @@ public: QVariant toVariant() const; - 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 advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attributes); + static void put(Managed *m, String *name, const ValueRef value); + static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes); static void destroy(Managed *that); }; diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 36523af..809bcca 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -120,7 +120,7 @@ ReturnedValue QmlTypeWrapper::create(QV8Engine *v8, QObject *o, QQmlTypeNameCach } -ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasProperty) +ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty) { QV4::ExecutionEngine *v4 = m->engine(); QV4::Scope scope(v4); @@ -166,7 +166,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasPro } // check for property. - return QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, qobjectSingleton, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, hasProperty); + return QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty); } else if (!siinfo->scriptApi(e).isUndefined()) { // NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable. QV4::ScopedObject o(scope, QJSValuePrivate::get(siinfo->scriptApi(e))->getValue(v4)); @@ -189,7 +189,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasPro } else if (w->d()->object) { QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object); if (ao) - return QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, ao, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, hasProperty); + return QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, ao, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty); // Fall through to base implementation } @@ -230,7 +230,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasPro } -void QmlTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value) +void QmlTypeWrapper::put(Managed *m, String *name, const ValueRef value) { QmlTypeWrapper *w = m->as(); QV4::ExecutionEngine *v4 = m->engine(); @@ -250,7 +250,7 @@ void QmlTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value) QObject *object = w->d()->object; QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object); if (ao) - QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, ao, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value); + QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, ao, name, QV4::QObjectWrapper::IgnoreRevision, value); } else if (type && type->isSingleton()) { QQmlEngine *e = v8engine->engine(); QQmlType::SingletonInstanceInfo *siinfo = type->singletonInstanceInfo(); @@ -258,7 +258,7 @@ void QmlTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value) QObject *qobjectSingleton = siinfo->qobjectApi(e); if (qobjectSingleton) { - QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, qobjectSingleton, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value); + QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, value); } else if (!siinfo->scriptApi(e).isUndefined()) { QV4::ScopedObject apiprivate(scope, QJSValuePrivate::get(siinfo->scriptApi(e))->value); if (!apiprivate) { @@ -272,13 +272,11 @@ void QmlTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value) } } -PropertyAttributes QmlTypeWrapper::query(const Managed *m, StringRef name) +PropertyAttributes QmlTypeWrapper::query(const Managed *m, String *name) { // ### Implement more efficiently. - Scope scope(m->engine()); - ScopedString n(scope, name); bool hasProperty = false; - static_cast(const_cast(m))->get(n, &hasProperty); + static_cast(const_cast(m))->get(name, &hasProperty); return hasProperty ? Attr_Data : Attr_Invalid; } diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h index 8aa9b01..e7fa64d 100644 --- a/src/qml/qml/qqmltypewrapper_p.h +++ b/src/qml/qml/qqmltypewrapper_p.h @@ -104,9 +104,9 @@ public: static ReturnedValue create(QV8Engine *, QObject *, QQmlTypeNameCache *, const void *, TypeNameMode = IncludeEnums); - 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 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 destroy(Managed *that); static bool isEqualTo(Managed *that, Managed *o); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index b54b355..7388a65 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -206,7 +206,7 @@ bool QmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other) return false; } -PropertyAttributes QmlValueTypeWrapper::query(const Managed *m, StringRef name) +PropertyAttributes QmlValueTypeWrapper::query(const Managed *m, String *name) { const QmlValueTypeWrapper *r = m->as(); QV4::ExecutionEngine *v4 = m->engine(); @@ -220,9 +220,9 @@ PropertyAttributes QmlValueTypeWrapper::query(const Managed *m, StringRef name) { QQmlData *ddata = QQmlData::get(r->d()->type, false); if (ddata && ddata->propertyCache) - result = ddata->propertyCache->property(name.getPointer(), 0, 0); + result = ddata->propertyCache->property(name, 0, 0); else - result = QQmlPropertyCache::property(r->d()->v8->engine(), r->d()->type, name.getPointer(), 0, local); + result = QQmlPropertyCache::property(r->d()->v8->engine(), r->d()->type, name, 0, local); } return result ? Attr_Data : Attr_Invalid; } @@ -270,7 +270,7 @@ ReturnedValue QmlValueTypeWrapper::method_toString(CallContext *ctx) } } -ReturnedValue QmlValueTypeWrapper::get(Managed *m, const StringRef name, bool *hasProperty) +ReturnedValue QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty) { QmlValueTypeWrapper *r = m->as(); QV4::ExecutionEngine *v4 = m->engine(); @@ -297,7 +297,7 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, const StringRef name, bool *h { QQmlData *ddata = QQmlData::get(r->d()->type, false); if (ddata && ddata->propertyCache) - result = ddata->propertyCache->property(name.getPointer(), 0, 0); + result = ddata->propertyCache->property(name, 0, 0); else result = QQmlPropertyCache::property(r->d()->v8->engine(), r->d()->type, name, 0, local); } @@ -308,7 +308,7 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, const StringRef name, bool *h if (result->isFunction()) { // calling a Q_INVOKABLE function of a value type QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4); - return QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), qmlContext, r->d()->type, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision); + return QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), qmlContext, r->d()->type, name, QV4::QObjectWrapper::IgnoreRevision); } #define VALUE_TYPE_LOAD(metatype, cpptype, constructor) \ @@ -332,7 +332,7 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, const StringRef name, bool *h #undef VALUE_TYPE_ACCESSOR } -void QmlValueTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value) +void QmlValueTypeWrapper::put(Managed *m, String *name, const ValueRef value) { ExecutionEngine *v4 = m->engine(); Scope scope(v4); diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h index 3b52d3e..ae73f07 100644 --- a/src/qml/qml/qqmlvaluetypewrapper_p.h +++ b/src/qml/qml/qqmlvaluetypewrapper_p.h @@ -93,11 +93,11 @@ public: QVariant toVariant() const; bool isEqual(const QVariant& value); - static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty); - static void put(Managed *m, const StringRef name, const ValueRef value); + static ReturnedValue get(Managed *m, String *name, bool *hasProperty); + static void put(Managed *m, String *name, const ValueRef value); static void destroy(Managed *that); static bool isEqualTo(Managed *m, Managed *other); - static PropertyAttributes query(const Managed *, StringRef name); + static PropertyAttributes query(const Managed *, String *name); static QV4::ReturnedValue method_toString(CallContext *ctx); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 734c05f..e302574 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -105,9 +105,9 @@ static ReturnedValue constructMeObject(const ValueRef thisObj, QV8Engine *e) ExecutionEngine *v4 = QV8Engine::getV4(e); Scope scope(v4); Scoped meObj(scope, v4->newObject()); - meObj->put(ScopedString(scope, v4->newString(QStringLiteral("ThisObject"))), thisObj); + meObj->put(ScopedString(scope, v4->newString(QStringLiteral("ThisObject"))).getPointer(), thisObj); ScopedValue v(scope, QmlContextWrapper::qmlScope(e, e->callingContext(), 0)); - meObj->put(ScopedString(scope, v4->newString(QStringLiteral("ActivationObject"))), v); + meObj->put(ScopedString(scope, v4->newString(QStringLiteral("ActivationObject"))).getPointer(), v); return meObj.asReturnedValue(); } @@ -219,7 +219,7 @@ public: static void destroy(Managed *that) { that->as()->~NamedNodeMap(); } - 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); }; @@ -255,7 +255,7 @@ public: static void destroy(Managed *that) { that->as()->~NodeList(); } - 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); // C++ API @@ -942,7 +942,7 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty return Encode::undefined(); } -ReturnedValue NamedNodeMap::get(Managed *m, const StringRef name, bool *hasProperty) +ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty) { NamedNodeMap *r = m->as(); QV4::ExecutionEngine *v4 = m->engine(); @@ -1000,7 +1000,7 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) return Encode::undefined(); } -ReturnedValue NodeList::get(Managed *m, const StringRef name, bool *hasProperty) +ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty) { QV4::ExecutionEngine *v4 = m->engine(); NodeList *r = m->as(); @@ -1570,21 +1570,21 @@ void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me) } ScopedString s(scope, v4->newString(QStringLiteral("ThisObject"))); - Scoped thisObj(scope, o->get(s)); + Scoped thisObj(scope, o->get(s.getPointer())); if (!thisObj) { ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject")); return; } s = v4->newString(QStringLiteral("onreadystatechange")); - Scoped callback(scope, thisObj->get(s)); + Scoped callback(scope, thisObj->get(s.getPointer())); if (!callback) { // not an error, but no onreadystatechange function to call. return; } s = v4->newString(QStringLiteral("ActivationObject")); - Scoped activationObject(scope, o->get(s)); + Scoped activationObject(scope, o->get(s.getPointer())); if (!activationObject) { v4->currentContext()->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject")); return; @@ -1676,7 +1676,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject if (!d()->proto) setupProto(); ScopedString s(scope, engine->id_prototype); - defineDefaultProperty(s, ScopedObject(scope, d()->proto)); + defineDefaultProperty(s.getPointer(), ScopedObject(scope, d()->proto)); } ~QQmlXMLHttpRequestCtor() {} @@ -2028,7 +2028,7 @@ void *qt_add_qmlxmlhttprequest(QV8Engine *engine) Scoped ctor(scope, new (v4->memoryManager) QQmlXMLHttpRequestCtor(v4)); ScopedString s(scope, v4->newString(QStringLiteral("XMLHttpRequest"))); - v4->globalObject->defineReadonlyProperty(s, ctor); + v4->globalObject->defineReadonlyProperty(s.getPointer(), ctor); QQmlXMLHttpRequestData *data = new QQmlXMLHttpRequestData; return data; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 996f41b..c255c83 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -101,11 +101,11 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine) for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) { QMetaEnum enumerator = qtMetaObject->enumerator(ii); for (int jj = 0; jj < enumerator.keyCount(); ++jj) { - put((str = v4->newString(QString::fromUtf8(enumerator.key(jj)))), (v = QV4::Primitive::fromInt32(enumerator.value(jj)))); + put((str = v4->newString(QString::fromUtf8(enumerator.key(jj)))).getPointer(), (v = QV4::Primitive::fromInt32(enumerator.value(jj)))); } } - put((str = v4->newString(QStringLiteral("Asynchronous"))), (v = QV4::Primitive::fromInt32(0))); - put((str = v4->newString(QStringLiteral("Synchronous"))), (v = QV4::Primitive::fromInt32(1))); + put((str = v4->newString(QStringLiteral("Asynchronous"))).getPointer(), (v = QV4::Primitive::fromInt32(0))); + put((str = v4->newString(QStringLiteral("Synchronous"))).getPointer(), (v = QV4::Primitive::fromInt32(1))); defineDefaultProperty(QStringLiteral("include"), QV4Include::method_include); defineDefaultProperty(QStringLiteral("isQtObject"), method_isQtObject); @@ -961,16 +961,16 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) const QQmlError &error = errors.at(ii); errorstr += QLatin1String("\n ") + error.toString(); qmlerror = v4->newObject(); - qmlerror->put((s = v4->newString(QStringLiteral("lineNumber"))), (v = QV4::Primitive::fromInt32(error.line()))); - qmlerror->put((s = v4->newString(QStringLiteral("columnNumber"))), (v = QV4::Primitive::fromInt32(error.column()))); - qmlerror->put((s = v4->newString(QStringLiteral("fileName"))), (v = v4->newString(error.url().toString()))); - qmlerror->put((s = v4->newString(QStringLiteral("message"))), (v = v4->newString(error.description()))); + qmlerror->put((s = v4->newString(QStringLiteral("lineNumber"))).getPointer(), (v = QV4::Primitive::fromInt32(error.line()))); + qmlerror->put((s = v4->newString(QStringLiteral("columnNumber"))).getPointer(), (v = QV4::Primitive::fromInt32(error.column()))); + qmlerror->put((s = v4->newString(QStringLiteral("fileName"))).getPointer(), (v = v4->newString(error.url().toString()))); + qmlerror->put((s = v4->newString(QStringLiteral("message"))).getPointer(), (v = v4->newString(error.description()))); qmlerrors->putIndexed(ii, qmlerror); } v = v4->newString(errorstr); Scoped errorObject(scope, v4->newErrorObject(v)); - errorObject->put((s = v4->newString(QStringLiteral("qmlErrors"))), qmlerrors); + errorObject->put((s = v4->newString(QStringLiteral("qmlErrors"))).getPointer(), qmlerrors); return errorObject.asReturnedValue(); } }; diff --git a/src/qml/qml/v8/qv4domerrors_p.h b/src/qml/qml/v8/qv4domerrors_p.h index c650ed8..30cbd61 100644 --- a/src/qml/qml/v8/qv4domerrors_p.h +++ b/src/qml/qml/v8/qv4domerrors_p.h @@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE #define V4THROW_DOM(error, string) { \ QV4::ScopedValue v(scope, scope.engine->newString(QStringLiteral(string))); \ QV4::Scoped ex(scope, scope.engine->newErrorObject(v)); \ - ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \ + ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \ return ctx->throwError(ex); \ } diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index e524b60..5dcbae6 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -231,7 +231,7 @@ static QV4::ReturnedValue objectFromVariantMap(QV8Engine *engine, const QVariant uint idx = s->asArrayIndex(); if (idx > 16 && (!o->arrayData() || idx > o->arrayData()->length() * 2)) o->initSparseArray(); - o->put(s, (v = engine->fromVariant(iter.value()))); + o->put(s.getPointer(), (v = engine->fromVariant(iter.value()))); } return o.asReturnedValue(); } @@ -605,7 +605,7 @@ QV4::ReturnedValue QV8Engine::variantMapToJS(const QVariantMap &vmap) if (idx < UINT_MAX) o->arraySet(idx, v); else - o->insertMember(s, v); + o->insertMember(s.getPointer(), v); } return o.asReturnedValue(); } @@ -898,7 +898,7 @@ bool QV8Engine::metaTypeFromJS(const QV4::ValueRef value, int type, void *data) } else if (proto->as()) { QByteArray className = name.left(name.size()-1); - QV4::ScopedObject p(scope, proto); + QV4::ScopedObject p(scope, proto.getPointer()); if (QObject *qobject = qtObjectFromJS(p)) canCast = qobject->qt_metacast(className) != 0; } diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 73cb177..14518bf 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1694,26 +1694,26 @@ void QQmlDelegateModelItemMetaType::initializePrototype() s = v4->newString(QStringLiteral("isUnresolved")); p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, 30, QQmlDelegateModelItem::get_member)); p->setSetter(0); - proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); + proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); s = v4->newString(QStringLiteral("inItems")); p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_member)); p->setSetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::set_member)); - proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); + proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); s = v4->newString(QStringLiteral("inPersistedItems")); p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_member)); p->setSetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::set_member)); - proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); + proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); s = v4->newString(QStringLiteral("itemsIndex")); p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_index)); - proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); + proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); s = v4->newString(QStringLiteral("persistedItemsIndex")); p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_index)); p->setSetter(0); - proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); + proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); for (int i = 2; i < groupNames.count(); ++i) { QString propertyName = QStringLiteral("in") + groupNames.at(i); @@ -1721,14 +1721,14 @@ void QQmlDelegateModelItemMetaType::initializePrototype() s = v4->newString(propertyName); p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, i + 1, QQmlDelegateModelItem::get_member)); p->setSetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, i + 1, QQmlDelegateModelItem::set_member)); - proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); + proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); } for (int i = 2; i < groupNames.count(); ++i) { const QString propertyName = groupNames.at(i) + QStringLiteral("Index"); s = v4->newString(propertyName); p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, i + 1, QQmlDelegateModelItem::get_index)); p->setSetter(0); - proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); + proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); } modelItemProto = proto; } @@ -3301,7 +3301,7 @@ public: return object.asReturnedValue(); } - static QV4::ReturnedValue get(QV4::Managed *m, const QV4::StringRef name, bool *hasProperty) + static QV4::ReturnedValue get(QV4::Managed *m, QV4::String *name, bool *hasProperty) { QQmlDelegateModelGroupChangeArray *array = m->as(); if (!array) diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 8de48c2..00ddf13 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -103,9 +103,9 @@ const ListLayout::Role &ListLayout::getRoleOrCreate(const QString &key, Role::Da return createRole(key, type); } -const ListLayout::Role &ListLayout::getRoleOrCreate(const QV4::StringRef key, Role::DataType type) +const ListLayout::Role &ListLayout::getRoleOrCreate(QV4::String *key, Role::DataType type) { - QStringHash::Node *node = roleHash.findNode(key.getPointer()); + QStringHash::Node *node = roleHash.findNode(key); if (node) { const Role &r = *node->value; if (type != r.type) @@ -239,10 +239,10 @@ const ListLayout::Role *ListLayout::getExistingRole(const QString &key) return r; } -const ListLayout::Role *ListLayout::getExistingRole(const QV4::StringRef key) +const ListLayout::Role *ListLayout::getExistingRole(QV4::String *key) { Role *r = 0; - QStringHash::Node *node = roleHash.findNode(key.getPointer()); + QStringHash::Node *node = roleHash.findNode(key); if (node) r = node->value; return r; @@ -432,13 +432,13 @@ void ListModel::set(int elementIndex, QV4::ObjectRef object, QVector *roles // Add the value now if ((s = propertyValue)) { - const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String); + const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName.getPointer(), ListLayout::Role::String); roleIndex = e->setStringProperty(r, s->toQString()); } else if (propertyValue->isNumber()) { - const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number); + const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName.getPointer(), ListLayout::Role::Number); roleIndex = e->setDoubleProperty(r, propertyValue->asDouble()); } else if ((a = propertyValue)) { - const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List); + const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName.getPointer(), ListLayout::Role::List); ListModel *subModel = new ListModel(r.subLayout, 0, -1); int arrayLength = a->getLength(); @@ -449,16 +449,16 @@ void ListModel::set(int elementIndex, QV4::ObjectRef object, QVector *roles roleIndex = e->setListProperty(r, subModel); } else if (propertyValue->isBoolean()) { - const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Bool); + const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName.getPointer(), ListLayout::Role::Bool); roleIndex = e->setBoolProperty(r, propertyValue->booleanValue()); } else if (QV4::DateObject *dd = propertyValue->asDateObject()) { - const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::DateTime); + const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName.getPointer(), ListLayout::Role::DateTime); QDateTime dt = dd->toQDateTime(); roleIndex = e->setDateTimeProperty(r, dt); } else if (QV4::Object *o = propertyValue->asObject()) { if (QV4::QObjectWrapper *wrapper = o->as()) { QObject *o = wrapper->object(); - const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject); + const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName.getPointer(), ListLayout::Role::QObject); if (role.type == ListLayout::Role::QObject) roleIndex = e->setQObjectProperty(role, o); } else { diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index 924d89c..4f9b3c1 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -209,12 +209,12 @@ public: }; const Role *getRoleOrCreate(const QString &key, const QVariant &data); - const Role &getRoleOrCreate(const QV4::StringRef key, Role::DataType type); + const Role &getRoleOrCreate(QV4::String *key, Role::DataType type); const Role &getRoleOrCreate(const QString &key, Role::DataType type); const Role &getExistingRole(int index) { return *roles.at(index); } const Role *getExistingRole(const QString &key); - const Role *getExistingRole(const QV4::StringRef key); + const Role *getExistingRole(QV4::String *key); int roleCount() const { return roles.count(); } diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 26b0bef..4d1f9f1 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -235,7 +235,7 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init() QV4::Scoped createsendconstructor(scope, createsendscript.run()); Q_ASSERT(!scope.engine->hasException); QV4::ScopedString name(scope, m_v4Engine->newString(QStringLiteral("sendMessage"))); - QV4::ScopedValue function(scope, m_v4Engine->newBuiltinFunction(m_v4Engine->rootContext, name, + QV4::ScopedValue function(scope, m_v4Engine->newBuiltinFunction(m_v4Engine->rootContext, name.getPointer(), QQuickWorkerScriptEnginePrivate::method_sendMessage)); QV4::ScopedCallData callData(scope, 1); callData->args[0] = function; @@ -315,9 +315,9 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::getWorker(WorkerScript *scri w->setReadOnly(false); QV4::Scoped api(scope, v4->newObject()); - api->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("sendMessage"))), QV4::ScopedValue(scope, workerEngine->sendFunction(script->id))); + api->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("sendMessage"))).getPointer(), QV4::ScopedValue(scope, workerEngine->sendFunction(script->id))); - w->QV4::Object::put(QV4::ScopedString(scope, v4->newString(QStringLiteral("WorkerScript"))), api); + w->QV4::Object::put(QV4::ScopedString(scope, v4->newString(QStringLiteral("WorkerScript"))).getPointer(), api); w->setReadOnly(true); } diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index c661a3b..446020d 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -229,7 +229,7 @@ public: QV4::ScopedString name(scope, v4->newString(QString::fromUtf8(propertyName))); p->setGetter(new (v4->memoryManager) QV4::IndexedBuiltinFunction(v4->rootContext, propertyId, QQmlDMCachedModelData::get_property)); p->setSetter(new (v4->memoryManager) QV4::IndexedBuiltinFunction(v4->rootContext, propertyId, QQmlDMCachedModelData::set_property)); - proto->insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable); + proto->insertMember(name.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable); } prototype = proto; } diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 9636523..059123e 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -1748,7 +1748,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::CallCon if (QV4::Object *o = ctx->d()->callData->args[0].asObject()) { QV4::ScopedString s(scope, scope.engine->newString(QStringLiteral("data"))); - QV4::Scoped pixelData(scope, o->get(s)); + QV4::Scoped pixelData(scope, o->get(s.getPointer())); if (!!pixelData) { patternTexture = pixelData->d()->image; } @@ -2859,7 +2859,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(QV4::CallConte QFontMetrics fm(r->d()->context->state.font); uint width = fm.width(ctx->d()->callData->args[0].toQStringNoThrow()); QV4::Scoped tm(scope, scope.engine->newObject()); - tm->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("width"))), + tm->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("width"))).getPointer(), QV4::ScopedValue(scope, QV4::Primitive::fromDouble(width))); return tm.asReturnedValue(); } @@ -4198,8 +4198,7 @@ QQuickContext2DEngineData::QQuickContext2DEngineData(QV8Engine *engine) gradientProto = proto; proto = scope.engine->newObject(); - QV4::ScopedString s(scope, scope.engine->id_length); - proto->defineAccessorProperty(s, QQuickJSContext2DPixelData::proto_get_length, 0); + proto->defineAccessorProperty(scope.engine->id_length, QQuickJSContext2DPixelData::proto_get_length, 0); pixelArrayProto = proto; } diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 73047ad..51bec66 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -4002,15 +4002,15 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const QRectF r = mapRectFromItem(itemObj, QRectF(x, y, w, h)); - rv->put((s = v4->newString(QStringLiteral("x"))), (v = QV4::Primitive::fromDouble(r.x()))); - rv->put((s = v4->newString(QStringLiteral("y"))), (v = QV4::Primitive::fromDouble(r.y()))); - rv->put((s = v4->newString(QStringLiteral("width"))), (v = QV4::Primitive::fromDouble(r.width()))); - rv->put((s = v4->newString(QStringLiteral("height"))), (v = QV4::Primitive::fromDouble(r.height()))); + rv->put((s = v4->newString(QStringLiteral("x"))).getPointer(), (v = QV4::Primitive::fromDouble(r.x()))); + rv->put((s = v4->newString(QStringLiteral("y"))).getPointer(), (v = QV4::Primitive::fromDouble(r.y()))); + rv->put((s = v4->newString(QStringLiteral("width"))).getPointer(), (v = QV4::Primitive::fromDouble(r.width()))); + rv->put((s = v4->newString(QStringLiteral("height"))).getPointer(), (v = QV4::Primitive::fromDouble(r.height()))); } else { QPointF p = mapFromItem(itemObj, QPointF(x, y)); - rv->put((s = v4->newString(QStringLiteral("x"))), (v = QV4::Primitive::fromDouble(p.x()))); - rv->put((s = v4->newString(QStringLiteral("y"))), (v = QV4::Primitive::fromDouble(p.y()))); + rv->put((s = v4->newString(QStringLiteral("x"))).getPointer(), (v = QV4::Primitive::fromDouble(p.x()))); + rv->put((s = v4->newString(QStringLiteral("y"))).getPointer(), (v = QV4::Primitive::fromDouble(p.y()))); } } } @@ -4082,15 +4082,15 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const QRectF r = mapRectToItem(itemObj, QRectF(x, y, w, h)); - rv->put((s = v4->newString(QStringLiteral("x"))), (v = QV4::Primitive::fromDouble(r.x()))); - rv->put((s = v4->newString(QStringLiteral("y"))), (v = QV4::Primitive::fromDouble(r.y()))); - rv->put((s = v4->newString(QStringLiteral("width"))), (v = QV4::Primitive::fromDouble(r.width()))); - rv->put((s = v4->newString(QStringLiteral("height"))), (v = QV4::Primitive::fromDouble(r.height()))); + rv->put((s = v4->newString(QStringLiteral("x"))).getPointer(), (v = QV4::Primitive::fromDouble(r.x()))); + rv->put((s = v4->newString(QStringLiteral("y"))).getPointer(), (v = QV4::Primitive::fromDouble(r.y()))); + rv->put((s = v4->newString(QStringLiteral("width"))).getPointer(), (v = QV4::Primitive::fromDouble(r.width()))); + rv->put((s = v4->newString(QStringLiteral("height"))).getPointer(), (v = QV4::Primitive::fromDouble(r.height()))); } else { QPointF p = mapToItem(itemObj, QPointF(x, y)); - rv->put((s = v4->newString(QStringLiteral("x"))), (v = QV4::Primitive::fromDouble(p.x()))); - rv->put((s = v4->newString(QStringLiteral("y"))), (v = QV4::Primitive::fromDouble(p.y()))); + rv->put((s = v4->newString(QStringLiteral("x"))).getPointer(), (v = QV4::Primitive::fromDouble(p.x()))); + rv->put((s = v4->newString(QStringLiteral("y"))).getPointer(), (v = QV4::Primitive::fromDouble(p.y()))); } } } diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 4428452..b92613a 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -286,17 +286,17 @@ public: QV4::ScopedString s(scope); - QV4::ScopedValue vbold(scope, obj->get((s = v4->newString(QStringLiteral("bold"))))); - QV4::ScopedValue vcap(scope, obj->get((s = v4->newString(QStringLiteral("capitalization"))))); - QV4::ScopedValue vfam(scope, obj->get((s = v4->newString(QStringLiteral("family"))))); - QV4::ScopedValue vital(scope, obj->get((s = v4->newString(QStringLiteral("italic"))))); - QV4::ScopedValue vlspac(scope, obj->get((s = v4->newString(QStringLiteral("letterSpacing"))))); - QV4::ScopedValue vpixsz(scope, obj->get((s = v4->newString(QStringLiteral("pixelSize"))))); - QV4::ScopedValue vpntsz(scope, obj->get((s = v4->newString(QStringLiteral("pointSize"))))); - QV4::ScopedValue vstrk(scope, obj->get((s = v4->newString(QStringLiteral("strikeout"))))); - QV4::ScopedValue vundl(scope, obj->get((s = v4->newString(QStringLiteral("underline"))))); - QV4::ScopedValue vweight(scope, obj->get((s = v4->newString(QStringLiteral("weight"))))); - QV4::ScopedValue vwspac(scope, obj->get((s = v4->newString(QStringLiteral("wordSpacing"))))); + QV4::ScopedValue vbold(scope, obj->get((s = v4->newString(QStringLiteral("bold"))).getPointer())); + QV4::ScopedValue vcap(scope, obj->get((s = v4->newString(QStringLiteral("capitalization"))).getPointer())); + QV4::ScopedValue vfam(scope, obj->get((s = v4->newString(QStringLiteral("family"))).getPointer())); + QV4::ScopedValue vital(scope, obj->get((s = v4->newString(QStringLiteral("italic"))).getPointer())); + QV4::ScopedValue vlspac(scope, obj->get((s = v4->newString(QStringLiteral("letterSpacing"))).getPointer())); + QV4::ScopedValue vpixsz(scope, obj->get((s = v4->newString(QStringLiteral("pixelSize"))).getPointer())); + QV4::ScopedValue vpntsz(scope, obj->get((s = v4->newString(QStringLiteral("pointSize"))).getPointer())); + QV4::ScopedValue vstrk(scope, obj->get((s = v4->newString(QStringLiteral("strikeout"))).getPointer())); + QV4::ScopedValue vundl(scope, obj->get((s = v4->newString(QStringLiteral("underline"))).getPointer())); + QV4::ScopedValue vweight(scope, obj->get((s = v4->newString(QStringLiteral("weight"))).getPointer())); + QV4::ScopedValue vwspac(scope, obj->get((s = v4->newString(QStringLiteral("wordSpacing"))).getPointer())); // pull out the values, set ok to true if at least one valid field is given. if (vbold->isBoolean()) { diff --git a/tools/qmljs/main.cpp b/tools/qmljs/main.cpp index f42e8fc..f3642cd 100644 --- a/tools/qmljs/main.cpp +++ b/tools/qmljs/main.cpp @@ -120,7 +120,7 @@ static void showException(QV4::ExecutionContext *ctx, const QV4::ValueRef except std::cerr << "Uncaught exception: " << qPrintable(ex->toString(ctx)->toQString()) << std::endl; } else { QV4::ScopedString m(scope, scope.engine->newString(QStringLiteral("message"))); - QV4::ScopedValue message(scope, e->get(m)); + QV4::ScopedValue message(scope, e->get(m.getPointer())); std::cerr << "Uncaught exception: " << qPrintable(message->toQStringNoThrow()) << std::endl; } @@ -191,9 +191,9 @@ int main(int argc, char *argv[]) QV4::ScopedObject globalObject(scope, vm.globalObject); QV4::ScopedObject print(scope, new (scope.engine->memoryManager) builtins::Print(ctx)); - globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))), print); + globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))).getPointer(), print); QV4::ScopedObject gc(scope, new (scope.engine->memoryManager) builtins::GC(ctx)); - globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))), gc); + globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc); foreach (const QString &fn, args) { QFile file(fn);