コード例 #1
0
static JSValue JSC_HOST_CALL callRuntimeMethod(ExecState* exec, JSObject* function, JSValue thisValue, const ArgList& args)
{
    RuntimeMethod* method = static_cast<RuntimeMethod*>(function);

    if (method->methods()->isEmpty())
        return jsUndefined();
    
    RuntimeObjectImp* imp;

    if (thisValue.isObject(&RuntimeObjectImp::s_info)) {
        imp = static_cast<RuntimeObjectImp*>(asObject(thisValue));
    } else {
        // If thisObj is the DOM object for a plugin, get the corresponding
        // runtime object from the DOM object.
        JSValue value = thisValue.get(exec, Identifier(exec, "__apple_runtime_object"));
        if (value.isObject(&RuntimeObjectImp::s_info))    
            imp = static_cast<RuntimeObjectImp*>(asObject(value));
        else
            return throwError(exec, TypeError);
    }

    RefPtr<Instance> instance = imp->getInternalInstance();
    if (!instance) 
        return RuntimeObjectImp::throwInvalidAccessError(exec);
        
    instance->begin();
    JSValue result = instance->invokeMethod(exec, *method->methods(), args);
    instance->end();
    return result;
}
コード例 #2
0
static EncodedJSValue JSC_HOST_CALL callRuntimeMethod(ExecState* exec)
{
    RuntimeMethod* method = static_cast<RuntimeMethod*>(exec->callee());

    if (method->methods()->isEmpty())
        return JSValue::encode(jsUndefined());

    RefPtr<Instance> instance;

    JSValue thisValue = exec->hostThisValue();
    if (thisValue.inherits(&RuntimeObject::s_info)) {
        RuntimeObject* runtimeObject = static_cast<RuntimeObject*>(asObject(thisValue));
        instance = runtimeObject->getInternalInstance();
        if (!instance) 
            return JSValue::encode(RuntimeObject::throwInvalidAccessError(exec));
    } else {
        // Calling a runtime object of a plugin element?
        if (thisValue.inherits(&JSHTMLElement::s_info)) {
            HTMLElement* element = jsCast<JSHTMLElement*>(asObject(thisValue))->impl();
            instance = pluginInstance(element);
        }
        if (!instance)
            return throwVMTypeError(exec);
    }
    ASSERT(instance);

    instance->begin();
    JSValue result = instance->invokeMethod(exec, method);
    instance->end();
    return JSValue::encode(result);
}