I'm trying to emulate the behavior of LispWork's
DEFINE-FOREIGN-FUNCALLABLE [1] in Allegro CL 6.2. The current
definition I have is
(def-foreign-funcallable int-caller :int ((x :int)))
==>
(defun int-caller (fptr x)
(system::ff-funcall fptr ':int ':int))
But this segv's. I obtained system::ff-funcall from the macroexpansion
of def-foreign-call exhibited in the manual, but there are a few
differences I'd like to make a note of first:
;; This taken from def-foreign-call macroexpansion
(system::ff-funcall
(load-time-value
(excl::determine-foreign-address '("foo" :language :c)
2
nil))
'(:int (integer * *))
x
'((* :char)
(array character (*)))
y
'(:int (integer * *)))
As you can see, there is a lot more information here. The conversion of
:int to '(:int (integer * *)) is done by the def-foreign-call macro, for
example. Also, the return value of excl::determine-foreign-address is
something like: #("foo" 1078448336 134570392 2 1075560002)
where the function pointers I am getting are just integers (and when I
try to use ff-funcall with them, it segv's as well).
So my question basically boils down to:
(a) Is there some proper interface for this functionality that I am
missing?
(b) If not, how do I go about using what is available? Do I need to
deduce (:int (integer * *)) from :int? How do I obtain a
function pointer object suitable for ff-funcall's consumption?
Thanks
P.S. I am not sure whether I am subscribed to this list yet or not, so
please CC me on replies.
[1]
In LispWorks, this looks like,
(fli:define-foreign-funcallable int-caller ((x :int))
:result-type :int)
(int-caller (fli:make-pointer :symbol-name "IntAbs") -100)
(Drawn from KnowledgeBase article under FLI ``Implementing COM...'')
--
; Matthew Danish <andrew.cmu.edu at mdanish>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."