| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4cdecc5 commit b1e5491
19 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,6 +61,7 @@ using v8::EscapableHandleScope; | |||
| 61 | 61 | using v8::FunctionCallbackInfo; | |
| 62 | 62 | using v8::FunctionTemplate; | |
| 63 | 63 | using v8::HandleScope; | |
| 64 | + using v8::Int32; | ||
| 64 | 65 | using v8::Integer; | |
| 65 | 66 | using v8::Local; | |
| 66 | 67 | using v8::Null; | |
@@ -1987,23 +1988,23 @@ void GetAddrInfo(const FunctionCallbackInfo<Value>& args) { | |||
| 1987 | 1988 | ||
| 1988 | 1989 | int32_t flags = 0; | |
| 1989 | 1990 | if (args[3]->IsInt32()) { | |
| 1990 | - flags = args[3]->Int32Value(env->context()).FromJust(); | ||
| 1991 | + flags = args[3].As<Int32>()->Value(); | ||
| 1991 | 1992 | } | |
| 1992 | 1993 | ||
| 1993 | 1994 | int family; | |
| 1994 | 1995 | ||
| 1995 | - switch (args[2]->Int32Value(env->context()).FromJust()) { | ||
| 1996 | - case 0: | ||
| 1997 | - family = AF_UNSPEC; | ||
| 1998 | - break; | ||
| 1999 | - case 4: | ||
| 2000 | - family = AF_INET; | ||
| 2001 | - break; | ||
| 2002 | - case 6: | ||
| 2003 | - family = AF_INET6; | ||
| 2004 | - break; | ||
| 2005 | - default: | ||
| 2006 | - CHECK(0 && "bad address family"); | ||
| 1996 | + switch (args[2].As<Int32>()->Value()) { | ||
| 1997 | + case 0: | ||
| 1998 | + family = AF_UNSPEC; | ||
| 1999 | + break; | ||
| 2000 | + case 4: | ||
| 2001 | + family = AF_INET; | ||
| 2002 | + break; | ||
| 2003 | + case 6: | ||
| 2004 | + family = AF_INET6; | ||
| 2005 | + break; | ||
| 2006 | + default: | ||
| 2007 | + CHECK(0 && "bad address family"); | ||
| 2007 | 2008 | } | |
| 2008 | 2009 | ||
| 2009 | 2010 | auto req_wrap = new GetAddrInfoReqWrap(env, req_wrap_obj, args[4]->IsTrue()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,7 @@ using v8::Context; | |||
| 14 | 14 | using v8::FunctionCallbackInfo; | |
| 15 | 15 | using v8::FunctionTemplate; | |
| 16 | 16 | using v8::HandleScope; | |
| 17 | + using v8::Int32; | ||
| 17 | 18 | using v8::Local; | |
| 18 | 19 | using v8::Object; | |
| 19 | 20 | using v8::String; | |
@@ -154,7 +155,8 @@ void JSStream::Finish(const FunctionCallbackInfo<Value>& args) { | |||
| 154 | 155 | CHECK(args[0]->IsObject()); | |
| 155 | 156 | Wrap* w = static_cast<Wrap*>(StreamReq::FromObject(args[0].As<Object>())); | |
| 156 | 157 | ||
| 157 | - w->Done(args[1]->Int32Value()); | ||
| 158 | + CHECK(args[1]->IsInt32()); | ||
| 159 | + w->Done(args[1].As<Int32>()->Value()); | ||
| 158 | 160 | } | |
| 159 | 161 | ||
| 160 | 162 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1197,7 +1197,8 @@ static void Exit(const FunctionCallbackInfo<Value>& args) { | |||
| 1197 | 1197 | Environment* env = Environment::GetCurrent(args); | |
| 1198 | 1198 | WaitForInspectorDisconnect(env); | |
| 1199 | 1199 | v8_platform.StopTracingAgent(); | |
| 1200 | - env->Exit(args[0]->Int32Value()); | ||
| 1200 | + int code = args[0]->Int32Value(env->context()).FromMaybe(0); | ||
| 1201 | + env->Exit(code); | ||
| 1201 | 1202 | } | |
| 1202 | 1203 | ||
| 1203 | 1204 | extern "C" void node_module_register(void* m) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1039,7 +1039,7 @@ void SecureContext::SetSessionTimeout(const FunctionCallbackInfo<Value>& args) { | |||
| 1039 | 1039 | sc->env(), "Session timeout must be a 32-bit integer"); | |
| 1040 | 1040 | } | |
| 1041 | 1041 | ||
| 1042 | - int32_t sessionTimeout = args[0]->Int32Value(); | ||
| 1042 | + int32_t sessionTimeout = args[0].As<Int32>()->Value(); | ||
| 1043 | 1043 | SSL_CTX_set_timeout(sc->ctx_.get(), sessionTimeout); | |
| 1044 | 1044 | } | |
| 1045 | 1045 | ||
@@ -1261,7 +1261,8 @@ int SecureContext::TicketKeyCallback(SSL* ssl, | |||
| 1261 | 1261 | {0, 0}).ToLocalChecked(); | |
| 1262 | 1262 | Local<Array> arr = ret.As<Array>(); | |
| 1263 | 1263 | ||
| 1264 | - int r = arr->Get(kTicketKeyReturnIndex)->Int32Value(); | ||
| 1264 | + int r = | ||
| 1265 | + arr->Get(kTicketKeyReturnIndex)->Int32Value(env->context()).FromJust(); | ||
| 1265 | 1266 | if (r < 0) | |
| 1266 | 1267 | return r; | |
| 1267 | 1268 | ||
@@ -3632,14 +3633,10 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) { | |||
| 3632 | 3633 | char* buf = Buffer::Data(args[0]); | |
| 3633 | 3634 | ||
| 3634 | 3635 | CHECK(args[2]->IsInt32()); | |
| 3635 | - Maybe<int32_t> maybe_padding = args[2]->Int32Value(env->context()); | ||
| 3636 | - CHECK(maybe_padding.IsJust()); | ||
| 3637 | - int padding = maybe_padding.ToChecked(); | ||
| 3636 | + int padding = args[2].As<Int32>()->Value(); | ||
| 3638 | 3637 | ||
| 3639 | 3638 | CHECK(args[3]->IsInt32()); | |
| 3640 | - Maybe<int32_t> maybe_salt_len = args[3]->Int32Value(env->context()); | ||
| 3641 | - CHECK(maybe_salt_len.IsJust()); | ||
| 3642 | - int salt_len = maybe_salt_len.ToChecked(); | ||
| 3639 | + int salt_len = args[3].As<Int32>()->Value(); | ||
| 3643 | 3640 | ||
| 3644 | 3641 | ClearErrorOnReturn clear_error_on_return; | |
| 3645 | 3642 | unsigned char md_value[8192]; | |
@@ -3786,8 +3783,6 @@ SignBase::Error Verify::VerifyFinal(const char* key_pem, | |||
| 3786 | 3783 | ||
| 3787 | 3784 | ||
| 3788 | 3785 | void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) { | |
| 3789 | - Environment* env = Environment::GetCurrent(args); | ||
| 3790 | - | ||
| 3791 | 3786 | ClearErrorOnReturn clear_error_on_return; | |
| 3792 | 3787 | ||
| 3793 | 3788 | Verify* verify; | |
@@ -3800,14 +3795,10 @@ void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) { | |||
| 3800 | 3795 | ssize_t hlen = Buffer::Length(args[1]); | |
| 3801 | 3796 | ||
| 3802 | 3797 | CHECK(args[2]->IsInt32()); | |
| 3803 | - Maybe<int32_t> maybe_padding = args[2]->Int32Value(env->context()); | ||
| 3804 | - CHECK(maybe_padding.IsJust()); | ||
| 3805 | - int padding = maybe_padding.ToChecked(); | ||
| 3798 | + int padding = args[2].As<Int32>()->Value(); | ||
| 3806 | 3799 | ||
| 3807 | 3800 | CHECK(args[3]->IsInt32()); | |
| 3808 | - Maybe<int32_t> maybe_salt_len = args[3]->Int32Value(env->context()); | ||
| 3809 | - CHECK(maybe_salt_len.IsJust()); | ||
| 3810 | - int salt_len = maybe_salt_len.ToChecked(); | ||
| 3801 | + int salt_len = args[3].As<Int32>()->Value(); | ||
| 3811 | 3802 | ||
| 3812 | 3803 | bool verify_result; | |
| 3813 | 3804 | Error err = verify->VerifyFinal(kbuf, klen, hbuf, hlen, padding, salt_len, | |
@@ -4079,14 +4070,14 @@ void DiffieHellman::New(const FunctionCallbackInfo<Value>& args) { | |||
| 4079 | 4070 | if (args.Length() == 2) { | |
| 4080 | 4071 | if (args[0]->IsInt32()) { | |
| 4081 | 4072 | if (args[1]->IsInt32()) { | |
| 4082 | - initialized = diffieHellman->Init(args[0]->Int32Value(), | ||
| 4083 | - args[1]->Int32Value()); | ||
| 4073 | + initialized = diffieHellman->Init(args[0].As<Int32>()->Value(), | ||
| 4074 | + args[1].As<Int32>()->Value()); | ||
| 4084 | 4075 | } | |
| 4085 | 4076 | } else { | |
| 4086 | 4077 | if (args[1]->IsInt32()) { | |
| 4087 | 4078 | initialized = diffieHellman->Init(Buffer::Data(args[0]), | |
| 4088 | 4079 | Buffer::Length(args[0]), | |
| 4089 | - args[1]->Int32Value()); | ||
| 4080 | + args[1].As<Int32>()->Value()); | ||
| 4090 | 4081 | } else { | |
| 4091 | 4082 | initialized = diffieHellman->Init(Buffer::Data(args[0]), | |
| 4092 | 4083 | Buffer::Length(args[0]), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,13 +69,15 @@ using v8::Value; | |||
| 69 | 69 | if ((*(const char **)valp = *_##member) == nullptr) \ | |
| 70 | 70 | *(const char **)valp = "<unknown>"; | |
| 71 | 71 | ||
| 72 | - #define SLURP_INT(obj, member, valp) \ | ||
| 73 | - if (!(obj)->IsObject()) { \ | ||
| 74 | - return node::THROW_ERR_INVALID_ARG_TYPE(env, \ | ||
| 75 | - "expected object for " #obj " to contain integer member " #member);\ | ||
| 76 | - } \ | ||
| 77 | - *valp = obj->Get(OneByteString(env->isolate(), #member)) \ | ||
| 78 | - ->Int32Value(); | ||
| 72 | + #define SLURP_INT(obj, member, valp) \ | ||
| 73 | + if (!(obj)->IsObject()) { \ | ||
| 74 | + return node::THROW_ERR_INVALID_ARG_TYPE( \ | ||
| 75 | + env, \ | ||
| 76 | + "expected object for " #obj " to contain integer member " #member); \ | ||
| 77 | + } \ | ||
| 78 | + *valp = obj->Get(OneByteString(env->isolate(), #member)) \ | ||
| 79 | + ->Int32Value(env->context()) \ | ||
| 80 | + .FromJust(); | ||
| 79 | 81 | ||
| 80 | 82 | #define SLURP_OBJECT(obj, member, valp) \ | |
| 81 | 83 | if (!(obj)->IsObject()) { \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,6 +57,7 @@ using v8::Function; | |||
| 57 | 57 | using v8::FunctionCallbackInfo; | |
| 58 | 58 | using v8::FunctionTemplate; | |
| 59 | 59 | using v8::HandleScope; | |
| 60 | + using v8::Int32; | ||
| 60 | 61 | using v8::Integer; | |
| 61 | 62 | using v8::Local; | |
| 62 | 63 | using v8::MaybeLocal; | |
@@ -361,8 +362,9 @@ class Parser : public AsyncWrap, public StreamListener { | |||
| 361 | 362 | ||
| 362 | 363 | static void New(const FunctionCallbackInfo<Value>& args) { | |
| 363 | 364 | Environment* env = Environment::GetCurrent(args); | |
| 365 | + CHECK(args[0]->IsInt32()); | ||
| 364 | 366 | http_parser_type type = | |
| 365 | - static_cast<http_parser_type>(args[0]->Int32Value()); | ||
| 367 | + static_cast<http_parser_type>(args[0].As<Int32>()->Value()); | ||
| 366 | 368 | CHECK(type == HTTP_REQUEST || type == HTTP_RESPONSE); | |
| 367 | 369 | new Parser(env, args.This(), type); | |
| 368 | 370 | } | |
@@ -458,8 +460,9 @@ class Parser : public AsyncWrap, public StreamListener { | |||
| 458 | 460 | static void Reinitialize(const FunctionCallbackInfo<Value>& args) { | |
| 459 | 461 | Environment* env = Environment::GetCurrent(args); | |
| 460 | 462 | ||
| 463 | + CHECK(args[0]->IsInt32()); | ||
| 461 | 464 | http_parser_type type = | |
| 462 | - static_cast<http_parser_type>(args[0]->Int32Value()); | ||
| 465 | + static_cast<http_parser_type>(args[0].As<Int32>()->Value()); | ||
| 463 | 466 | ||
| 464 | 467 | CHECK(type == HTTP_REQUEST || type == HTTP_RESPONSE); | |
| 465 | 468 | Parser* parser; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,6 +87,7 @@ namespace node { | |||
| 87 | 87 | using v8::Context; | |
| 88 | 88 | using v8::FunctionCallbackInfo; | |
| 89 | 89 | using v8::HandleScope; | |
| 90 | + using v8::Int32; | ||
| 90 | 91 | using v8::Isolate; | |
| 91 | 92 | using v8::Local; | |
| 92 | 93 | using v8::MaybeLocal; | |
@@ -502,7 +503,8 @@ void Transcode(const FunctionCallbackInfo<Value>&args) { | |||
| 502 | 503 | ||
| 503 | 504 | void ICUErrorName(const FunctionCallbackInfo<Value>& args) { | |
| 504 | 505 | Environment* env = Environment::GetCurrent(args); | |
| 505 | - UErrorCode status = static_cast<UErrorCode>(args[0]->Int32Value()); | ||
| 506 | + CHECK(args[0]->IsInt32()); | ||
| 507 | + UErrorCode status = static_cast<UErrorCode>(args[0].As<Int32>()->Value()); | ||
| 506 | 508 | args.GetReturnValue().Set( | |
| 507 | 509 | String::NewFromUtf8(env->isolate(), | |
| 508 | 510 | u_errorName(status), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -159,12 +159,15 @@ void HrtimeBigInt(const FunctionCallbackInfo<Value>& args) { | |||
| 159 | 159 | ||
| 160 | 160 | void Kill(const FunctionCallbackInfo<Value>& args) { | |
| 161 | 161 | Environment* env = Environment::GetCurrent(args); | |
| 162 | + Local<Context> context = env->context(); | ||
| 162 | 163 | ||
| 163 | 164 | if (args.Length() != 2) | |
| 164 | 165 | return env->ThrowError("Bad argument."); | |
| 165 | 166 | ||
| 166 | - int pid = args[0]->Int32Value(); | ||
| 167 | - int sig = args[1]->Int32Value(); | ||
| 167 | + int pid; | ||
| 168 | + if (!args[0]->Int32Value(context).To(&pid)) return; | ||
| 169 | + int sig; | ||
| 170 | + if (!args[1]->Int32Value(context).To(&sig)) return; | ||
| 168 | 171 | int err = uv_kill(pid, sig); | |
| 169 | 172 | args.GetReturnValue().Set(err); | |
| 170 | 173 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,6 +45,7 @@ using v8::Function; | |||
| 45 | 45 | using v8::FunctionCallbackInfo; | |
| 46 | 46 | using v8::FunctionTemplate; | |
| 47 | 47 | using v8::HandleScope; | |
| 48 | + using v8::Int32; | ||
| 48 | 49 | using v8::Local; | |
| 49 | 50 | using v8::Number; | |
| 50 | 51 | using v8::Object; | |
@@ -419,7 +420,8 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { | |||
| 419 | 420 | static void New(const FunctionCallbackInfo<Value>& args) { | |
| 420 | 421 | Environment* env = Environment::GetCurrent(args); | |
| 421 | 422 | CHECK(args[0]->IsInt32()); | |
| 422 | - node_zlib_mode mode = static_cast<node_zlib_mode>(args[0]->Int32Value()); | ||
| 423 | + node_zlib_mode mode = | ||
| 424 | + static_cast<node_zlib_mode>(args[0].As<Int32>()->Value()); | ||
| 423 | 425 | new ZCtx(env, args.This(), mode); | |
| 424 | 426 | } | |
| 425 | 427 | ||
@@ -459,7 +461,8 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { | |||
| 459 | 461 | "invalid windowBits"); | |
| 460 | 462 | } | |
| 461 | 463 | ||
| 462 | - int level = args[1]->Int32Value(); | ||
| 464 | + int level; | ||
| 465 | + if (!args[1]->Int32Value(context).To(&level)) return; | ||
| 463 | 466 | CHECK((level >= Z_MIN_LEVEL && level <= Z_MAX_LEVEL) && | |
| 464 | 467 | "invalid compression level"); | |
| 465 | 468 | ||
@@ -506,7 +509,12 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { | |||
| 506 | 509 | CHECK(args.Length() == 2 && "params(level, strategy)"); | |
| 507 | 510 | ZCtx* ctx; | |
| 508 | 511 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder()); | |
| 509 | - ctx->Params(args[0]->Int32Value(), args[1]->Int32Value()); | ||
| 512 | + Environment* env = ctx->env(); | ||
| 513 | + int level; | ||
| 514 | + if (!args[0]->Int32Value(env->context()).To(&level)) return; | ||
| 515 | + int strategy; | ||
| 516 | + if (!args[1]->Int32Value(env->context()).To(&strategy)) return; | ||
| 517 | + ctx->Params(level, strategy); | ||
| 510 | 518 | } | |
| 511 | 519 | ||
| 512 | 520 | static void Reset(const FunctionCallbackInfo<Value> &args) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,7 +173,8 @@ void PipeWrap::Bind(const FunctionCallbackInfo<Value>& args) { | |||
| 173 | 173 | void PipeWrap::SetPendingInstances(const FunctionCallbackInfo<Value>& args) { | |
| 174 | 174 | PipeWrap* wrap; | |
| 175 | 175 | ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); | |
| 176 | - int instances = args[0]->Int32Value(); | ||
| 176 | + CHECK(args[0]->IsInt32()); | ||
| 177 | + int instances = args[0].As<Int32>()->Value(); | ||
| 177 | 178 | uv_pipe_pending_instances(&wrap->handle_, instances); | |
| 178 | 179 | } | |
| 179 | 180 | #endif | |
@@ -193,7 +194,9 @@ void PipeWrap::Fchmod(const v8::FunctionCallbackInfo<v8::Value>& args) { | |||
| 193 | 194 | void PipeWrap::Listen(const FunctionCallbackInfo<Value>& args) { | |
| 194 | 195 | PipeWrap* wrap; | |
| 195 | 196 | ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); | |
| 196 | - int backlog = args[0]->Int32Value(); | ||
| 197 | + Environment* env = wrap->env(); | ||
| 198 | + int backlog; | ||
| 199 | + if (!args[0]->Int32Value(env->context()).To(&backlog)) return; | ||
| 197 | 200 | int err = uv_listen(reinterpret_cast<uv_stream_t*>(&wrap->handle_), | |
| 198 | 201 | backlog, | |
| 199 | 202 | OnConnection); | |
@@ -207,7 +210,8 @@ void PipeWrap::Open(const FunctionCallbackInfo<Value>& args) { | |||
| 207 | 210 | PipeWrap* wrap; | |
| 208 | 211 | ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); | |
| 209 | 212 | ||
| 210 | - int fd = args[0]->Int32Value(); | ||
| 213 | + int fd; | ||
| 214 | + if (!args[0]->Int32Value(env->context()).To(&fd)) return; | ||
| 211 | 215 | ||
| 212 | 216 | int err = uv_pipe_open(&wrap->handle_, fd); | |
| 213 | 217 | wrap->set_fd(fd); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments