id_index = newIdentifier(QStringLiteral("index"));
id_input = newIdentifier(QStringLiteral("input"));
id_toString = newIdentifier(QStringLiteral("toString"));
+ id_destroy = newIdentifier(QStringLiteral("destroy"));
id_valueOf = newIdentifier(QStringLiteral("valueOf"));
ObjectPrototype *objectPrototype = new (memoryManager) ObjectPrototype(InternalClass::create(this, ObjectPrototype::staticVTable(), 0));
id_index->mark(this);
id_input->mark(this);
id_toString->mark(this);
+ id_destroy->mark(this);
id_valueOf->mark(this);
objectCtor.mark(this);
StringValue id_index;
StringValue id_input;
StringValue id_toString;
+ StringValue id_destroy;
StringValue id_valueOf;
QSet<CompiledData::CompilationUnit*> compilationUnits;
Object::markObjects(that, e);
}
-FunctionObject *FunctionObject::creatScriptFunction(ExecutionContext *scope, Function *function)
+FunctionObject *FunctionObject::creatScriptFunction(ExecutionContext *scope, Function *function, bool createProto)
{
if (function->needsActivation() ||
function->compiledFunction->flags & CompiledData::Function::HasCatchOrWith ||
function->compiledFunction->nFormals > QV4::Global::ReservedArgumentCount ||
function->isNamedExpression())
return new (scope->engine->memoryManager) ScriptFunction(scope, function);
- return new (scope->engine->memoryManager) SimpleScriptFunction(scope, function);
+ return new (scope->engine->memoryManager) SimpleScriptFunction(scope, function, createProto);
}
ReturnedValue FunctionObject::protoProperty()
DEFINE_OBJECT_VTABLE(SimpleScriptFunction);
-SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *function)
- : FunctionObject(scope, function->name, true)
+SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *function, bool createProto)
+ : FunctionObject(scope, function->name, createProto)
{
setVTable(staticVTable());
return v.asFunctionObject();
}
- static FunctionObject *creatScriptFunction(ExecutionContext *scope, Function *function);
+ static FunctionObject *creatScriptFunction(ExecutionContext *scope, Function *function, bool createProto = true);
ReturnedValue protoProperty();
InternalClass *internalClassForConstructor();
struct SimpleScriptFunction: FunctionObject {
V4_OBJECT
- SimpleScriptFunction(ExecutionContext *scope, Function *function);
+ SimpleScriptFunction(ExecutionContext *scope, Function *function, bool createProto);
static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
Scope scope(engine);
ScopedObject protectThis(scope, this);
-
- m_destroy = engine->newIdentifier(QStringLiteral("destroy"));
}
void QObjectWrapper::initializeBindings(ExecutionEngine *engine)
QV4::Scope scope(ctx);
QV4::ScopedString name(scope, n);
- if (name->equals(m_destroy) || name->equals(scope.engine->id_toString)) {
- int index = name->equals(m_destroy) ? QV4::QObjectMethod::DestroyMethod : QV4::QObjectMethod::ToStringMethod;
+ if (name->equals(scope.engine->id_destroy) || name->equals(scope.engine->id_toString)) {
+ int index = name->equals(scope.engine->id_destroy) ? QV4::QObjectMethod::DestroyMethod : QV4::QObjectMethod::ToStringMethod;
QV4::ScopedValue method(scope, QV4::QObjectMethod::create(ctx->engine->rootContext, m_object, index));
if (hasProperty)
*hasProperty = true;
QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(engine);
QQmlPropertyData local;
if (that->findProperty(engine, qmlContext, name, IgnoreRevision, &local)
- || name->equals(const_cast<StringValue &>(that->m_destroy)) || name->equals(engine->id_toString))
+ || name->equals(engine->id_destroy) || name->equals(engine->id_toString))
return QV4::Attr_Data;
else
return QV4::Object::query(m, name);
QQmlPropertyData *findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const;
QPointer<QObject> m_object;
- StringValue m_destroy;
static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static void put(Managed *m, const StringRef name, const ValueRef value);
QV4::ReturnedValue __qmljs_get_qml_singleton(QV4::NoThrowContext *ctx, const QV4::StringRef name)
{
- return ctx->engine->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->qmlSingletonWrapper(name);
+ return ctx->engine->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->qmlSingletonWrapper(ctx->engine->v8Engine, name);
}
void __qmljs_builtin_convert_this_to_object(ExecutionContext *ctx)
QmlContextWrapper::QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext)
: Object(QV8Engine::getV4(engine)),
- v8(engine), readOnly(true), ownsContext(ownsContext), isNullWrapper(false),
+ readOnly(true), ownsContext(ownsContext), isNullWrapper(false),
context(context), scopeObject(scopeObject), idObjectsWrapper(0)
{
setVTable(staticVTable());
// context = context->parent
// }
- QV8Engine *engine = resource->v8;
+ QV8Engine *engine = v4->v8Engine;
QObject *scopeObject = resource->getScopeObject();
return idObjectsWrapper->asReturnedValue();
}
-ReturnedValue QmlContextWrapper::qmlSingletonWrapper(const StringRef &name)
+ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, const StringRef &name)
{
if (!context->imports)
return Encode::undefined();
Q_ASSERT(r.isValid());
Q_ASSERT(r.type);
Q_ASSERT(r.type->isSingleton());
+ Q_ASSERT(v8);
QQmlEngine *e = v8->engine();
QQmlType::SingletonInstanceInfo *siinfo = r.type->singletonInstanceInfo();
static void registerQmlDependencies(ExecutionEngine *context, const CompiledData::Function *compiledFunction);
ReturnedValue idObjectsArray();
- ReturnedValue qmlSingletonWrapper(const StringRef &name);
+ ReturnedValue qmlSingletonWrapper(QV8Engine *e, const StringRef &name);
- QV8Engine *v8; // ### temporary, remove
bool readOnly;
bool ownsContext;
bool isNullWrapper;
QV4::Function *runtimeFunction = compiledData->compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex];
QV4::Scope scope(_qmlContext);
- QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::creatScriptFunction(_qmlContext, runtimeFunction));
+ QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::creatScriptFunction(_qmlContext, runtimeFunction, /*createProto*/ false));
if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) {
int signalIndex = _propertyCache->methodIndexToSignalIndex(property->coreIndex);
QV4::Function *runtimeFunction = COMP->compilationUnit->runtimeFunctions[instr.runtimeFunctionIndex];
- tmpValue = QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction);
+ tmpValue = QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false);
QQmlBoundSignal *bs = new QQmlBoundSignal(target, instr.signalIndex, target, engine);
QQmlBoundSignalExpression *expr =
QV4::Function *runtimeFunction = COMP->compilationUnit->runtimeFunctions[instr.functionIndex];
- tmpValue = QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction);
+ tmpValue = QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false);
QQmlBinding *bind = new QQmlBinding(tmpValue, context, CTXT, COMP->name, instr.line, instr.column);
bindValues.push(bind);