| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2157,10 +2157,11 @@ void TLSWrap::SetMaxSendFragment(const FunctionCallbackInfo<Value>& args) { | |||
| 2157 | 2157 | Environment* env = Environment::GetCurrent(args); | |
| 2158 | 2158 | TLSWrap* w; | |
| 2159 | 2159 | ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); | |
| 2160 | - int rv = SSL_set_max_send_fragment( | ||
| 2161 | - w->ssl_.get(), | ||
| 2162 | - args[0]->Int32Value(env->context()).FromJust()); | ||
| 2163 | - args.GetReturnValue().Set(rv); | ||
| 2160 | + int val; | ||
| 2161 | + if (args[0]->Int32Value(env->context()).To(&val)) { | ||
| 2162 | + int32_t ret = SSL_set_max_send_fragment(w->ssl_.get(), val); | ||
| 2163 | + args.GetReturnValue().Set(ret); | ||
| 2164 | + } | ||
| 2164 | 2165 | } | |
| 2165 | 2166 | #endif // SSL_set_max_send_fragment | |
| 2166 | 2167 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -231,8 +231,10 @@ template <void (Agent::*asyncTaskFn)(void*)> | |||
| 231 | 231 | static void InvokeAsyncTaskFnWithId(const FunctionCallbackInfo<Value>& args) { | |
| 232 | 232 | Environment* env = Environment::GetCurrent(args); | |
| 233 | 233 | CHECK(args[0]->IsNumber()); | |
| 234 | - int64_t task_id = args[0]->IntegerValue(env->context()).FromJust(); | ||
| 235 | - (env->inspector_agent()->*asyncTaskFn)(GetAsyncTask(task_id)); | ||
| 234 | + int64_t task_id; | ||
| 235 | + if (args[0]->IntegerValue(env->context()).To(&task_id)) { | ||
| 236 | + (env->inspector_agent()->*asyncTaskFn)(GetAsyncTask(task_id)); | ||
| 237 | + } | ||
| 236 | 238 | } | |
| 237 | 239 | ||
| 238 | 240 | static void AsyncTaskScheduledWrapper(const FunctionCallbackInfo<Value>& args) { | |
@@ -244,7 +246,10 @@ static void AsyncTaskScheduledWrapper(const FunctionCallbackInfo<Value>& args) { | |||
| 244 | 246 | StringView task_name_view(*task_name_value, task_name_value.length()); | |
| 245 | 247 | ||
| 246 | 248 | CHECK(args[1]->IsNumber()); | |
| 247 | - int64_t task_id = args[1]->IntegerValue(env->context()).FromJust(); | ||
| 249 | + int64_t task_id; | ||
| 250 | + if (!args[1]->IntegerValue(env->context()).To(&task_id)) { | ||
| 251 | + return; | ||
| 252 | + } | ||
| 248 | 253 | void* task = GetAsyncTask(task_id); | |
| 249 | 254 | ||
| 250 | 255 | CHECK(args[2]->IsBoolean()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -561,7 +561,10 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) { | |||
| 561 | 561 | CHECK_EQ(args.Length(), 2); | |
| 562 | 562 | ||
| 563 | 563 | CHECK(args[0]->IsNumber()); | |
| 564 | - int64_t timeout = args[0]->IntegerValue(realm->context()).FromJust(); | ||
| 564 | + int64_t timeout; | ||
| 565 | + if (!args[0]->IntegerValue(realm->context()).To(&timeout)) { | ||
| 566 | + return; | ||
| 567 | + } | ||
| 565 | 568 | ||
| 566 | 569 | CHECK(args[1]->IsBoolean()); | |
| 567 | 570 | bool break_on_sigint = args[1]->IsTrue(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -278,10 +278,10 @@ MaybeLocal<Uint8Array> New(Environment* env, | |||
| 278 | 278 | size_t length) { | |
| 279 | 279 | CHECK(!env->buffer_prototype_object().IsEmpty()); | |
| 280 | 280 | Local<Uint8Array> ui = Uint8Array::New(ab, byte_offset, length); | |
| 281 | - Maybe<bool> mb = | ||
| 282 | - ui->SetPrototypeV2(env->context(), env->buffer_prototype_object()); | ||
| 283 | - if (mb.IsNothing()) | ||
| 281 | + if (ui->SetPrototypeV2(env->context(), env->buffer_prototype_object()) | ||
| 282 | + .IsNothing()) { | ||
| 284 | 283 | return MaybeLocal<Uint8Array>(); | |
| 284 | + } | ||
| 285 | 285 | return ui; | |
| 286 | 286 | } | |
| 287 | 287 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,7 +79,9 @@ void BuiltinLoader::GetNatives(Local<Name> property, | |||
| 79 | 79 | auto source = env->builtin_loader()->source_.read(); | |
| 80 | 80 | for (auto const& x : *source) { | |
| 81 | 81 | Local<String> key = OneByteString(isolate, x.first); | |
| 82 | - out->Set(context, key, x.second.ToStringChecked(isolate)).FromJust(); | ||
| 82 | + if (out->Set(context, key, x.second.ToStringChecked(isolate)).IsNothing()) { | ||
| 83 | + return; | ||
| 84 | + } | ||
| 83 | 85 | } | |
| 84 | 86 | info.GetReturnValue().Set(out); | |
| 85 | 87 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1237,7 +1237,10 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) { | |||
| 1237 | 1237 | TRACE_EVENT0(TRACING_CATEGORY_NODE2(vm, script), "RunInContext"); | |
| 1238 | 1238 | ||
| 1239 | 1239 | CHECK(args[1]->IsNumber()); | |
| 1240 | - int64_t timeout = args[1]->IntegerValue(env->context()).FromJust(); | ||
| 1240 | + int64_t timeout; | ||
| 1241 | + if (!args[1]->IntegerValue(env->context()).To(&timeout)) { | ||
| 1242 | + return; | ||
| 1243 | + } | ||
| 1241 | 1244 | ||
| 1242 | 1245 | CHECK(args[2]->IsBoolean()); | |
| 1243 | 1246 | bool display_errors = args[2]->IsTrue(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -254,10 +254,20 @@ void FileHandle::New(const FunctionCallbackInfo<Value>& args) { | |||
| 254 | 254 | ||
| 255 | 255 | std::optional<int64_t> maybeOffset = std::nullopt; | |
| 256 | 256 | std::optional<int64_t> maybeLength = std::nullopt; | |
| 257 | - if (args[1]->IsNumber()) | ||
| 258 | - maybeOffset = args[1]->IntegerValue(realm->context()).FromJust(); | ||
| 259 | - if (args[2]->IsNumber()) | ||
| 260 | - maybeLength = args[2]->IntegerValue(realm->context()).FromJust(); | ||
| 257 | + if (args[1]->IsNumber()) { | ||
| 258 | + int64_t val; | ||
| 259 | + if (!args[1]->IntegerValue(realm->context()).To(&val)) { | ||
| 260 | + return; | ||
| 261 | + } | ||
| 262 | + maybeOffset = val; | ||
| 263 | + } | ||
| 264 | + if (args[2]->IsNumber()) { | ||
| 265 | + int64_t val; | ||
| 266 | + if (!args[2]->IntegerValue(realm->context()).To(&val)) { | ||
| 267 | + return; | ||
| 268 | + } | ||
| 269 | + maybeLength = val; | ||
| 270 | + } | ||
| 261 | 271 | ||
| 262 | 272 | FileHandle::New(binding_data, | |
| 263 | 273 | args[0].As<Int32>()->Value(), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1090,9 +1090,10 @@ void MessagePort::PostMessage(const FunctionCallbackInfo<Value>& args) { | |||
| 1090 | 1090 | return; | |
| 1091 | 1091 | } | |
| 1092 | 1092 | ||
| 1093 | - Maybe<bool> res = port->PostMessage(env, context, args[0], transfer_list); | ||
| 1094 | - if (res.IsJust()) | ||
| 1095 | - args.GetReturnValue().Set(res.FromJust()); | ||
| 1093 | + bool res; | ||
| 1094 | + if (port->PostMessage(env, context, args[0], transfer_list).To(&res)) { | ||
| 1095 | + args.GetReturnValue().Set(res); | ||
| 1096 | + } | ||
| 1096 | 1097 | } | |
| 1097 | 1098 | ||
| 1098 | 1099 | void MessagePort::Start() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,10 +189,10 @@ void SerializerContext::WriteHeader(const FunctionCallbackInfo<Value>& args) { | |||
| 189 | 189 | void SerializerContext::WriteValue(const FunctionCallbackInfo<Value>& args) { | |
| 190 | 190 | SerializerContext* ctx; | |
| 191 | 191 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.This()); | |
| 192 | - Maybe<bool> ret = | ||
| 193 | - ctx->serializer_.WriteValue(ctx->env()->context(), args[0]); | ||
| 194 | - | ||
| 195 | - if (ret.IsJust()) args.GetReturnValue().Set(ret.FromJust()); | ||
| 192 | + bool ret; | ||
| 193 | + if (ctx->serializer_.WriteValue(ctx->env()->context(), args[0]).To(&ret)) { | ||
| 194 | + args.GetReturnValue().Set(ret); | ||
| 195 | + } | ||
| 196 | 196 | } | |
| 197 | 197 | ||
| 198 | 198 | void SerializerContext::SetTreatArrayBufferViewsAsHostObjects( | |
@@ -223,50 +223,55 @@ void SerializerContext::TransferArrayBuffer( | |||
| 223 | 223 | SerializerContext* ctx; | |
| 224 | 224 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.This()); | |
| 225 | 225 | ||
| 226 | - Maybe<uint32_t> id = args[0]->Uint32Value(ctx->env()->context()); | ||
| 227 | - if (id.IsNothing()) return; | ||
| 226 | + uint32_t id; | ||
| 227 | + if (!args[0]->Uint32Value(ctx->env()->context()).To(&id)) { | ||
| 228 | + return; | ||
| 229 | + } | ||
| 228 | 230 | ||
| 229 | - if (!args[1]->IsArrayBuffer()) | ||
| 231 | + if (!args[1]->IsArrayBuffer()) { | ||
| 230 | 232 | return node::THROW_ERR_INVALID_ARG_TYPE( | |
| 231 | 233 | ctx->env(), "arrayBuffer must be an ArrayBuffer"); | |
| 234 | + } | ||
| 232 | 235 | ||
| 233 | 236 | Local<ArrayBuffer> ab = args[1].As<ArrayBuffer>(); | |
| 234 | - ctx->serializer_.TransferArrayBuffer(id.FromJust(), ab); | ||
| 235 | - return; | ||
| 237 | + ctx->serializer_.TransferArrayBuffer(id, ab); | ||
| 236 | 238 | } | |
| 237 | 239 | ||
| 238 | 240 | void SerializerContext::WriteUint32(const FunctionCallbackInfo<Value>& args) { | |
| 239 | 241 | SerializerContext* ctx; | |
| 240 | 242 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.This()); | |
| 241 | 243 | ||
| 242 | - Maybe<uint32_t> value = args[0]->Uint32Value(ctx->env()->context()); | ||
| 243 | - if (value.IsNothing()) return; | ||
| 244 | - | ||
| 245 | - ctx->serializer_.WriteUint32(value.FromJust()); | ||
| 244 | + uint32_t value; | ||
| 245 | + if (args[0]->Uint32Value(ctx->env()->context()).To(&value)) { | ||
| 246 | + ctx->serializer_.WriteUint32(value); | ||
| 247 | + } | ||
| 246 | 248 | } | |
| 247 | 249 | ||
| 248 | 250 | void SerializerContext::WriteUint64(const FunctionCallbackInfo<Value>& args) { | |
| 249 | 251 | SerializerContext* ctx; | |
| 250 | 252 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.This()); | |
| 251 | 253 | ||
| 252 | - Maybe<uint32_t> arg0 = args[0]->Uint32Value(ctx->env()->context()); | ||
| 253 | - Maybe<uint32_t> arg1 = args[1]->Uint32Value(ctx->env()->context()); | ||
| 254 | - if (arg0.IsNothing() || arg1.IsNothing()) | ||
| 254 | + uint32_t hi; | ||
| 255 | + uint32_t lo; | ||
| 256 | + | ||
| 257 | + if (!args[0]->Uint32Value(ctx->env()->context()).To(&hi) || | ||
| 258 | + !args[1]->Uint32Value(ctx->env()->context()).To(&lo)) { | ||
| 255 | 259 | return; | |
| 260 | + } | ||
| 256 | 261 | ||
| 257 | - uint64_t hi = arg0.FromJust(); | ||
| 258 | - uint64_t lo = arg1.FromJust(); | ||
| 259 | - ctx->serializer_.WriteUint64((hi << 32) | lo); | ||
| 262 | + uint64_t hiu64 = hi; | ||
| 263 | + uint64_t lou64 = lo; | ||
| 264 | + ctx->serializer_.WriteUint64((hiu64 << 32) | lou64); | ||
| 260 | 265 | } | |
| 261 | 266 | ||
| 262 | 267 | void SerializerContext::WriteDouble(const FunctionCallbackInfo<Value>& args) { | |
| 263 | 268 | SerializerContext* ctx; | |
| 264 | 269 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.This()); | |
| 265 | 270 | ||
| 266 | - Maybe<double> value = args[0]->NumberValue(ctx->env()->context()); | ||
| 267 | - if (value.IsNothing()) return; | ||
| 268 | - | ||
| 269 | - ctx->serializer_.WriteDouble(value.FromJust()); | ||
| 271 | + double value; | ||
| 272 | + if (args[0]->NumberValue(ctx->env()->context()).To(&value)) { | ||
| 273 | + ctx->serializer_.WriteDouble(value); | ||
| 274 | + } | ||
| 270 | 275 | } | |
| 271 | 276 | ||
| 272 | 277 | void SerializerContext::WriteRawBytes(const FunctionCallbackInfo<Value>& args) { | |
@@ -341,9 +346,10 @@ void DeserializerContext::ReadHeader(const FunctionCallbackInfo<Value>& args) { | |||
| 341 | 346 | DeserializerContext* ctx; | |
| 342 | 347 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.This()); | |
| 343 | 348 | ||
| 344 | - Maybe<bool> ret = ctx->deserializer_.ReadHeader(ctx->env()->context()); | ||
| 345 | - | ||
| 346 | - if (ret.IsJust()) args.GetReturnValue().Set(ret.FromJust()); | ||
| 349 | + bool ret; | ||
| 350 | + if (ctx->deserializer_.ReadHeader(ctx->env()->context()).To(&ret)) { | ||
| 351 | + args.GetReturnValue().Set(ret); | ||
| 352 | + } | ||
| 347 | 353 | } | |
| 348 | 354 | ||
| 349 | 355 | void DeserializerContext::ReadValue(const FunctionCallbackInfo<Value>& args) { | |
@@ -361,18 +367,20 @@ void DeserializerContext::TransferArrayBuffer( | |||
| 361 | 367 | DeserializerContext* ctx; | |
| 362 | 368 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.This()); | |
| 363 | 369 | ||
| 364 | - Maybe<uint32_t> id = args[0]->Uint32Value(ctx->env()->context()); | ||
| 365 | - if (id.IsNothing()) return; | ||
| 370 | + uint32_t id; | ||
| 371 | + if (!args[0]->Uint32Value(ctx->env()->context()).To(&id)) { | ||
| 372 | + return; | ||
| 373 | + } | ||
| 366 | 374 | ||
| 367 | 375 | if (args[1]->IsArrayBuffer()) { | |
| 368 | 376 | Local<ArrayBuffer> ab = args[1].As<ArrayBuffer>(); | |
| 369 | - ctx->deserializer_.TransferArrayBuffer(id.FromJust(), ab); | ||
| 377 | + ctx->deserializer_.TransferArrayBuffer(id, ab); | ||
| 370 | 378 | return; | |
| 371 | 379 | } | |
| 372 | 380 | ||
| 373 | 381 | if (args[1]->IsSharedArrayBuffer()) { | |
| 374 | 382 | Local<SharedArrayBuffer> sab = args[1].As<SharedArrayBuffer>(); | |
| 375 | - ctx->deserializer_.TransferSharedArrayBuffer(id.FromJust(), sab); | ||
| 383 | + ctx->deserializer_.TransferSharedArrayBuffer(id, sab); | ||
| 376 | 384 | return; | |
| 377 | 385 | } | |
| 378 | 386 | ||
@@ -433,9 +441,11 @@ void DeserializerContext::ReadRawBytes( | |||
| 433 | 441 | DeserializerContext* ctx; | |
| 434 | 442 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.This()); | |
| 435 | 443 | ||
| 436 | - Maybe<int64_t> length_arg = args[0]->IntegerValue(ctx->env()->context()); | ||
| 437 | - if (length_arg.IsNothing()) return; | ||
| 438 | - size_t length = length_arg.FromJust(); | ||
| 444 | + int64_t length_arg; | ||
| 445 | + if (!args[0]->IntegerValue(ctx->env()->context()).To(&length_arg)) { | ||
| 446 | + return; | ||
| 447 | + } | ||
| 448 | + size_t length = length_arg; | ||
| 439 | 449 | ||
| 440 | 450 | const void* data; | |
| 441 | 451 | bool ok = ctx->deserializer_.ReadRawBytes(length, &data); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -968,7 +968,11 @@ void DatabaseSync::CreateSession(const FunctionCallbackInfo<Value>& args) { | |||
| 968 | 968 | Local<Object> options = args[0].As<Object>(); | |
| 969 | 969 | ||
| 970 | 970 | Local<String> table_key = FIXED_ONE_BYTE_STRING(env->isolate(), "table"); | |
| 971 | - if (options->HasOwnProperty(env->context(), table_key).FromJust()) { | ||
| 971 | + bool hasIt; | ||
| 972 | + if (!options->HasOwnProperty(env->context(), table_key).To(&hasIt)) { | ||
| 973 | + return; | ||
| 974 | + } | ||
| 975 | + if (hasIt) { | ||
| 972 | 976 | Local<Value> table_value; | |
| 973 | 977 | if (!options->Get(env->context(), table_key).ToLocal(&table_value)) { | |
| 974 | 978 | return; | |
@@ -986,7 +990,10 @@ void DatabaseSync::CreateSession(const FunctionCallbackInfo<Value>& args) { | |||
| 986 | 990 | ||
| 987 | 991 | Local<String> db_key = FIXED_ONE_BYTE_STRING(env->isolate(), "db"); | |
| 988 | 992 | ||
| 989 | - if (options->HasOwnProperty(env->context(), db_key).FromJust()) { | ||
| 993 | + if (!options->HasOwnProperty(env->context(), db_key).To(&hasIt)) { | ||
| 994 | + return; | ||
| 995 | + } | ||
| 996 | + if (hasIt) { | ||
| 990 | 997 | Local<Value> db_value; | |
| 991 | 998 | if (!options->Get(env->context(), db_key).ToLocal(&db_value)) { | |
| 992 | 999 | // An error will have been scheduled. | |
@@ -1205,8 +1212,12 @@ void DatabaseSync::ApplyChangeset(const FunctionCallbackInfo<Value>& args) { | |||
| 1205 | 1212 | }; | |
| 1206 | 1213 | } | |
| 1207 | 1214 | ||
| 1208 | - if (options->HasOwnProperty(env->context(), env->filter_string()) | ||
| 1209 | - .FromJust()) { | ||
| 1215 | + bool hasIt; | ||
| 1216 | + if (!options->HasOwnProperty(env->context(), env->filter_string()) | ||
| 1217 | + .To(&hasIt)) { | ||
| 1218 | + return; | ||
| 1219 | + } | ||
| 1220 | + if (hasIt) { | ||
| 1210 | 1221 | Local<Value> filterValue; | |
| 1211 | 1222 | if (!options->Get(env->context(), env->filter_string()) | |
| 1212 | 1223 | .ToLocal(&filterValue)) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments