Пример #1
0
JSValue *RuntimeMethod::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
    if (_methodList->isEmpty())
        return jsUndefined();
    
    RuntimeObjectImp *imp = 0;

    if (thisObj->classInfo() == &KJS::RuntimeObjectImp::info) {
        imp = static_cast<RuntimeObjectImp*>(thisObj);
    } else {
        // If thisObj is the DOM object for a plugin, get the corresponding
        // runtime object from the DOM object.
        JSValue* value = thisObj->get(exec, "__apple_runtime_object");
        if (value->isObject(&KJS::RuntimeObjectImp::info))    
            imp = static_cast<RuntimeObjectImp*>(value);
    }

    if (!imp)
        return throwError(exec, TypeError);

    Instance *instance = imp->getInternalInstance();
    if (!instance) 
        return RuntimeObjectImp::throwInvalidAccessError(exec);
        
    instance->begin();
    JSValue *aValue = instance->invokeMethod(exec, *_methodList, args);
    instance->end();
    return aValue;
}
static JSValue JSC_HOST_CALL callPlugin(ExecState* exec, JSObject* function, JSValue, const ArgList& args)
{
    Instance* instance = pluginInstance(static_cast<JSHTMLElement*>(function)->impl());
    instance->begin();
    JSValue result = instance->invokeDefaultMethod(exec, args);
    instance->end();
    return result;
}
void WebMediaPlayerProxy::invokeMethod(const String& methodName)
{
    Frame* frame = element()->document()->frame();
    RootObject *root = frame->script()->bindingRootObject();
    if (!root)
        return;
    ExecState *exec = root->globalObject()->globalExec();
    Instance* instance = pluginInstance().get();
    if (!instance)
        return;

    instance->begin();
    Class *aClass = instance->getClass();
    Identifier iden(exec, methodName);
    MethodList methodList = aClass->methodsNamed(iden, instance);
    ArgList args;
    instance->invokeMethod(exec, methodList , args);
    instance->end();
}