summaryrefslogtreecommitdiff
path: root/src/node_buffer.cc
diff options
context:
space:
mode:
authorUjjwal Sharma <usharma1998@gmail.com>2018-08-29 16:46:36 +0200
committerMichaƫl Zasso <targos@protonmail.com>2018-09-02 16:32:15 +0200
commit37cd10a1165537d25cd73454ffa81a4e964a56f7 (patch)
treed9146f1c17e1a7f5e0cfe9d3e8833c66662e7f7c /src/node_buffer.cc
parent5da155398ef8645c76872c6db3114a3e796a80da (diff)
downloadnode-new-37cd10a1165537d25cd73454ffa81a4e964a56f7.tar.gz
src: remove calls to deprecated v8 functions (Uint32Value)
Remove all calls to deprecated v8 functions (here: Value::Uint32Value) inside the code (src directory only). PR-URL: https://github.com/nodejs/node/pull/22143 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r--src/node_buffer.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index d2cb79d414..4a29873c34 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -83,6 +83,7 @@ using v8::Maybe;
using v8::MaybeLocal;
using v8::Object;
using v8::String;
+using v8::Uint32;
using v8::Uint32Array;
using v8::Uint8Array;
using v8::Value;
@@ -565,12 +566,15 @@ void Copy(const FunctionCallbackInfo<Value> &args) {
void Fill(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
+ Local<Context> ctx = env->context();
THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]);
SPREAD_BUFFER_ARG(args[0], ts_obj);
- size_t start = args[2]->Uint32Value();
- size_t end = args[3]->Uint32Value();
+ uint32_t start;
+ if (!args[2]->Uint32Value(ctx).To(&start)) return;
+ uint32_t end;
+ if (!args[3]->Uint32Value(ctx).To(&end)) return;
size_t fill_length = end - start;
Local<String> str_obj;
size_t str_length;
@@ -590,7 +594,9 @@ void Fill(const FunctionCallbackInfo<Value>& args) {
// Then coerce everything that's not a string.
if (!args[1]->IsString()) {
- int value = args[1]->Uint32Value() & 255;
+ uint32_t val;
+ if (!args[1]->Uint32Value(ctx).To(&val)) return;
+ int value = val & 255;
memset(ts_obj_data + start, value, fill_length);
return;
}
@@ -1000,14 +1006,14 @@ void IndexOfBuffer(const FunctionCallbackInfo<Value>& args) {
}
void IndexOfNumber(const FunctionCallbackInfo<Value>& args) {
- CHECK(args[1]->IsNumber());
+ CHECK(args[1]->IsUint32());
CHECK(args[2]->IsNumber());
CHECK(args[3]->IsBoolean());
THROW_AND_RETURN_UNLESS_BUFFER(Environment::GetCurrent(args), args[0]);
SPREAD_BUFFER_ARG(args[0], ts_obj);
- uint32_t needle = args[1]->Uint32Value();
+ uint32_t needle = args[1].As<Uint32>()->Value();
int64_t offset_i64 = args[2]->IntegerValue();
bool is_forward = args[3]->IsTrue();