void V8InjectedScriptHost::isHTMLAllCollectionCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1) return; if (!info[0]->IsObject()) { v8SetReturnValue(info, false); return; } v8SetReturnValue(info, V8HTMLAllCollection::hasInstance(info[0], info.GetIsolate())); }
void V8InjectedScriptHost::idToObjectGroupNameCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1 || !info[0]->IsInt32()) return; InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjectedScriptHost(info.Holder()); if (!injectedScriptNative) return; int id = info[0].As<v8::Int32>()->Value(); String groupName = injectedScriptNative->groupName(id); if (!groupName.isEmpty()) info.GetReturnValue().Set(v8String(info.GetIsolate(), groupName)); }
void SetupSniffer(const v8::FunctionCallbackInfo<v8::Value>& args) { Isolate* isolate = args.GetIsolate(); int pin = Handle<Integer>::Cast(args[0])->Int32Value(); int tolerance = Handle<Integer>::Cast(args[1])->Int32Value(); rcswitch_init(); if(tolerance) { rcswitch_set_receive_tolerance(tolerance); } rcswitch_enable_receive(pin); }
void BatchModule::destroyVert(const v8::FunctionCallbackInfo<v8::Value>& args) { v8::Isolate* isolate = args.GetIsolate(); v8::HandleScope scope(isolate); if(!args[0].IsEmpty()){ uint32_t id = args[0]->ToUint32()->Value(); StaticFactory::remove<VertBatch>(isolate, id); } return; }
static void v8HTMLImageElementConstructorMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) { if (!args.IsConstructCall()) { throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate()); return; } if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { v8SetReturnValue(args, args.Holder()); return; } Document* document = currentDocument(); ASSERT(document); // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance // may end up being the only node in the map and get garbage-collected prematurely. // FIXME: The correct way to do this would be to make HTMLImageElement derive from // ActiveDOMObject and use its interface to keep its wrapper alive. Then we would // remove this code and the special case in isObservableThroughDOM. toV8(document, args.Holder(), args.GetIsolate()); int width; int height; int* optionalWidth = 0; int* optionalHeight = 0; if (args.Length() > 0) { width = toInt32(args[0]); optionalWidth = &width; } if (args.Length() > 1) { height = toInt32(args[1]); optionalHeight = &height; } RefPtr<HTMLImageElement> image = HTMLImageElement::createForJSConstructor(*document, optionalWidth, optionalHeight); v8::Handle<v8::Object> wrapper = args.Holder(); V8DOMWrapper::associateObjectWithWrapper<V8HTMLImageElement>(image.release(), &V8HTMLImageElementConstructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); v8SetReturnValue(args, wrapper); }
void V8MessageEvent::initMessageEventMethodCustom( const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "initMessageEvent", "MessageEvent", info.Holder(), info.GetIsolate()); MessageEvent* event = V8MessageEvent::toImpl(info.Holder()); TOSTRING_VOID(V8StringResource<>, typeArg, info[0]); bool canBubbleArg = false; bool cancelableArg = false; if (!v8Call(info[1]->BooleanValue(info.GetIsolate()->GetCurrentContext()), canBubbleArg) || !v8Call(info[2]->BooleanValue(info.GetIsolate()->GetCurrentContext()), cancelableArg)) return; v8::Local<v8::Value> dataArg = info[3]; TOSTRING_VOID(V8StringResource<>, originArg, info[4]); TOSTRING_VOID(V8StringResource<>, lastEventIdArg, info[5]); DOMWindow* sourceArg = toDOMWindow(info.GetIsolate(), info[6]); MessagePortArray* portArray = nullptr; const int portArrayIndex = 7; if (!isUndefinedOrNull(info[portArrayIndex])) { portArray = new MessagePortArray; *portArray = toMemberNativeArray<MessagePort>( info[portArrayIndex], portArrayIndex + 1, info.GetIsolate(), exceptionState); if (exceptionState.hadException()) return; } event->initMessageEvent( typeArg, canBubbleArg, cancelableArg, ScriptValue(ScriptState::current(info.GetIsolate()), dataArg), originArg, lastEventIdArg, sourceArg, portArray); }
void AddFuncCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { int result = 0; auto len = args.Length(); if ((len == 2) && args[0]->IsInt32() && args[1]->IsInt32()) { result = args[0]->Int32Value() + args[1]->Int32Value(); } args.GetReturnValue().Set(v8::Int32::New(args.GetIsolate(), result)); }
void Path2D::ConicTo(const v8::FunctionCallbackInfo<Value>& args) { if (args.Length() != 5) { args.GetIsolate()->ThrowException( v8::String::NewFromUtf8( args.GetIsolate(), "Error: 5 args required.")); return; } double x1 = args[0]->NumberValue(); double y1 = args[1]->NumberValue(); double x2 = args[2]->NumberValue(); double y2 = args[3]->NumberValue(); double w = args[4]->NumberValue(); Path2D* path = Unwrap(args); path->fSkPath.conicTo( SkDoubleToScalar(x1), SkDoubleToScalar(y1), SkDoubleToScalar(x2), SkDoubleToScalar(y2), SkDoubleToScalar(w) ); }
typename std::enable_if<std::is_member_function_pointer<F>::value, typename function_traits<F>::return_type>::type invoke(v8::FunctionCallbackInfo<v8::Value> const& args) { using arguments = typename function_traits<F>::arguments; static_assert(std::tuple_size<arguments>::value > 0, ""); using class_type = typename std::tuple_element<0, arguments>::type; F f = get_external_data<F>(args.Data()); class_type& obj = from_v8<class_type&>(args.GetIsolate(), args.This()); return call_from_v8(obj, std::forward<F>(f), args); }
static void iteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "iterator"); TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); ScriptState* scriptState = ScriptState::forReceiverObject(info); Iterator* result = impl->iterator(scriptState, exceptionState); if (exceptionState.hadException()) { return; } v8SetReturnValue(info, result); }
void V8XMLHttpRequest::responseTextAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toImpl(info.Holder()); ExceptionState exceptionState(ExceptionState::GetterContext, "responseText", "XMLHttpRequest", info.Holder(), info.GetIsolate()); ScriptString text = xmlHttpRequest->responseText(exceptionState); if (exceptionState.throwIfNeeded()) return; if (text.isEmpty()) { v8SetReturnValueString(info, emptyString(), info.GetIsolate()); return; } v8SetReturnValue(info, text.v8Value()); }
void MainThreadDebugger::querySelectorCallback( const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1) return; String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); if (selector.isEmpty()) return; Node* node = secondArgumentAsNode(info); if (!node || !node->isContainerNode()) return; ExceptionState exceptionState(ExceptionState::ExecutionContext, "$", "CommandLineAPI", info.Holder(), info.GetIsolate()); Element* element = toContainerNode(node)->querySelector( AtomicString(selector), exceptionState); if (exceptionState.hadException()) return; if (element) info.GetReturnValue().Set(toV8(element, info.Holder(), info.GetIsolate())); else info.GetReturnValue().Set(v8::Null(info.GetIsolate())); }
static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info) { V8StringResource<> stringArg; { stringArg = info[0]; if (!stringArg.prepare()) return; } RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(stringArg); v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); }
static void svgPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "svgPointMethod", "TestSVG", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length())); exceptionState.throwIfNeeded(); return; } TestSVG* imp = V8TestSVG::toNative(info.Holder()); V8TRYCATCH_VOID(SVGPointTearOff*, item, V8SVGPoint::hasInstance(info[0], info.GetIsolate()) ? V8SVGPoint::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0); V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[1], exceptionState), exceptionState); v8SetReturnValue(info, imp->svgPointMethod(item, index)); }
static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { if (UNLIKELY(info.Length() < 1)) { V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("func", "TestInterfaceGarbageCollected", 1, info.Length(), info.GetIsolate()), info.GetIsolate()); return; } TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); TestInterfaceGarbageCollected* arg; { arg = V8TestInterfaceGarbageCollected::toImplWithTypeCheck(info.GetIsolate(), info[0]); } impl->func(arg); }
void V8SVGLength::convertToSpecifiedUnitsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) { SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(args.Holder()); if (wrapper->isReadOnly()) { setDOMException(NoModificationAllowedError, args.GetIsolate()); return; } if (args.Length() < 1) { throwNotEnoughArgumentsError(args.GetIsolate()); return; } SVGLength& imp = wrapper->propertyReference(); ExceptionState es(args.GetIsolate()); V8TRYCATCH_VOID(int, unitType, toUInt32(args[0])); SVGLengthContext lengthContext(wrapper->contextElement()); imp.convertToSpecifiedUnits(unitType, lengthContext, es); if (es.throwIfNeeded()) return; wrapper->commitChange(); }
void JSMain::Include(const v8::FunctionCallbackInfo<Value>& args) { for (int i = 0; i < args.Length(); i++) { HandleScope handle_scope(args.GetIsolate()); String::Utf8Value str(args[i]); // load_file loads the file with this name into a string string js_file = LoadFileToString(js_safe_str(*str)); if (js_file.length() > 0) { Handle<String> source = String::NewFromUtf8(args.GetIsolate(), js_file.c_str()); Handle<Script> script = Script::Compile(source, args[i]); args.GetReturnValue().Set(script->Run()); return; } } args.GetReturnValue().Set(Undefined(args.GetIsolate())); }
/** write: * write data from one buffer to an other * * @param Buffer Object data * buffer to be writen into the current buffer */ void CJSBuffer::FxWrite(const v8::FunctionCallbackInfo<v8::Value> &args) { v8::HandleScope HandleScope(v8::Isolate::GetCurrent()); CJSBuffer* jBuffer = GetJSObject<CJSBuffer>(args.Holder()); CBufferObj* pBuffer = jBuffer->m_pBuffer; if (args.Length() < 1 || !args[0]->IsObject()) { args.GetIsolate()->ThrowException(v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), (uint8_t*)"Invalid Argument")); return; } CBufferObj* pData = GetCObject<CBufferObj>(args[0]->ToObject()); if (!pData) { args.GetIsolate()->ThrowException(v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), (uint8_t*)"Invalid Argument")); return; } BUFFER_TRY pBuffer->WriteData(pData->GetBuffer(), pData->GetSize()); args.GetReturnValue().SetUndefined(); BUFFER_CATCH }
void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 2 || !info[1]->IsString()) return; InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjectedScriptHost(info.Holder()); if (!injectedScriptNative) return; v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); String groupName = toCoreStringWithUndefinedOrNullCheck(v8groupName); int id = injectedScriptNative->bind(info[0], groupName); info.GetReturnValue().Set(id); }
void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder()); if (info.Length() > 2) { if (RefPtr<LocalFrame> frame = htmlDocument->frame()) { // Fetch the global object for the frame. v8::Local<v8::Context> context = toV8Context(info.GetIsolate(), frame.get(), DOMWrapperWorld::current(info.GetIsolate())); // Bail out if we cannot get the context. if (context.IsEmpty()) return; v8::Local<v8::Object> global = context->Global(); // Get the open property of the global object. v8::Local<v8::Value> function = global->Get(v8AtomicString(info.GetIsolate(), "open")); // Failed; return without throwing (new) exception. if (function.IsEmpty()) return; // If the open property is not a function throw a type error. if (!function->IsFunction()) { throwTypeError("open is not a function", info.GetIsolate()); return; } // Wrap up the arguments and call the function. OwnPtr<v8::Local<v8::Value>[]> params = adoptArrayPtr(new v8::Local<v8::Value>[info.Length()]); for (int i = 0; i < info.Length(); i++) params[i] = info[i]; v8SetReturnValue(info, frame->script().callFunction(v8::Local<v8::Function>::Cast(function), global, info.Length(), params.get())); return; } } ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Document", info.Holder(), info.GetIsolate()); htmlDocument->open(callingDOMWindow(info.GetIsolate())->document(), exceptionState); if (exceptionState.throwIfNeeded()) return; v8SetReturnValue(info, info.Holder()); }
void V8SVGLength::convertToSpecifiedUnitsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(info.Holder()); if (wrapper->isReadOnly()) { setDOMException(NoModificationAllowedError, info.GetIsolate()); return; } if (info.Length() < 1) { throwTypeError(ExceptionMessages::failedToExecute("convertToSpecifiedUnits", "SVGLength", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); return; } SVGLength& imp = wrapper->propertyReference(); ExceptionState exceptionState(info.Holder(), info.GetIsolate()); V8TRYCATCH_VOID(int, unitType, toUInt32(info[0])); SVGLengthContext lengthContext(wrapper->contextElement()); imp.convertToSpecifiedUnits(unitType, lengthContext, exceptionState); if (exceptionState.throwIfNeeded()) return; wrapper->commitChange(); }
void JSZAttribute::jsGetStatus(const v8::FunctionCallbackInfo<v8::Value> &info) { Isolate *isolate = info.GetIsolate(); try { Local<External> wrap = Local<External>::Cast(info.Holder()->GetInternalField(0)); ZCLAttribute *attribute = (ZCLAttribute *) wrap->Value(); ZCLAttribute::Status status = attribute->getStatus(); Local<String> name = String::NewFromUtf8(isolate, statusMap[status].c_str()); info.GetReturnValue().Set(name); } catch (std::exception &excp) { v8::Local<v8::String> errorMsg = v8::String::NewFromUtf8(isolate, excp.what()); isolate->ThrowException(errorMsg); } }
void V8CustomEvent::detailAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { CustomEvent* event = V8CustomEvent::toImpl(info.Holder()); v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::detail(info.GetIsolate())); if (!result.IsEmpty()) { v8SetReturnValue(info, result); return; } // Be careful not to return a V8 value which is created in different world. v8::Local<v8::Value> detail; if (SerializedScriptValue* serializedValue = event->serializedDetail()) detail = serializedValue->deserialize(); else detail = event->detail().v8ValueFor(ScriptState::current(info.GetIsolate())); // |detail| should be null when it is an empty handle because its default value is null. if (detail.IsEmpty()) detail = v8::Null(info.GetIsolate()); v8SetReturnValue(info, cacheState(info.GetIsolate(), info.Holder(), detail)); }
static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterfaceOriginTrialEnabled", "voidMethodDoubleArgFloatArg"); TestInterfaceOriginTrialEnabled* impl = V8TestInterfaceOriginTrialEnabled::toImpl(info.Holder()); if (UNLIKELY(info.Length() < 2)) { exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length())); return; } double doubleArg; float floatArg; doubleArg = toRestrictedDouble(info.GetIsolate(), info[0], exceptionState); if (exceptionState.hadException()) return; floatArg = toRestrictedFloat(info.GetIsolate(), info[1], exceptionState); if (exceptionState.hadException()) return; impl->voidMethodDoubleArgFloatArg(doubleArg, floatArg); }
void V8Worker::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) { Worker* worker = V8Worker::toNative(args.Holder()); MessagePortArray ports; ArrayBufferArray arrayBuffers; if (args.Length() > 1) { if (!extractTransferables(args[1], ports, arrayBuffers, args.GetIsolate())) return; } bool didThrow = false; RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0], &ports, &arrayBuffers, didThrow, args.GetIsolate()); if (didThrow) return; ExceptionCode ec = 0; worker->postMessage(message.release(), &ports, ec); setDOMException(ec, args.GetIsolate()); }
static void FXJSE_V8ProxyCallback_getOwnPropertyDescriptor_setter( const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>(); FXJSE_CLASS* lpClass = static_cast<FXJSE_CLASS*>( hCallBackInfo->GetAlignedPointerFromInternalField(0)); v8::Local<v8::String> hPropName = hCallBackInfo->GetInternalField(1).As<v8::String>(); ASSERT(lpClass && !hPropName.IsEmpty()); v8::String::Utf8Value szPropName(hPropName); CFX_ByteStringC szFxPropName = *szPropName; CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate()); lpThisValue->ForceSetValue(info.This()); lpNewValue->ForceSetValue(info[0]); FXJSE_DynPropSetterAdapter( lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName, reinterpret_cast<FXJSE_HVALUE>(lpNewValue)); delete lpThisValue; lpThisValue = nullptr; delete lpNewValue; lpNewValue = nullptr; }
Handle<Value> FSXML::GetJSObjFromXMLObj(const switch_xml_t xml, const v8::FunctionCallbackInfo<Value>& info) { FSXML *newObj, *rootObj = NULL; if (!_rootObject) { rootObj = this; } else { rootObj = _rootObject; } if (!rootObj) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find XML root node\n"); return Handle<Value>(); } /* Try to find an existing object in the hash */ if (!(newObj = rootObj->FindObjectInHash(xml))) { /* Create a new object if it wasn't found in the hash */ if ((newObj = new FSXML(info))) { if (_rootJSObject.IsEmpty()) { newObj->_rootJSObject.Reset(info.GetIsolate(), info.Holder()); /* The caller is the owner */ } else { newObj->_rootJSObject.Reset(info.GetIsolate(), _rootJSObject); /* The owner is stored in the persistent object */ } newObj->_xml = xml; newObj->_rootObject = rootObj; rootObj->StoreObjectInHash(xml, newObj); newObj->RegisterInstance(info.GetIsolate(), "", true); } } if (newObj) { return newObj->GetJavaScriptObject(); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new object - memory error?\n"); return Handle<Value>(); }
void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1) return; v8::Isolate* isolate = info.GetIsolate(); v8::Local<v8::Value> value = info[0]; if (value->IsArray() || value->IsTypedArray() || value->IsArgumentsObject()) { v8SetReturnValue(info, v8AtomicString(isolate, "array")); return; } if (value->IsDate()) { v8SetReturnValue(info, v8AtomicString(isolate, "date")); return; } if (value->IsRegExp()) { v8SetReturnValue(info, v8AtomicString(isolate, "regexp")); return; } if (value->IsMap() || value->IsWeakMap()) { v8SetReturnValue(info, v8AtomicString(isolate, "map")); return; } if (value->IsSet() || value->IsWeakSet()) { v8SetReturnValue(info, v8AtomicString(isolate, "set")); return; } if (value->IsMapIterator() || value->IsSetIterator()) { v8SetReturnValue(info, v8AtomicString(isolate, "iterator")); return; } if (value->IsGeneratorObject()) { v8SetReturnValue(info, v8AtomicString(isolate, "generator")); return; } if (V8Node::hasInstance(value, isolate)) { v8SetReturnValue(info, v8AtomicString(isolate, "node")); return; } if (V8NodeList::hasInstance(value, isolate) || V8DOMTokenList::hasInstance(value, isolate) || V8HTMLCollection::hasInstance(value, isolate) || V8HTMLAllCollection::hasInstance(value, isolate)) { v8SetReturnValue(info, v8AtomicString(isolate, "array")); return; } if (value->IsNativeError() || V8DOMException::hasInstance(value, isolate)) { v8SetReturnValue(info, v8AtomicString(isolate, "error")); return; } }
static void constructor4(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor2", info.Holder(), info.GetIsolate()); TestInterfaceEmpty* testInterfaceEmptyArg; int longArg; V8StringResource<> defaultUndefinedOptionalStringArg; V8StringResource<> defaultNullStringOptionalStringArg; Dictionary defaultUndefinedOptionalDictionaryArg; V8StringResource<> optionalStringArg; { testInterfaceEmptyArg = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[0]); TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(longArg, toInt32(info[1], exceptionState), exceptionState); TOSTRING_VOID_INTERNAL(defaultUndefinedOptionalStringArg, info[2]); if (!info[3]->IsUndefined()) { TOSTRING_VOID_INTERNAL(defaultNullStringOptionalStringArg, info[3]); } else { defaultNullStringOptionalStringArg = nullptr; } if (!isUndefinedOrNull(info[4]) && !info[4]->IsObject()) { exceptionState.throwTypeError("parameter 5 ('defaultUndefinedOptionalDictionaryArg') is not an object."); exceptionState.throwIfNeeded(); return; } defaultUndefinedOptionalDictionaryArg = Dictionary(info[4], info.GetIsolate()); if (UNLIKELY(info.Length() <= 5)) { RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg); v8::Handle<v8::Object> wrapper = info.Holder(); impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate()); v8SetReturnValue(info, wrapper); return; } TOSTRING_VOID_INTERNAL(optionalStringArg, info[5]); } RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg, optionalStringArg); v8::Handle<v8::Object> wrapper = info.Holder(); impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate()); v8SetReturnValue(info, wrapper); }
void V8EventTarget::addEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "addEventListener", "EventTarget", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { setMinimumArityTypeError(exceptionState, 2, info.Length()); exceptionState.throwIfNeeded(); return; } EventTarget* impl = V8EventTarget::toImpl(info.Holder()); if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), impl, exceptionState)) { exceptionState.throwIfNeeded(); return; } V8StringResource<> type; RefPtrWillBeRawPtr<EventListener> listener; EventListenerOptionsOrBoolean options; { type = info[0]; if (!type.prepare()) return; listener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[1], false, ListenerFindOrCreate); // TODO(dtapuska): This custom binding code can be eliminated once // EventListenerOptions runtime enabled feature is removed. // http://crbug.com/545163 if (UNLIKELY(info.Length() <= 2) || isUndefinedOrNull(info[2])) { addEventListenerMethodPrologueCustom(info, impl); impl->addEventListener(type, listener); addEventListenerMethodEpilogueCustom(info, impl); return; } V8EventListenerOptionsOrBoolean::toImpl(info.GetIsolate(), info[2], options, UnionTypeConversionMode::NotNullable, exceptionState); if (exceptionState.throwIfNeeded()) return; } addEventListenerMethodPrologueCustom(info, impl); impl->addEventListener(type, listener, options); addEventListenerMethodEpilogueCustom(info, impl); }