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
Address some limitations of delegates and callbacks #11333
Conversation
Now it would be possible to go a step further with this and remove the need for resolve on callbacks altogether, but that would mean moving the default return value to the constructor arguments rather than setting it in device_start. However, it would reduce total line count and avoid possible confusion between callback and device delegate resolve semantics. I like this idea a lot. Combine it with requiring the default value to be explicitly set (I also don't like the default zero) and I think it's a winner. |
I’ll separate the device delegate part since that isn’t controversial anyway. Then I can mess around with getting rid of |
I don't think there's anything controversial in there, only cool stuff. One thing I would find nice, if you go and tweak all devdb constructors, is to add a name to them. Multiple times I would have liked a gtkwave-like display of live devcbs in the debugger (for instance to debug adb) but without naming it's impractical. |
Sorry, named devcbs aren’t going to make it this time. I’ll put it on my TODO list. |
No worries :-) |
I love the named devcbs idea, but it's fine to wait on that too. |
Read callbacks now need a default return value supplied at constrcution. Replaced isnull() with isunset() which tells you if the callback wasn't configured rather than whether it isn't safe to call. Enabled validation of device callbacks (it seems it was disabled at some point, probably accidentally). Device callbacks and object finders now implement the same interface for resolution.
…edev#11333) Read callbacks now need a default return value supplied at construction. Replaced isnull() with isunset() which tells you if the callback wasn't configured rather than whether it isn't safe to call. Enabled validation of device callbacks (it seems it was disabled at some point, probably accidentally). Device callbacks and object finders now implement the same interface for resolution.
…edev#11333) Read callbacks now need a default return value supplied at construction. Replaced isnull() with isunset() which tells you if the callback wasn't configured rather than whether it isn't safe to call. Enabled validation of device callbacks (it seems it was disabled at some point, probably accidentally). Device callbacks and object finders now implement the same interface for resolution.
) Fixes handlers not being called after e9c1f4a (GitHub PR mamedev#11333).
This is mostly a response to comments from @rb6502 and @galibert. This is split up into three commits to make it a bit easier to see what’s going on:
The big change answers the question, “Why does devcb have
resolve
as well asresolve_safe
?” by making removing them both altogether. This entails a number of changes:isnull()
accessor and cast tobool
operator have been removed.isunset()
accessor that tells you if the callback wasn’t configured, even when it’s callable after being resolved.I can think of arguments against this:
resolve
you need to check that the callback is configured every time. With this change you play fast and loose.isunset
every time and do something different if they aren’t configured.This does make the code tidier, though:
device_resolve_objects