node native/nan questions

23 views
Skip to first unread message

Axel Kittenberger

unread,
Dec 18, 2015, 12:02:44 PM12/18/15
to nodejs
I'm just trying to understand nan/node native extensions.

First question, class hierachy when wrapping C++ stuff.

Is unwrapping a static cast? (So far I guess so ) or can it in fact be a dynamic cast?

Say I got in C++ Wrapper AClass and Wrapper BClass that both inherit from Wrapper MasterClass.

Can I put in

NAN_METHOD( myFunc )
{
   MasterClass *mc = Nan::ObjectWrap::Unwrap<MasterClass>( info[ 0 ]->ToObject( ) );
}

and have it work when javascript hands a Wrapper for AClass or BClass?

If not, how can I determine which type of wrapped object javascript handed to myFunc?

Second question:

How can I throw an javascript Exception from native if its simple sync code without I/O. Usually should do when the arguments are not what they need to be.

Kind regards, Axel
Reply all
Reply to author
Forward
0 new messages