static EncodedJSValue JSC_HOST_CALL callRuntimeMethod(ExecState* exec) { VM& vm = exec->vm(); auto scope = DECLARE_THROW_SCOPE(vm); RuntimeMethod* method = static_cast<RuntimeMethod*>(exec->jsCallee()); if (!method->method()) return JSValue::encode(jsUndefined()); RefPtr<Instance> instance; JSValue thisValue = exec->thisValue(); if (thisValue.inherits(RuntimeObject::info())) { RuntimeObject* runtimeObject = static_cast<RuntimeObject*>(asObject(thisValue)); instance = runtimeObject->getInternalInstance(); if (!instance) return JSValue::encode(RuntimeObject::throwInvalidAccessError(exec, scope)); } else { // Calling a runtime object of a plugin element? if (thisValue.inherits(JSHTMLElement::info())) instance = pluginInstance(jsCast<JSHTMLElement*>(asObject(thisValue))->wrapped()); if (!instance) return throwVMTypeError(exec, scope); } ASSERT(instance); instance->begin(); JSValue result = instance->invokeMethod(exec, method); instance->end(); return JSValue::encode(result); }
static EncodedJSValue JSC_HOST_CALL callRuntimeMethod(ExecState* exec) { RuntimeMethod* method = static_cast<RuntimeMethod*>(exec->callee()); if (!method->method()) 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); }