$NetBSD$ * Part of patchset to build electron on NetBSD * Based on OpenBSD's chromium patches, and FreeBSD's electron patches --- third_party/nan/nan_callbacks_12_inl.h.orig 2023-09-12 12:23:33.000000000 +0000 +++ third_party/nan/nan_callbacks_12_inl.h @@ -255,7 +255,98 @@ typedef void (*NativeSetter)( , const v8::PropertyCallbackInfo &); #endif -#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION +#if NODE_MODULE_VERSION > NODE_21_0_MODULE_VERSION +static +v8::Intercepted PropertyGetterCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + PropertyGetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyGetterIndex) + .As().As()->Value())); + callback(property.As(), cbinfo); + return v8::Intercepted::kYes; +} + +typedef v8::Intercepted (*NativePropertyGetter) + (v8::Local, const v8::PropertyCallbackInfo &); + +static +v8::Intercepted PropertySetterCallbackWrapper( + v8::Local property + , v8::Local value + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + PropertySetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertySetterIndex) + .As().As()->Value())); + callback(property.As(), value, *reinterpret_cast*>(&cbinfo)); + return v8::Intercepted::kYes; +} + +typedef v8::Intercepted (*NativePropertySetter)( + v8::Local + , v8::Local + , const v8::PropertyCallbackInfo &); + +static +void PropertyEnumeratorCallbackWrapper( + const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + PropertyEnumeratorCallback callback = + reinterpret_cast(reinterpret_cast( + obj->GetInternalField(kPropertyEnumeratorIndex) + .As().As()->Value())); + callback(cbinfo); +} + +typedef void (*NativePropertyEnumerator) + (const v8::PropertyCallbackInfo &); + +static +v8::Intercepted PropertyDeleterCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + PropertyDeleterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyDeleterIndex) + .As().As()->Value())); + callback(property.As(), cbinfo); + return v8::Intercepted::kYes; +} + +typedef v8::Intercepted (NativePropertyDeleter) + (v8::Local, const v8::PropertyCallbackInfo &); + +static +v8::Intercepted PropertyQueryCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + PropertyQueryCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyQueryIndex) + .As().As()->Value())); + callback(property.As(), cbinfo); + return v8::Intercepted::kYes; +} + +typedef v8::Intercepted (*NativePropertyQuery) + (v8::Local, const v8::PropertyCallbackInfo &); +#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION static void PropertyGetterCallbackWrapper( v8::Local property @@ -431,6 +522,96 @@ typedef void (*NativePropertyQuery) (v8::Local, const v8::PropertyCallbackInfo &); #endif +#if NODE_MODULE_VERSION > NODE_21_0_MODULE_VERSION +static +v8::Intercepted IndexGetterCallbackWrapper( + uint32_t index, const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + IndexGetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyGetterIndex) + .As().As()->Value())); + callback(index, cbinfo); + return v8::Intercepted::kYes; +} + +typedef v8::Intercepted (*NativeIndexGetter) + (uint32_t, const v8::PropertyCallbackInfo &); + +static +v8::Intercepted IndexSetterCallbackWrapper( + uint32_t index + , v8::Local value + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + IndexSetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertySetterIndex) + .As().As()->Value())); + callback(index, value, *reinterpret_cast*>(&cbinfo)); + return v8::Intercepted::kYes; +} + +typedef v8::Intercepted (*NativeIndexSetter)( + uint32_t + , v8::Local + , const v8::PropertyCallbackInfo &); + +static +void IndexEnumeratorCallbackWrapper( + const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + IndexEnumeratorCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField( + kIndexPropertyEnumeratorIndex) + .As().As()->Value())); + callback(cbinfo); +} + +typedef void (*NativeIndexEnumerator) + (const v8::PropertyCallbackInfo &); + +static +v8::Intercepted IndexDeleterCallbackWrapper( + uint32_t index, const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + IndexDeleterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyDeleterIndex) + .As().As()->Value())); + callback(index, cbinfo); + return v8::Intercepted::kYes; +} + +typedef v8::Intercepted (*NativeIndexDeleter) + (uint32_t, const v8::PropertyCallbackInfo &); + +static +v8::Intercepted IndexQueryCallbackWrapper( + uint32_t index, const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex).As()); + IndexQueryCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyQueryIndex) + .As().As()->Value())); + callback(index, cbinfo); + return v8::Intercepted::kYes; +} + +typedef v8::Intercepted (*NativeIndexQuery) + (uint32_t, const v8::PropertyCallbackInfo &); +#else static void IndexGetterCallbackWrapper( uint32_t index, const v8::PropertyCallbackInfo &info) { @@ -515,6 +696,8 @@ void IndexQueryCallbackWrapper( typedef void (*NativeIndexQuery) (uint32_t, const v8::PropertyCallbackInfo &); +#endif + } // end of namespace imp #endif // NAN_CALLBACKS_12_INL_H_