I'm attempting to wrap a C++ function that takes an object as an input so that it's accessible via Nodejs. Here's a trivial example to show what I'm trying to do.
Suppose in C++,
struct query {
string m_foo;
string m_bar;
query(string foo, string bar)
:m_foo(foo), m_bar(bar) {}
}
static string ExecuteQuery(query q); // Implemented somewhere
In Javascript (node.js) I want to be able to do,
var q = new plugin.query("foo", "bar");
var result = plugin.ExecuteQuery(q);
All of the nodejs C++ plugin examples I've found are working with simple data types and fairly trivial examples. Are there any good examples or patterns for doing something like this? With the lack of v8 documentation and cumbersome/verbose syntax of making plugins, I haven't had much luck with this on my own.
Needed,
- Ability to create C++ objects in Javascript
- Ability to pass those objects to methods or static functions that need them via Javascript
Also, is there anything better than v8-juice/cvv8 for trying to simplify the process of wrapping C++ libraries so they're accessible via node.js?