Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle ObjectTemplate::SetAccessor API change in v8 12.1 #204

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions v8pp/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,17 @@ class module
static_assert(!detail::is_callable<Variable>::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<Variable>, &var_set<Variable>,
detail::external_data::set(isolate_, &var),
v8::PropertyAttribute(v8::DontDelete));
#else
obj_->SetAccessor(v8pp::to_v8(isolate_, name),
&var_get<Variable>, &var_set<Variable>,
detail::external_data::set(isolate_, &var),
v8::DEFAULT, v8::PropertyAttribute(v8::DontDelete));
#endif
return *this;
}

Expand All @@ -107,7 +114,11 @@ class module
v8::AccessorSetterCallback setter = property_type::is_readonly ? nullptr : property_type::template set<Traits>;
v8::Local<v8::String> v8_name = v8pp::to_v8(isolate_, name);
v8::Local<v8::Value> 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;
}

Expand Down
Loading