void V8StringOrArrayBufferOrArrayBufferView::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrArrayBufferOrArrayBufferView& impl, UnionTypeConversionMode conversionMode, ExceptionState& exceptionState) { if (v8Value.IsEmpty()) return; if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull(v8Value)) return; if (V8ArrayBuffer::hasInstance(v8Value, isolate)) { TestArrayBuffer* cppValue = V8ArrayBuffer::toImpl(v8::Local<v8::Object>::Cast(v8Value)); impl.setArrayBuffer(cppValue); return; } if (V8ArrayBufferView::hasInstance(v8Value, isolate)) { TestArrayBufferView* cppValue = V8ArrayBufferView::toImpl(v8::Local<v8::Object>::Cast(v8Value)); impl.setArrayBufferView(cppValue); return; } { V8StringResource<> cppValue = v8Value; if (!cppValue.prepare(exceptionState)) return; impl.setString(cppValue); return; } }
static void constructor4(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ConstructionContext, "TestInterfaceConstructor"); ScriptState* scriptState = ScriptState::forReceiverObject(info); V8StringResource<> arg; V8StringResource<> arg2; V8StringResource<> arg3; arg = info[0]; if (!arg.prepare()) return; arg2 = info[1]; if (!arg2.prepare()) return; arg3 = info[2]; if (!arg3.prepare()) return; ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); Document& document = *toDocument(currentExecutionContext(info.GetIsolate())); TestInterfaceConstructor* impl = TestInterfaceConstructor::create(scriptState, executionContext, document, arg, arg2, arg3, exceptionState); if (exceptionState.hadException()) { return; } v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); }
void V8BooleanOrStringOrUnrestrictedDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, BooleanOrStringOrUnrestrictedDouble& impl, UnionTypeConversionMode conversionMode, ExceptionState& exceptionState) { if (v8Value.IsEmpty()) return; if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull(v8Value)) return; if (v8Value->IsBoolean()) { impl.setBoolean(v8Value.As<v8::Boolean>()->Value()); return; } if (v8Value->IsNumber()) { double cppValue = toDouble(isolate, v8Value, exceptionState); if (exceptionState.hadException()) return; impl.setUnrestrictedDouble(cppValue); return; } { V8StringResource<> cppValue = v8Value; if (!cppValue.prepare(exceptionState)) return; impl.setString(cppValue); return; } }
static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceEventInitConstructor", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { setMinimumArityTypeError(exceptionState, 2, info.Length()); exceptionState.throwIfNeeded(); return; } V8StringResource<> type; TestInterfaceEventInit testInterfaceEventInit; { type = info[0]; if (!type.prepare()) return; if (!isUndefinedOrNull(info[1]) && !info[1]->IsObject()) { exceptionState.throwTypeError("parameter 2 ('testInterfaceEventInit') is not an object."); exceptionState.throwIfNeeded(); return; } V8TestInterfaceEventInit::toImpl(info.GetIsolate(), info[1], testInterfaceEventInit, exceptionState); if (exceptionState.throwIfNeeded()) return; } RefPtrWillBeRawPtr<TestInterfaceEventInitConstructor> impl = TestInterfaceEventInitConstructor::create(type, testInterfaceEventInit); v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceEventInitConstructor::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); }
void V8TestInterfaceEventInit::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceEventInit& impl, ExceptionState& exceptionState) { if (isUndefinedOrNull(v8Value)) { return; } if (!v8Value->IsObject()) { exceptionState.throwTypeError("cannot convert to dictionary."); return; } V8EventInit::toImpl(isolate, v8Value, impl, exceptionState); if (exceptionState.hadException()) return; v8::TryCatch block(isolate); v8::Local<v8::Object> v8Object; if (!v8Call(v8Value->ToObject(isolate->GetCurrentContext()), v8Object, block)) { exceptionState.rethrowV8Exception(block.Exception()); return; } v8::Local<v8::Value> stringMemberValue; if (!v8Object->Get(isolate->GetCurrentContext(), v8String(isolate, "stringMember")).ToLocal(&stringMemberValue)) { exceptionState.rethrowV8Exception(block.Exception()); return; } if (stringMemberValue.IsEmpty() || stringMemberValue->IsUndefined()) { // Do nothing. } else { V8StringResource<> stringMember = stringMemberValue; if (!stringMember.prepare(exceptionState)) return; impl.setStringMember(stringMember); } }
static void V8TestInterfaceWillBeGarbageCollectedConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (!info.IsConstructCall()) { V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("TestInterface")); return; } if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) { v8SetReturnValue(info, info.Holder()); return; } if (UNLIKELY(info.Length() < 1)) { V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor(info.GetIsolate(), "TestInterfaceWillBeGarbageCollected", 1, info.Length()), info.GetIsolate()); return; } V8StringResource<> str; { str = info[0]; if (!str.prepare()) return; } RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> impl = TestInterfaceWillBeGarbageCollected::createForJSConstructor(str); v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceWillBeGarbageCollectedConstructor::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); }
static void partialVoidTestEnumModulesArgMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "partialVoidTestEnumModulesArgMethod", "TestInterface", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 1)) { setMinimumArityTypeError(exceptionState, 1, info.Length()); exceptionState.throwIfNeeded(); return; } TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); V8StringResource<> arg; { arg = info[0]; if (!arg.prepare()) return; const char* validValues[] = { "EnumModulesValue1", "EnumModulesValue2", }; if (!isValidEnum(arg, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnumModules", exceptionState)) { exceptionState.throwIfNeeded(); return; } } TestPartialInterfaceImplementation3::partialVoidTestEnumModulesArgMethod(*impl, arg); }
static void setNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "setNamedItem", "TestInterface2", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { setMinimumArityTypeError(exceptionState, 2, info.Length()); exceptionState.throwIfNeeded(); return; } TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); V8StringResource<> name; TestInterfaceEmpty* value; { name = info[0]; if (!name.prepare()) return; value = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[1]); if (!value && !isUndefinedOrNull(info[1])) { exceptionState.throwTypeError("parameter 2 is not of type 'TestInterfaceEmpty'."); exceptionState.throwIfNeeded(); return; } } TestInterfaceEmpty* result = impl->setNamedItem(name, value, exceptionState); if (exceptionState.hadException()) { exceptionState.throwIfNeeded(); return; } v8SetReturnValue(info, result); }
static void staticStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { // Prepare the value to be set. V8StringResource<> cppValue = v8Value; if (!cppValue.prepare()) return; TestInterfaceOriginTrialEnabled::setStaticStringAttribute(cppValue); }
static void reflectUrlStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); Element* impl = V8Element::toImpl(holder); V8StringResource<> cppValue = v8Value; if (!cppValue.prepare()) return; impl->setAttribute(HTMLNames::reflecturlstringattributeAttr, cppValue); }
static void hrefAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); TestNode* impl = V8TestNode::toImpl(holder); V8StringResource<> cppValue = v8Value; if (!cppValue.prepare()) return; impl->setHref(cppValue); }
static void hrefCallWithAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); TestNode* impl = V8TestNode::toImpl(holder); V8StringResource<> cppValue = v8Value; if (!cppValue.prepare()) return; ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); impl->setHrefCallWith(executionContext, currentDOMWindow(info.GetIsolate()), enteredDOMWindow(info.GetIsolate()), cppValue); }
static void staticVoidMethodPartialOverload2Method(const v8::FunctionCallbackInfo<v8::Value>& info) { V8StringResource<> value; { value = info[0]; if (!value.prepare()) return; } TestPartialInterfaceImplementation3::staticVoidMethodPartialOverload(value); }
static void staticPromiseMethodPartialOverload2MethodPromise(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionState) { V8StringResource<> value; { value = info[0]; if (!value.prepare(exceptionState)) return; } v8SetReturnValue(info, TestPartialInterfaceImplementation3::staticPromiseMethodPartialOverload(value).v8Value()); }
static void typeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); SVGTestInterface* impl = V8SVGTestInterface::toImpl(holder); V8StringResource<> cppValue = v8Value; if (!cppValue.prepare()) return; CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; impl->setAttribute(SVGNames::typeAttr, cppValue); }
static void hrefThrowsAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); ExceptionState exceptionState(ExceptionState::SetterContext, "hrefThrows", "TestNode", holder, info.GetIsolate()); TestNode* impl = V8TestNode::toImpl(holder); V8StringResource<> cppValue = v8Value; if (!cppValue.prepare()) return; impl->setHrefThrows(cppValue, exceptionState); exceptionState.throwIfNeeded(); }
static void voidMethodPartialOverload3Method(const v8::FunctionCallbackInfo<v8::Value>& info) { TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); V8StringResource<> value; { value = info[0]; if (!value.prepare()) return; } TestPartialInterfaceImplementation3::voidMethodPartialOverload(*impl, value); }
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 voidMethodPartial2Method(const v8::FunctionCallbackInfo<v8::Value>& info) { if (UNLIKELY(info.Length() < 1)) { V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "voidMethodPartial2", "TestInterface2", 1, info.Length()), info.GetIsolate()); return; } TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); V8StringResource<> value; { value = info[0]; if (!value.prepare()) return; } TestInterface2Partial2::voidMethodPartial2(*impl, value); }
static void locationAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); TestInterfaceDocument* proxyImpl = V8TestInterfaceDocument::toImpl(holder); Location* impl = WTF::getPtr(proxyImpl->location()); if (!impl) return; ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterfaceDocument", "location"); // Prepare the value to be set. V8StringResource<> cppValue = v8Value; if (!cppValue.prepare()) return; impl->setHref(currentDOMWindow(info.GetIsolate()), enteredDOMWindow(info.GetIsolate()), cppValue, exceptionState); }
static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) { if (UNLIKELY(info.Length() < 1)) { V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor(info.GetIsolate(), "TestInterfaceConstructor3", 1, info.Length()), info.GetIsolate()); return; } V8StringResource<> stringArg; { stringArg = info[0]; if (!stringArg.prepare()) return; } RefPtr<TestInterfaceConstructor3> impl = TestInterfaceConstructor3::create(stringArg); v8::Local<v8::Object> wrapper = info.Holder(); impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor3::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); }
static void constructor3(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ConstructionContext, "TestInterfaceConstructor"); ScriptState* scriptState = ScriptState::forReceiverObject(info); V8StringResource<> arg; V8StringResource<> optArg; int numArgsPassed = info.Length(); while (numArgsPassed > 0) { if (!info[numArgsPassed - 1]->IsUndefined()) break; --numArgsPassed; } arg = info[0]; if (!arg.prepare()) return; if (UNLIKELY(numArgsPassed <= 1)) { ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); Document& document = *toDocument(currentExecutionContext(info.GetIsolate())); TestInterfaceConstructor* impl = TestInterfaceConstructor::create(scriptState, executionContext, document, arg, exceptionState); if (exceptionState.hadException()) { return; } v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); return; } optArg = info[1]; if (!optArg.prepare()) return; ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); Document& document = *toDocument(currentExecutionContext(info.GetIsolate())); TestInterfaceConstructor* impl = TestInterfaceConstructor::create(scriptState, executionContext, document, arg, optArg, exceptionState); if (exceptionState.hadException()) { return; } v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); }
static void voidMethodFloatArgStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodFloatArgStringArg", "TestTypedefs", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { setMinimumArityTypeError(exceptionState, 2, info.Length()); exceptionState.throwIfNeeded(); return; } TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder()); float floatArg; V8StringResource<> stringArg; { floatArg = toRestrictedFloat(info.GetIsolate(), info[0], exceptionState); if (exceptionState.throwIfNeeded()) return; stringArg = info[1]; if (!stringArg.prepare()) return; } impl->voidMethodFloatArgStringArg(floatArg, stringArg); }
void V8TestInterfaceGarbageCollectedOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceGarbageCollectedOrString& impl, UnionTypeConversionMode conversionMode, ExceptionState& exceptionState) { if (v8Value.IsEmpty()) return; if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull(v8Value)) return; if (V8TestInterfaceGarbageCollected::hasInstance(v8Value, isolate)) { TestInterfaceGarbageCollected* cppValue = V8TestInterfaceGarbageCollected::toImpl(v8::Local<v8::Object>::Cast(v8Value)); impl.setTestInterfaceGarbageCollected(cppValue); return; } { V8StringResource<> cppValue = v8Value; if (!cppValue.prepare(exceptionState)) return; impl.setString(cppValue); return; } }
static void deleteNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "deleteNamedItem"); TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); if (UNLIKELY(info.Length() < 1)) { exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); return; } V8StringResource<> name; name = info[0]; if (!name.prepare()) return; bool result = impl->deleteNamedItem(name, exceptionState); if (exceptionState.hadException()) { return; } v8SetReturnValueBool(info, result); }
static void deleteNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "deleteNamedItem", "TestInterface2", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 1)) { setMinimumArityTypeError(exceptionState, 1, info.Length()); exceptionState.throwIfNeeded(); return; } TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); V8StringResource<> name; { name = info[0]; if (!name.prepare()) return; } bool result = impl->deleteNamedItem(name, exceptionState); if (exceptionState.hadException()) { exceptionState.throwIfNeeded(); return; } v8SetReturnValueBool(info, result); }
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; { int numArgsPassed = info.Length(); while (numArgsPassed > 0) { if (!info[numArgsPassed - 1]->IsUndefined()) break; --numArgsPassed; } testInterfaceEmptyArg = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[0]); if (!testInterfaceEmptyArg) { exceptionState.throwTypeError("parameter 1 is not of type 'TestInterfaceEmpty'."); exceptionState.throwIfNeeded(); return; } longArg = toInt32(info.GetIsolate(), info[1], NormalConversion, exceptionState); if (exceptionState.throwIfNeeded()) return; defaultUndefinedOptionalStringArg = info[2]; if (!defaultUndefinedOptionalStringArg.prepare()) return; if (!info[3]->IsUndefined()) { defaultNullStringOptionalStringArg = info[3]; if (!defaultNullStringOptionalStringArg.prepare()) return; } 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(), exceptionState); if (exceptionState.throwIfNeeded()) return; if (UNLIKELY(numArgsPassed <= 5)) { RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg); v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); return; } optionalStringArg = info[5]; if (!optionalStringArg.prepare()) return; } RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg, optionalStringArg); v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper); 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); }
static void deleteMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "delete", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 1)) { setMinimumArityTypeError(exceptionState, 1, info.Length()); exceptionState.throwIfNeeded(); return; } TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); V8StringResource<> value; { value = info[0]; if (!value.prepare()) return; } ScriptState* scriptState = ScriptState::current(info.GetIsolate()); bool result = impl->deleteForBinding(scriptState, value, exceptionState); if (exceptionState.hadException()) { exceptionState.throwIfNeeded(); return; } v8SetReturnValueBool(info, result); }
static void V8TestInterfaceNamedConstructorConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (!info.IsConstructCall()) { V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("Audio")); return; } if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) { v8SetReturnValue(info, info.Holder()); return; } ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceNamedConstructor", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 1)) { setMinimumArityTypeError(exceptionState, 1, info.Length()); exceptionState.throwIfNeeded(); return; } V8StringResource<> stringArg; bool defaultUndefinedOptionalBooleanArg; int defaultUndefinedOptionalLongArg; V8StringResource<> defaultUndefinedOptionalStringArg; V8StringResource<> defaultNullStringOptionalstringArg; V8StringResource<> optionalStringArg; { int numArgsPassed = info.Length(); while (numArgsPassed > 0) { if (!info[numArgsPassed - 1]->IsUndefined()) break; --numArgsPassed; } stringArg = info[0]; if (!stringArg.prepare()) return; defaultUndefinedOptionalBooleanArg = toBoolean(info.GetIsolate(), info[1], exceptionState); if (exceptionState.throwIfNeeded()) return; defaultUndefinedOptionalLongArg = toInt32(info.GetIsolate(), info[2], NormalConversion, exceptionState); if (exceptionState.throwIfNeeded()) return; defaultUndefinedOptionalStringArg = info[3]; if (!defaultUndefinedOptionalStringArg.prepare()) return; if (!info[4]->IsUndefined()) { defaultNullStringOptionalstringArg = info[4]; if (!defaultNullStringOptionalstringArg.prepare()) return; } else { defaultNullStringOptionalstringArg = nullptr; } if (UNLIKELY(numArgsPassed <= 5)) { Document& document = *toDocument(currentExecutionContext(info.GetIsolate())); RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::createForJSConstructor(document, stringArg, defaultUndefinedOptionalBooleanArg, defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalstringArg, exceptionState); if (exceptionState.hadException()) { exceptionState.throwIfNeeded(); return; } v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); return; } optionalStringArg = info[5]; if (!optionalStringArg.prepare()) return; } Document& document = *toDocument(currentExecutionContext(info.GetIsolate())); RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::createForJSConstructor(document, stringArg, defaultUndefinedOptionalBooleanArg, defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalstringArg, optionalStringArg, exceptionState); if (exceptionState.hadException()) { exceptionState.throwIfNeeded(); return; } v8::Local<v8::Object> wrapper = info.Holder(); wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); }