Search code examples
firefoxxpcomjsctypes

js-ctypes: load a nsISupports from a Windows DLL


Is it possible to use js-ctypes to call a Windows DLL and have it return a nsISupports instance? The Windows DLL does XPCOMGlue, but by not needing NSModule I hope I can improve the registration process. I was hoping there was a ctypes.nsISupports type defined to use as return value, so if it's possible, how do I declare the call?


Solution

  • From my reading and experimentation, no, it doesn't look like you can. However, you could do the next best thing.

    1. Create a win32 DLL exporting plain "C" symbols.

    2. Create a "wrapper" XPCom component using JavaScript.

    http://kb.mozillazine.org/Implementing_XPCOM_components_in_JavaScript

    3. Plumb each plain "C" function exported by the DLL into the JavaScript object.

    Possible improvement: create a generic JavaScript shim that does the plumbing automatically.