void V8DeviceMotionEvent::initDeviceMotionEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "initDeviceMotionEvent", "DeviceMotionEvent", info.Holder(), info.GetIsolate()); DeviceMotionEvent* impl = V8DeviceMotionEvent::toImpl(info.Holder()); v8::Isolate* isolate = info.GetIsolate(); V8StringResource<> type(info[0]); if (!type.prepare()) return; v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); bool bubbles = false; V8_CALL(bubbles, info[1], BooleanValue(context), return); bool cancelable = false; V8_CALL(cancelable, info[2], BooleanValue(context), return); DeviceMotionData::Acceleration* acceleration = readAccelerationArgument(info[3], isolate); DeviceMotionData::Acceleration* accelerationIncludingGravity = readAccelerationArgument(info[4], isolate); DeviceMotionData::RotationRate* rotationRate = readRotationRateArgument(info[5], isolate); bool intervalProvided = !isUndefinedOrNull(info[6]); double interval = 0; if (intervalProvided) { interval = toRestrictedDouble(isolate, info[6], exceptionState); if (exceptionState.throwIfNeeded()) return; } DeviceMotionData* deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval); impl->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData); }
static void voidMethodPartialOverload2Method(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterfaceOriginTrialEnabled", "voidMethodPartialOverload"); TestInterfaceOriginTrialEnabled* impl = V8TestInterfaceOriginTrialEnabled::toImpl(info.Holder()); double doubleArg; doubleArg = toRestrictedDouble(info.GetIsolate(), info[0], exceptionState); if (exceptionState.hadException()) return; impl->voidMethodPartialOverload(doubleArg); }
static void doubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); TestInterfaceOriginTrialEnabled* impl = V8TestInterfaceOriginTrialEnabled::toImpl(holder); ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterfaceOriginTrialEnabled", "doubleAttribute"); // Prepare the value to be set. double cppValue = toRestrictedDouble(info.GetIsolate(), v8Value, exceptionState); if (exceptionState.hadException()) return; impl->setDoubleAttribute(cppValue); }
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); }
static void voidMethodDocumentMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodDocument", "TestInterface3", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { setMinimumArityTypeError(exceptionState, 2, info.Length()); exceptionState.throwIfNeeded(); return; } Document* document; double d; { document = V8Document::toImplWithTypeCheck(info.GetIsolate(), info[0]); if (!document) { exceptionState.throwTypeError("parameter 1 is not of type 'Document'."); exceptionState.throwIfNeeded(); return; } d = toRestrictedDouble(info.GetIsolate(), info[1], exceptionState); if (exceptionState.throwIfNeeded()) return; } TestPartialInterface4::voidMethodDocument(document, d); }
void V8StringOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrDouble& impl, UnionTypeConversionMode conversionMode, ExceptionState& exceptionState) { if (v8Value.IsEmpty()) return; if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull(v8Value)) return; if (v8Value->IsNumber()) { double cppValue = toRestrictedDouble(isolate, v8Value, exceptionState); if (exceptionState.hadException()) return; impl.setDouble(cppValue); return; } { V8StringResource<> cppValue = v8Value; if (!cppValue.prepare(exceptionState)) return; impl.setString(cppValue); return; } }