Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum not available in Java #51

Open
zvasicek56 opened this issue Jun 19, 2023 · 0 comments
Open

Enum not available in Java #51

zvasicek56 opened this issue Jun 19, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@zvasicek56
Copy link

Enums are not propagated to Java code.

The C++ code

 class adapter: public scapix::bridge::object<adapter>
 {
    public:

        enum class AdapterEnum : std::uint32_t
        {
            One = 1, Two
        };
        void adapter_test(AdapterEnum evt) {};
 };

is translated by the scapix generator to the following Java code:

public class Adapter extends com.scapix.Bridge
{
	public Adapter() { super(nop); _init(); }

        public native void adapterTest(int evt);
}

To address this issue, the scapix generator should generate the following code:

public class Adapter extends com.scapix.Bridge
{
	public Adapter() { super(nop); _init(); }

	public static enum AdapterEnum {
            One(1),
            Two(2);
    	      
    	    private final int value;

            AdapterEnum(final int val) {
                  value = val;
            }

   	    public int getValue() { return value; }
      }

     public native void adapterTest(AdapterEnum evt);

The nested enum AdapterEnum must be public to allow it to be used from external code.

Another option is to get the integer values from the native library but this causes more overhead.

Thank you.

@Boris-Rasin Boris-Rasin added the enhancement New feature or request label Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants