I have a SDK from a third party. I don't have the source code, just the headers, dll and lib files. This SDK provides C APIs to communicate with a device through USB. I'd like to use this SDK in Javascript.
I've search on this topic and there are a few approaches. However, based on my understanding, each of them has some difficulties to be readily applied to my situation:
- emscripten - require all source code to be compiled into bitcode, which I don't have. And it also has limitations on what c++ code can be successfully parsed.
- SWIG - has some known issues that are non-trival. E.g., long long is not supported, Javascript callbacks are not supported (I don't understand about this one, does this mean the js code that calls the c/c++ lib cannot use callback function?)
- Node gyp - seems you have to be familiar with the V8 source and several other libs before you can get it done.
- WebIDL - not quite sure about what its about, how much effort it requires to get it work, if it's possible at all.
Any thoughts/suggestions are welcome!
Edit 1: the context is that I'd like to get that data from the device into a browser, or a stand-alone node-webkit app. Similar to the use case that to get geolocation info in a browser. In general, I don't think my question (use C++ component with JS) is a bizaare idea. For example, Mozilla developed lots of XPCOM components in C++, then wrapped with XPConnect so that those components can be used by Javascript in Firefox, or an XUL project. But this approach is very labor intensive and put too much dependencies on Mozilla's toolchain. Node js looks like a promising alternative. Node-webkit is essentially doing the same thing as XUL: help building/running a cross-platform GUI app based on browser.
long long. I've used it years ago on a Python/C++ project. It can support literally any time if you write type maps, but I believe there is native support as well. Callback in your case means the c++ code calling JS code.