bytedeco/javacpp

Problem with enum with function as a value

Open

#614 opened on 2022年10月11日

GitHub で見る
 (4 comments) (0 reactions) (0 assignees)Java (620 forks)batch import
bughelp wanted

Repository metrics

Stars
 (4,279 stars)
PR merge metrics
 (30d に merged PR はありません)

説明

I've got stuck with such cpp enum:

enum MyErrorResponse_ErrorCode {
  MyErrorResponse_ErrorCode_kServerError = 0,
  MyErrorResponse_ErrorCode_kOk = 1,
  MyErrorResponse_ErrorCode_ErrorResponse_ErrorCode_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<std::int16_t>::min()
};

It's parsed to

public enum MyErrorResponse_ErrorCode {
  MyErrorResponse_ErrorCode_kServerError(0),
  MyErrorResponse_ErrorCode_kOk(1);
  MyErrorResponse_ErrorCode_ErrorResponse_ErrorCode_INT_MIN_SENTINEL_DO_NOT_USE_(MyErrorResponse_ErrorCode_ErrorResponse_ErrorCode_INT_MIN_SENTINEL_DO_NOT_USE_());

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

The problem is with MyErrorResponse_ErrorCode_ErrorResponse_ErrorCode_INT_MIN_SENTINEL_DO_NOT_USE_. I've tried to replace std::numeric_limits<std::int16_t>::min() to specific value with javaText or just skip it, but failed. How it can be fixed?

コントリビューターガイド