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

jnaerator (with BridJ) generates code that uses reserved keywords as enum names #334

Closed
siamak-haschemi opened this issue Sep 2, 2012 · 2 comments

Comments

@siamak-haschemi
Copy link

The following C-code

typedef enum {false=0, true=1} boolean;

produces following Java-Code:

...
    /// enum values
    public enum boolean implements IntValuedEnum<boolean > {
        false(0),
        true(1);
        boolean(long value) {
            this.value = value;
        }
        public final long value;
        public long value() {
            return this.value;
        }
        public Iterator<boolean > iterator() {
            return Collections.singleton(this).iterator();
        }
        public static IntValuedEnum<boolean > fromValue(int value) {
            return FlagSet.fromValue(value, values());
        }
    };
...

Two problems here:

  • boolean is not a valid class name
  • false and true als not valid enum-names

Instead, jnaerator should generate safe-names like below:

... 
    /// enum values
    public enum JNAErator_boolean_ implements IntValuedEnum<JNAErator_boolean_ > {
        JNAErator_false(0),
        JNAErator_true(1);
        JNAErator_boolean_(long value) {
            this.value = value;
        }
        public final long value;
        public long value() {
            return this.value;
        }
        public Iterator<JNAErator_boolean_ > iterator() {
            return Collections.singleton(this).iterator();
        }
        public static IntValuedEnum<JNAErator_boolean_ > fromValue(int value) {
            return FlagSet.fromValue(value, values());
        }
    };
...
@ochafik
Copy link
Member

ochafik commented Sep 18, 2012

Hi @siamak-haschemi ,

Thanks a lot for your report!

This is really bad, will fix asap :-)

Cheers

@ochafik
Copy link
Member

ochafik commented Oct 4, 2012

Hi @siamak-haschemi ,

Thanks for your patience, this is now fixed (a new snapshot is being uploaded as I write, should be available within an hour).

Cheers

@ochafik ochafik closed this as completed Oct 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants