there's a problem with WITH-FOREIGN-SLOTS that shows up when a c-struct is defined in one package and used from another one. here's an example:
(in-package :cl-user)
(defpackage :internals (:use :cl :cffi))
(defpackage :mypackage (:use :cl :cffi))
(in-package :internals)
(defcstruct foo (x :int))
(in-package :mypackage)
(with-foreign-object (fooptr 'internals::foo) (with-foreign-slots ((x) fooptr internals::foo) x))
(with-foreign-slots ((x) fooptr internals::foo) x) gets expanded to
(LET ((#:PTR2455 FOOPTR)) (SYMBOL-MACROLET ((X (FOREIGN-SLOT-VALUE #:PTR2455 'INTERNALS::FOO 'X))) X))
instead of
(LET ((#:PTR2455 FOOPTR)) (SYMBOL-MACROLET ((X (FOREIGN-SLOT-VALUE #:PTR2455 'INTERNALS::FOO 'INTERNALS::X))) X)) ; ^^^^^^^^^^^
the attached patch fixes this
On Thu, Dec 07, 2006 at 12:17:24AM +0100, Stelian Ionescu wrote:
there's a problem with WITH-FOREIGN-SLOTS that shows up when a c-struct is defined in one package and used from another one. here's an example: the attached patch fixes this
this time I've attached it
On 12/6/06, Stelian Ionescu stelian.ionescu-zeus@poste.it wrote: [...]
(in-package :mypackage)
(with-foreign-object (fooptr 'internals::foo) (with-foreign-slots ((x) fooptr internals::foo) x))
(with-foreign-slots ((x) fooptr internals::foo) x) gets expanded to
(LET ((#:PTR2455 FOOPTR)) (SYMBOL-MACROLET ((X (FOREIGN-SLOT-VALUE #:PTR2455 'INTERNALS::FOO 'X))) X))
This is consistent with the way WITH-SLOTS, SLOT-VALUE, and pretty much anything that deals with symbols and consequently packages. WITH-FOREIGN-SLOTS is doing the right thing here.