Can not use IDL long type as return type.
In the current implementation, we can not use IDL long type as return type. If we add some test method returning long type, the following build error occurs.
.././core/js_type_traits.h:25:10: error: no viable conversion from returned value of type 'long' to function return type 'Napi::Value'
return T();
^~~
Release/obj/gen/test/test_interface_bridge.cc:286:10: note: in instantiation of function template specialization 'JSTypeTraits<long>' requested here
return JSTypeTraits(info.Env(), return_value);
^
/Users/zino/bacardi/node_modules/node-addon-api/napi.h:118:9: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'long' to 'const Napi::Value &' for 1st argument
class Value {
^
/Users/zino/bacardi/node_modules/node-addon-api/napi.h:118:9: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'long' to 'Napi::Value &&' for 1st argument
1 error generated.
The above error is because there is no template-specialization for long type in JSTypeTraits. So, if we add the specialization, it works. But it's not a right way I think. The long type's range might be changed in C++ side depending on each platform. So, we should find a better way to map explicit range type such as int32_t.
@corona10 Are u interested in this issue?
Sure!
Are you working on this? If not so, I can take this issue.
@romandev It might be better.