We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Related to #446. Given the following C code:
typedef enum { ok = 1, error = 2, } Status; Status getStatus() { return ok; } int getValue(Status status) { if (status == ok) return 1; else return 2; }
ffigen will generate the following Dart code:
enum Status { ok(1), error(2); final int value; const Status(this.value); } // ... int getStatus() { return _getStatus(); } int getValue(int status) { return _getValue(status); }
So it's still returning an integer. I think it should instead generate something like:
enum Status { // ... static Status fromValue(int value) => switch (value) { 1 => Status.ok, 2 => Status.error, _ => throw ArgumentError("Invalid value for Status: $value"), }; } // ... Status getStatus() { return Status.fromValue(_getStatus()); } int getValue(Status status) { return _getValue(status.value); }
cc @dcharkes and @eernstg from the previous discussions. PR at #1202
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Related to #446. Given the following C code:
ffigen will generate the following Dart code:
So it's still returning an integer. I think it should instead generate something like:
cc @dcharkes and @eernstg from the previous discussions. PR at #1202
The text was updated successfully, but these errors were encountered: