Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit94363bb

Browse files
zcbenzUlisesGascon
authored andcommitted
src: fix compatility with upcoming V8 12.1 APIs
PR-URL:#50709Reviewed-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 parent30baacb commit94363bb

File tree

4 files changed

+50
-41
lines changed

4 files changed

+50
-41
lines changed

‎src/env-inl.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,13 +775,18 @@ inline void Environment::ThrowRangeError(const char* errmsg) {
775775
ThrowError(v8::Exception::RangeError, errmsg);
776776
}
777777

778-
inlinevoidEnvironment::ThrowError(
779-
v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
780-
const char* errmsg) {
778+
inlinevoidEnvironment::ThrowError(V8ExceptionConstructorOld fun,
779+
constchar* errmsg) {
781780
v8::HandleScopehandle_scope(isolate());
782781
isolate()->ThrowException(fun(OneByteString(isolate(), errmsg)));
783782
}
784783

784+
inlinevoidEnvironment::ThrowError(V8ExceptionConstructorNew fun,
785+
constchar* errmsg) {
786+
v8::HandleScopehandle_scope(isolate());
787+
isolate()->ThrowException(fun(OneByteString(isolate(), errmsg), {}));
788+
}
789+
785790
inlinevoidEnvironment::ThrowErrnoException(int errorno,
786791
constchar* syscall,
787792
constchar* message,

‎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-
inlinevoidThrowError(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+
inlinevoidThrowError(V8ExceptionConstructorOld fun,constchar* errmsg);
1026+
inlinevoidThrowError(V8ExceptionConstructorNew fun,constchar* errmsg);
10211027
voidTrackContext(v8::Local<v8::Context> context);
10221028
voidUntrackContext(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
}elseif (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
Original file line numberDiff line numberDiff line change
@@ -680,37 +680,38 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
680680
Local<ObjectTemplate> target) {
681681
Isolate* isolate = isolate_data->isolate();
682682

683-
target->SetAccessor(isolate_data->config_string(),
684-
ConfigStringGetter,
685-
nullptr,
686-
Local<Value>(),
687-
DEFAULT,
688-
None,
689-
SideEffectType::kHasNoSideEffect);
690-
691-
target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate,"builtinIds"),
692-
BuiltinIdsGetter,
693-
nullptr,
694-
Local<Value>(),
695-
DEFAULT,
696-
None,
697-
SideEffectType::kHasNoSideEffect);
698-
699-
target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate,"builtinCategories"),
700-
GetBuiltinCategories,
701-
nullptr,
702-
Local<Value>(),
703-
DEFAULT,
704-
None,
705-
SideEffectType::kHasNoSideEffect);
706-
707-
target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate,"natives"),
708-
GetNatives,
709-
nullptr,
710-
Local<Value>(),
711-
DEFAULT,
712-
None,
713-
SideEffectType::kHasNoSideEffect);
683+
target->SetNativeDataProperty(isolate_data->config_string(),
684+
ConfigStringGetter,
685+
nullptr,
686+
Local<Value>(),
687+
None,
688+
DEFAULT,
689+
SideEffectType::kHasNoSideEffect);
690+
691+
target->SetNativeDataProperty(FIXED_ONE_BYTE_STRING(isolate,"builtinIds"),
692+
BuiltinIdsGetter,
693+
nullptr,
694+
Local<Value>(),
695+
None,
696+
DEFAULT,
697+
SideEffectType::kHasNoSideEffect);
698+
699+
target->SetNativeDataProperty(
700+
FIXED_ONE_BYTE_STRING(isolate,"builtinCategories"),
701+
GetBuiltinCategories,
702+
nullptr,
703+
Local<Value>(),
704+
None,
705+
DEFAULT,
706+
SideEffectType::kHasNoSideEffect);
707+
708+
target->SetNativeDataProperty(FIXED_ONE_BYTE_STRING(isolate,"natives"),
709+
GetNatives,
710+
nullptr,
711+
Local<Value>(),
712+
None,
713+
DEFAULT,
714+
SideEffectType::kHasNoSideEffect);
714715

715716
SetMethod(isolate, target,"getCacheUsage", BuiltinLoader::GetCacheUsage);
716717
SetMethod(isolate, target,"compileFunction", BuiltinLoader::CompileFunction);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp