bytedeco / javacpp

The missing bridge between Java and native C++
Other
4.46k stars 581 forks source link

Enum class dealing problem #688

Closed carlostp12 closed 1 year ago

carlostp12 commented 1 year ago

I want to report you a problem we encountering dealing with a pointer to an enum class, the code we have is like

void foo(Session & sess, ..., const Bar* bar);

where Bar is

enum class Bar : uint16_t{ VALUE1= 1, ... }

in Java part (javacpp) is translated to something like

pubic static native foo( @ByRef Session session, ... Bar bar)

It seems ignoring the pointer and the const specifiers. Also it is generating not compiling cpp code due to this dismatch of the pointer and value type. Is there a way to deal with this situation?

Thanks!

saudet commented 1 year ago

It's not possible to use a Java enum for pointers. In this case we need something like @Cast("Bar*") ShortPointer and/or @Cast("Bar*") short[].

carlostp12 commented 1 year ago

Hello Samuel, we implemented your first suggestion using the ShortPointer and it worked! Thanks a lot , we appreciate it.

saudet commented 1 year ago

I thought you hit a bug maybe so that's why I asked you to open an issue here, but in general you can ask questions on Gitter, that's fine. Thanks!