[Ecls-list] Subject: callbacks to ecl
Naveen Garg
naveen.garg at gmail.com
Wed Apr 22 08:34:00 UTC 2009
Hi,
I am able to use foreign-funcall-pointer to call an ecl callback from within
ecl. However, I get a memory access violation when I use the same pointer
to callback from within a dll loaded into ecl. Does anyone else have the
same issue calling into lisp from c? This technique works fine from sbcl
for me. I tried defining the ecl callbacks without using cffi, but got
similar problems.
I am using the *win32*-msvc-*stable git branch compiled with threads enabled
on windows xp using msvc 2008
bit branch by **Samium Gromoff *
although when i startup ecl, it still says this outdated message:
ECL (Embeddable Common-Lisp) 0.9l (CVS 2008-07-12 18:54)
Thanks,
Naveen
Here is the ecl-code:
(in-package :cffi)
(load-foreign-library "AutoHotkey.dll")
(defvar *ahk* "")
(defcallback sbclHotkey
:int
((x :string))
(progn
(print x)(print " recieved from dll")
0))
(setf sbclHotkeyP (format nil "~d" (pointer-address (callback sbclHotkey))))
(defcfun "ahkdll"
:int
(file :string) ; ahk script to launch
(p :string) ; pointer to sbclHotkey callback
(q :string) ; pointer to sbclHotkey callback
)
(defcfun "ahkgetvar"
:string
(varname :string) )
(ahkdll "clinit.ahk" "" sbclHotkeyP)
(setf *ahk* (ahkgetvar "ahkCallBack"))
(foreign-funcall-pointer (make-pointer (read-from-string *ahk*)) ()
:string "Execute, Hotkey, !g, sbclHotkey" :int)
; a hotkey is registered, but the callback fails
(foreign-funcall-pointer (make-pointer (pointer-address (callback
sbclHotkey)))()
:string "test" :int)
; this works, but its from within ecl.
the ahk side of the code is available here:
http://github.com/tinku99/ahklisp/tree/master
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20090422/86ec042d/attachment.html>
More information about the ecl-devel
mailing list