Search
Thursday, 13th of February 2020, 1:42:22 UTC
3:36:10
Lord_of_Life_
** NICK Lord_of_Life
4:23:21
beach
Good morning everyone!
4:30:49
no-defun-allowed
Good morning beach!
7:42:42
no-defun-allowed
Good morning phoe!
11:44:19
Xach
Today is a Quicklisp release day
11:46:09
Josh_2
Happy Quicklisp release day :D
11:46:18
decent-username
Xach: What exactly does that mean? Are we out of beta?
12:08:06
Xach
decent-username: i am too terse. i meant a quicklisp dist release, not a quicklisp non-beta release.
13:00:49
Cymew
Talking about that. How goes the effort to get out of beta?
13:07:51
Xach
Cymew: very very slow. there are many tasks and little progress is made.
13:08:45
Xach
I do what I can to keep updates coming, but it's been slow progress on other stuff.
13:09:12
jmercouris
I have the following code: http://dpaste.com/15ZXX2D
13:09:39
jmercouris
what I would like to do is pass the callback function from web-view-execute to be executed in js-execution-complete
13:11:02
jmercouris
I don't know how to do that though since js-execution-complete is a cffi callback
13:12:38
jmercouris
my only ideas so far are to use global state, but I don't like that
13:12:49
shka_
https://common-lisp.net/project/cffi/manual/html_node/get_002dcallback.html ?
13:13:22
jmercouris
shka_: I don't understand where you are going with this
13:13:52
shka_
jmercouris: get-callback allows you to obtain callback object from a symbol
13:15:59
Nilby
Xach: Do you have a quicklisp todo list somewhere I could help remove things from?
13:21:18
jmercouris
OK, shka_ and what will I do with the callback-object?
13:21:23
shka_
jmercouris: (cffi:foreign-funcall-pointer (cffi:get-callback 'callback-no-arguments) ())
13:21:40
jmercouris
I can't call the callback function though
13:21:57
jmercouris
it is handled by webkit2:webkit-web-view-run-javascript
13:22:12
shka_
this is function that can be called like C callback, so call it like c callback
13:22:35
jmercouris
it is like a C callback
13:22:43
jmercouris
so you are saying I can substitute my own callback functio
13:22:55
jmercouris
instead of js-execution-complete?
13:23:00
shka_
i think i don't understand this, let me read
13:23:15
jmercouris
let me try to re-explain
13:23:35
jmercouris
I have webkit-web-view-run-javascript which runs some javascript in C land, and calls js-execution-complete with the result of that javascript
13:23:48
jmercouris
I want to take that javascript result and call my OWN callback
13:23:56
jmercouris
which I specify by passing into web-view-execute
13:24:10
jmercouris
does that make more sense?
13:24:59
jmercouris
so my original way of doing this was having some global state like (defparamater callback-fn (lambda (x) (print x))) and then I'd funcall (callback-fn..) within js-execution-complete
13:25:12
shka_
ok, so i suggest to define callback with defcallback, pass it as pointer whetever it is needed, and then foreign-funcall-pointer it when it is needed
13:25:43
jmercouris
can you please explain this further for me, I'm not sure I understand
13:25:59
jmercouris
I have a defcallback already made
13:26:03
jmercouris
what is the purpose of this new one?
13:26:34
shka_
ok so you have js-execution-complete callback
13:26:45
jmercouris
and it accepts the correct number of arguments
13:26:59
shka_
and you want to call another callback within it
13:27:00
jmercouris
which will be automatically invoked by webkit-web-view-run-javascript WHEN the javascript has completed evaluation
13:27:08
jmercouris
I want to call my own custom callback within it
13:27:21
jmercouris
I want it to be a simple lisp function that accepts one argument
13:27:28
jmercouris
(defun my-callback (x) (print x))
13:27:50
shka_
ok, so typically C APIs work by passing void* pointers holding arbitrary state
13:28:03
jmercouris
I'm not sure, I don't remember the API
13:29:04
shka_
https://lazka.github.io/pgi-docs/WebKit2-4.0/classes/WebView.html#WebKit2.WebView.run_javascript
13:29:10
shka_
jmercouris: it appears to be the case
13:29:25
jmercouris
so the last argument is user data
13:29:28
shka_
therefore i recommend to pass another callback as your user data
13:29:41
jmercouris
I can pass a lisp function as my void*?
13:29:43
shka_
and the call it as you would do with a C code
13:29:46
jmercouris
that will work ? and it won't lose its mind?
13:29:50
Nilby
You'd have to name it an pass the name as a string or something, because the callback is in lisp isn't in C memory, so you can't just put it in a void*
13:30:07
jmercouris
so I could pass the symbol string value or so?
13:30:12
jmercouris
what if it is a lambda
13:30:15
shka_
jmercouris: you can pass pointer to callback defined with defcallback
13:30:28
shka_
and the pointer can be obtained with (get-callback ...)
13:30:31
jmercouris
shka_: say that again?
13:31:20
jmercouris
so I can do (get-callback (lambda (xyz) (print xyz)))?
13:31:42
jmercouris
I must always use defcallbackk
13:31:55
shka_
ok, so i am saying that I recommend to rewrite your lisp function callback to cffi callback, pass pointer to it as user data and call it as C function
13:32:04
shka_
which i demonstrated above
13:32:24
jmercouris
I'm not the only user of this function
13:32:31
jmercouris
and I can't expect everyone to write CFFI callbacks
13:32:47
jmercouris
is there a way to transform the lisp function transparently to a CFFI callback?
13:33:28
jmercouris
I was hoping to be able to use a closure or something, anything
13:33:44
jmercouris
you know it's OK, I'll think about it for a bit and get back to this later
13:33:57
jmercouris
some times these things just need time to settle
13:34:28
jmercouris
In the worst case I'll go back to a global hash table of callback IDs... :-D
13:34:52
jmercouris
or maybe I extend wekit-webview-run-javascript so that it is not obvious that is what is happening :-P
13:35:13
shka_
yeah, i really don't know, i never quite figure out what is the best way to pass lisp objects to C
13:36:17
Nilby
Symbols are already a hash table, so if you just name it you get it back.
13:37:57
jmercouris
which does not allow for lambdas
13:38:11
jmercouris
then again, I might make a macro that transparently gensym or something
13:38:42
Nilby
Yes. You can gensym, and even put in a separate package if you want.
13:39:12
jmercouris
that's an interesssante idea
13:39:25
jmercouris
I'll play with that later
13:41:08
decent-username
Is there a variable you can set to disable "Sort slots alphabetically" inside the *slime-inspector*?
13:41:27
decent-username
Or rather: I know that such a variable exists. How do I figure out it's name?
13:41:55
decent-username
currently I always have to uncheck that box whenever I inspect an object.
Thursday, 13th of February 2020, 13:42:22 UTC