Closed Ambrevar closed 4 years ago
I am not even sure this is possible to do in generic way.
But you can do it in your code. Here you can find inspiration and hints how to do this. Idea is that you have global hash table with lambdas and single callback which uses that table to dispatch call.
This could do it, thanks.
Out of curiosity, why is it different from gir:connect
which can take
a lambda?
gir:connect
works with GObject signals. They allow to pass GClosure -- data structure designed for representing functions and for marshaling/unmarshaling arguments/results.
Makes sense, thanks!
I'm trying to run some javascript in a web view. The following works:
But having to define the callbacks in advance is not very convenient. It also makes the passing of user data a bit cumbersome compared to closures.
Is there a way to use a lambda instead, as with
gir:connect
? Ideally, I'd like to write something like the following:(Note that there would be no need for the last
(cffi:null-pointer)
argument ofgir:invoke
.)