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