#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(); \
}
#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; \
}
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;
// 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;
}
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);
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)
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)
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();
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);
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();
}
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();
}
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;
return false;
ScopedString s(scope, engine->newIdentifier(name));
- return o->hasProperty(s);
+ return o->hasProperty(s.getPointer());
}
/*!
return false;
ScopedString s(scope, engine->newIdentifier(name));
- return o->hasOwnProperty(s);
+ return o->hasOwnProperty(s.getPointer());
}
/*!
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;
}
/*!
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;
}
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;
}
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;
// 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();
R += r4;
name = Primitive::fromDouble(k).toString(ctx);
- r12 = self->get(name);
+ r12 = self->get(name.getPointer());
if (scope.hasException())
return Encode::undefined();
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())
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;
-void ExecutionContext::createMutableBinding(const StringRef name, bool deletable)
+void ExecutionContext::createMutableBinding(String *name, bool deletable)
{
Scope scope(this);
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;
-bool ExecutionContext::deleteProperty(const StringRef name)
+bool ExecutionContext::deleteProperty(String *name)
{
Scope scope(this);
bool hasWith = false;
}
}
-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) {
}
}
}
- 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;
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;
return v.asReturnedValue();
}
}
- ScopedValue n(scope, name.asReturnedValue());
+ ScopedValue n(scope, name);
return throwReferenceError(n);
}
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);
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);
} __data;
V4_MANAGED
- CatchContext(ExecutionEngine *engine, const StringRef exceptionVarName, const ValueRef exceptionValue);
+ CatchContext(ExecutionEngine *engine, String *exceptionVarName, const ValueRef exceptionValue);
};
struct WithContext : public ExecutionContext
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)
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()
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>();
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());
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();
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();
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(); }
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;
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)
Scope s(scope);
ScopedValue protectThis(s, this);
ScopedString n(s, name);
- init(n, false);
+ init(n.getPointer(), false);
}
FunctionObject::FunctionObject(InternalClass *ic)
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);
memberData()[Index_Prototype] = Encode::undefined();
}
- ScopedValue v(s, n.asReturnedValue());
+ ScopedValue v(s, n);
defineReadonlyProperty(scope()->d()->engine->id_name, v);
}
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;
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();
} __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);
typedef Returned<Object> ReturnedObject;
typedef Returned<FunctionObject> ReturnedFunctionObject;
struct ManagedRef;
-struct StringRef;
struct ObjectRef;
struct ArrayObjectRef;
struct FunctionObjectRef;
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();
}
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());
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);
}
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();
}
-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();
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);
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();
if (idx < UINT_MAX) {
o->putIndexed(idx, val);
} else {
- o->insertMember(s, val);
+ o->insertMember(s.getPointer(), val);
}
END;
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;
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);
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();
}
ScopedString name(scope, index->toString(ctx));
if (scope.hasException())
return Encode::undefined();
- return o->get(name);
+ return o->get(name.getPointer());
}
}
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)
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);
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)
if (!o) // type error
return;
ScopedString s(scope, l->name);
- o->put(s, value);
+ o->put(s.getPointer(), value);
return;
}
o->setLookup(l, value);
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);
}
}
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);
};
{
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)
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)
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);
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);
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);
}
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);
}
// 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)
}
// 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)
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];
return 0;
}
-bool Object::hasProperty(const StringRef name) const
+bool Object::hasProperty(String *name) const
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
return false;
}
-bool Object::hasOwnProperty(const StringRef name) const
+bool Object::hasOwnProperty(String *name) const
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
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);
}
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);
}
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];
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);
}
}
ScopedString s(scope, l->name);
- o->put(s, value);
+ o->put(s.getPointer(), value);
if (o->internalClass() == c)
return;
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;
}
// 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)
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;
// 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;
name->makeIdentifier();
- uint member = internalClass()->find(name.getPointer());
+ uint member = internalClass()->find(name);
Property *pd = 0;
PropertyAttributes attrs;
if (member < UINT_MAX) {
}
// Section 8.12.7
-bool Object::internalDeleteProperty(const StringRef name)
+bool Object::internalDeleteProperty(String *name)
{
if (internalClass()->engine->hasException)
return false;
}
// 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)
}
// Clause 1
- memberIndex = internalClass()->find(name.getPointer());
+ memberIndex = internalClass()->find(name);
current = (memberIndex < UINT_MAX) ? propertyAt(memberIndex) : 0;
cattrs = internalClass()->propertyData.constData() + memberIndex;
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())
Property *current;
PropertyAttributes cattrs;
- if (!member.isNull()) {
+ if (member) {
current = propertyAt(index);
cattrs = internalClass()->propertyData[index];
} else {
// 9b
cattrs.setType(PropertyAttributes::Accessor);
cattrs.clearWritable();
- if (member.isNull()) {
+ if (!member) {
// need to convert the array and the slot
initSparseArray();
setArrayAttributes(index, cattrs);
// 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);
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);
}
{
Scope scope(ctx);
ScopedString s(scope, ctx->d()->engine->newString(name));
- return __defineOwnProperty__(ctx, s, p, attrs);
+ return __defineOwnProperty__(ctx, s.getPointer(), p, attrs);
}
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);
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; }
}
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); }
{ 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); }
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;
}
}
-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;
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();
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();
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();
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();
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)
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);
}
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();
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;
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)
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);
}
if (scope.engine->hasException)
return Encode::undefined();
PropertyAttributes attrs;
- o->__getOwnProperty__(p, &attrs);
+ o->__getOwnProperty__(p.getPointer(), &attrs);
return Encode(attrs.isEnumerable());
}
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();
}
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();
}
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();
}
}
}
}
- return QV4::Object::get(this, name, hasProperty);
+ return QV4::Object::get(this, name.getPointer(), hasProperty);
}
QQmlData *ddata = QQmlData::get(d()->object, false);
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 {
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();
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.
}
}
-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();
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*)");
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);
++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;
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);
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;
{
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();
}
}
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));
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));
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);
}
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));
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)
}
ScopedString name(scope, index->toString(ctx));
- o->put(name, value);
+ o->put(name.getPointer(), value);
}
ReturnedValue Runtime::foreachIterator(ExecutionContext *ctx, const ValueRef in)
}
-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);
return o->get(name);
}
-ReturnedValue Runtime::getActivationProperty(ExecutionContext *ctx, const StringRef name)
+ReturnedValue Runtime::getActivationProperty(ExecutionContext *ctx, String *name)
{
return ctx->getProperty(name);
}
}
-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);
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);
return Encode::undefined();
callData->thisObject = baseObject;
- ScopedObject o(scope, baseObject->get(s));
+ ScopedObject o(scope, baseObject->get(s.getPointer()));
if (!o)
return context->throwTypeError();
}
-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));
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));
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));
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));
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);
}
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));
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);
}
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);
}
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);
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);
return *this;
}
+ operator T *() {
+ return static_cast<T *>(ptr->managed());
+ }
T *operator->() {
return static_cast<T *>(ptr->managed());
};
-struct StringRef;
struct ObjectRef;
struct FunctionObjectRef;
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);
}
}
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;
{ 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)
QV4::ExecutionContext *ctx = v4->currentContext();
str = s;
- val = o->get(str);
+ val = o->get(str.getPointer());
if (scope.hasException())
ctx->catchException();
name = deserialize(data, engine);
value = deserialize(data, engine);
n = name.asReturnedValue();
- o->put(n, value);
+ o->put(n.getPointer(), value);
}
return o.asReturnedValue();
}
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);
}
}
-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);
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())
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)
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;
}
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;
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;
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);
return v.toString(e)->asReturnedValue();
}
-DEFINE_REF(String, Managed);
#endif
}
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);
// ### 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;
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;
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;
}
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);
};
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()); }
}
-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);
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) {
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;
// 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;
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);
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;
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();
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);
};
}
-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>();
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);
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;
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);
};
}
-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);
}
// 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));
} 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
}
}
-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();
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();
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) {
}
}
-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;
}
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);
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();
{
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;
}
}
}
-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();
{
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);
}
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) \
#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);
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);
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();
}
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);
};
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
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();
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>();
}
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;
if (!d()->proto)
setupProto();
ScopedString s(scope, engine->id_prototype);
- defineDefaultProperty(s, ScopedObject(scope, d()->proto));
+ defineDefaultProperty(s.getPointer(), ScopedObject(scope, d()->proto));
}
~QQmlXMLHttpRequestCtor()
{}
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;
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);
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();
}
};
#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); \
}
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();
}
if (idx < UINT_MAX)
o->arraySet(idx, v);
else
- o->insertMember(s, v);
+ o->insertMember(s.getPointer(), v);
}
return o.asReturnedValue();
}
}
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;
}
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);
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;
}
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)
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)
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;
// 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();
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 {
};
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(); }
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;
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);
}
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;
}
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;
}
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();
}
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;
}
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())));
}
}
}
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())));
}
}
}
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()) {
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;
}
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);