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….