| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a0da234 commit 456fca0
22 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,7 @@ using v8::MaybeLocal; | |||
| 44 | 44 | using v8::Nothing; | |
| 45 | 45 | using v8::Number; | |
| 46 | 46 | using v8::Object; | |
| 47 | + using v8::ObjectTemplate; | ||
| 47 | 48 | using v8::PropertyAttribute; | |
| 48 | 49 | using v8::ReadOnly; | |
| 49 | 50 | using v8::String; | |
@@ -351,24 +352,31 @@ Local<FunctionTemplate> AsyncWrap::GetConstructorTemplate( | |||
| 351 | 352 | return tmpl; | |
| 352 | 353 | } | |
| 353 | 354 | ||
| 354 | - void AsyncWrap::Initialize(Local<Object> target, | ||
| 355 | - Local<Value> unused, | ||
| 356 | - Local<Context> context, | ||
| 357 | - void* priv) { | ||
| 355 | + void AsyncWrap::CreatePerIsolateProperties(IsolateData* isolate_data, | ||
| 356 | + Local<FunctionTemplate> ctor) { | ||
| 357 | + Isolate* isolate = isolate_data->isolate(); | ||
| 358 | + Local<ObjectTemplate> target = ctor->InstanceTemplate(); | ||
| 359 | + | ||
| 360 | + SetMethod(isolate, target, "setupHooks", SetupHooks); | ||
| 361 | + SetMethod(isolate, target, "setCallbackTrampoline", SetCallbackTrampoline); | ||
| 362 | + SetMethod(isolate, target, "pushAsyncContext", PushAsyncContext); | ||
| 363 | + SetMethod(isolate, target, "popAsyncContext", PopAsyncContext); | ||
| 364 | + SetMethod(isolate, target, "executionAsyncResource", ExecutionAsyncResource); | ||
| 365 | + SetMethod(isolate, target, "clearAsyncIdStack", ClearAsyncIdStack); | ||
| 366 | + SetMethod(isolate, target, "queueDestroyAsyncId", QueueDestroyAsyncId); | ||
| 367 | + SetMethod(isolate, target, "setPromiseHooks", SetPromiseHooks); | ||
| 368 | + SetMethod(isolate, target, "registerDestroyHook", RegisterDestroyHook); | ||
| 369 | + AsyncWrap::GetConstructorTemplate(isolate_data); | ||
| 370 | + } | ||
| 371 | + | ||
| 372 | + void AsyncWrap::CreatePerContextProperties(Local<Object> target, | ||
| 373 | + Local<Value> unused, | ||
| 374 | + Local<Context> context, | ||
| 375 | + void* priv) { | ||
| 358 | 376 | Environment* env = Environment::GetCurrent(context); | |
| 359 | 377 | Isolate* isolate = env->isolate(); | |
| 360 | 378 | HandleScope scope(isolate); | |
| 361 | 379 | ||
| 362 | - SetMethod(context, target, "setupHooks", SetupHooks); | ||
| 363 | - SetMethod(context, target, "setCallbackTrampoline", SetCallbackTrampoline); | ||
| 364 | - SetMethod(context, target, "pushAsyncContext", PushAsyncContext); | ||
| 365 | - SetMethod(context, target, "popAsyncContext", PopAsyncContext); | ||
| 366 | - SetMethod(context, target, "executionAsyncResource", ExecutionAsyncResource); | ||
| 367 | - SetMethod(context, target, "clearAsyncIdStack", ClearAsyncIdStack); | ||
| 368 | - SetMethod(context, target, "queueDestroyAsyncId", QueueDestroyAsyncId); | ||
| 369 | - SetMethod(context, target, "setPromiseHooks", SetPromiseHooks); | ||
| 370 | - SetMethod(context, target, "registerDestroyHook", RegisterDestroyHook); | ||
| 371 | - | ||
| 372 | 380 | PropertyAttribute ReadOnlyDontDelete = | |
| 373 | 381 | static_cast<PropertyAttribute>(ReadOnly | DontDelete); | |
| 374 | 382 | ||
@@ -625,7 +633,6 @@ void AsyncWrap::AsyncReset(Local<Object> resource, double execution_async_id, | |||
| 625 | 633 | async_id_, trigger_async_id_); | |
| 626 | 634 | } | |
| 627 | 635 | ||
| 628 | - | ||
| 629 | 636 | void AsyncWrap::EmitAsyncInit(Environment* env, | |
| 630 | 637 | Local<Object> object, | |
| 631 | 638 | Local<String> type, | |
@@ -710,6 +717,9 @@ Local<Object> AsyncWrap::GetOwner(Environment* env, Local<Object> obj) { | |||
| 710 | 717 | ||
| 711 | 718 | } // namespace node | |
| 712 | 719 | ||
| 713 | - NODE_BINDING_CONTEXT_AWARE_INTERNAL(async_wrap, node::AsyncWrap::Initialize) | ||
| 720 | + NODE_BINDING_CONTEXT_AWARE_INTERNAL(async_wrap, | ||
| 721 | + node::AsyncWrap::CreatePerContextProperties) | ||
| 722 | + NODE_BINDING_PER_ISOLATE_INIT(async_wrap, | ||
| 723 | + node::AsyncWrap::CreatePerIsolateProperties) | ||
| 714 | 724 | NODE_BINDING_EXTERNAL_REFERENCE(async_wrap, | |
| 715 | 725 | node::AsyncWrap::RegisterExternalReferences) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -145,10 +145,12 @@ class AsyncWrap : public BaseObject { | |||
| 145 | 145 | Environment* env); | |
| 146 | 146 | ||
| 147 | 147 | static void RegisterExternalReferences(ExternalReferenceRegistry* registry); | |
| 148 | - static void Initialize(v8::Local<v8::Object> target, | ||
| 149 | - v8::Local<v8::Value> unused, | ||
| 150 | - v8::Local<v8::Context> context, | ||
| 151 | - void* priv); | ||
| 148 | + static void CreatePerContextProperties(v8::Local<v8::Object> target, | ||
| 149 | + v8::Local<v8::Value> unused, | ||
| 150 | + v8::Local<v8::Context> context, | ||
| 151 | + void* priv); | ||
| 152 | + static void CreatePerIsolateProperties( | ||
| 153 | + IsolateData* isolate_data, v8::Local<v8::FunctionTemplate> target); | ||
| 152 | 154 | ||
| 153 | 155 | static void GetAsyncId(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 154 | 156 | static void PushAsyncContext(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,10 +16,12 @@ using v8::ArrayBuffer; | |||
| 16 | 16 | using v8::BackingStore; | |
| 17 | 17 | using v8::Context; | |
| 18 | 18 | using v8::FunctionCallbackInfo; | |
| 19 | + using v8::FunctionTemplate; | ||
| 19 | 20 | using v8::Isolate; | |
| 20 | 21 | using v8::Local; | |
| 21 | 22 | using v8::MaybeLocal; | |
| 22 | 23 | using v8::Object; | |
| 24 | + using v8::ObjectTemplate; | ||
| 23 | 25 | using v8::String; | |
| 24 | 26 | using v8::Uint8Array; | |
| 25 | 27 | using v8::Value; | |
@@ -216,20 +218,23 @@ void BindingData::ToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args) { | |||
| 216 | 218 | String::NewFromUtf8(env->isolate(), out.c_str()).ToLocalChecked()); | |
| 217 | 219 | } | |
| 218 | 220 | ||
| 219 | - void BindingData::Initialize(Local<Object> target, | ||
| 220 | - Local<Value> unused, | ||
| 221 | - Local<Context> context, | ||
| 222 | - void* priv) { | ||
| 221 | + void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data, | ||
| 222 | + Local<FunctionTemplate> ctor) { | ||
| 223 | + Isolate* isolate = isolate_data->isolate(); | ||
| 224 | + Local<ObjectTemplate> target = ctor->InstanceTemplate(); | ||
| 225 | + SetMethod(isolate, target, "encodeInto", EncodeInto); | ||
| 226 | + SetMethodNoSideEffect(isolate, target, "encodeUtf8String", EncodeUtf8String); | ||
| 227 | + SetMethodNoSideEffect(isolate, target, "decodeUTF8", DecodeUTF8); | ||
| 228 | + SetMethodNoSideEffect(isolate, target, "toASCII", ToASCII); | ||
| 229 | + SetMethodNoSideEffect(isolate, target, "toUnicode", ToUnicode); | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + void BindingData::CreatePerContextProperties(Local<Object> target, | ||
| 233 | + Local<Value> unused, | ||
| 234 | + Local<Context> context, | ||
| 235 | + void* priv) { | ||
| 223 | 236 | Realm* realm = Realm::GetCurrent(context); | |
| 224 | - BindingData* const binding_data = | ||
| 225 | - realm->AddBindingData<BindingData>(context, target); | ||
| 226 | - if (binding_data == nullptr) return; | ||
| 227 | - | ||
| 228 | - SetMethod(context, target, "encodeInto", EncodeInto); | ||
| 229 | - SetMethodNoSideEffect(context, target, "encodeUtf8String", EncodeUtf8String); | ||
| 230 | - SetMethodNoSideEffect(context, target, "decodeUTF8", DecodeUTF8); | ||
| 231 | - SetMethodNoSideEffect(context, target, "toASCII", ToASCII); | ||
| 232 | - SetMethodNoSideEffect(context, target, "toUnicode", ToUnicode); | ||
| 237 | + realm->AddBindingData<BindingData>(context, target); | ||
| 233 | 238 | } | |
| 234 | 239 | ||
| 235 | 240 | void BindingData::RegisterTimerExternalReferences( | |
@@ -245,7 +250,11 @@ void BindingData::RegisterTimerExternalReferences( | |||
| 245 | 250 | } // namespace node | |
| 246 | 251 | ||
| 247 | 252 | NODE_BINDING_CONTEXT_AWARE_INTERNAL( | |
| 248 | - encoding_binding, node::encoding_binding::BindingData::Initialize) | ||
| 253 | + encoding_binding, | ||
| 254 | + node::encoding_binding::BindingData::CreatePerContextProperties) | ||
| 255 | + NODE_BINDING_PER_ISOLATE_INIT( | ||
| 256 | + encoding_binding, | ||
| 257 | + node::encoding_binding::BindingData::CreatePerIsolateProperties) | ||
| 249 | 258 | NODE_BINDING_EXTERNAL_REFERENCE( | |
| 250 | 259 | encoding_binding, | |
| 251 | 260 | node::encoding_binding::BindingData::RegisterTimerExternalReferences) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,10 +35,12 @@ class BindingData : public SnapshotableObject { | |||
| 35 | 35 | static void ToASCII(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 36 | 36 | static void ToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 37 | 37 | ||
| 38 | - static void Initialize(v8::Local<v8::Object> target, | ||
| 39 | - v8::Local<v8::Value> unused, | ||
| 40 | - v8::Local<v8::Context> context, | ||
| 41 | - void* priv); | ||
| 38 | + static void CreatePerIsolateProperties(IsolateData* isolate_data, | ||
| 39 | + v8::Local<v8::FunctionTemplate> ctor); | ||
| 40 | + static void CreatePerContextProperties(v8::Local<v8::Object> target, | ||
| 41 | + v8::Local<v8::Value> unused, | ||
| 42 | + v8::Local<v8::Context> context, | ||
| 43 | + void* priv); | ||
| 42 | 44 | static void RegisterTimerExternalReferences( | |
| 43 | 45 | ExternalReferenceRegistry* registry); | |
| 44 | 46 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,19 +154,24 @@ void HandleWrap::OnClose(uv_handle_t* handle) { | |||
| 154 | 154 | wrap->MakeCallback(env->handle_onclose_symbol(), 0, nullptr); | |
| 155 | 155 | } | |
| 156 | 156 | } | |
| 157 | - | ||
| 158 | 157 | Local<FunctionTemplate> HandleWrap::GetConstructorTemplate(Environment* env) { | |
| 159 | - Local<FunctionTemplate> tmpl = env->handle_wrap_ctor_template(); | ||
| 158 | + return GetConstructorTemplate(env->isolate_data()); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + Local<FunctionTemplate> HandleWrap::GetConstructorTemplate( | ||
| 162 | + IsolateData* isolate_data) { | ||
| 163 | + Local<FunctionTemplate> tmpl = isolate_data->handle_wrap_ctor_template(); | ||
| 160 | 164 | if (tmpl.IsEmpty()) { | |
| 161 | - Isolate* isolate = env->isolate(); | ||
| 165 | + Isolate* isolate = isolate_data->isolate(); | ||
| 162 | 166 | tmpl = NewFunctionTemplate(isolate, nullptr); | |
| 163 | - tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "HandleWrap")); | ||
| 164 | - tmpl->Inherit(AsyncWrap::GetConstructorTemplate(env)); | ||
| 167 | + tmpl->SetClassName( | ||
| 168 | + FIXED_ONE_BYTE_STRING(isolate_data->isolate(), "HandleWrap")); | ||
| 169 | + tmpl->Inherit(AsyncWrap::GetConstructorTemplate(isolate_data)); | ||
| 165 | 170 | SetProtoMethod(isolate, tmpl, "close", HandleWrap::Close); | |
| 166 | 171 | SetProtoMethodNoSideEffect(isolate, tmpl, "hasRef", HandleWrap::HasRef); | |
| 167 | 172 | SetProtoMethod(isolate, tmpl, "ref", HandleWrap::Ref); | |
| 168 | 173 | SetProtoMethod(isolate, tmpl, "unref", HandleWrap::Unref); | |
| 169 | - env->set_handle_wrap_ctor_template(tmpl); | ||
| 174 | + isolate_data->set_handle_wrap_ctor_template(tmpl); | ||
| 170 | 175 | } | |
| 171 | 176 | return tmpl; | |
| 172 | 177 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,6 +76,8 @@ class HandleWrap : public AsyncWrap { | |||
| 76 | 76 | virtual void Close( | |
| 77 | 77 | v8::Local<v8::Value> close_callback = v8::Local<v8::Value>()); | |
| 78 | 78 | ||
| 79 | + static v8::Local<v8::FunctionTemplate> GetConstructorTemplate( | ||
| 80 | + IsolateData* isolate_data); | ||
| 79 | 81 | static v8::Local<v8::FunctionTemplate> GetConstructorTemplate( | |
| 80 | 82 | Environment* env); | |
| 81 | 83 | static void RegisterExternalReferences(ExternalReferenceRegistry* registry); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,8 +31,16 @@ static_assert(static_cast<int>(NM_F_LINKED) == | |||
| 31 | 31 | #endif | |
| 32 | 32 | ||
| 33 | 33 | #define NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V) \ | |
| 34 | + V(async_wrap) \ | ||
| 35 | + V(blob) \ | ||
| 34 | 36 | V(builtins) \ | |
| 37 | + V(contextify) \ | ||
| 38 | + V(encoding_binding) \ | ||
| 39 | + V(fs) \ | ||
| 40 | + V(timers) \ | ||
| 41 | + V(process_methods) \ | ||
| 35 | 42 | V(performance) \ | |
| 43 | + V(url) \ | ||
| 36 | 44 | V(worker) \ | |
| 37 | 45 | NODE_BUILTIN_ICU_BINDINGS(V) | |
| 38 | 46 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,7 @@ using v8::Int32; | |||
| 29 | 29 | using v8::Isolate; | |
| 30 | 30 | using v8::Local; | |
| 31 | 31 | using v8::Object; | |
| 32 | + using v8::ObjectTemplate; | ||
| 32 | 33 | using v8::String; | |
| 33 | 34 | using v8::Uint32; | |
| 34 | 35 | using v8::Undefined; | |
@@ -107,23 +108,25 @@ void BlobFromFilePath(const FunctionCallbackInfo<Value>& args) { | |||
| 107 | 108 | } | |
| 108 | 109 | } // namespace | |
| 109 | 110 | ||
| 110 | - void Blob::Initialize( | ||
| 111 | - Local<Object> target, | ||
| 112 | - Local<Value> unused, | ||
| 113 | - Local<Context> context, | ||
| 114 | - void* priv) { | ||
| 115 | - Realm* realm = Realm::GetCurrent(context); | ||
| 111 | + void Blob::CreatePerIsolateProperties(IsolateData* isolate_data, | ||
| 112 | + Local<FunctionTemplate> ctor) { | ||
| 113 | + Isolate* isolate = isolate_data->isolate(); | ||
| 114 | + Local<ObjectTemplate> target = ctor->InstanceTemplate(); | ||
| 116 | 115 | ||
| 117 | - BlobBindingData* const binding_data = | ||
| 118 | - realm->AddBindingData<BlobBindingData>(context, target); | ||
| 119 | - if (binding_data == nullptr) return; | ||
| 116 | + SetMethod(isolate, target, "createBlob", New); | ||
| 117 | + SetMethod(isolate, target, "storeDataObject", StoreDataObject); | ||
| 118 | + SetMethod(isolate, target, "getDataObject", GetDataObject); | ||
| 119 | + SetMethod(isolate, target, "revokeObjectURL", RevokeObjectURL); | ||
| 120 | + SetMethod(isolate, target, "concat", Concat); | ||
| 121 | + SetMethod(isolate, target, "createBlobFromFilePath", BlobFromFilePath); | ||
| 122 | + } | ||
| 120 | 123 | ||
| 121 | - SetMethod(context, target, "createBlob", New); | ||
| 122 | - SetMethod(context, target, "storeDataObject", StoreDataObject); | ||
| 123 | - SetMethod(context, target, "getDataObject", GetDataObject); | ||
| 124 | - SetMethod(context, target, "revokeObjectURL", RevokeObjectURL); | ||
| 125 | - SetMethod(context, target, "concat", Concat); | ||
| 126 | - SetMethod(context, target, "createBlobFromFilePath", BlobFromFilePath); | ||
| 124 | + void Blob::CreatePerContextProperties(Local<Object> target, | ||
| 125 | + Local<Value> unused, | ||
| 126 | + Local<Context> context, | ||
| 127 | + void* priv) { | ||
| 128 | + Realm* realm = Realm::GetCurrent(context); | ||
| 129 | + realm->AddBindingData<BlobBindingData>(context, target); | ||
| 127 | 130 | } | |
| 128 | 131 | ||
| 129 | 132 | Local<FunctionTemplate> Blob::GetConstructorTemplate(Environment* env) { | |
@@ -562,5 +565,7 @@ void Blob::RegisterExternalReferences(ExternalReferenceRegistry* registry) { | |||
| 562 | 565 | ||
| 563 | 566 | } // namespace node | |
| 564 | 567 | ||
| 565 | - NODE_BINDING_CONTEXT_AWARE_INTERNAL(blob, node::Blob::Initialize) | ||
| 568 | + NODE_BINDING_CONTEXT_AWARE_INTERNAL(blob, | ||
| 569 | + node::Blob::CreatePerContextProperties) | ||
| 570 | + NODE_BINDING_PER_ISOLATE_INIT(blob, node::Blob::CreatePerIsolateProperties) | ||
| 566 | 571 | NODE_BINDING_EXTERNAL_REFERENCE(blob, node::Blob::RegisterExternalReferences) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,11 +26,12 @@ class Blob : public BaseObject { | |||
| 26 | 26 | static void RegisterExternalReferences( | |
| 27 | 27 | ExternalReferenceRegistry* registry); | |
| 28 | 28 | ||
| 29 | - static void Initialize( | ||
| 30 | - v8::Local<v8::Object> target, | ||
| 31 | - v8::Local<v8::Value> unused, | ||
| 32 | - v8::Local<v8::Context> context, | ||
| 33 | - void* priv); | ||
| 29 | + static void CreatePerIsolateProperties(IsolateData* isolate_data, | ||
| 30 | + v8::Local<v8::FunctionTemplate> ctor); | ||
| 31 | + static void CreatePerContextProperties(v8::Local<v8::Object> target, | ||
| 32 | + v8::Local<v8::Value> unused, | ||
| 33 | + v8::Local<v8::Context> context, | ||
| 34 | + void* priv); | ||
| 34 | 35 | ||
| 35 | 36 | static void New(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 36 | 37 | static void GetReader(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments