From 7b3d1b640aa795dc1515e6eb51a7fe72eb984977 Mon Sep 17 00:00:00 2001 From: Jean-Claude Monnin Date: Tue, 2 Jan 2024 11:39:55 +0100 Subject: [PATCH] handle ObjectTemplate::SetAccessor API change in v8 12.1 https://github.com/v8/v8/commit/e48c47268c53499814c88c35064d564dbb92e6fd --- v8pp/module.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/v8pp/module.hpp b/v8pp/module.hpp index e8344b16..80eb7094 100644 --- a/v8pp/module.hpp +++ b/v8pp/module.hpp @@ -81,10 +81,17 @@ class module static_assert(!detail::is_callable::value, "Variable must not be callable"); v8::HandleScope scope(isolate_); +#if V8_MAJOR_VERSION > 12 || (V8_MAJOR_VERSION == 12 && V8_MINOR_VERSION >= 1) + obj_->SetAccessor(v8pp::to_v8(isolate_, name), + &var_get, &var_set, + detail::external_data::set(isolate_, &var), + v8::PropertyAttribute(v8::DontDelete)); +#else obj_->SetAccessor(v8pp::to_v8(isolate_, name), &var_get, &var_set, detail::external_data::set(isolate_, &var), v8::DEFAULT, v8::PropertyAttribute(v8::DontDelete)); +#endif return *this; } @@ -107,7 +114,11 @@ class module v8::AccessorSetterCallback setter = property_type::is_readonly ? nullptr : property_type::template set; v8::Local v8_name = v8pp::to_v8(isolate_, name); v8::Local data = detail::external_data::set(isolate_, property_type(std::move(get), std::move(set))); +#if V8_MAJOR_VERSION > 12 || (V8_MAJOR_VERSION == 12 && V8_MINOR_VERSION >= 1) + obj_->SetAccessor(v8_name, getter, setter, data, v8::PropertyAttribute(v8::DontDelete)); +#else obj_->SetAccessor(v8_name, getter, setter, data, v8::DEFAULT, v8::PropertyAttribute(v8::DontDelete)); +#endif return *this; }