[cffi-devel] [PATCH] fix with-foreign-slots

Stelian Ionescu stelian.ionescu-zeus at poste.it
Wed Dec 6 23:17:24 UTC 2006


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

-- 
(sign :name "Stelian Ionescu" :aka "fe[nl]ix"
      :quote "Quidquid latine dictum sit, altum sonatur.")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20061207/4c978c83/attachment.sig>


More information about the cffi-devel mailing list