Hey.

Have you considered getting „this“ from the „args“ parameter? This would allow 
you to store callbacks in the local module. That is how I handled the issue of 
storing a void* in the current instance.

It is ages ago that I coded with v8, but I think what you want is this:

    Local<Object> _this = args.getHolder();

Please forgive me, but I pretty much forgot all about the API ^^“

Using the method I suggest is equivalent of this JS:

cApiBinding.prototype.call_func = function( uuid ) {
    var cbs = this.callbacks; // <-
    _c_lib_function( uuid, cbs[uuid] );
}

Hope it helped!

Kind regards, Ingwie

On Mo. Apr. 27 2015 01:21:14 [email protected] wrote:
> Hi!
> 
> I am writing node.js bindings for a C library. Some of the C API takes 
> callback function pointers, so my corresponding JS API will accept JS 
> callbacks. I intend to use a hybrid JS/C++ solution to achieve running the JS 
> callback whenever the C callback gets called. Let's say the C API has the 
> following signature:
> 
> void c_api_function( int flags, void (*callback)() );
> 
> Let's further say that the name of my module is cApiBindings (i.e., you will 
> load the module by doing require( "bindings" )( "cApiBindings" ) ), and that 
> I intend to expose the above function as cApiBindings.c_api_function(). I was 
> thinking about achieving this as follows:



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/A12834C9-9D78-4D22-AEEC-F60D10280273%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to