adding example for wrapping pre-created objects
Hey! This is more like something I am stuck at.
I have a library with header files, and I want to make bindings for that library. Yet, I can not change the already existing classes. So, I am looking for a way to wrap these existing classes into a nodejs module.
Currently, I am waiting for some peeps to respond. But it would still be awesome if that would be added here, as it is quite a usual case.
Kind regards, Ingwie! ^^
generally the way you have to approach this is write completely new wrappers for the classes with explicit accessors, I don't believe there's a generic way to just wrap an object other than writing the whole wrapper yourself. I probably wouldn't bother subclassing either because your exposed methods need their own signatures for V8 so just keep a private instance of the class you're wrapping and write accessors for it.
Check out https://github.com/justmoon/node-bignum/blob/master/bignum.cc for some intensive wrapping of existing methods on existing classes.
Should this issue remain open? Moreover, is this repository something that should be archived?