Get rid of StringRef

Remove the Ref classes, as they won't be required
anymore once Managed and Managed::Data are separated.

Change-Id: Ic6bec2d5b4ecf2595ce129dbb45bbf6a385138a5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
Lars Knoll 2014-05-07 13:33:24 +02:00 committed by Simon Hausmann
parent 9afc7d9a53
commit 33593f00e8
63 changed files with 380 additions and 388 deletions

View File

@ -66,7 +66,7 @@ using namespace QV4;
#define V4THROW_SQL(error, desc) { \
QV4::Scoped<String> v(scope, scope.engine->newString(desc)); \
QV4::Scoped<Object> 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<String> v(scope, scope.engine->newString(desc)); \
QV4::Scoped<Object> 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;
}

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -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());
}
/*!

View File

@ -109,7 +109,9 @@ QJSValueIterator::QJSValueIterator(const QJSValue& object)
QV4::Scope scope(v4);
QV4::Scoped<QV4::ForEachIteratorObject> 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<QV4::ForEachIteratorObject> 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<QV4::ForEachIteratorObject> 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;
}

View File

@ -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())

View File

@ -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);
}

View File

@ -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

View File

@ -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)

View File

@ -412,7 +412,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
globalObject->defineDefaultProperty(QStringLiteral("unescape"), GlobalFunctions::method_unescape, 1);
Scoped<String> name(scope, newString(QStringLiteral("thrower")));
thrower = newBuiltinFunction(rootContext, name, throwTypeError)->getPointer();
thrower = newBuiltinFunction(rootContext, name.getPointer(), throwTypeError)->getPointer();
}
ExecutionEngine::~ExecutionEngine()
@ -481,7 +481,7 @@ ExecutionContext *ExecutionEngine::pushGlobalContext()
return g;
}
Returned<FunctionObject> *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *))
Returned<FunctionObject> *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *))
{
BuiltinFunction *f = new (memoryManager) BuiltinFunction(scope, name, code);
return f->asReturned<FunctionObject>();
@ -969,7 +969,7 @@ QQmlError ExecutionEngine::catchExceptionAsQmlError(ExecutionContext *context)
QV4::Scoped<QV4::ErrorObject> errorObj(scope, exception);
if (!!errorObj && errorObj->asSyntaxError()) {
QV4::ScopedString m(scope, errorObj->engine()->newString(QStringLiteral("message")));
QV4::ScopedValue v(scope, errorObj->get(m));
QV4::ScopedValue v(scope, errorObj->get(m.getPointer()));
error.setDescription(v->toQStringNoThrow());
} else
error.setDescription(exception->toQStringNoThrow());

View File

@ -307,7 +307,7 @@ public:
void pushContext(CallContext *context);
ExecutionContext *popContext();
Returned<FunctionObject> *newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *));
Returned<FunctionObject> *newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *));
Returned<BoundFunction> *newBoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QV4::Members &boundArgs);
Returned<Object> *newObject();

View File

@ -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();

View File

@ -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(); }

View File

@ -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;

View File

@ -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);

View File

@ -164,7 +164,6 @@ typedef Returned<String> ReturnedString;
typedef Returned<Object> ReturnedObject;
typedef Returned<FunctionObject> ReturnedFunctionObject;
struct ManagedRef;
struct StringRef;
struct ObjectRef;
struct ArrayObjectRef;
struct FunctionObjectRef;

View File

@ -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);
}

View File

@ -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);

View File

@ -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();

View File

@ -290,7 +290,7 @@ bool JsonParser::parseMember(ObjectRef o)
if (idx < UINT_MAX) {
o->putIndexed(idx, val);
} else {
o->insertMember(s, val);
o->insertMember(s.getPointer(), val);
}
END;
@ -711,7 +711,7 @@ QString Stringify::Str(const QString &key, ValueRef v)
ScopedObject o(scope, value);
if (o) {
ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toJSON")));
Scoped<FunctionObject> toJSON(scope, o->get(s));
Scoped<FunctionObject> toJSON(scope, o->get(s.getPointer()));
if (!!toJSON) {
ScopedCallData callData(scope, 1);
callData->thisObject = value;
@ -814,7 +814,7 @@ QString Stringify::JO(ObjectRef o)
for (int i = 0; i < propertyList.size(); ++i) {
bool exists;
s = propertyList.at(i);
ScopedValue v(scope, o->get(s, &exists));
ScopedValue v(scope, o->get(s.getPointer(), &exists));
if (!exists)
continue;
QString member = makeMember(s->toQString(), v);
@ -1008,7 +1008,7 @@ QV4::ReturnedValue JsonObject::fromJsonObject(ExecutionEngine *engine, const QJs
ScopedValue v(scope);
for (QJsonObject::const_iterator it = object.begin(); it != object.end(); ++it) {
v = fromJsonValue(engine, it.value());
o->put((s = engine->newString(it.key())), v);
o->put((s = engine->newString(it.key())).getPointer(), v);
}
return o.asReturnedValue();
}

View File

@ -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);
}
}

View File

@ -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);
};

View File

@ -104,7 +104,7 @@ void Object::put(ExecutionContext *ctx, const QString &name, const ValueRef valu
{
Scope scope(ctx);
ScopedString n(scope, ctx->d()->engine->newString(name));
put(n, value);
put(n.getPointer(), value);
}
ReturnedValue Object::getValue(const ValueRef thisObject, const Property *p, PropertyAttributes attrs)
@ -154,7 +154,7 @@ void Object::defineDefaultProperty(const QString &name, ValueRef value)
ExecutionEngine *e = engine();
Scope scope(e);
ScopedString s(scope, e->newIdentifier(name));
defineDefaultProperty(s, value);
defineDefaultProperty(s.getPointer(), value);
}
void Object::defineDefaultProperty(const QString &name, ReturnedValue (*code)(CallContext *), int argumentCount)
@ -162,12 +162,12 @@ void Object::defineDefaultProperty(const QString &name, ReturnedValue (*code)(Ca
ExecutionEngine *e = engine();
Scope scope(e);
ScopedString s(scope, e->newIdentifier(name));
Scoped<FunctionObject> function(scope, e->newBuiltinFunction(e->rootContext, s, code));
Scoped<FunctionObject> function(scope, e->newBuiltinFunction(e->rootContext, s.getPointer(), code));
function->defineReadonlyProperty(e->id_length, Primitive::fromInt32(argumentCount));
defineDefaultProperty(s, function);
defineDefaultProperty(s.getPointer(), function);
}
void Object::defineDefaultProperty(const StringRef name, ReturnedValue (*code)(CallContext *), int argumentCount)
void Object::defineDefaultProperty(String *name, ReturnedValue (*code)(CallContext *), int argumentCount)
{
ExecutionEngine *e = engine();
Scope scope(e);
@ -181,10 +181,10 @@ void Object::defineAccessorProperty(const QString &name, ReturnedValue (*getter)
ExecutionEngine *e = engine();
Scope scope(e);
Scoped<String> s(scope, e->newIdentifier(name));
defineAccessorProperty(s, getter, setter);
defineAccessorProperty(s.getPointer(), getter, setter);
}
void Object::defineAccessorProperty(const StringRef name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *))
void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *))
{
ExecutionEngine *v4 = engine();
QV4::Scope scope(v4);
@ -199,10 +199,10 @@ void Object::defineReadonlyProperty(const QString &name, ValueRef value)
QV4::ExecutionEngine *e = engine();
Scope scope(e);
ScopedString s(scope, e->newIdentifier(name));
defineReadonlyProperty(s, value);
defineReadonlyProperty(s.getPointer(), value);
}
void Object::defineReadonlyProperty(const StringRef name, ValueRef value)
void Object::defineReadonlyProperty(String *name, ValueRef value)
{
insertMember(name, value, Attr_ReadOnly);
}
@ -221,10 +221,10 @@ void Object::ensureMemberIndex(uint idx)
memberData().ensureIndex(engine(), idx);
}
void Object::insertMember(const StringRef s, const Property &p, PropertyAttributes attributes)
void Object::insertMember(String *s, const Property &p, PropertyAttributes attributes)
{
uint idx;
InternalClass::addMember(this, s.getPointer(), attributes, &idx);
InternalClass::addMember(this, s, attributes, &idx);
ensureMemberIndex(internalClass()->size);
@ -240,7 +240,7 @@ void Object::insertMember(const StringRef s, const Property &p, PropertyAttribut
}
// Section 8.12.1
Property *Object::__getOwnProperty__(const StringRef name, PropertyAttributes *attrs)
Property *Object::__getOwnProperty__(String *name, PropertyAttributes *attrs)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
@ -278,7 +278,7 @@ Property *Object::__getOwnProperty__(uint index, PropertyAttributes *attrs)
}
// Section 8.12.2
Property *Object::__getPropertyDescriptor__(const StringRef name, PropertyAttributes *attrs) const
Property *Object::__getPropertyDescriptor__(String *name, PropertyAttributes *attrs) const
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
@ -287,7 +287,7 @@ Property *Object::__getPropertyDescriptor__(const StringRef name, PropertyAttrib
const Object *o = this;
while (o) {
uint idx = o->internalClass()->find(name.getPointer());
uint idx = o->internalClass()->find(name);
if (idx < UINT_MAX) {
if (attrs)
*attrs = o->internalClass()->propertyData[idx];
@ -326,7 +326,7 @@ Property *Object::__getPropertyDescriptor__(uint index, PropertyAttributes *attr
return 0;
}
bool Object::hasProperty(const StringRef name) const
bool Object::hasProperty(String *name) const
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
@ -356,7 +356,7 @@ bool Object::hasProperty(uint index) const
return false;
}
bool Object::hasOwnProperty(const StringRef name) const
bool Object::hasOwnProperty(String *name) const
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
@ -393,7 +393,7 @@ ReturnedValue Object::call(Managed *m, CallData *)
return m->engine()->currentContext()->throwTypeError();
}
ReturnedValue Object::get(Managed *m, const StringRef name, bool *hasProperty)
ReturnedValue Object::get(Managed *m, String *name, bool *hasProperty)
{
return static_cast<Object *>(m)->internalGet(name, hasProperty);
}
@ -403,7 +403,7 @@ ReturnedValue Object::getIndexed(Managed *m, uint index, bool *hasProperty)
return static_cast<Object *>(m)->internalGetIndexed(index, hasProperty);
}
void Object::put(Managed *m, const StringRef name, const ValueRef value)
void Object::put(Managed *m, String *name, const ValueRef value)
{
static_cast<Object *>(m)->internalPut(name, value);
}
@ -413,14 +413,14 @@ void Object::putIndexed(Managed *m, uint index, const ValueRef value)
static_cast<Object *>(m)->internalPutIndexed(index, value);
}
PropertyAttributes Object::query(const Managed *m, StringRef name)
PropertyAttributes Object::query(const Managed *m, String *name)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
return queryIndexed(m, idx);
const Object *o = static_cast<const Object *>(m);
idx = o->internalClass()->find(name.getPointer());
idx = o->internalClass()->find(name);
if (idx < UINT_MAX)
return o->internalClass()->propertyData[idx];
@ -441,7 +441,7 @@ PropertyAttributes Object::queryIndexed(const Managed *m, uint index)
return Attr_Invalid;
}
bool Object::deleteProperty(Managed *m, const StringRef name)
bool Object::deleteProperty(Managed *m, String *name)
{
return static_cast<Object *>(m)->internalDeleteProperty(name);
}
@ -505,7 +505,7 @@ void Object::setLookup(Managed *m, Lookup *l, const ValueRef value)
}
ScopedString s(scope, l->name);
o->put(s, value);
o->put(s.getPointer(), value);
if (o->internalClass() == c)
return;
@ -534,7 +534,7 @@ void Object::setLookup(Managed *m, Lookup *l, const ValueRef value)
l->setter = Lookup::setterGeneric;
}
void Object::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *pd, PropertyAttributes *attrs)
void Object::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *pd, PropertyAttributes *attrs)
{
Object *o = static_cast<Object *>(m);
name = (String *)0;
@ -601,7 +601,7 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uin
}
// Section 8.12.3
ReturnedValue Object::internalGet(const StringRef name, bool *hasProperty)
ReturnedValue Object::internalGet(String *name, bool *hasProperty)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
@ -611,7 +611,7 @@ ReturnedValue Object::internalGet(const StringRef name, bool *hasProperty)
Object *o = this;
while (o) {
uint idx = o->internalClass()->find(name.getPointer());
uint idx = o->internalClass()->find(name);
if (idx < UINT_MAX) {
if (hasProperty)
*hasProperty = true;
@ -661,7 +661,7 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty)
// Section 8.12.5
void Object::internalPut(const StringRef name, const ValueRef value)
void Object::internalPut(String *name, const ValueRef value)
{
if (internalClass()->engine->hasException)
return;
@ -672,7 +672,7 @@ void Object::internalPut(const StringRef name, const ValueRef value)
name->makeIdentifier();
uint member = internalClass()->find(name.getPointer());
uint member = internalClass()->find(name);
Property *pd = 0;
PropertyAttributes attrs;
if (member < UINT_MAX) {
@ -814,7 +814,7 @@ void Object::internalPutIndexed(uint index, const ValueRef value)
}
// Section 8.12.7
bool Object::internalDeleteProperty(const StringRef name)
bool Object::internalDeleteProperty(String *name)
{
if (internalClass()->engine->hasException)
return false;
@ -853,7 +853,7 @@ bool Object::internalDeleteIndexedProperty(uint index)
}
// Section 8.12.9
bool Object::__defineOwnProperty__(ExecutionContext *ctx, const StringRef name, const Property &p, PropertyAttributes attrs)
bool Object::__defineOwnProperty__(ExecutionContext *ctx, String *name, const Property &p, PropertyAttributes attrs)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
@ -895,7 +895,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, const StringRef name,
}
// Clause 1
memberIndex = internalClass()->find(name.getPointer());
memberIndex = internalClass()->find(name);
current = (memberIndex < UINT_MAX) ? propertyAt(memberIndex) : 0;
cattrs = internalClass()->propertyData.constData() + memberIndex;
@ -963,14 +963,14 @@ bool Object::defineOwnProperty2(ExecutionContext *ctx, uint index, const Propert
return true;
}
return __defineOwnProperty__(ctx, index, StringRef::null(), p, attrs);
return __defineOwnProperty__(ctx, index, 0, p, attrs);
reject:
if (ctx->d()->strictMode)
ctx->throwTypeError();
return false;
}
bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const StringRef member, const Property &p, PropertyAttributes attrs)
bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, String *member, const Property &p, PropertyAttributes attrs)
{
// clause 5
if (attrs.isEmpty())
@ -978,7 +978,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri
Property *current;
PropertyAttributes cattrs;
if (!member.isNull()) {
if (member) {
current = propertyAt(index);
cattrs = internalClass()->propertyData[index];
} else {
@ -1011,7 +1011,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri
// 9b
cattrs.setType(PropertyAttributes::Accessor);
cattrs.clearWritable();
if (member.isNull()) {
if (!member) {
// need to convert the array and the slot
initSparseArray();
setArrayAttributes(index, cattrs);
@ -1023,7 +1023,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri
// 9c
cattrs.setType(PropertyAttributes::Data);
cattrs.setWritable(false);
if (member.isNull()) {
if (!member) {
// need to convert the array and the slot
setArrayAttributes(index, cattrs);
current = arrayData()->getProperty(index);
@ -1048,8 +1048,8 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri
accept:
current->merge(cattrs, p, attrs);
if (!member.isNull()) {
InternalClass::changeMember(this, member.getPointer(), cattrs);
if (member) {
InternalClass::changeMember(this, member, cattrs);
} else {
setArrayAttributes(index, cattrs);
}
@ -1067,7 +1067,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, const QString &name, c
{
Scope scope(ctx);
ScopedString s(scope, ctx->d()->engine->newString(name));
return __defineOwnProperty__(ctx, s, p, attrs);
return __defineOwnProperty__(ctx, s.getPointer(), p, attrs);
}

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -133,10 +133,9 @@ void ObjectPrototype::init(ExecutionEngine *v4, ObjectRef ctor)
defineDefaultProperty(QStringLiteral("__defineGetter__"), method_defineGetter, 2);
defineDefaultProperty(QStringLiteral("__defineSetter__"), method_defineSetter, 2);
Scoped<String> id_proto(scope, v4->id___proto__);
Property p(v4->newBuiltinFunction(v4->rootContext, id_proto, method_get_proto)->getPointer(),
v4->newBuiltinFunction(v4->rootContext, id_proto, method_set_proto)->getPointer());
insertMember(StringRef(v4->id___proto__), p, Attr_Accessor|Attr_NotEnumerable);
Property p(v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_get_proto)->getPointer(),
v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_set_proto)->getPointer());
insertMember(v4->id___proto__, p, Attr_Accessor|Attr_NotEnumerable);
}
ReturnedValue ObjectPrototype::method_getPrototypeOf(CallContext *ctx)
@ -165,7 +164,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(CallContext *ctx)
if (scope.hasException())
return Encode::undefined();
PropertyAttributes attrs;
Property *desc = O->__getOwnProperty__(name, &attrs);
Property *desc = O->__getOwnProperty__(name.getPointer(), &attrs);
return fromPropertyDescriptor(ctx, desc, attrs);
}
@ -216,7 +215,7 @@ ReturnedValue ObjectPrototype::method_defineProperty(CallContext *ctx)
if (scope.engine->hasException)
return Encode::undefined();
if (!O->__defineOwnProperty__(ctx, name, pd, attrs))
if (!O->__defineOwnProperty__(ctx, name.getPointer(), pd, attrs))
return ctx->throwTypeError();
return O.asReturnedValue();
@ -240,7 +239,9 @@ ReturnedValue ObjectPrototype::method_defineProperties(CallContext *ctx)
uint index;
PropertyAttributes attrs;
Property pd;
it.next(name, &index, &pd, &attrs);
String *nm;
it.next(nm, &index, &pd, &attrs);
name = nm;
if (attrs.isEmpty())
break;
Property n;
@ -251,7 +252,7 @@ ReturnedValue ObjectPrototype::method_defineProperties(CallContext *ctx)
return Encode::undefined();
bool ok;
if (name)
ok = O->__defineOwnProperty__(ctx, name, n, nattrs);
ok = O->__defineOwnProperty__(ctx, name.getPointer(), n, nattrs);
else
ok = O->__defineOwnProperty__(ctx, index, n, nattrs);
if (!ok)
@ -455,9 +456,9 @@ ReturnedValue ObjectPrototype::method_hasOwnProperty(CallContext *ctx)
Scoped<Object> O(scope, ctx->d()->callData->thisObject, Scoped<Object>::Convert);
if (scope.engine->hasException)
return Encode::undefined();
bool r = O->hasOwnProperty(P);
bool r = O->hasOwnProperty(P.getPointer());
if (!r)
r = !O->query(P).isEmpty();
r = !O->query(P.getPointer()).isEmpty();
return Encode(r);
}
@ -491,7 +492,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(CallContext *ctx)
if (scope.engine->hasException)
return Encode::undefined();
PropertyAttributes attrs;
o->__getOwnProperty__(p, &attrs);
o->__getOwnProperty__(p.getPointer(), &attrs);
return Encode(attrs.isEnumerable());
}
@ -519,7 +520,7 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx)
Property pd;
pd.value = f;
pd.set = Primitive::emptyValue();
o->__defineOwnProperty__(ctx, prop, pd, Attr_Accessor);
o->__defineOwnProperty__(ctx, prop.getPointer(), pd, Attr_Accessor);
return Encode::undefined();
}
@ -547,7 +548,7 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx)
Property pd;
pd.value = Primitive::emptyValue();
pd.set = f;
o->__defineOwnProperty__(ctx, prop, pd, Attr_Accessor);
o->__defineOwnProperty__(ctx, prop.getPointer(), pd, Attr_Accessor);
return Encode::undefined();
}
@ -671,24 +672,24 @@ ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionContext *ctx, con
if (attrs.isData()) {
pd.value = desc->value;
s = engine->newString(QStringLiteral("value"));
o->__defineOwnProperty__(ctx, s, pd, Attr_Data);
o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
pd.value = Primitive::fromBoolean(attrs.isWritable());
s = engine->newString(QStringLiteral("writable"));
o->__defineOwnProperty__(ctx, s, pd, Attr_Data);
o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
} else {
pd.value = desc->getter() ? desc->getter()->asReturnedValue() : Encode::undefined();
s = engine->newString(QStringLiteral("get"));
o->__defineOwnProperty__(ctx, s, pd, Attr_Data);
o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
pd.value = desc->setter() ? desc->setter()->asReturnedValue() : Encode::undefined();
s = engine->newString(QStringLiteral("set"));
o->__defineOwnProperty__(ctx, s, pd, Attr_Data);
o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
}
pd.value = Primitive::fromBoolean(attrs.isEnumerable());
s = engine->newString(QStringLiteral("enumerable"));
o->__defineOwnProperty__(ctx, s, pd, Attr_Data);
o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
pd.value = Primitive::fromBoolean(attrs.isConfigurable());
s = engine->newString(QStringLiteral("configurable"));
o->__defineOwnProperty__(ctx, s, pd, Attr_Data);
o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
return o.asReturnedValue();
}

View File

@ -314,7 +314,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD
}
}
}
return QV4::Object::get(this, name, hasProperty);
return QV4::Object::get(this, name.getPointer(), hasProperty);
}
QQmlData *ddata = QQmlData::get(d()->object, false);
@ -352,8 +352,8 @@ ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx
QV4::ScopedString connect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("connect")));
QV4::ScopedString disconnect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("disconnect")));
handler->put(connect, QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(connect)));
handler->put(disconnect, QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(disconnect)));
handler->put(connect.getPointer(), QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(connect.getPointer())));
handler->put(disconnect.getPointer(), QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(disconnect.getPointer())));
return handler.asReturnedValue();
} else {
@ -664,15 +664,15 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
return (new (engine->memoryManager) QV4::QObjectWrapper(engine, object))->asReturnedValue();
}
QV4::ReturnedValue QObjectWrapper::get(Managed *m, const StringRef name, bool *hasProperty)
QV4::ReturnedValue QObjectWrapper::get(Managed *m, String *name, bool *hasProperty)
{
QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
ExecutionEngine *v4 = m->engine();
QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4);
return that->getQmlProperty(v4->currentContext(), qmlContext, name.getPointer(), IgnoreRevision, hasProperty, /*includeImports*/ true);
return that->getQmlProperty(v4->currentContext(), qmlContext, name, IgnoreRevision, hasProperty, /*includeImports*/ true);
}
void QObjectWrapper::put(Managed *m, const StringRef name, const ValueRef value)
void QObjectWrapper::put(Managed *m, String *name, const ValueRef value)
{
QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
ExecutionEngine *v4 = m->engine();
@ -681,7 +681,7 @@ void QObjectWrapper::put(Managed *m, const StringRef name, const ValueRef value)
return;
QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4);
if (!setQmlProperty(v4->currentContext(), qmlContext, that->d()->object, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value)) {
if (!setQmlProperty(v4->currentContext(), qmlContext, that->d()->object, name, QV4::QObjectWrapper::IgnoreRevision, value)) {
QQmlData *ddata = QQmlData::get(that->d()->object);
// Types created by QML are not extensible at run-time, but for other QObjects we can store them
// as regular JavaScript properties, like on JavaScript objects.
@ -695,7 +695,7 @@ void QObjectWrapper::put(Managed *m, const StringRef name, const ValueRef value)
}
}
PropertyAttributes QObjectWrapper::query(const Managed *m, StringRef name)
PropertyAttributes QObjectWrapper::query(const Managed *m, String *name)
{
const QObjectWrapper *that = static_cast<const QObjectWrapper*>(m);
ExecutionEngine *engine = that->engine();
@ -708,7 +708,7 @@ PropertyAttributes QObjectWrapper::query(const Managed *m, StringRef name)
return QV4::Object::query(m, name);
}
void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attributes)
void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes)
{
// Used to block access to QObject::destroyed() and QObject::deleteLater() from QML
static const int destroyedIdx1 = QObject::staticMetaObject.indexOfSignal("destroyed(QObject*)");
@ -724,7 +724,7 @@ void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, StringRef n
const QMetaObject *mo = that->d()->object->metaObject();
const int propertyCount = mo->propertyCount();
if (it->arrayIndex < static_cast<uint>(propertyCount)) {
name = that->engine()->newString(QString::fromUtf8(mo->property(it->arrayIndex).name()));
name = that->engine()->newString(QString::fromUtf8(mo->property(it->arrayIndex).name()))->getPointer();
++it->arrayIndex;
*attributes = QV4::Attr_Data;
p->value = that->get(name);
@ -737,7 +737,7 @@ void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, StringRef n
++it->arrayIndex;
if (method.access() == QMetaMethod::Private || index == deleteLaterIdx || index == destroyedIdx1 || index == destroyedIdx2)
continue;
name = that->engine()->newString(QString::fromUtf8(method.name()));
name = that->engine()->newString(QString::fromUtf8(method.name()))->getPointer();
*attributes = QV4::Attr_Data;
p->value = that->get(name);
return;

View File

@ -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);

View File

@ -151,7 +151,7 @@ void RegExpObject::init(ExecutionEngine *engine)
ScopedString lastIndex(scope, engine->newIdentifier(QStringLiteral("lastIndex")));
ScopedValue v(scope, Primitive::fromInt32(0));
insertMember(lastIndex, v, Attr_NotEnumerable|Attr_NotConfigurable);
insertMember(lastIndex.getPointer(), v, Attr_NotEnumerable|Attr_NotConfigurable);
if (!this->value())
return;
@ -211,7 +211,7 @@ QString RegExpObject::source() const
{
Scope scope(engine());
ScopedString source(scope, scope.engine->newIdentifier(QStringLiteral("source")));
ScopedValue s(scope, const_cast<RegExpObject *>(this)->get(source));
ScopedValue s(scope, const_cast<RegExpObject *>(this)->get(source.getPointer()));
return s->toQString();
}

View File

@ -283,10 +283,10 @@ ReturnedValue Runtime::deleteElement(ExecutionContext *ctx, const ValueRef base,
}
ScopedString name(scope, index->toString(ctx));
return Runtime::deleteMember(ctx, base, name);
return Runtime::deleteMember(ctx, base, name.getPointer());
}
ReturnedValue Runtime::deleteMember(ExecutionContext *ctx, const ValueRef base, const StringRef name)
ReturnedValue Runtime::deleteMember(ExecutionContext *ctx, const ValueRef base, String *name)
{
Scope scope(ctx);
ScopedObject obj(scope, base->toObject(ctx));
@ -295,7 +295,7 @@ ReturnedValue Runtime::deleteMember(ExecutionContext *ctx, const ValueRef base,
return Encode(obj->deleteProperty(name));
}
ReturnedValue Runtime::deleteName(ExecutionContext *ctx, const StringRef name)
ReturnedValue Runtime::deleteName(ExecutionContext *ctx, String *name)
{
Scope scope(ctx);
return Encode(ctx->deleteProperty(name));
@ -341,7 +341,7 @@ QV4::ReturnedValue Runtime::in(ExecutionContext *ctx, const ValueRef left, const
ScopedString s(scope, left->toString(ctx));
if (scope.hasException())
return Encode::undefined();
bool r = right->objectValue()->hasProperty(s);
bool r = right->objectValue()->hasProperty(s.getPointer());
return Encode(r);
}
@ -551,7 +551,7 @@ QV4::ReturnedValue Runtime::addString(QV4::ExecutionContext *ctx, const QV4::Val
return (new (ctx->engine()->memoryManager) String(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue();
}
void Runtime::setProperty(ExecutionContext *ctx, const ValueRef object, const StringRef name, const ValueRef value)
void Runtime::setProperty(ExecutionContext *ctx, const ValueRef object, String *name, const ValueRef value)
{
Scope scope(ctx);
ScopedObject o(scope, object->toObject(ctx));
@ -600,7 +600,7 @@ ReturnedValue Runtime::getElement(ExecutionContext *ctx, const ValueRef object,
ScopedString name(scope, index->toString(ctx));
if (scope.hasException())
return Encode::undefined();
return o->get(name);
return o->get(name.getPointer());
}
void Runtime::setElement(ExecutionContext *ctx, const ValueRef object, const ValueRef index, const ValueRef value)
@ -624,7 +624,7 @@ void Runtime::setElement(ExecutionContext *ctx, const ValueRef object, const Val
}
ScopedString name(scope, index->toString(ctx));
o->put(name, value);
o->put(name.getPointer(), value);
}
ReturnedValue Runtime::foreachIterator(ExecutionContext *ctx, const ValueRef in)
@ -648,12 +648,12 @@ ReturnedValue Runtime::foreachNextPropertyName(const ValueRef foreach_iterator)
}
void Runtime::setActivationProperty(ExecutionContext *ctx, const StringRef name, const ValueRef value)
void Runtime::setActivationProperty(ExecutionContext *ctx, String *name, const ValueRef value)
{
ctx->setProperty(name, value);
}
ReturnedValue Runtime::getProperty(ExecutionContext *ctx, const ValueRef object, const StringRef name)
ReturnedValue Runtime::getProperty(ExecutionContext *ctx, const ValueRef object, String *name)
{
Scope scope(ctx);
@ -672,7 +672,7 @@ ReturnedValue Runtime::getProperty(ExecutionContext *ctx, const ValueRef object,
return o->get(name);
}
ReturnedValue Runtime::getActivationProperty(ExecutionContext *ctx, const StringRef name)
ReturnedValue Runtime::getActivationProperty(ExecutionContext *ctx, String *name)
{
return ctx->getProperty(name);
}
@ -883,7 +883,7 @@ ReturnedValue Runtime::callGlobalLookup(ExecutionContext *context, uint index, C
}
ReturnedValue Runtime::callActivationProperty(ExecutionContext *context, const StringRef name, CallDataRef callData)
ReturnedValue Runtime::callActivationProperty(ExecutionContext *context, String *name, CallDataRef callData)
{
Q_ASSERT(callData->thisObject.isUndefined());
Scope scope(context);
@ -912,7 +912,7 @@ ReturnedValue Runtime::callActivationProperty(ExecutionContext *context, const S
return o->call(callData);
}
ReturnedValue Runtime::callProperty(ExecutionContext *context, const StringRef name, CallDataRef callData)
ReturnedValue Runtime::callProperty(ExecutionContext *context, String *name, CallDataRef callData)
{
Scope scope(context);
Scoped<Object> baseObject(scope, callData->thisObject);
@ -959,7 +959,7 @@ ReturnedValue Runtime::callElement(ExecutionContext *context, const ValueRef ind
return Encode::undefined();
callData->thisObject = baseObject;
ScopedObject o(scope, baseObject->get(s));
ScopedObject o(scope, baseObject->get(s.getPointer()));
if (!o)
return context->throwTypeError();
@ -989,7 +989,7 @@ ReturnedValue Runtime::constructGlobalLookup(ExecutionContext *context, uint ind
}
ReturnedValue Runtime::constructActivationProperty(ExecutionContext *context, const StringRef name, CallDataRef callData)
ReturnedValue Runtime::constructActivationProperty(ExecutionContext *context, String *name, CallDataRef callData)
{
Scope scope(context);
ScopedValue func(scope, context->getProperty(name));
@ -1012,7 +1012,7 @@ ReturnedValue Runtime::constructValue(ExecutionContext *context, const ValueRef
return f->construct(callData);
}
ReturnedValue Runtime::constructProperty(ExecutionContext *context, const StringRef name, CallDataRef callData)
ReturnedValue Runtime::constructProperty(ExecutionContext *context, String *name, CallDataRef callData)
{
Scope scope(context);
ScopedObject thisObject(scope, callData->thisObject.toObject(context));
@ -1073,7 +1073,7 @@ ReturnedValue Runtime::typeofValue(ExecutionContext *ctx, const ValueRef value)
return res.asReturnedValue();
}
QV4::ReturnedValue Runtime::typeofName(ExecutionContext *context, const StringRef name)
QV4::ReturnedValue Runtime::typeofName(ExecutionContext *context, String *name)
{
Scope scope(context);
ScopedValue prop(scope, context->getProperty(name));
@ -1082,7 +1082,7 @@ QV4::ReturnedValue Runtime::typeofName(ExecutionContext *context, const StringRe
return Runtime::typeofValue(context, prop);
}
QV4::ReturnedValue Runtime::typeofMember(ExecutionContext *context, const ValueRef base, const StringRef name)
QV4::ReturnedValue Runtime::typeofMember(ExecutionContext *context, const ValueRef base, String *name)
{
Scope scope(context);
ScopedObject obj(scope, base->toObject(context));
@ -1099,7 +1099,7 @@ QV4::ReturnedValue Runtime::typeofElement(ExecutionContext *context, const Value
ScopedObject obj(scope, base->toObject(context));
if (scope.engine->hasException)
return Encode::undefined();
ScopedValue prop(scope, obj->get(name));
ScopedValue prop(scope, obj->get(name.getPointer()));
return Runtime::typeofValue(context, prop);
}
@ -1117,7 +1117,7 @@ ReturnedValue Runtime::unwindException(ExecutionContext *ctx)
return ctx->engine()->catchException(ctx, 0);
}
ExecutionContext *Runtime::pushCatchScope(ExecutionContext *ctx, const StringRef exceptionVarName)
ExecutionContext *Runtime::pushCatchScope(ExecutionContext *ctx, String *exceptionVarName)
{
Scope scope(ctx);
ScopedValue v(scope, ctx->engine()->catchException(ctx, 0));
@ -1129,7 +1129,7 @@ ExecutionContext *Runtime::popScope(ExecutionContext *ctx)
return ctx->engine()->popContext();
}
void Runtime::declareVar(ExecutionContext *ctx, bool deletable, const StringRef name)
void Runtime::declareVar(ExecutionContext *ctx, bool deletable, String *name)
{
ctx->createMutableBinding(name, deletable);
}
@ -1344,7 +1344,7 @@ ReturnedValue Runtime::getQmlImportedScripts(NoThrowContext *ctx)
return context->importedScripts.value();
}
QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowContext *ctx, const QV4::StringRef name)
QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowContext *ctx, String *name)
{
return ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->qmlSingletonWrapper(ctx->engine()->v8Engine, name);
}

View File

@ -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);

View File

@ -308,6 +308,9 @@ struct Scoped
return *this;
}
operator T *() {
return static_cast<T *>(ptr->managed());
}
T *operator->() {
return static_cast<T *>(ptr->managed());
@ -379,7 +382,6 @@ struct ScopedCallData {
};
struct StringRef;
struct ObjectRef;
struct FunctionObjectRef;

View File

@ -155,7 +155,7 @@ Returned<FunctionObject> *QmlBindingWrapper::createQmlCallableForFunction(QQmlCo
p->setGetter(new (engine->memoryManager) QV4::IndexedBuiltinFunction(wrapper->context(), index++, signalParameterGetter));
p->setSetter(0);
s = engine->newString(QString::fromUtf8(param));
qmlScopeObject->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable);
qmlScopeObject->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable);
}
}

View File

@ -300,7 +300,7 @@ public:
return (signedIdx < d()->container.count()) ? QV4::Attr_Data : QV4::Attr_Invalid;
}
void containerAdvanceIterator(ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attrs)
void containerAdvanceIterator(ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
{
name = (String *)0;
*index = UINT_MAX;
@ -519,7 +519,7 @@ private:
{ return static_cast<QQmlSequence<Container> *>(that)->containerDeleteIndexedProperty(index); }
static bool isEqualTo(Managed *that, Managed *other)
{ return static_cast<QQmlSequence<Container> *>(that)->containerIsEqualTo(other); }
static void advanceIterator(Managed *that, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attrs)
static void advanceIterator(Managed *that, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
{ return static_cast<QQmlSequence<Container> *>(that)->containerAdvanceIterator(it, name, index, p, attrs); }
static void destroy(Managed *that)

View File

@ -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);

View File

@ -139,7 +139,7 @@ void String::markObjects(Managed *that, ExecutionEngine *e)
}
}
ReturnedValue String::get(Managed *m, const StringRef name, bool *hasProperty)
ReturnedValue String::get(Managed *m, String *name, bool *hasProperty)
{
ExecutionEngine *v4 = m->engine();
Scope scope(v4);
@ -185,7 +185,7 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty)
return engine->stringObjectClass->prototype->getValue(that, pd, attrs);
}
void String::put(Managed *m, const StringRef name, const ValueRef value)
void String::put(Managed *m, String *name, const ValueRef value)
{
Scope scope(m->engine());
if (scope.hasException())
@ -206,7 +206,7 @@ void String::putIndexed(Managed *m, uint index, const ValueRef value)
o->putIndexed(index, value);
}
PropertyAttributes String::query(const Managed *m, StringRef name)
PropertyAttributes String::query(const Managed *m, String *name)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
@ -220,7 +220,7 @@ PropertyAttributes String::queryIndexed(const Managed *m, uint index)
return (index < static_cast<uint>(that->d()->text->size)) ? Attr_NotConfigurable|Attr_NotWritable : Attr_Invalid;
}
bool String::deleteProperty(Managed *, const StringRef)
bool String::deleteProperty(Managed *, String *)
{
return false;
}
@ -304,9 +304,9 @@ uint String::toUInt(bool *ok) const
return UINT_MAX;
}
bool String::equals(const StringRef other) const
bool String::equals(String *other) const
{
if (this == other.getPointer())
if (this == other)
return true;
if (hashValue() != other->hashValue())
return false;

View File

@ -100,7 +100,7 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed {
QStringData::deallocate(d()->text);
}
bool equals(const StringRef other) const;
bool equals(String *other) const;
inline bool isEqualTo(const String *other) const {
if (this == other)
return true;
@ -176,13 +176,13 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed {
protected:
static void destroy(Managed *);
static void markObjects(Managed *that, ExecutionEngine *e);
static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void put(Managed *m, const StringRef name, const ValueRef value);
static void put(Managed *m, String *name, const ValueRef value);
static void putIndexed(Managed *m, uint index, const ValueRef value);
static PropertyAttributes query(const Managed *m, StringRef name);
static PropertyAttributes query(const Managed *m, String *name);
static PropertyAttributes queryIndexed(const Managed *m, uint index);
static bool deleteProperty(Managed *, const StringRef);
static bool deleteProperty(Managed *, String *);
static bool deleteIndexedProperty(Managed *m, uint index);
static bool isEqualTo(Managed *that, Managed *o);
static uint getLength(const Managed *m);
@ -207,7 +207,6 @@ inline ReturnedValue value_convert<String>(ExecutionEngine *e, const Value &v)
return v.toString(e)->asReturnedValue();
}
DEFINE_REF(String, Managed);
#endif
}

View File

@ -135,7 +135,7 @@ bool StringObject::deleteIndexedProperty(Managed *m, uint index)
return true;
}
void StringObject::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attrs)
void StringObject::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
{
name = (String *)0;
StringObject *s = static_cast<StringObject *>(m);
@ -400,7 +400,7 @@ ReturnedValue StringPrototype::method_match(CallContext *context)
// ### use the standard builtin function, not the one that might be redefined in the proto
ScopedString execString(scope, context->d()->engine->newString(QStringLiteral("exec")));
Scoped<FunctionObject> exec(scope, context->d()->engine->regExpClass->prototype->get(execString));
Scoped<FunctionObject> exec(scope, context->d()->engine->regExpClass->prototype->get(execString.getPointer()));
ScopedCallData callData(scope, 1);
callData->thisObject = rx;
@ -409,7 +409,7 @@ ReturnedValue StringPrototype::method_match(CallContext *context)
return exec->call(callData);
ScopedString lastIndex(scope, context->d()->engine->newString(QStringLiteral("lastIndex")));
rx->put(lastIndex, ScopedValue(scope, Primitive::fromInt32(0)));
rx->put(lastIndex.getPointer(), ScopedValue(scope, Primitive::fromInt32(0)));
Scoped<ArrayObject> a(scope, context->d()->engine->newArrayObject());
double previousLastIndex = 0;
@ -422,11 +422,11 @@ ReturnedValue StringPrototype::method_match(CallContext *context)
if (result->isNull())
break;
assert(result->isObject());
index = rx->get(lastIndex, 0);
index = rx->get(lastIndex.getPointer(), 0);
double thisIndex = index->toInteger();
if (previousLastIndex == thisIndex) {
previousLastIndex = thisIndex + 1;
rx->put(lastIndex, ScopedValue(scope, Primitive::fromDouble(previousLastIndex)));
rx->put(lastIndex.getPointer(), ScopedValue(scope, Primitive::fromDouble(previousLastIndex)));
} else {
previousLastIndex = thisIndex;
}

View File

@ -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);
};

