I am new to Nan, V8, and C++ (so if I haven't put a big enough target on my
back I don't know what else I can add). I've written a lot of JavaScript
and, in the past, C, assembler, and kernel mode code, so hopefully the
bulls-eye is a little smaller now.
I'm working with an existing code base and am trying to understand why
things were done the way they were. It uses Nan to create an addon for
nodejs. I'm hoping someone here can help me understand some pieces that
escape me.
1. The code sets internal field count for each class - sometimes to 1 and
sometimes to 2 - but never invokes "setInternalField()" or
"getInternalField()". Is there some reason, possibly historical, that
"setInternalFieldCount()" needed to be called to set a value? The way I
have interpreted what I've read is that my code needs to set and get the
value explicitly, so setting a value but never storing anything there makes
no sense to me.
// Prepare constructor template
v8::Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(New);
ctor->InstanceTemplate()->SetInternalFieldCount(2);
ctor->SetClassName(Nan::New("MyClass").ToLocalChecked());
2. Given that I'm storing something in internal fields, my understanding is
that I need to free any resources (memory, etc.) that are used by the
internal field if the object is GC'd. Doing that in the destructor seems to
be the right way to handle that. Is that all there is to it?
3. What difference does it make to v8 if the internal field is an aligned
pointer or not? Is the ability to set/get aligned pointers a consistency
check so assumptions can be made? Does the interface check the alignment?
(Not critical for me, I don't think, but I'd like to understand.)
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.