-
-
Notifications
You must be signed in to change notification settings - Fork 482
Closed
Description
I have been messing around with objects and functions.
Napi::Value position(const Napi::CallbackInfo& info) {
float* a = (float*) info.Data();
return Napi::Number::New(info.Env(), a);
}
void myClass::getStuff(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
float* a = new float(As<Napi::Number>().FloatValue());
Napi::Function cb = info[3].As<Napi::Function>();
auto function1 = Napi::PropertyDescriptor::Function("function1", function1, napi_default, a);
Napi::Object obj = Napi::Object::New(env);
obj.DefineProperties({ function1 });
cb.Call(env.Global(), { obj });
}
When I try to call function1 in javascript, I get nothing. I was able to verify that (int*) info.Data() returns nullptr even though I passed a pointer to an integer on the heap. Am I doing this wrong? How should I approach this?
Metadata
Metadata
Assignees
Labels
No labels