@@ -121,7 +121,7 @@ Local<Value> ContextifyContext::CreateDataWrapper(Environment* env) {
121
121
if (wrapper.IsEmpty ())
122
122
return scope.Escape (Local<Value>::New (env->isolate (), Local<Value>()));
123
123
124
- Wrap ( wrapper, this );
124
+ wrapper-> SetAlignedPointerInInternalField ( 0 , this );
125
125
return scope.Escape (wrapper);
126
126
}
127
127
@@ -291,12 +291,19 @@ ContextifyContext* ContextifyContext::ContextFromContextifiedSandbox(
291
291
return nullptr ;
292
292
}
293
293
294
+ // static
295
+ template <typename T>
296
+ ContextifyContext* ContextifyContext::Get (const PropertyCallbackInfo<T>& args) {
297
+ Local<Value> data = args.Data ();
298
+ return static_cast <ContextifyContext*>(
299
+ data.As <Object>()->GetAlignedPointerFromInternalField (0 ));
300
+ }
301
+
294
302
// static
295
303
void ContextifyContext::PropertyGetterCallback (
296
304
Local<Name> property,
297
305
const PropertyCallbackInfo<Value>& args) {
298
- ContextifyContext* ctx;
299
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
306
+ ContextifyContext* ctx = ContextifyContext::Get (args);
300
307
301
308
// Still initializing
302
309
if (ctx->context_ .IsEmpty ())
@@ -325,8 +332,7 @@ void ContextifyContext::PropertySetterCallback(
325
332
Local<Name> property,
326
333
Local<Value> value,
327
334
const PropertyCallbackInfo<Value>& args) {
328
- ContextifyContext* ctx;
329
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
335
+ ContextifyContext* ctx = ContextifyContext::Get (args);
330
336
331
337
// Still initializing
332
338
if (ctx->context_ .IsEmpty ())
@@ -386,8 +392,7 @@ void ContextifyContext::PropertySetterCallback(
386
392
void ContextifyContext::PropertyDescriptorCallback (
387
393
Local<Name> property,
388
394
const PropertyCallbackInfo<Value>& args) {
389
- ContextifyContext* ctx;
390
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
395
+ ContextifyContext* ctx = ContextifyContext::Get (args);
391
396
392
397
// Still initializing
393
398
if (ctx->context_ .IsEmpty ())
@@ -409,8 +414,7 @@ void ContextifyContext::PropertyDefinerCallback(
409
414
Local<Name> property,
410
415
const PropertyDescriptor& desc,
411
416
const PropertyCallbackInfo<Value>& args) {
412
- ContextifyContext* ctx;
413
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
417
+ ContextifyContext* ctx = ContextifyContext::Get (args);
414
418
415
419
// Still initializing
416
420
if (ctx->context_ .IsEmpty ())
@@ -472,8 +476,7 @@ void ContextifyContext::PropertyDefinerCallback(
472
476
void ContextifyContext::PropertyDeleterCallback (
473
477
Local<Name> property,
474
478
const PropertyCallbackInfo<Boolean >& args) {
475
- ContextifyContext* ctx;
476
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
479
+ ContextifyContext* ctx = ContextifyContext::Get (args);
477
480
478
481
// Still initializing
479
482
if (ctx->context_ .IsEmpty ())
@@ -492,8 +495,7 @@ void ContextifyContext::PropertyDeleterCallback(
492
495
// static
493
496
void ContextifyContext::PropertyEnumeratorCallback (
494
497
const PropertyCallbackInfo<Array>& args) {
495
- ContextifyContext* ctx;
496
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
498
+ ContextifyContext* ctx = ContextifyContext::Get (args);
497
499
498
500
// Still initializing
499
501
if (ctx->context_ .IsEmpty ())
@@ -506,8 +508,7 @@ void ContextifyContext::PropertyEnumeratorCallback(
506
508
void ContextifyContext::IndexedPropertyGetterCallback (
507
509
uint32_t index,
508
510
const PropertyCallbackInfo<Value>& args) {
509
- ContextifyContext* ctx;
510
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
511
+ ContextifyContext* ctx = ContextifyContext::Get (args);
511
512
512
513
// Still initializing
513
514
if (ctx->context_ .IsEmpty ())
@@ -522,8 +523,7 @@ void ContextifyContext::IndexedPropertySetterCallback(
522
523
uint32_t index,
523
524
Local<Value> value,
524
525
const PropertyCallbackInfo<Value>& args) {
525
- ContextifyContext* ctx;
526
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
526
+ ContextifyContext* ctx = ContextifyContext::Get (args);
527
527
528
528
// Still initializing
529
529
if (ctx->context_ .IsEmpty ())
@@ -537,8 +537,7 @@ void ContextifyContext::IndexedPropertySetterCallback(
537
537
void ContextifyContext::IndexedPropertyDescriptorCallback (
538
538
uint32_t index,
539
539
const PropertyCallbackInfo<Value>& args) {
540
- ContextifyContext* ctx;
541
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
540
+ ContextifyContext* ctx = ContextifyContext::Get (args);
542
541
543
542
// Still initializing
544
543
if (ctx->context_ .IsEmpty ())
@@ -553,8 +552,7 @@ void ContextifyContext::IndexedPropertyDefinerCallback(
553
552
uint32_t index,
554
553
const PropertyDescriptor& desc,
555
554
const PropertyCallbackInfo<Value>& args) {
556
- ContextifyContext* ctx;
557
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
555
+ ContextifyContext* ctx = ContextifyContext::Get (args);
558
556
559
557
// Still initializing
560
558
if (ctx->context_ .IsEmpty ())
@@ -568,8 +566,7 @@ void ContextifyContext::IndexedPropertyDefinerCallback(
568
566
void ContextifyContext::IndexedPropertyDeleterCallback (
569
567
uint32_t index,
570
568
const PropertyCallbackInfo<Boolean >& args) {
571
- ContextifyContext* ctx;
572
- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
569
+ ContextifyContext* ctx = ContextifyContext::Get (args);
573
570
574
571
// Still initializing
575
572
if (ctx->context_ .IsEmpty ())
0 commit comments