コード例 #1
0
ファイル: c_instance.cpp プロジェクト: jackiekaon/owb-mirror
JSValue* CInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const List& args)
{
    // Overloading methods are not allowed by NPObjects.  Should only be one
    // name match for a particular method.
    assert(methodList.length() == 1);

    CMethod* method = static_cast<CMethod*>(methodList.methodAt(0));

    NPIdentifier ident = _NPN_GetStringIdentifier(method->name());
    if (!_object->_class->hasMethod(_object, ident))
        return jsUndefined();

    unsigned count = args.size();
    Vector<NPVariant, 128> cArgs(count);

    unsigned i;
    for (i = 0; i < count; i++)
        convertValueToNPVariant(exec, args.at(i), &cArgs[i]);

    // Invoke the 'C' method.
    NPVariant resultVariant;
    VOID_TO_NPVARIANT(resultVariant);
    _object->_class->invoke(_object, ident, cArgs, count, &resultVariant);

    for (i = 0; i < count; i++)
        _NPN_ReleaseVariantValue(&cArgs[i]);

    JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant);
    _NPN_ReleaseVariantValue(&resultVariant);
    return resultValue;
}
コード例 #2
0
ファイル: c_instance.cpp プロジェクト: jackiekaon/owb-mirror
JSValue* CInstance::invokeConstruct(ExecState* exec, const ArgList& args)
{
    if (!_object->_class->construct)
        return jsUndefined();

    unsigned count = args.size();
    Vector<NPVariant, 8> cArgs(count);

    unsigned i;
    for (i = 0; i < count; i++)
        convertValueToNPVariant(exec, args.at(exec, i), &cArgs[i]);

    // Invoke the 'C' method.
    NPVariant resultVariant;
    VOID_TO_NPVARIANT(resultVariant);
    {
        JSLock::DropAllLocks dropAllLocks(false);
        _object->_class->construct(_object, cArgs.data(), count, &resultVariant);
    }
    
    for (i = 0; i < count; i++)
        _NPN_ReleaseVariantValue(&cArgs[i]);

    JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get());
    _NPN_ReleaseVariantValue(&resultVariant);
    return resultValue;
}
コード例 #3
0
ファイル: JSConsole.cpp プロジェクト: DreamOnTheGo/src
EncodedJSValue JSC_HOST_CALL jsConsolePrototypeFunctionDebug(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSConsole* castedThis = static_cast<JSConsole*>(asObject(thisValue));
    Console* imp = static_cast<Console*>(castedThis->impl());
    
    unsigned count = exec->argumentCount();
    Vector<NPVariant, 8> cArgs(count);

    unsigned i;
    for (i = 0; i < count; i++)
        JSC::Bindings::convertValueToNPVariant(exec, exec->argument(i), &cArgs[i]);

    // Invoke the 'C' method.
    bool retval = true;
    NPVariant resultVariant;
    VOID_TO_NPVARIANT(resultVariant);

    {
        JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
        //ASSERT(JSC::Bindings::globalExceptionString().isNull());

        NPInvokeFunctionPtr ptr = (NPInvokeFunctionPtr)(imp->frame()->page()->chrome()->client()->getJavascriptCallCppCallback());
        retval = ptr(0, 0, cArgs.data(), count, &resultVariant);
        //CInstance::moveGlobalExceptionToExecState(exec);
    }

    if (!retval)
        throwError(exec, createError(exec, "Error calling method on NPObject."));

    for (i = 0; i < count; i++)
        _NPN_ReleaseVariantValue(&cArgs[i]);

    JSValue resultValue = JSC::Bindings::convertNPVariantToValue(exec, &resultVariant, 0);
    _NPN_ReleaseVariantValue(&resultVariant);
    return resultValue;

//     JSValue thisValue = exec->hostThisValue();
//     if (!thisValue.inherits(&JSConsole::s_info))
//         return throwVMTypeError(exec);
//     JSConsole* castedThis = static_cast<JSConsole*>(asObject(thisValue));
//     Console* imp = static_cast<Console*>(castedThis->impl());
//     RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 0));
//     size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
//     RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));
// 
//     imp->debug(scriptArguments, callStack);
//     return JSValue::encode(jsUndefined());
}
コード例 #4
0
ファイル: bal_instance.cpp プロジェクト: acss/owb-mirror
JSValue* BalInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const ArgList& args)
{
    ASSERT(methodList.size() == 1);

    BalMethod* method = static_cast<BalMethod*>(methodList[0]);

    const char *ident = method->name();
    if (!m_object->hasMethod( ident ))
        return jsUndefined();

    unsigned count = args.size();
    Vector<BalValue *, 128> cArgs(count);

    unsigned i;
    for (i = 0; i < count; i++) {
        BalValuePrivate *priv = new BalValuePrivate(exec, args.at(exec, i));
        cArgs[i] = new BalValue(priv);
    }

    BalValue *val = m_object->invoke(ident, cArgs);
    cArgs.clear();

    return val->d->getValue();
}
コード例 #5
0
ファイル: c_instance.cpp プロジェクト: jackiekaon/owb-mirror
JSValue* CInstance::invokeDefaultMethod(ExecState* exec, const List& args)
{
    if (!_object->_class->invokeDefault)
        return jsUndefined();

    unsigned count = args.size();
    Vector<NPVariant, 128> cArgs(count);

    unsigned i;
    for (i = 0; i < count; i++)
        convertValueToNPVariant(exec, args.at(i), &cArgs[i]);

    // Invoke the 'C' method.
    NPVariant resultVariant;
    VOID_TO_NPVARIANT(resultVariant);
    _object->_class->invokeDefault(_object, cArgs, count, &resultVariant);

    for (i = 0; i < count; i++)
        _NPN_ReleaseVariantValue(&cArgs[i]);

    JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant);
    _NPN_ReleaseVariantValue(&resultVariant);
    return resultValue;
}