This is against the owner for ObjectWrap :: Unwrap

The class v8::FunctionCallbackInfodistinguishes between Thisand Holder. I know that Thisin JavaScript, and suppose that Thisreflects this parameter. But I only have a vague idea of ​​that Holder, and very little about when I should use Holderinstead This.

In particular, when writing an extension based on n node.js and deploying ObjectWrap, from which should I go?

Currently, node::ObjectWrapdocumentation has examples using Holder, and current Nan::ObjectWrapdocumentation uses This, so "just follow the examples in the documentation" doesn't help answer this question.

+4
source share
1 answer

When writing the question above, I did a few more digging and eventually found some relevant threads in the v8-users Google Group . I will give a short part of two messages that seem to me the most important, but they are taken out of context, so containing streams may be useful for further information. Added markup formatting.

Christian "Little Jim" Plesner wrote in 2009:

: Signature , T, Holder , T , FunctionTemplate::Inherit T. This.

Stephan Beal 2010 . :

Holder This , , . -, This() != Holder()- .

2014 .

, -, , Holder , nan . , This , - ObjectWrap.

, , This , :

var x = { }
x.__proto__ = document;
var div = x.createElement('div');

, " ". ( ), , , , TypeError: Illegal invocation. , . ObjectWrap::Unwrap , This Holder. : Node 0.10, , , Holder , , nan pull # 524 .

. Holder() , , , -, , This .

+3

Source: https://habr.com/ru/post/1619758/


All Articles