src: fix compatility with upcoming V8 12.1 APIs · nodejs/node@94363bb · GitHub
Skip to content

Commit 94363bb

Browse files
zcbenzUlisesGascon
authored andcommitted
src: fix compatility with upcoming V8 12.1 APIs
PR-URL: #50709 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 30baacb commit 94363bb

4 files changed

Lines changed: 50 additions & 41 deletions

File tree

src/env-inl.h

Lines changed: 8 additions & 3 deletions

src/env.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,14 @@ class Environment : public MemoryRetainer {
10161016
};
10171017

10181018
private:
1019-
inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
1020-
const char* errmsg);
1019+
// V8 has changed the constructor of exceptions, support both APIs before Node
1020+
// updates to V8 12.1.
1021+
using V8ExceptionConstructorOld =
1022+
v8::Local<v8::Value> (*)(v8::Local<v8::String>);
1023+
using V8ExceptionConstructorNew =
1024+
v8::Local<v8::Value> (*)(v8::Local<v8::String>, v8::Local<v8::Value>);
1025+
inline void ThrowError(V8ExceptionConstructorOld fun, const char* errmsg);
1026+
inline void ThrowError(V8ExceptionConstructorNew fun, const char* errmsg);
10211027
void TrackContext(v8::Local<v8::Context> context);
10221028
void UntrackContext(v8::Local<v8::Context> context);
10231029

src/js_native_api_v8.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -968,11 +968,8 @@ napi_define_class(napi_env env,
968968
env, p->setter, p->data, &setter_tpl));
969969
}
970970

971-
tpl->PrototypeTemplate()->SetAccessorProperty(property_name,
972-
getter_tpl,
973-
setter_tpl,
974-
attributes,
975-
v8::AccessControl::DEFAULT);
971+
tpl->PrototypeTemplate()->SetAccessorProperty(
972+
property_name, getter_tpl, setter_tpl, attributes);
976973
} else if (p->method != nullptr) {
977974
v8::Local<v8::FunctionTemplate> t;
978975
STATUS_CALL(v8impl::FunctionCallbackWrapper::NewTemplate(

src/node_builtins.cc

Lines changed: 32 additions & 31 deletions

0 commit comments

Comments
 (0)