static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { TestInterface* impl = V8TestInterface::toNative(info.Holder()); AtomicString propertyName = toCoreAtomicString(name); v8::String::Utf8Value namedProperty(name); ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestInterface", info.Holder(), info.GetIsolate()); bool result = impl->namedPropertyQuery(propertyName, exceptionState); if (exceptionState.throwIfNeeded()) return; if (!result) return; v8SetReturnValueInt(info, v8::None); }
static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { if (!name->IsString()) return; TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); v8::String::Utf8Value namedProperty(name); ExceptionState exceptionState(ExceptionState::DeletionContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate()); DeleteResult result = impl->deleteNamedItem(propertyName, exceptionState); if (exceptionState.throwIfNeeded()) return; if (result != DeleteUnknownProperty) return v8SetReturnValueBool(info, result == DeleteSuccess); }
static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { if (!name->IsString()) return; auto nameString = name.As<v8::String>(); TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(nameString); v8::String::Utf8Value namedProperty(nameString); ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate()); TestInterfaceEmpty* result = impl->namedItem(propertyName, exceptionState); if (exceptionState.throwIfNeeded()) return; if (!result) return; v8SetReturnValueFast(info, result, impl); }
static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { if (!name->IsString()) return; auto nameString = name.As<v8::String>(); v8::String::Utf8Value namedProperty(nameString); ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate()); TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); V8StringResource<> propertyName(nameString); if (!propertyName.prepare()) return; TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), v8Value); if (!propertyValue && !isUndefinedOrNull(v8Value)) { exceptionState.throwTypeError("The provided value is not of type 'TestInterfaceEmpty'."); exceptionState.throwIfNeeded(); return; } bool result = impl->setNamedItem(propertyName, propertyValue, exceptionState); if (exceptionState.throwIfNeeded()) return; if (!result) return; v8SetReturnValue(info, v8Value); }