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

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


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

-- 
(sign :name "Stelian Ionescu" :aka "fe[nl]ix"
      :quote "Quidquid latine dictum sit, altum sonatur.")
-------------- next part --------------
--- old-cffi/src/types.lisp	2006-12-05 01:12:07.000000000 +0100
+++ new-cffi/src/types.lisp	2006-12-05 01:12:07.000000000 +0100
@@ -452,11 +452,14 @@
 (defmacro with-foreign-slots ((vars ptr type) &body body)
   "Create local symbol macros for each var in VARS to reference
 foreign slots in PTR of TYPE.  Similar to WITH-SLOTS."
-  (let ((ptr-var (gensym "PTR")))
+  (let ((ptr-var (gensym "PTR"))
+        (type-package (symbol-package type)))
     `(let ((,ptr-var ,ptr))
        (symbol-macrolet
            ,(loop for var in vars
-                  collect `(,var (foreign-slot-value ,ptr-var ',type ',var)))
+               for true-slot = (intern (string-upcase (symbol-name var))
+                                       type-package)
+               collect `(,var (foreign-slot-value ,ptr-var ',type ',true-slot)))
          , at body))))
 
 ;;;# Foreign Unions
-------------- 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/c3d8c1a7/attachment.sig>


More information about the cffi-devel mailing list