Search code examples
v8

Return structure as object


I'm attempting to write a Node.js binding for a C++ library. The main function that I'm trying to bind returns a custom struct which contains nodes that would need to be accessible as an object on the JavaScript side.

So here is what I've tried:

String::Utf8Value value(args[0]);
CustomOutput *output = output_parse(*value);
gumbo_destroy_output(&kCustomDefaultOptions, output);

return scope.Close(Object::New(output));

Which doesn't work because Object isn't a primitive type, right? So how do you then convert it?


Solution

  • Nevermind, bindings have already been made for Node.js, which you can see here.