bacardi icon indicating copy to clipboard operation
bacardi copied to clipboard

Can not use IDL long type as return type.

Open romandev opened this issue 8 years ago • 4 comments

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.

romandev avatar Oct 08 '17 07:10 romandev

@corona10 Are u interested in this issue?

romandev avatar Oct 08 '17 07:10 romandev

Sure!

corona10 avatar Oct 08 '17 07:10 corona10

Are you working on this? If not so, I can take this issue.

romandev avatar Oct 20 '17 17:10 romandev

@romandev It might be better.

corona10 avatar Oct 21 '17 03:10 corona10