Npm building separate .node file is something that cannot change now, I 
don't think it would be a good idea anyway.

Before I go on and expose a possible solution, I need to stress out that 
pointer ownership is very important =)

What I would suggest is that, instead of using Buffer objects as 
intermediary for data exchange, you use C-style pointers. In v8 you can 
store C-style pointer on JS Objects. You could create an object and store 
your BIGNUM pointer in it. Then pass the object around in your C++ or JS 
code. Then when you need your pointer back, cast it to BIGNUM and use it. 
Casting to BIGNUM can be an unsafe operation as you have no practical 
guarantee that the memory it points to has not been deallocated. But hey, 
I'm just opening doors.

hope this helps.


On Friday, 22 August 2014 03:45:44 UTC+2, [email protected] wrote:
>
> I’ve been asked to look at cleaning up issues that concern the way the 
> native C++ code in one module interacts with the native C++ code in another 
> module. 
>
> The module dependency tree is like this:
>
> App -> Module B -> Module A -> node.js
>
> Module A has a standard C++ class with the normal V8 / node.js API 
> bindings so that JavaScript code in Module B can call it via the 
> “require('foo')” primitive etc. 
>
> My problem is that there is JavaScript code in Module B that calls native 
> code in Module A and native code in Module B. All this works fine, but 
> there is a very expensive conversion process when data from the native code 
> in A has to be supplied to the native code in B.
>
> The crazy thing is that the data that needs to be transferred is actually 
> defined in the native code in node.js itself (a BIGNUM in the OpenSSL 
> crypto library). So the current process is to get the native code in Module 
> A to convert the BIGNUM to a Buffer, this is then passed to the native code 
> in Module B which immediately turns it back into a BIGNUM. 
>
> So I started to look at the how I could get the native code in Module B to 
> directly interact with the native code in Module A (in just the same as 
> both modules interact, for example, with the OpenSSL code in node.js). 
>
> I’m very new to all this, but it would seem that because of the way npm 
> builds things. The native code in the two modules end up being compiled 
> separately and placed in different “.node” files.
>
> So my questions are:
>
> 1, Is there a way for the code in Module B to get at the run-time linkage 
> information after Module A has been loaded?
> 2, If not, what is the recommended way to sort his out. The only thing 
> that comes to my mind is to abandon the nice modularity, remove Module A 
> altogether, and cut/paste the code directly into Module B, which would be 
> rather sad.
>
> Thanks in advance….
>

-- 
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/dde173bc-59c0-45ee-94df-f850e99f0015%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to