Re: deref-array types
Cyrus Harmon <ch-uffi-dl6SmSK5uza1Z/[email protected]> Mon, 7 Feb 2005 08:36:55 -0800
| Newsgroups | gmane.lisp.uffi.devel |
|---|---|
| Message-ID | <[email protected]> |
Ok, then this fails on openmcl:
(defun test-deref-array ()
(let ((fa (uffi:allocate-foreign-object :int 32)))
(dotimes (i 32)
(setf (uffi:deref-array fa '(* :int) i) (* i i)))
(dotimes (i 32)
(print (uffi:deref-array fa '(* :int) i)))))
I get the following error message:
value 0 is not of the expected type MACPTR.
[Condition of type TYPE-ERROR]
Restarts:
0: [RETRY-LOAD] Retry loading "bootstrap.cl"
1: [SKIP-LOAD] Skip loading "bootstrap.cl"
2: [LOAD-OTHER] Load other file instead of "bootstrap.cl"
3: [ABORT] Abort handling SLIME request.
4: [ABORT-BREAK] Reset this process
5: [ABORT] Kill this process
Backtrace:
0: (FFI-TEST::TEST-DEREF-ARRAY)
1: (CCL::CALL-CHECK-REGS 'FFI-TEST::TEST-DEREF-ARRAY)
If I change the type in the deref-array to :int, it works as expected.
For SBCL, it's ignored, so both ways work fine.
Furthermore, 18 of the 61 tests in the UFFI test suite fail on OpenMCL.
I can't be the first one to have run this. Has anyone else seen this?
Thanks,
Cyrus
On Feb 7, 2005, at 7:53 AM, Kevin Rosenberg wrote:
>
> Cyrus Harmon wrote:
>> The UFFI manual says that deref-array takes a type argument and that
>> this is the "foreign type of the array". The example given uses the
>> def-array-pointer function to generate the type that is used. I was
>> trying to make this work in OpenMCL and, while I could have sworn this
>> stuff was working before, in order to get it working again I had to
>> change my deref-array calls to not the array type, but the type of the
>> elements contained in the array, e.g.:
>>
>> (uffi:deref-array ,lengths :int ,isym)
>>
>> instead of
>>
>> (uffi:deref-array ,lengths (* :int) ,isym)
>
> (uffi:deref-array ptr '(* :int) pos)
>
> is correct.
>
> Look at the examples in the test suite:
>
> $ grep deref-array tests/*.lisp
>
> --
> Kevin Rosenberg
> kevin-HJRc7zDS/[email protected]