-
Notifications
You must be signed in to change notification settings - Fork 28
All set_*_callback now return the cffi function wrapper #4
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
Conversation
This makes it easy to reuse wrapped python functions in other C code.
|
Is it possible that the two functions you are using ( |
|
You're right, the set_*_functions returning cffi function pointers are only necessary when you want to pass the same functions along to other cffi stuff. All i'm trying to do is avoid duplicating the wrapping/reference saving from |
|
So what about returning the cdata only in |
|
Abandoning this, I changed my code to not need this, the cffi stuff could be used directly if really needed. |
|
Wow, I find the idea of using How did you come up with this? Is this a common idiom? I was thinking about using this idiom in the examples, but the presence of the |
It's a nice idea, you just need to keep in mind that using it as a decorator will eat the original function(the way stuff is right now). You would have to return the register_callback argument(the callback itself) for all of the functions that you have(similar to how i wanted to do it with the cffi versions of the callbacks).
The way i had them totally failed. You can't decorate instance methods easily since at decoration time self is not known, so it will actually register a 2 parameter function ([self, msg] instead of just [msg]). You can use this pattern in your examples just fine, chatty_client.py should work perfectly.
|
|
Another way that jackclient could deal with all these callback setters is just with inheritance: Designing jack_client to work this way would not necessary be backwards incompatible, the |
|
Thanks for the comments regarding decorators. I don't like the solution with inheritance, though. More importantly, I think there is even a quite bad disadvantage, since all callbacks are called, even if they are empty functions. At least for the process callback, this adds unnecessary overhead. |
This makes it easy to reuse wrapped python functions in other C code.
This is to prevent the keepalive savings, and to make the code neater looking.
Old discussions: amstan@1d1db6f