Skip to content

[BUG] enum class xyz: bool not correctly parsed #388

@razajafri

Description

@razajafri

Javacpp is not translating the cpp boolean enums correctly. Here is the enum defined in cpp

enum class null_order : bool {
  AFTER,  ///< NULL values ordered *after* all other values
  BEFORE  ///< NULL values ordered *before* all other values
};

without info.enumerate() it gets translated to

public static final boolean
  /** NULL values ordered *after* all other values */
  AFTER = 0,
  /** NULL values ordered *before* all other values */
  BEFORE = 1;

with enumerate() the following is the output.

@Namespace("cudf") public enum null_order {
  /** NULL values ordered *after* all other values */
  AFTER(0),
  /** NULL values ordered *before* all other values */
  BEFORE(1);

    public final boolean value;
    private null_order(boolean v) { this.value = v; }
    private null_order(null_order e) { this.value = e.value; }
    public null_order intern() { for (null_order e : values()) if (e.value == value) return e; return this; }
    @Override public String toString() { return intern().name(); }
}

In both cases it is trying to assign an int value to a boolean. How can we get this to correctly generate the code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions