| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e972ff7 commit 54608d8
78 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -390,32 +390,33 @@ void Initialize(Local<Object> target, | |||
| 390 | 390 | void* priv) { | |
| 391 | 391 | Environment* env = Environment::GetCurrent(context); | |
| 392 | 392 | ||
| 393 | - env->SetMethod(target, "getaddrinfo", GetAddrInfo); | ||
| 394 | - env->SetMethod(target, "getnameinfo", GetNameInfo); | ||
| 393 | + SetMethod(context, target, "getaddrinfo", GetAddrInfo); | ||
| 394 | + SetMethod(context, target, "getnameinfo", GetNameInfo); | ||
| 395 | 395 | ||
| 396 | 396 | // 'SetMethodNoSideEffect' means that debuggers can safely execute this | |
| 397 | 397 | // function for e.g. previews. | |
| 398 | - env->SetMethodNoSideEffect(target, "canonicalizeIP", CanonicalizeIP); | ||
| 398 | + SetMethodNoSideEffect(context, target, "canonicalizeIP", CanonicalizeIP); | ||
| 399 | 399 | ||
| 400 | 400 | // ... more code ... | |
| 401 | 401 | ||
| 402 | + Isolate* isolate = env->isolate(); | ||
| 402 | 403 | // Building the `ChannelWrap` class for JS: | |
| 403 | 404 | Local<FunctionTemplate> channel_wrap = | |
| 404 | - env->NewFunctionTemplate(ChannelWrap::New); | ||
| 405 | + NewFunctionTemplate(isolate, ChannelWrap::New); | ||
| 405 | 406 | // Allow for 1 internal field, see `BaseObject` for details on this: | |
| 406 | 407 | channel_wrap->InstanceTemplate()->SetInternalFieldCount(1); | |
| 407 | 408 | channel_wrap->Inherit(AsyncWrap::GetConstructorTemplate(env)); | |
| 408 | 409 | ||
| 409 | 410 | // Set various methods on the class (i.e. on the prototype): | |
| 410 | - env->SetProtoMethod(channel_wrap, "queryAny", Query<QueryAnyWrap>); | ||
| 411 | - env->SetProtoMethod(channel_wrap, "queryA", Query<QueryAWrap>); | ||
| 411 | + SetProtoMethod(isolate, channel_wrap, "queryAny", Query<QueryAnyWrap>); | ||
| 412 | + SetProtoMethod(isolate, channel_wrap, "queryA", Query<QueryAWrap>); | ||
| 412 | 413 | // ... | |
| 413 | - env->SetProtoMethod(channel_wrap, "querySoa", Query<QuerySoaWrap>); | ||
| 414 | - env->SetProtoMethod(channel_wrap, "getHostByAddr", Query<GetHostByAddrWrap>); | ||
| 414 | + SetProtoMethod(isolate, channel_wrap, "querySoa", Query<QuerySoaWrap>); | ||
| 415 | + SetProtoMethod(isolate, channel_wrap, "getHostByAddr", Query<GetHostByAddrWrap>); | ||
| 415 | 416 | ||
| 416 | - env->SetProtoMethodNoSideEffect(channel_wrap, "getServers", GetServers); | ||
| 417 | + SetProtoMethodNoSideEffect(isolate, channel_wrap, "getServers", GetServers); | ||
| 417 | 418 | ||
| 418 | - env->SetConstructorFunction(target, "ChannelWrap", channel_wrap); | ||
| 419 | + SetConstructorFunction(context, target, "ChannelWrap", channel_wrap); | ||
| 419 | 420 | } | |
| 420 | 421 | ||
| 421 | 422 | // Run the `Initialize` function when loading this module through | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -340,12 +340,14 @@ void AsyncWrap::SetCallbackTrampoline(const FunctionCallbackInfo<Value>& args) { | |||
| 340 | 340 | Local<FunctionTemplate> AsyncWrap::GetConstructorTemplate(Environment* env) { | |
| 341 | 341 | Local<FunctionTemplate> tmpl = env->async_wrap_ctor_template(); | |
| 342 | 342 | if (tmpl.IsEmpty()) { | |
| 343 | - tmpl = env->NewFunctionTemplate(nullptr); | ||
| 343 | + Isolate* isolate = env->isolate(); | ||
| 344 | + tmpl = NewFunctionTemplate(isolate, nullptr); | ||
| 344 | 345 | tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap")); | |
| 345 | 346 | tmpl->Inherit(BaseObject::GetConstructorTemplate(env)); | |
| 346 | - env->SetProtoMethod(tmpl, "getAsyncId", AsyncWrap::GetAsyncId); | ||
| 347 | - env->SetProtoMethod(tmpl, "asyncReset", AsyncWrap::AsyncReset); | ||
| 348 | - env->SetProtoMethod(tmpl, "getProviderType", AsyncWrap::GetProviderType); | ||
| 347 | + SetProtoMethod(isolate, tmpl, "getAsyncId", AsyncWrap::GetAsyncId); | ||
| 348 | + SetProtoMethod(isolate, tmpl, "asyncReset", AsyncWrap::AsyncReset); | ||
| 349 | + SetProtoMethod( | ||
| 350 | + isolate, tmpl, "getProviderType", AsyncWrap::GetProviderType); | ||
| 349 | 351 | env->set_async_wrap_ctor_template(tmpl); | |
| 350 | 352 | } | |
| 351 | 353 | return tmpl; | |
@@ -359,15 +361,15 @@ void AsyncWrap::Initialize(Local<Object> target, | |||
| 359 | 361 | Isolate* isolate = env->isolate(); | |
| 360 | 362 | HandleScope scope(isolate); | |
| 361 | 363 | ||
| 362 | - env->SetMethod(target, "setupHooks", SetupHooks); | ||
| 363 | - env->SetMethod(target, "setCallbackTrampoline", SetCallbackTrampoline); | ||
| 364 | - env->SetMethod(target, "pushAsyncContext", PushAsyncContext); | ||
| 365 | - env->SetMethod(target, "popAsyncContext", PopAsyncContext); | ||
| 366 | - env->SetMethod(target, "executionAsyncResource", ExecutionAsyncResource); | ||
| 367 | - env->SetMethod(target, "clearAsyncIdStack", ClearAsyncIdStack); | ||
| 368 | - env->SetMethod(target, "queueDestroyAsyncId", QueueDestroyAsyncId); | ||
| 369 | - env->SetMethod(target, "setPromiseHooks", SetPromiseHooks); | ||
| 370 | - env->SetMethod(target, "registerDestroyHook", RegisterDestroyHook); | ||
| 364 | + SetMethod(context, target, "setupHooks", SetupHooks); | ||
| 365 | + SetMethod(context, target, "setCallbackTrampoline", SetCallbackTrampoline); | ||
| 366 | + SetMethod(context, target, "pushAsyncContext", PushAsyncContext); | ||
| 367 | + SetMethod(context, target, "popAsyncContext", PopAsyncContext); | ||
| 368 | + SetMethod(context, target, "executionAsyncResource", ExecutionAsyncResource); | ||
| 369 | + SetMethod(context, target, "clearAsyncIdStack", ClearAsyncIdStack); | ||
| 370 | + SetMethod(context, target, "queueDestroyAsyncId", QueueDestroyAsyncId); | ||
| 371 | + SetMethod(context, target, "setPromiseHooks", SetPromiseHooks); | ||
| 372 | + SetMethod(context, target, "registerDestroyHook", RegisterDestroyHook); | ||
| 371 | 373 | ||
| 372 | 374 | PropertyAttribute ReadOnlyDontDelete = | |
| 373 | 375 | static_cast<PropertyAttribute>(ReadOnly | DontDelete); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1876,12 +1876,13 @@ void Initialize(Local<Object> target, | |||
| 1876 | 1876 | Local<Context> context, | |
| 1877 | 1877 | void* priv) { | |
| 1878 | 1878 | Environment* env = Environment::GetCurrent(context); | |
| 1879 | + Isolate* isolate = env->isolate(); | ||
| 1879 | 1880 | ||
| 1880 | - env->SetMethod(target, "getaddrinfo", GetAddrInfo); | ||
| 1881 | - env->SetMethod(target, "getnameinfo", GetNameInfo); | ||
| 1882 | - env->SetMethodNoSideEffect(target, "canonicalizeIP", CanonicalizeIP); | ||
| 1881 | + SetMethod(context, target, "getaddrinfo", GetAddrInfo); | ||
| 1882 | + SetMethod(context, target, "getnameinfo", GetNameInfo); | ||
| 1883 | + SetMethodNoSideEffect(context, target, "canonicalizeIP", CanonicalizeIP); | ||
| 1883 | 1884 | ||
| 1884 | - env->SetMethod(target, "strerror", StrError); | ||
| 1885 | + SetMethod(context, target, "strerror", StrError); | ||
| 1885 | 1886 | ||
| 1886 | 1887 | target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET"), | |
| 1887 | 1888 | Integer::New(env->isolate(), AF_INET)).Check(); | |
@@ -1903,44 +1904,45 @@ void Initialize(Local<Object> target, | |||
| 1903 | 1904 | Local<FunctionTemplate> aiw = | |
| 1904 | 1905 | BaseObject::MakeLazilyInitializedJSTemplate(env); | |
| 1905 | 1906 | aiw->Inherit(AsyncWrap::GetConstructorTemplate(env)); | |
| 1906 | - env->SetConstructorFunction(target, "GetAddrInfoReqWrap", aiw); | ||
| 1907 | + SetConstructorFunction(context, target, "GetAddrInfoReqWrap", aiw); | ||
| 1907 | 1908 | ||
| 1908 | 1909 | Local<FunctionTemplate> niw = | |
| 1909 | 1910 | BaseObject::MakeLazilyInitializedJSTemplate(env); | |
| 1910 | 1911 | niw->Inherit(AsyncWrap::GetConstructorTemplate(env)); | |
| 1911 | - env->SetConstructorFunction(target, "GetNameInfoReqWrap", niw); | ||
| 1912 | + SetConstructorFunction(context, target, "GetNameInfoReqWrap", niw); | ||
| 1912 | 1913 | ||
| 1913 | 1914 | Local<FunctionTemplate> qrw = | |
| 1914 | 1915 | BaseObject::MakeLazilyInitializedJSTemplate(env); | |
| 1915 | 1916 | qrw->Inherit(AsyncWrap::GetConstructorTemplate(env)); | |
| 1916 | - env->SetConstructorFunction(target, "QueryReqWrap", qrw); | ||
| 1917 | + SetConstructorFunction(context, target, "QueryReqWrap", qrw); | ||
| 1917 | 1918 | ||
| 1918 | 1919 | Local<FunctionTemplate> channel_wrap = | |
| 1919 | - env->NewFunctionTemplate(ChannelWrap::New); | ||
| 1920 | + NewFunctionTemplate(isolate, ChannelWrap::New); | ||
| 1920 | 1921 | channel_wrap->InstanceTemplate()->SetInternalFieldCount( | |
| 1921 | 1922 | ChannelWrap::kInternalFieldCount); | |
| 1922 | 1923 | channel_wrap->Inherit(AsyncWrap::GetConstructorTemplate(env)); | |
| 1923 | 1924 | ||
| 1924 | - env->SetProtoMethod(channel_wrap, "queryAny", Query<QueryAnyWrap>); | ||
| 1925 | - env->SetProtoMethod(channel_wrap, "queryA", Query<QueryAWrap>); | ||
| 1926 | - env->SetProtoMethod(channel_wrap, "queryAaaa", Query<QueryAaaaWrap>); | ||
| 1927 | - env->SetProtoMethod(channel_wrap, "queryCaa", Query<QueryCaaWrap>); | ||
| 1928 | - env->SetProtoMethod(channel_wrap, "queryCname", Query<QueryCnameWrap>); | ||
| 1929 | - env->SetProtoMethod(channel_wrap, "queryMx", Query<QueryMxWrap>); | ||
| 1930 | - env->SetProtoMethod(channel_wrap, "queryNs", Query<QueryNsWrap>); | ||
| 1931 | - env->SetProtoMethod(channel_wrap, "queryTxt", Query<QueryTxtWrap>); | ||
| 1932 | - env->SetProtoMethod(channel_wrap, "querySrv", Query<QuerySrvWrap>); | ||
| 1933 | - env->SetProtoMethod(channel_wrap, "queryPtr", Query<QueryPtrWrap>); | ||
| 1934 | - env->SetProtoMethod(channel_wrap, "queryNaptr", Query<QueryNaptrWrap>); | ||
| 1935 | - env->SetProtoMethod(channel_wrap, "querySoa", Query<QuerySoaWrap>); | ||
| 1936 | - env->SetProtoMethod(channel_wrap, "getHostByAddr", Query<GetHostByAddrWrap>); | ||
| 1937 | - | ||
| 1938 | - env->SetProtoMethodNoSideEffect(channel_wrap, "getServers", GetServers); | ||
| 1939 | - env->SetProtoMethod(channel_wrap, "setServers", SetServers); | ||
| 1940 | - env->SetProtoMethod(channel_wrap, "setLocalAddress", SetLocalAddress); | ||
| 1941 | - env->SetProtoMethod(channel_wrap, "cancel", Cancel); | ||
| 1942 | - | ||
| 1943 | - env->SetConstructorFunction(target, "ChannelWrap", channel_wrap); | ||
| 1925 | + SetProtoMethod(isolate, channel_wrap, "queryAny", Query<QueryAnyWrap>); | ||
| 1926 | + SetProtoMethod(isolate, channel_wrap, "queryA", Query<QueryAWrap>); | ||
| 1927 | + SetProtoMethod(isolate, channel_wrap, "queryAaaa", Query<QueryAaaaWrap>); | ||
| 1928 | + SetProtoMethod(isolate, channel_wrap, "queryCaa", Query<QueryCaaWrap>); | ||
| 1929 | + SetProtoMethod(isolate, channel_wrap, "queryCname", Query<QueryCnameWrap>); | ||
| 1930 | + SetProtoMethod(isolate, channel_wrap, "queryMx", Query<QueryMxWrap>); | ||
| 1931 | + SetProtoMethod(isolate, channel_wrap, "queryNs", Query<QueryNsWrap>); | ||
| 1932 | + SetProtoMethod(isolate, channel_wrap, "queryTxt", Query<QueryTxtWrap>); | ||
| 1933 | + SetProtoMethod(isolate, channel_wrap, "querySrv", Query<QuerySrvWrap>); | ||
| 1934 | + SetProtoMethod(isolate, channel_wrap, "queryPtr", Query<QueryPtrWrap>); | ||
| 1935 | + SetProtoMethod(isolate, channel_wrap, "queryNaptr", Query<QueryNaptrWrap>); | ||
| 1936 | + SetProtoMethod(isolate, channel_wrap, "querySoa", Query<QuerySoaWrap>); | ||
| 1937 | + SetProtoMethod( | ||
| 1938 | + isolate, channel_wrap, "getHostByAddr", Query<GetHostByAddrWrap>); | ||
| 1939 | + | ||
| 1940 | + SetProtoMethodNoSideEffect(isolate, channel_wrap, "getServers", GetServers); | ||
| 1941 | + SetProtoMethod(isolate, channel_wrap, "setServers", SetServers); | ||
| 1942 | + SetProtoMethod(isolate, channel_wrap, "setLocalAddress", SetLocalAddress); | ||
| 1943 | + SetProtoMethod(isolate, channel_wrap, "cancel", Cancel); | ||
| 1944 | + | ||
| 1945 | + SetConstructorFunction(context, target, "ChannelWrap", channel_wrap); | ||
| 1944 | 1946 | } | |
| 1945 | 1947 | ||
| 1946 | 1948 | } // namespace cares_wrap | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,10 +13,12 @@ namespace node { | |||
| 13 | 13 | using v8::Array; | |
| 14 | 14 | using v8::ArrayBuffer; | |
| 15 | 15 | using v8::BackingStore; | |
| 16 | + using v8::Context; | ||
| 16 | 17 | using v8::FunctionCallbackInfo; | |
| 17 | 18 | using v8::FunctionTemplate; | |
| 18 | 19 | using v8::HandleScope; | |
| 19 | 20 | using v8::Int32; | |
| 21 | + using v8::Isolate; | ||
| 20 | 22 | using v8::Local; | |
| 21 | 23 | using v8::Object; | |
| 22 | 24 | using v8::Uint32; | |
@@ -270,43 +272,54 @@ void CipherBase::MemoryInfo(MemoryTracker* tracker) const { | |||
| 270 | 272 | } | |
| 271 | 273 | ||
| 272 | 274 | void CipherBase::Initialize(Environment* env, Local<Object> target) { | |
| 273 | - Local<FunctionTemplate> t = env->NewFunctionTemplate(New); | ||
| 275 | + Isolate* isolate = env->isolate(); | ||
| 276 | + Local<Context> context = env->context(); | ||
| 277 | + | ||
| 278 | + Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New); | ||
| 274 | 279 | ||
| 275 | 280 | t->InstanceTemplate()->SetInternalFieldCount( | |
| 276 | 281 | CipherBase::kInternalFieldCount); | |
| 277 | 282 | t->Inherit(BaseObject::GetConstructorTemplate(env)); | |
| 278 | 283 | ||
| 279 | - env->SetProtoMethod(t, "init", Init); | ||
| 280 | - env->SetProtoMethod(t, "initiv", InitIv); | ||
| 281 | - env->SetProtoMethod(t, "update", Update); | ||
| 282 | - env->SetProtoMethod(t, "final", Final); | ||
| 283 | - env->SetProtoMethod(t, "setAutoPadding", SetAutoPadding); | ||
| 284 | - env->SetProtoMethodNoSideEffect(t, "getAuthTag", GetAuthTag); | ||
| 285 | - env->SetProtoMethod(t, "setAuthTag", SetAuthTag); | ||
| 286 | - env->SetProtoMethod(t, "setAAD", SetAAD); | ||
| 287 | - env->SetConstructorFunction(target, "CipherBase", t); | ||
| 288 | - | ||
| 289 | - env->SetMethodNoSideEffect(target, "getSSLCiphers", GetSSLCiphers); | ||
| 290 | - env->SetMethodNoSideEffect(target, "getCiphers", GetCiphers); | ||
| 291 | - | ||
| 292 | - env->SetMethod(target, "publicEncrypt", | ||
| 293 | - PublicKeyCipher::Cipher<PublicKeyCipher::kPublic, | ||
| 294 | - EVP_PKEY_encrypt_init, | ||
| 295 | - EVP_PKEY_encrypt>); | ||
| 296 | - env->SetMethod(target, "privateDecrypt", | ||
| 297 | - PublicKeyCipher::Cipher<PublicKeyCipher::kPrivate, | ||
| 298 | - EVP_PKEY_decrypt_init, | ||
| 299 | - EVP_PKEY_decrypt>); | ||
| 300 | - env->SetMethod(target, "privateEncrypt", | ||
| 301 | - PublicKeyCipher::Cipher<PublicKeyCipher::kPrivate, | ||
| 302 | - EVP_PKEY_sign_init, | ||
| 303 | - EVP_PKEY_sign>); | ||
| 304 | - env->SetMethod(target, "publicDecrypt", | ||
| 305 | - PublicKeyCipher::Cipher<PublicKeyCipher::kPublic, | ||
| 306 | - EVP_PKEY_verify_recover_init, | ||
| 307 | - EVP_PKEY_verify_recover>); | ||
| 308 | - | ||
| 309 | - env->SetMethodNoSideEffect(target, "getCipherInfo", GetCipherInfo); | ||
| 284 | + SetProtoMethod(isolate, t, "init", Init); | ||
| 285 | + SetProtoMethod(isolate, t, "initiv", InitIv); | ||
| 286 | + SetProtoMethod(isolate, t, "update", Update); | ||
| 287 | + SetProtoMethod(isolate, t, "final", Final); | ||
| 288 | + SetProtoMethod(isolate, t, "setAutoPadding", SetAutoPadding); | ||
| 289 | + SetProtoMethodNoSideEffect(isolate, t, "getAuthTag", GetAuthTag); | ||
| 290 | + SetProtoMethod(isolate, t, "setAuthTag", SetAuthTag); | ||
| 291 | + SetProtoMethod(isolate, t, "setAAD", SetAAD); | ||
| 292 | + SetConstructorFunction(context, target, "CipherBase", t); | ||
| 293 | + | ||
| 294 | + SetMethodNoSideEffect(context, target, "getSSLCiphers", GetSSLCiphers); | ||
| 295 | + SetMethodNoSideEffect(context, target, "getCiphers", GetCiphers); | ||
| 296 | + | ||
| 297 | + SetMethod(context, | ||
| 298 | + target, | ||
| 299 | + "publicEncrypt", | ||
| 300 | + PublicKeyCipher::Cipher<PublicKeyCipher::kPublic, | ||
| 301 | + EVP_PKEY_encrypt_init, | ||
| 302 | + EVP_PKEY_encrypt>); | ||
| 303 | + SetMethod(context, | ||
| 304 | + target, | ||
| 305 | + "privateDecrypt", | ||
| 306 | + PublicKeyCipher::Cipher<PublicKeyCipher::kPrivate, | ||
| 307 | + EVP_PKEY_decrypt_init, | ||
| 308 | + EVP_PKEY_decrypt>); | ||
| 309 | + SetMethod(context, | ||
| 310 | + target, | ||
| 311 | + "privateEncrypt", | ||
| 312 | + PublicKeyCipher::Cipher<PublicKeyCipher::kPrivate, | ||
| 313 | + EVP_PKEY_sign_init, | ||
| 314 | + EVP_PKEY_sign>); | ||
| 315 | + SetMethod(context, | ||
| 316 | + target, | ||
| 317 | + "publicDecrypt", | ||
| 318 | + PublicKeyCipher::Cipher<PublicKeyCipher::kPublic, | ||
| 319 | + EVP_PKEY_verify_recover_init, | ||
| 320 | + EVP_PKEY_verify_recover>); | ||
| 321 | + | ||
| 322 | + SetMethodNoSideEffect(context, target, "getCipherInfo", GetCipherInfo); | ||
| 310 | 323 | ||
| 311 | 324 | NODE_DEFINE_CONSTANT(target, kWebCryptoCipherEncrypt); | |
| 312 | 325 | NODE_DEFINE_CONSTANT(target, kWebCryptoCipherDecrypt); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments