Open Ambrevar opened 2 years ago
On second thought, relying on CFFI to pass any callback, including closures, may have a drawback: it seems that the CFFI callbacks are never freed. Is this a CFFI limitation?
If so, it's problematic for Nyxt because it means that lots and lots of closures would capture data that can never be freed.
The current approach on master
has the benefit of calling defcallback
only on a some 2-3 hard-coded function, and it's we do clean up after use, thus freeing the closures.
To do:
callbacks
and freed after it's called.SBCL callbacks are not freed, as far as I understand by
;;; FIXME: This call assembles a new callback for every closure,
;;; which sucks hugely. ...not that I can think of an obvious
;;; solution. Possibly maybe we could write a generalized closure
;;; callback analogous to closure_tramp, and share the actual wrapper?
;;;
;;; For lambdas that result in simple-funs we get the callback from
;;; the cache on subsequent calls.
(defmacro alien-lambda (result-type typed-lambda-list &body forms)
(multiple-value-bind (specifier lambda-list)
(parse-callback-specification result-type typed-lambda-list)
`(alien-callback ,specifier (lambda ,lambda-list ,@forms))))
Let's go for the intermediary solution then?
Yes!
Agreed on the intermediary solution.
Fixes #65.
For some reason Nyxt crashes on my machine when I load my local cl-webkit (unrelated to this change). I'll figure it out next week.
Feel free to test @aartaka
To do:
can-execute-command-checked
andmessage-replied-to
.uri-scheme-processed
callback and adapt the code.