@@ -187,10 +187,10 @@ void SerializerContext::WriteHeader(const FunctionCallbackInfo<Value>& args) {
187
187
void SerializerContext::WriteValue (const FunctionCallbackInfo<Value>& args) {
188
188
SerializerContext* ctx;
189
189
ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
190
- Maybe< bool > ret =
191
- ctx->serializer_ .WriteValue (ctx->env ()->context (), args[0 ]);
192
-
193
- if (ret. IsJust ()) args. GetReturnValue (). Set (ret. FromJust ());
190
+ bool ret;
191
+ if ( ctx->serializer_ .WriteValue (ctx->env ()->context (), args[0 ]). To (&ret)) {
192
+ args. GetReturnValue (). Set (ret);
193
+ }
194
194
}
195
195
196
196
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) {
@@ -360,18 +366,20 @@ void DeserializerContext::TransferArrayBuffer(
360
366
DeserializerContext* ctx;
361
367
ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
362
368
363
- Maybe<uint32_t > id = args[0 ]->Uint32Value (ctx->env ()->context ());
364
- if (id.IsNothing ()) return ;
369
+ uint32_t id;
370
+ if (!args[0 ]->Uint32Value (ctx->env ()->context ()).To (&id)) {
371
+ return ;
372
+ }
365
373
366
374
if (args[1 ]->IsArrayBuffer ()) {
367
375
Local<ArrayBuffer> ab = args[1 ].As <ArrayBuffer>();
368
- ctx->deserializer_ .TransferArrayBuffer (id. FromJust () , ab);
376
+ ctx->deserializer_ .TransferArrayBuffer (id, ab);
369
377
return ;
370
378
}
371
379
372
380
if (args[1 ]->IsSharedArrayBuffer ()) {
373
381
Local<SharedArrayBuffer> sab = args[1 ].As <SharedArrayBuffer>();
374
- ctx->deserializer_ .TransferSharedArrayBuffer (id. FromJust () , sab);
382
+ ctx->deserializer_ .TransferSharedArrayBuffer (id, sab);
375
383
return ;
376
384
}
377
385
@@ -432,9 +440,11 @@ void DeserializerContext::ReadRawBytes(
432
440
DeserializerContext* ctx;
433
441
ASSIGN_OR_RETURN_UNWRAP (&ctx, args.This ());
434
442
435
- Maybe<int64_t > length_arg = args[0 ]->IntegerValue (ctx->env ()->context ());
436
- if (length_arg.IsNothing ()) return ;
437
- size_t length = length_arg.FromJust ();
443
+ int64_t length_arg;
444
+ if (!args[0 ]->IntegerValue (ctx->env ()->context ()).To (&length_arg)) {
445
+ return ;
446
+ }
447
+ size_t length = length_arg;
438
448
439
449
const void * data;
440
450
bool ok = ctx->deserializer_ .ReadRawBytes (length, &data);
0 commit comments