memset(data->data(), 0, length + 1);
}
- : Heap::Object(e->emptyClass, e->arrayBufferPrototype.asObject())
+ Heap::ArrayBuffer::ArrayBuffer(ExecutionEngine *e, const QByteArray& array)
++ : Heap::Object(e->emptyClass, e->arrayBufferPrototype.as<QV4::Object>())
+ , data(const_cast<QByteArray&>(array).data_ptr())
+ {
+ data->ref.ref();
+ }
+
Heap::ArrayBuffer::~ArrayBuffer()
{
if (!data->ref.deref())
uint index;
InternalClass *functionProtoClass = emptyClass->addMember(id_prototype, Attr_NotEnumerable, &index);
Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
- functionPrototype = memoryManager->alloc<FunctionPrototype>(functionProtoClass, objectPrototype.asObject());
+ functionPrototype = memoryManager->alloc<FunctionPrototype>(functionProtoClass, objectPrototype.as<Object>());
functionClass = emptyClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index);
Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
+ simpleScriptFunctionClass = functionClass->addMember(id_name, Attr_ReadOnly, &index);
+ Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Name);
+ simpleScriptFunctionClass = simpleScriptFunctionClass->addMember(id_length, Attr_ReadOnly, &index);
+ Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Length);
protoClass = emptyClass->addMember(id_constructor, Attr_NotEnumerable, &index);
Q_ASSERT(index == Heap::FunctionObject::Index_ProtoConstructor);
DEFINE_OBJECT_VTABLE(FunctionObject);
Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, QV4::String *name, bool createProto)
- : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.asObject())
+ : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.objectValue())
, scope(scope->d())
+ , function(Q_NULLPTR)
{
Scope s(scope->engine());
ScopedFunctionObject f(s, this);
}
Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, Function *function, bool createProto)
- : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.asObject())
+ : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.objectValue())
, scope(scope->d())
+ , function(Q_NULLPTR)
{
Scope s(scope->engine());
ScopedString name(s, function->name());
}
Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const QString &name, bool createProto)
- : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.asObject())
+ : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.objectValue())
, scope(scope->d())
+ , function(Q_NULLPTR)
{
Scope s(scope->engine());
ScopedFunctionObject f(s, this);
}
Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto)
- : Heap::Object(scope->engine->functionClass, scope->engine->functionPrototype.asObject())
+ : Heap::Object(scope->engine->functionClass, scope->engine->functionPrototype.objectValue())
, scope(scope)
+ , function(Q_NULLPTR)
{
Scope s(scope->engine);
ScopedFunctionObject f(s, this);
}
Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const ReturnedValue name)
- : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.asObject())
+ : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.objectValue())
, scope(scope->d())
+ , function(Q_NULLPTR)
{
Scope s(scope);
ScopedFunctionObject f(s, this);
}
Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name)
- : Heap::Object(scope->engine->functionClass, scope->engine->functionPrototype.asObject())
+ : Heap::Object(scope->engine->functionClass, scope->engine->functionPrototype.objectValue())
, scope(scope)
+ , function(Q_NULLPTR)
{
Scope s(scope->engine);
ScopedFunctionObject f(s, this);
DEFINE_OBJECT_VTABLE(SimpleScriptFunction);
Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, Function *function, bool createProto)
- : Heap::FunctionObject(scope, function, createProto)
- : Heap::FunctionObject(function->compilationUnit->engine->simpleScriptFunctionClass, function->compilationUnit->engine->functionPrototype.asObject())
++ : Heap::FunctionObject(function->compilationUnit->engine->simpleScriptFunctionClass, function->compilationUnit->engine->functionPrototype.as<QV4::Object>())
{
+ this->scope = scope->d();
+
this->function = function;
function->compilationUnit->addref();
Q_ASSERT(function);
return (value == d()->toVariant());
}
+ int QQmlValueTypeWrapper::typeId() const
+ {
+ return d()->valueType->typeId;
+ }
+
+ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const
+ {
+ bool destructGadgetOnExit = false;
+ if (const QQmlValueTypeReference *ref = as<const QQmlValueTypeReference>()) {
+ if (!d()->gadgetPtr) {
+ d()->gadgetPtr = alloca(d()->valueType->metaType.sizeOf());
+ d()->valueType->metaType.construct(d()->gadgetPtr, 0);
+ destructGadgetOnExit = true;
+ }
+ if (!ref->readReferenceValue())
+ return false;
+ }
+
+ int flags = 0;
+ int status = -1;
+ void *a[] = { d()->gadgetPtr, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty, propertyIndex, a);
+
+ if (destructGadgetOnExit) {
+ d()->valueType->metaType.destruct(d()->gadgetPtr);
+ d()->gadgetPtr = 0;
+ }
+ return true;
+ }
+
ReturnedValue QQmlValueTypeWrapper::method_toString(CallContext *ctx)
{
- Object *o = ctx->thisObject().asObject();
+ Object *o = ctx->thisObject().as<Object>();
if (!o)
return ctx->engine()->throwTypeError();
QQmlValueTypeWrapper *w = o->as<QQmlValueTypeWrapper>();
static ReturnedValue create(ExecutionEngine *engine, const QVariant &, const QMetaObject *metaObject, int typeId);
QVariant toVariant() const;
- void toGadget(void *data) const;
+ bool toGadget(void *data) const;
bool isEqual(const QVariant& value);
+ int typeId() const;
+ bool write(QObject *target, int propertyIndex) const;
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
static bool isEqualTo(Managed *m, Managed *other);
static PropertyAttributes query(const Managed *, String *name);