For context, I started with this question. I need to call the callback for the emitter in another thread. I made a minimal example but it segfaults on emit.Call({cb, result}); My first instinct is that I have a problem with the lifetimes of env or…
I'm making a Node add-on to expose some functions from libmpg123 to Javascript. Specifically I need to somehow pass back a pointer to a out123_handle object to javascript, which is produced from out123_new. The examples do not mention passing back a…
i have this function in dll
static COMMANDERDLL_API int InsertCodeBar(const char* pszBuffer);
in my node addon i have this function
void InsertCodeBarWrapper(const FunctionCallbackInfo& args){
Isolate* isolate = args.GetIsolate();
…
I am using NAN for including a c++ library in node.js. I understand how to pass numbers and strings back and forth between the two, but I don't understand how to pass arrays. What I would like to do is something like this:
index.js
var test =…
I've found that *v8::String::Utf8Value(args[0]->ToString()) returns the proper string on node 0.8.2 32-bit and does not return the proper string on node 0.8.8 64-bit.
does anybody understand why?
My node.js addon looks like this:
#define…
I'm currently looking for C++ add-ons with node-gyp.
node-gyp configure works fine, but node-gyp build gives an error with
error C2661: 'v8::Value::ToNumber': no overloaded function take 0 parameter.
There are some warnings about deprecated, and…
I have difficulties to understand how to correctly use HandleScope and EscapableHandleScope. For example, from this Node example:
MyObject::MyObject(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info) {
Napi::Env env = info.Env();
…
I am trying to create a basic native node addon where a javascript array is passed from node and then processed in c++. The problem is I cannot figure out how to correctly pass the array. I can instantiate the array without issue but assigning it…
I try to configure & build a node.js C++ addon with this
binding.gyp file:
{
"targets": [
{
"target_name": "addon",
"sources": [ "addon.cpp" ],
"cflags": [
"-std=c++17"
]
}
]
}
But when I run…
I'm writing an addon for Node.js using N-API (the C interface, not to be confused with the node-addon-api C++ wrapper around N-API) which receives JSON-formatted data from an external source and needs to execute a JS callback function on its object…
I’m building a node-module wrapper for a C++ library to pass logging information through Nan to JavaScript. For this a NAN_Method is available to register a callback. The callback handler has to register itself as a callback at the C++ library via…
I was writing C++ Addon for Node.js. Tried to use sample library called libSample.so which has declaration of function printHello:
void printHello() {
std::cout << "Hello World\n";
}
It worked fine.(Compiled using node-gyp configure build and…
Imagine that I use a synchronous function, from my Node.js addon:
var check_ok = addon.my_function(parameters);
var final_results = addon.final_function(parameters);
But in the method code I have:
std::thread t[10]; //Global
//...
void…
The v8::FunctionCallbackInfo class distinguishes between This and Holder. I know what this is in JavaScript, and assume that This reflects that setting. But I have only a vague notion of what Holder is, and very little idea as to when I should use…
I'm trying to use nan in order to calculate something on an array of floats in an add-on and then return it as a Float32Array.
But while the args have IsNumber() and NumberValue()functions it only has a IsFloat32Array() function and no…