Exemplo n.º 1
0
ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData)
{
    ExecutionEngine *v4 = that->internalClass->engine;
    if (v4->hasException)
        return Encode::undefined();
    CHECK_STACK_LIMITS(v4);

    Scope scope(v4);
    Scoped<ScriptFunction> f(scope, static_cast<ScriptFunction *>(that));

    InternalClass *ic = f->internalClassForConstructor();
    ScopedObject obj(scope, v4->newObject(ic));

    ExecutionContext *context = v4->currentContext();
    callData->thisObject = obj.asReturnedValue();
    ExecutionContext *ctx = context->newCallContext(f.getPointer(), callData);

    if (f->function->compiledFunction->hasQmlDependencies())
        QmlContextWrapper::registerQmlDependencies(v4, f->function->compiledFunction);

    ExecutionContextSaver ctxSaver(context);
    ScopedValue result(scope, f->function->code(ctx, f->function->codeData));
    if (result->isObject())
        return result.asReturnedValue();
    return obj.asReturnedValue();
}
Exemplo n.º 2
0
ReturnedValue ScriptFunction::call(Managed *that, CallData *callData)
{
    ScriptFunction *f = static_cast<ScriptFunction *>(that);
    ExecutionEngine *v4 = f->internalClass->engine;
    if (v4->hasException)
        return Encode::undefined();
    CHECK_STACK_LIMITS(v4);

    ExecutionContext *context = v4->currentContext();
    Scope scope(context);

    CallContext *ctx = context->newCallContext(f, callData);

    if (f->function->compiledFunction->hasQmlDependencies())
        QmlContextWrapper::registerQmlDependencies(ctx->engine, f->function->compiledFunction);

    ExecutionContextSaver ctxSaver(context);
    return f->function->code(ctx, f->function->codeData);
}