View File

@ -444,6 +444,7 @@ struct TypedValue : public Value
bool operator!() const { return !managed(); }
operator T *() { return static_cast<T *>(managed()); }
T *operator->() { return static_cast<T *>(managed()); }
const T *operator->() const { return static_cast<T *>(managed()); }
T *getPointer() const { return static_cast<T *>(managed()); }

View File

@ -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();

View File

@ -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);
};

View File

@ -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<QmlListWrapper>();
@ -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;

View File

@ -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);
};

View File

@ -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<QmlTypeWrapper>();
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<Object *>(const_cast<Managed*>(m))->get(n, &hasProperty);
static_cast<Object *>(const_cast<Managed*>(m))->get(name, &hasProperty);
return hasProperty ? Attr_Data : Attr_Invalid;
}

View File

@ -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);

View File

@ -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<const QmlValueTypeWrapper>();
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<QmlValueTypeWrapper>();
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);

View File

@ -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);

View File

@ -105,9 +105,9 @@ static ReturnedValue constructMeObject(const ValueRef thisObj, QV8Engine *e)
ExecutionEngine *v4 = QV8Engine::getV4(e);
Scope scope(v4);
Scoped<Object> 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>()->~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>()->~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<NamedNodeMap>();
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<NodeList>();
@ -1570,21 +1570,21 @@ void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me)
}
ScopedString s(scope, v4->newString(QStringLiteral("ThisObject")));
Scoped<Object> thisObj(scope, o->get(s));
Scoped<Object> thisObj(scope, o->get(s.getPointer()));
if (!thisObj) {
ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
return;
}
s = v4->newString(QStringLiteral("onreadystatechange"));
Scoped<FunctionObject> callback(scope, thisObj->get(s));
Scoped<FunctionObject> callback(scope, thisObj->get(s.getPointer()));
if (!callback) {
// not an error, but no onreadystatechange function to call.
return;
}
s = v4->newString(QStringLiteral("ActivationObject"));
Scoped<Object> activationObject(scope, o->get(s));
Scoped<Object> 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<QQmlXMLHttpRequestCtor> 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;

View File

@ -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<Object> 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();
}
};

View File

@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE
#define V4THROW_DOM(error, string) { \
QV4::ScopedValue v(scope, scope.engine->newString(QStringLiteral(string))); \
QV4::Scoped<Object> 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); \
}

View File

@ -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<QV4::QObjectWrapper>()) {
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;
}

View File

@ -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<QQmlDelegateModelGroupChangeArray>();
if (!array)

View File

@ -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<Role *>::Node *node = roleHash.findNode(key.getPointer());
QStringHash<Role *>::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<Role *>::Node *node = roleHash.findNode(key.getPointer());
QStringHash<Role *>::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<int> *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<int> *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<QV4::QObjectWrapper>()) {
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 {

View File

@ -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(); }

View File

@ -235,7 +235,7 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init()
QV4::Scoped<QV4::FunctionObject> 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<QV4::Object> 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);
}

View File

@ -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;
}

View File

@ -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<QQuickJSContext2DPixelData> pixelData(scope, o->get(s));
QV4::Scoped<QQuickJSContext2DPixelData> 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<QV4::Object> 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;
}

View File

@ -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())));
}
}
}

View File

@ -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()) {

View File

@ -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);