@@ -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); |
|