From 4443bf8f5875c8eafd7dc7dab578ea83ed8f3a94 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Thu, 2 Aug 2018 02:30:46 +0530 Subject: [PATCH 1/2] src: remove calls to deprecated v8 functions (BooleanValue) Remove all calls to deprecated v8 functions (here: Value::BooleanValue) inside the code (src directory only). --- lib/internal/crypto/cipher.js | 2 +- lib/internal/readline.js | 8 +++++--- src/node_crypto.cc | 2 +- src/node_i18n.cc | 4 ++-- src/tcp_wrap.cc | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/internal/crypto/cipher.js b/lib/internal/crypto/cipher.js index 73a6c6ab49cf4a..4ca4171c1ae2d0 100644 --- a/lib/internal/crypto/cipher.js +++ b/lib/internal/crypto/cipher.js @@ -182,7 +182,7 @@ Cipher.prototype.final = function final(outputEncoding) { Cipher.prototype.setAutoPadding = function setAutoPadding(ap) { - if (!this._handle.setAutoPadding(ap)) + if (!this._handle.setAutoPadding(!!ap)) throw new ERR_CRYPTO_INVALID_STATE('setAutoPadding'); return this; }; diff --git a/lib/internal/readline.js b/lib/internal/readline.js index 5d7cbd32f362b3..45125db0c223ef 100644 --- a/lib/internal/readline.js +++ b/lib/internal/readline.js @@ -36,9 +36,11 @@ if (process.binding('config').hasIntl) { options = options || {}; if (!Number.isInteger(str)) str = stripVTControlCharacters(String(str)); - return icu.getStringWidth(str, - Boolean(options.ambiguousAsFullWidth), - Boolean(options.expandEmojiSequence)); + return icu.getStringWidth( + str, + Boolean(options.ambiguousAsFullWidth), + Boolean(options.expandEmojiSequence) + ); }; isFullWidthCodePoint = function isFullWidthCodePoint(code, options) { diff --git a/src/node_crypto.cc b/src/node_crypto.cc index fb0e1d6d8c5a31..c473decf7e7540 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3093,7 +3093,7 @@ void CipherBase::SetAutoPadding(const FunctionCallbackInfo& args) { CipherBase* cipher; ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); - bool b = cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue()); + bool b = cipher->SetAutoPadding(args.Length() < 1 || args[0]->IsTrue()); args.GetReturnValue().Set(b); // Possibly report invalid state failure } diff --git a/src/node_i18n.cc b/src/node_i18n.cc index e6c198fb634b48..e5d5c0d412dc4e 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -815,8 +815,8 @@ static void GetStringWidth(const FunctionCallbackInfo& args) { if (args.Length() < 1) return; - bool ambiguous_as_full_width = args[1]->BooleanValue(); - bool expand_emoji_sequence = args[2]->BooleanValue(); + bool ambiguous_as_full_width = args[1]->IsTrue(); + bool expand_emoji_sequence = args[2]->IsTrue(); if (args[0]->IsNumber()) { args.GetReturnValue().Set( diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index ebc82f46683200..5e0681300f6f20 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -168,7 +168,7 @@ void TCPWrap::SetNoDelay(const FunctionCallbackInfo& args) { ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder(), args.GetReturnValue().Set(UV_EBADF)); - int enable = static_cast(args[0]->BooleanValue()); + int enable = static_cast(args[0]->IsTrue()); int err = uv_tcp_nodelay(&wrap->handle_, enable); args.GetReturnValue().Set(err); } From 5baed2468a9fa137aa1743ffd51f5d1690203902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 29 Aug 2018 15:18:54 +0200 Subject: [PATCH 2/2] fixup! handle remaining cases --- lib/net.js | 2 +- src/node_crypto.cc | 3 ++- src/node_file.cc | 2 +- src/tcp_wrap.cc | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/net.js b/lib/net.js index 2700a54a0780ce..fa2de1da4892e8 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1724,7 +1724,7 @@ if (process.platform === 'win32') { } if (handle._simultaneousAccepts !== simultaneousAccepts) { - handle.setSimultaneousAccepts(simultaneousAccepts); + handle.setSimultaneousAccepts(!!simultaneousAccepts); handle._simultaneousAccepts = simultaneousAccepts; } }; diff --git a/src/node_crypto.cc b/src/node_crypto.cc index c473decf7e7540..a94aa702acc392 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5190,7 +5190,8 @@ void SetFipsCrypto(const FunctionCallbackInfo& args) { CHECK(!force_fips_crypto); Environment* env = Environment::GetCurrent(args); const bool enabled = FIPS_mode(); - const bool enable = args[0]->BooleanValue(); + bool enable; + if (!args[0]->BooleanValue(env->context()).To(&enable)) return; if (enable == enabled) return; // No action needed. if (!FIPS_mode_set(enable)) { diff --git a/src/node_file.cc b/src/node_file.cc index fb976a31a5b3c1..c1a936810fe1f9 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1460,7 +1460,7 @@ static void ReadDir(const FunctionCallbackInfo& args) { const enum encoding encoding = ParseEncoding(env->isolate(), args[1], UTF8); - bool with_types = args[2]->BooleanValue(); + bool with_types = args[2]->IsTrue(); FSReqBase* req_wrap_async = GetReqWrap(env, args[3]); if (req_wrap_async != nullptr) { // readdir(path, encoding, withTypes, req) diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 5e0681300f6f20..ab8b30e84606fb 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -192,7 +192,7 @@ void TCPWrap::SetSimultaneousAccepts(const FunctionCallbackInfo& args) { ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder(), args.GetReturnValue().Set(UV_EBADF)); - bool enable = args[0]->BooleanValue(); + bool enable = args[0]->IsTrue(); int err = uv_tcp_simultaneous_accepts(&wrap->handle_, enable); args.GetReturnValue().Set(err); }