kalwalt / webarkit-jsfeat-cpp

c++ jsfeat version
GNU Lesser General Public License v2.1
6 stars 3 forks source link

warning: non-void function does not return a value in all control paths [-Wreturn-type] } #20

Open kalwalt opened 2 years ago

kalwalt commented 2 years ago

The shown errror occur in the matrix_t class https://github.com/kalwalt/webarkit-jsfeat-cpp/blob/8ab7aab2917211ce904320334d3459232d0c503c/src/matrix_t/matrix_t.h#L128-L153 because the return view is not at the end of the statement. This should be fixed.

kalwalt commented 2 years ago

if i change that part of the code to this:

#ifdef __EMSCRIPTEN__
  emscripten::val getData() const {
    emscripten::val view;
    if (type == Types::U8_t) {
      view(emscripten::typed_memory_view(u8.size(), u8.data()));
      auto result = emscripten::val::global("Uint8Array").new_(u8.size());
      result.call<void>("set", view);   
    } else if (type == Types::S32_t) { 
      view(emscripten::typed_memory_view(i32.size(), i32.data()));
      auto result = emscripten::val::global("Int32Array").new_(i32.size());
      result.call<void>("set", view);
    } else if (type == Types::F32_t) {
      view(emscripten::typed_memory_view(f32.size(), f32.data()));
      auto result = emscripten::val::global("Float32Array").new_(f32.size());
      result.call<void>("set", view);
    } else if (type == Types::F64_t) {
      view(emscripten::typed_memory_view(f64.size(), f64.data()));
      auto result = emscripten::val::global("Float64Array").new_(f64.size());
      result.call<void>("set", view);
    }
    return view;
  }
#endif

The matrix_t class can not output data, see this error message:

jsfeatES6cpp_debug.js:3609 Uncaught TypeError: Cannot read properties of undefined (reading 'apply')
    at __emval_call (jsfeatES6cpp_debug.js:3609:23)
    at emscripten::val emscripten::val::internalCall<emscripten::_EM_VAL* (*)(emscripten::_EM_VAL*, unsigned int, void const* const*, void const*), emscripten::memory_view<unsigned char>>(emscripten::_EM_VAL* (*)(emscripten::_EM_VAL*, unsigned int, void const* const*, void const*), emscripten::memory_view<unsigned char>&&) const (00b023b6:0x29302)
    at emscripten::val emscripten::val::operator()<emscripten::memory_view<unsigned char>>(emscripten::memory_view<unsigned char>&&) const (00b023b6:0x107e7)
    at jsfeat::matrix_t::getData() const (00b023b6:0x6569)
    at emscripten::_EM_VAL* emscripten::internal::GetterPolicy<emscripten::val (jsfeat::matrix_t::*)() const>::get<jsfeat::matrix_t>(emscripten::val (jsfeat::matrix_t::* const&)() const, jsfeat::matrix_t const&) (00b023b6:0x6bf8)
    at matrix_t.get [as data] (jsfeatES6cpp_debug.js:2941:55)
    at matrix_t_test.html:17:34
__emval_call @ jsfeatES6cpp_debug.js:3609
$emscripten::val emscripten::val::internalCall<emscripten::_EM_VAL* (*)(emscripten::_EM_VAL*, unsigned int, void const* const*, void const*), emscripten::memory_view<unsigned char>>(emscripten::_EM_VAL* (*)(emscripten::_EM_VAL*, unsigned int, void const* const*, void const*), emscripten::memory_view<unsigned char>&&) const @ 00b023b6:0x29302
$emscripten::val emscripten::val::operator()<emscripten::memory_view<unsigned char>>(emscripten::memory_view<unsigned char>&&) const @ 00b023b6:0x107e7
$jsfeat::matrix_t::getData() const @ 00b023b6:0x6569
$emscripten::_EM_VAL* emscripten::internal::GetterPolicy<emscripten::val (jsfeat::matrix_t::*)() const>::get<jsfeat::matrix_t>(emscripten::val (jsfeat::matrix_t::* const&)() const, jsfeat::matrix_t const&) @ 00b023b6:0x6bf8
get @ jsfeatES6cpp_debug.js:2941
(anonymous) @ matrix_t_test.html:17
kalwalt commented 2 years ago

This code instead seems to works:

#ifdef __EMSCRIPTEN__
  emscripten::val getData() const {
    auto result = emscripten::val::null();
    if (type == Types::U8_t) {
      emscripten::val view{ emscripten::typed_memory_view(u8.size(), u8.data()) };
      result = emscripten::val::global("Uint8Array").new_(u8.size());
      result.call<void>("set", view);
    } else if (type == Types::S32_t) {
      emscripten::val view{ emscripten::typed_memory_view(i32.size(), i32.data()) };
      result = emscripten::val::global("Int32Array").new_(i32.size());
      result.call<void>("set", view);
    } else if (type == Types::F32_t) {
      emscripten::val view{ emscripten::typed_memory_view(f32.size(), f32.data()) };
      result = emscripten::val::global("Float32Array").new_(f32.size());
      result.call<void>("set", view);
    } else if (type == Types::F64_t) {
      emscripten::val view{ emscripten::typed_memory_view(f64.size(), f64.data()) };
      result = emscripten::val::global("Float64Array").new_(f64.size());
      result.call<void>("set", view);
    }
    return result;
  }
#endif

All examples works as expected, only the mixed orb example not create feature points nor can detect. It should be checked if it is caused by these changes or some changes before.

kalwalt commented 2 years ago

I checked and seems strange to me but it is caused by this code. Can not understand why...

kalwalt commented 2 years ago

Different result on different browsers, for example now chrome not load the script code maybe is something wrong with the js/html code ( a bit outdated...). I will try again in another moment.