[cffi-devel] Re: CFFI::CANONICALIZE with arguments (NIL)

Lou Vanek vanek at acd.net
Sat May 20 14:37:00 UTC 2006


this patch fixes cffi (today's darcs) so that it can work with clsql 3.6.1 
and clisp 2.38 and run example/clsql-tutorial-mysql.lisp against mysql 4.1.12
on cygwin. This patch may be slightly off since this stupid mail list doesn't
accept posts wider than 80 chars.

diff -urN --exclude '*.lib' --exclude '*.fas' --exclude files
cffi.clean/src/early-types.lisp cffi/src/early-types.lisp
--- cffi.clean/src/early-types.lisp     2006-05-20 08:35:15.083847000 -0400
+++ cffi/src/early-types.lisp   2006-05-20 08:47:59.708847000 -0400
@@ -266,7 +266,10 @@
 
 (defmethod canonicalize ((type foreign-type-alias))
   "Return the built-in type keyword for TYPE."
-  (canonicalize (actual-type type)))
+  (let ((atype (actual-type type)))
+         (if (null atype)
+               (format *standard-error* "WARNING! null base-type.")
+               (canonicalize atype))))
 
 (defmethod aggregatep ((type foreign-type-alias))
   "Return true if TYPE's actual type is aggregate."
diff -urN --exclude '*.lib' --exclude '*.fas' --exclude files
cffi.clean/src/utils.lisp cffi/src/utils.lisp
--- cffi.clean/src/utils.lisp   2006-05-20 08:35:15.130722000 -0400
+++ cffi/src/utils.lisp 2006-05-20 09:06:14.990097000 -0400
@@ -39,7 +39,8 @@
            #:let-when
            #:bif
            #:post-incf
-           #:single-bit-p))
+           #:single-bit-p
+                  #:getenv))
 
 (in-package #:cffi-utils)
 
@@ -166,6 +167,21 @@
          do (setf integer (ash integer -1))
          finally (return (zerop (ash integer -1))))))
 
+;; Taken from UFFI's src/os.lisp
+(defun getenv (var)
+  "Return the value of the environment variable."
+  #+allegro (sys::getenv (string var))
+  #+clisp (sys::getenv (string var))
+ #+(or cmu scl) (cdr (assoc (string var) ext:*environment-list* 
+                :test #'equalp  :key #'string))
+  #+gcl (si:getenv (string var))
+  #+lispworks (lw:environment-variable (string var))
+  #+lucid (lcl:environment-variable (string var))
+  #+mcl (ccl::getenv var)
+  #+sbcl (sb-ext:posix-getenv var)
+  #-(or allegro clisp cmu scl gcl lispworks lucid mcl sbcl)
+  (error 'not-implemented :proc (list 'getenv var)))
+
 ;(defun deprecation-warning (bad-name &optional good-name)
 ;  (warn "using deprecated ~S~@[, should use ~S instead~]"
 ;        bad-name
diff -urN --exclude '*.lib' --exclude '*.fas' --exclude files
cffi.clean/uffi-compat/uffi-compat.lisp cffi/uffi-compat/uffi-compat.lisp
--- cffi.clean/uffi-compat/uffi-compat.lisp 2006-05-20 08:35:15.068222000 -0400
+++ cffi/uffi-compat/uffi-compat.lisp   2006-05-20 09:06:27.255722000 -0400
@@ -90,7 +90,6 @@
    #:foreign-library-types
 
    ;; os
-   #:getenv
    #:run-shell-command
    ))
 
@@ -135,7 +134,7 @@
   (:documentation "UFFI's :array type."))
 
 (defmethod initialize-instance :after ((self uffi-array-type) &key)
-  (setf (cffi::actual-type self) (cffi::find-type :pointer)))
+  (setf (cffi::actual-type self) (cffi::parse-type :pointer)))
 
 (defmethod cffi:foreign-type-size ((type uffi-array-type))
   (* (cffi:foreign-type-size (element-type type)) (nelems type)))
@@ -143,7 +142,7 @@
 (defmethod cffi::aggregatep ((type uffi-array-type))
   t)
 
-(cffi::define-type-spec-parser uffi-array (element-type count)
+(cffi::define-type-spec-parser uffi-array (element-type &optional count)
   (make-instance 'uffi-array-type :element-type element-type
                  :nelems (or count 1)))
 
@@ -508,20 +507,6 @@
           (push filename *loaded-libraries*)
           t))))
 
-;; Taken from UFFI's src/os.lisp
-(defun getenv (var)
-  "Return the value of the environment variable."
-  #+allegro (sys::getenv (string var))
-  #+clisp (sys::getenv (string var))
- #+(or cmu scl) (cdr (assoc (string var) ext:*environment-list* :test #'equalp
-                             :key #'string))
-  #+gcl (si:getenv (string var))
-  #+lispworks (lw:environment-variable (string var))
-  #+lucid (lcl:environment-variable (string var))
-  #+mcl (ccl::getenv var)
-  #+sbcl (sb-ext:posix-getenv var)
-  #-(or allegro clisp cmu scl gcl lispworks lucid mcl sbcl)
-  (error 'not-implemented :proc (list 'getenv var)))
 
 ;; Taken from UFFI's src/os.lisp
 ;; modified from function ASDF -- Copyright Dan Barlow and Contributors
diff -urN --exclude '*.lib' --exclude '*.fas' --exclude files
cffi.clean/uffi.asd cffi/uffi.asd
--- cffi.clean/uffi.asd 1969-12-31 19:00:00.000000000 -0500
+++ cffi/uffi.asd       2006-05-20 09:15:36.990097000 -0400
@@ -0,0 +1,7 @@
+;;;-*- Mode: Lisp; Package: COMMON-LISP-USER -*-
+
+(defpackage :asdf-uffi (:use #:asdf #:cl))
+(in-package :asdf-uffi)
+(defsystem uffi :depends-on (:cffi-uffi-compat))
+
+;;; End file uffi.asd





More information about the cffi-devel mailing list