GeezerVison is showing github.com — src: fix compatility with upcoming V8 12.1 APIs · nodejs/node@94363bb
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/env-inl.h +8-3Lines changed: 8 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -775,13 +775,18 @@ inline void Environment::ThrowRangeError(const char* errmsg) { | 775 | 775 | ThrowError(v8::Exception::RangeError, errmsg); | 776 | 776 | } | 777 | 777 |
| 778 | | -inline void Environment::ThrowError( | 779 | | - v8::Local<v8::Value> (*fun)(v8::Local<v8::String>), | 780 | | - const char* errmsg) { | | 778 | +inline void Environment::ThrowError(V8ExceptionConstructorOld fun, | | 779 | + const char* errmsg) { | 781 | 780 | v8::HandleScope handle_scope(isolate()); | 782 | 781 | isolate()->ThrowException(fun(OneByteString(isolate(), errmsg))); | 783 | 782 | } | 784 | 783 |
| | 784 | +inline void Environment::ThrowError(V8ExceptionConstructorNew fun, | | 785 | + const char* errmsg) { | | 786 | + v8::HandleScope handle_scope(isolate()); | | 787 | + isolate()->ThrowException(fun(OneByteString(isolate(), errmsg), {})); | | 788 | +} | | 789 | + | 785 | 790 | inline void Environment::ThrowErrnoException(int errorno, | 786 | 791 | const char* syscall, | 787 | 792 | const char* message, | |
Collapse file Copy file name to clipboardExpand all lines: src/env.h +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1016,8 +1016,14 @@ class Environment : public MemoryRetainer { | 1016 | 1016 | }; | 1017 | 1017 |
| 1018 | 1018 | 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); | 1021 | 1027 | void TrackContext(v8::Local<v8::Context> context); | 1022 | 1028 | void UntrackContext(v8::Local<v8::Context> context); | 1023 | 1029 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/js_native_api_v8.cc +2-5Lines changed: 2 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -968,11 +968,8 @@ napi_define_class(napi_env env, | 968 | 968 | env, p->setter, p->data, &setter_tpl)); | 969 | 969 | } | 970 | 970 |
| 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); | 976 | 973 | } else if (p->method != nullptr) { | 977 | 974 | v8::Local<v8::FunctionTemplate> t; | 978 | 975 | STATUS_CALL(v8impl::FunctionCallbackWrapper::NewTemplate( | |
Collapse file Copy file name to clipboardExpand all lines: src/node_builtins.cc +32-31Lines changed: 32 additions & 31 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -680,37 +680,38 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data, | 680 | 680 | Local<ObjectTemplate> target) { | 681 | 681 | Isolate* isolate = isolate_data->isolate(); | 682 | 682 |
| 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); | 714 | 715 |
| 715 | 716 | SetMethod(isolate, target, "getCacheUsage", BuiltinLoader::GetCacheUsage); | 716 | 717 | SetMethod(isolate, target, "compileFunction", BuiltinLoader::CompileFunction); | |
|