mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
src: fix compatility with upcoming V8 12.1 APIs
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
30baacba41
commit
94363bb3fd
4 files changed
+47
-38
No files matched your search
+8
-3
@@ -775,13 +775,18 @@ inline void Environment::ThrowRangeError(const char* errmsg) {
|
||||
ThrowError(v8::Exception::RangeError, errmsg);
|
||||
}
|
||||
|
||||
inline void Environment::ThrowError(
|
||||
v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
|
||||
const char* errmsg) {
|
||||
inline void Environment::ThrowError(V8ExceptionConstructorOld fun,
|
||||
const char* errmsg) {
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
isolate()->ThrowException(fun(OneByteString(isolate(), errmsg)));
|
||||
}
|
||||
|
||||
inline void Environment::ThrowError(V8ExceptionConstructorNew fun,
|
||||
const char* errmsg) {
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
isolate()->ThrowException(fun(OneByteString(isolate(), errmsg), {}));
|
||||
}
|
||||
|
||||
inline void Environment::ThrowErrnoException(int errorno,
|
||||
const char* syscall,
|
||||
const char* message,
|
||||
|
||||
@@ -1016,8 +1016,14 @@ class Environment : public MemoryRetainer {
|
||||
};
|
||||
|
||||
private:
|
||||
inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
|
||||
const char* errmsg);
|
||||
// V8 has changed the constructor of exceptions, support both APIs before Node
|
||||
// updates to V8 12.1.
|
||||
using V8ExceptionConstructorOld =
|
||||
v8::Local<v8::Value> (*)(v8::Local<v8::String>);
|
||||
using V8ExceptionConstructorNew =
|
||||
v8::Local<v8::Value> (*)(v8::Local<v8::String>, v8::Local<v8::Value>);
|
||||
inline void ThrowError(V8ExceptionConstructorOld fun, const char* errmsg);
|
||||
inline void ThrowError(V8ExceptionConstructorNew fun, const char* errmsg);
|
||||
void TrackContext(v8::Local<v8::Context> context);
|
||||
void UntrackContext(v8::Local<v8::Context> context);
|
||||
|
||||
|
||||
@@ -968,11 +968,8 @@ napi_define_class(napi_env env,
|
||||
env, p->setter, p->data, &setter_tpl));
|
||||
}
|
||||
|
||||
tpl->PrototypeTemplate()->SetAccessorProperty(property_name,
|
||||
getter_tpl,
|
||||
setter_tpl,
|
||||
attributes,
|
||||
v8::AccessControl::DEFAULT);
|
||||
tpl->PrototypeTemplate()->SetAccessorProperty(
|
||||
property_name, getter_tpl, setter_tpl, attributes);
|
||||
} else if (p->method != nullptr) {
|
||||
v8::Local<v8::FunctionTemplate> t;
|
||||
STATUS_CALL(v8impl::FunctionCallbackWrapper::NewTemplate(
|
||||
|
||||
+29
-28
@@ -680,37 +680,38 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||
Local<ObjectTemplate> target) {
|
||||
Isolate* isolate = isolate_data->isolate();
|
||||
|
||||
target->SetAccessor(isolate_data->config_string(),
|
||||
ConfigStringGetter,
|
||||
nullptr,
|
||||
Local<Value>(),
|
||||
DEFAULT,
|
||||
None,
|
||||
SideEffectType::kHasNoSideEffect);
|
||||
target->SetNativeDataProperty(isolate_data->config_string(),
|
||||
ConfigStringGetter,
|
||||
nullptr,
|
||||
Local<Value>(),
|
||||
None,
|
||||
DEFAULT,
|
||||
SideEffectType::kHasNoSideEffect);
|
||||
|
||||
target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinIds"),
|
||||
BuiltinIdsGetter,
|
||||
nullptr,
|
||||
Local<Value>(),
|
||||
DEFAULT,
|
||||
None,
|
||||
SideEffectType::kHasNoSideEffect);
|
||||
target->SetNativeDataProperty(FIXED_ONE_BYTE_STRING(isolate, "builtinIds"),
|
||||
BuiltinIdsGetter,
|
||||
nullptr,
|
||||
Local<Value>(),
|
||||
None,
|
||||
DEFAULT,
|
||||
SideEffectType::kHasNoSideEffect);
|
||||
|
||||
target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinCategories"),
|
||||
GetBuiltinCategories,
|
||||
nullptr,
|
||||
Local<Value>(),
|
||||
DEFAULT,
|
||||
None,
|
||||
SideEffectType::kHasNoSideEffect);
|
||||
target->SetNativeDataProperty(
|
||||
FIXED_ONE_BYTE_STRING(isolate, "builtinCategories"),
|
||||
GetBuiltinCategories,
|
||||
nullptr,
|
||||
Local<Value>(),
|
||||
None,
|
||||
DEFAULT,
|
||||
SideEffectType::kHasNoSideEffect);
|
||||
|
||||
target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "natives"),
|
||||
GetNatives,
|
||||
nullptr,
|
||||
Local<Value>(),
|
||||
DEFAULT,
|
||||
None,
|
||||
SideEffectType::kHasNoSideEffect);
|
||||
target->SetNativeDataProperty(FIXED_ONE_BYTE_STRING(isolate, "natives"),
|
||||
GetNatives,
|
||||
nullptr,
|
||||
Local<Value>(),
|
||||
None,
|
||||
DEFAULT,
|
||||
SideEffectType::kHasNoSideEffect);
|
||||
|
||||
SetMethod(isolate, target, "getCacheUsage", BuiltinLoader::GetCacheUsage);
|
||||
SetMethod(isolate, target, "compileFunction", BuiltinLoader::CompileFunction);
|
||||
|
||||
Reference in new issue
Block a user