-
Notifications
You must be signed in to change notification settings - Fork 2
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
Interface abstraction #28
base: main
Are you sure you want to change the base?
Interface abstraction #28
Conversation
Key changes of this pull request so far:
|
Why did you replaced SaneHandle with a simple int? I prefer the class encapsulation of that concept. |
558a0d7
to
bd6eb2b
Compare
72364d3
to
40d1495
Compare
40d1495
to
cd76013
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little nitpicks :)
Sorry for the delay, I was too busy...
Uint8List read({required int bufferSize}) { | ||
_checkIfDisposed(); | ||
|
||
final handle = _handle ??= _open(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe create a _handleOrOpen
method/getter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, because the behavior is already so apparent (_handle ??= _open()
= "if handle is not null, return handle, otherwise open new handle"), it wouldn't bring much benefit other than it being an explicit method call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you want to combine _open() and this behavior, then maybe we could do that, other than that, I don't see much reason. Happy to discuss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I totally forgotten your PR... too busy 😓
What I mean is to remove this line duplicated in almost each function:
- final handle = _handle ??= _open();
- dylib.sane_function(handle);
+ dylib.sane_function(_handleOrOpen);
The goal is just to make the code less verbose.
And yes, this could be merged with open, or inside a dedicated getter/method 🤔
Resolves #18
Resolves #23