@@ -121,7 +121,7 @@ Local<Value> ContextifyContext::CreateDataWrapper(Environment* env) {
121121 if (wrapper.IsEmpty ())
122122 return scope.Escape (Local<Value>::New (env->isolate (), Local<Value>()));
123123
124- Wrap ( wrapper, this );
124+ wrapper-> SetAlignedPointerInInternalField ( 0 , this );
125125 return scope.Escape (wrapper);
126126}
127127
@@ -291,12 +291,19 @@ ContextifyContext* ContextifyContext::ContextFromContextifiedSandbox(
291291 return nullptr ;
292292}
293293
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+
294302// static
295303void ContextifyContext::PropertyGetterCallback (
296304 Local<Name> property,
297305 const PropertyCallbackInfo<Value>& args) {
298- ContextifyContext* ctx;
299- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
306+ ContextifyContext* ctx = ContextifyContext::Get (args);
300307
301308 // Still initializing
302309 if (ctx->context_ .IsEmpty ())
@@ -325,8 +332,7 @@ void ContextifyContext::PropertySetterCallback(
325332 Local<Name> property,
326333 Local<Value> value,
327334 const PropertyCallbackInfo<Value>& args) {
328- ContextifyContext* ctx;
329- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
335+ ContextifyContext* ctx = ContextifyContext::Get (args);
330336
331337 // Still initializing
332338 if (ctx->context_ .IsEmpty ())
@@ -386,8 +392,7 @@ void ContextifyContext::PropertySetterCallback(
386392void ContextifyContext::PropertyDescriptorCallback (
387393 Local<Name> property,
388394 const PropertyCallbackInfo<Value>& args) {
389- ContextifyContext* ctx;
390- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
395+ ContextifyContext* ctx = ContextifyContext::Get (args);
391396
392397 // Still initializing
393398 if (ctx->context_ .IsEmpty ())
@@ -409,8 +414,7 @@ void ContextifyContext::PropertyDefinerCallback(
409414 Local<Name> property,
410415 const PropertyDescriptor& desc,
411416 const PropertyCallbackInfo<Value>& args) {
412- ContextifyContext* ctx;
413- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
417+ ContextifyContext* ctx = ContextifyContext::Get (args);
414418
415419 // Still initializing
416420 if (ctx->context_ .IsEmpty ())
@@ -472,8 +476,7 @@ void ContextifyContext::PropertyDefinerCallback(
472476void ContextifyContext::PropertyDeleterCallback (
473477 Local<Name> property,
474478 const PropertyCallbackInfo<Boolean>& args) {
475- ContextifyContext* ctx;
476- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
479+ ContextifyContext* ctx = ContextifyContext::Get (args);
477480
478481 // Still initializing
479482 if (ctx->context_ .IsEmpty ())
@@ -492,8 +495,7 @@ void ContextifyContext::PropertyDeleterCallback(
492495// static
493496void ContextifyContext::PropertyEnumeratorCallback (
494497 const PropertyCallbackInfo<Array>& args) {
495- ContextifyContext* ctx;
496- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
498+ ContextifyContext* ctx = ContextifyContext::Get (args);
497499
498500 // Still initializing
499501 if (ctx->context_ .IsEmpty ())
@@ -506,8 +508,7 @@ void ContextifyContext::PropertyEnumeratorCallback(
506508void ContextifyContext::IndexedPropertyGetterCallback (
507509 uint32_t index,
508510 const PropertyCallbackInfo<Value>& args) {
509- ContextifyContext* ctx;
510- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
511+ ContextifyContext* ctx = ContextifyContext::Get (args);
511512
512513 // Still initializing
513514 if (ctx->context_ .IsEmpty ())
@@ -522,8 +523,7 @@ void ContextifyContext::IndexedPropertySetterCallback(
522523 uint32_t index,
523524 Local<Value> value,
524525 const PropertyCallbackInfo<Value>& args) {
525- ContextifyContext* ctx;
526- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
526+ ContextifyContext* ctx = ContextifyContext::Get (args);
527527
528528 // Still initializing
529529 if (ctx->context_ .IsEmpty ())
@@ -537,8 +537,7 @@ void ContextifyContext::IndexedPropertySetterCallback(
537537void ContextifyContext::IndexedPropertyDescriptorCallback (
538538 uint32_t index,
539539 const PropertyCallbackInfo<Value>& args) {
540- ContextifyContext* ctx;
541- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
540+ ContextifyContext* ctx = ContextifyContext::Get (args);
542541
543542 // Still initializing
544543 if (ctx->context_ .IsEmpty ())
@@ -553,8 +552,7 @@ void ContextifyContext::IndexedPropertyDefinerCallback(
553552 uint32_t index,
554553 const PropertyDescriptor& desc,
555554 const PropertyCallbackInfo<Value>& args) {
556- ContextifyContext* ctx;
557- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
555+ ContextifyContext* ctx = ContextifyContext::Get (args);
558556
559557 // Still initializing
560558 if (ctx->context_ .IsEmpty ())
@@ -568,8 +566,7 @@ void ContextifyContext::IndexedPropertyDefinerCallback(
568566void ContextifyContext::IndexedPropertyDeleterCallback (
569567 uint32_t index,
570568 const PropertyCallbackInfo<Boolean>& args) {
571- ContextifyContext* ctx;
572- ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Data ().As <Object>());
569+ ContextifyContext* ctx = ContextifyContext::Get (args);
573570
574571 // Still initializing
575572 if (ctx->context_ .IsEmpty ())
0 commit comments