X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=uffi%2Fclsql-uffi.lisp;h=1d072edcd2bc35f1a0e279a68f3f4db7dc12c48e;hb=81d2ebcdd182dd674191b29e00274c82660fd3f3;hp=41d38b0a88ba98c3bbd9b211e22f6e255b76b818;hpb=3acccef9826b2d59474d5d09bad453dba5df189c;p=clsql.git diff --git a/uffi/clsql-uffi.lisp b/uffi/clsql-uffi.lisp index 41d38b0..1d072ed 100644 --- a/uffi/clsql-uffi.lisp +++ b/uffi/clsql-uffi.lisp @@ -7,7 +7,7 @@ ;;;; Programmers: Kevin M. Rosenberg ;;;; Date Started: Mar 2002 ;;;; -;;;; $Id: clsql-uffi.lisp,v 1.29 2003/06/06 21:59:09 kevin Exp $ +;;;; $Id: clsql-uffi.lisp,v 1.32 2003/06/23 19:25:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -21,40 +21,43 @@ (defun canonicalize-type-list (types auto-list) "Ensure a field type list meets expectations" - (let ((length-types (length types)) - (new-types '())) - (loop for i from 0 below (length auto-list) - do - (if (>= i length-types) - (push t new-types) ;; types is shorted than num-fields - (push - (case (nth i types) - (:int - (case (nth i auto-list) - (:int32 - :int32) - (:int64 - :int64) - (t - t))) - (:double - (case (nth i auto-list) - (:double - :double) - (t - t))) - (:int32 - (if (eq :int32 (nth i auto-list)) - :int32 - t)) - (:int64 - (if (eq :int64 (nth i auto-list)) - :int64 - t)) - (t - t)) - new-types))) - (nreverse new-types))) + (declaim (optimize (speed 3) (safety 0))) + (do ((i 0 (1+ i)) + (new-types '()) + (length-types (length types)) + (length-auto-list (length auto-list))) + ((= i length-auto-list) + (nreverse new-types)) + (declaim (fixnum length-types length-auto-list i)) + (if (>= i length-types) + (push t new-types) ;; types is shorted than num-fields + (push + (case (nth i types) + (:int + (case (nth i auto-list) + (:int32 + :int32) + (:int64 + :int64) + (t + t))) + (:double + (case (nth i auto-list) + (:double + :double) + (t + t))) + (:int32 + (if (eq :int32 (nth i auto-list)) + :int32 + t)) + (:int64 + (if (eq :int64 (nth i auto-list)) + :int64 + t)) + (t + t)) + new-types)))) (uffi:def-function "atoi" ((str (* :unsigned-char))) @@ -77,29 +80,21 @@ (uffi:def-constant +2^32-1+ (1- +2^32+)) (defmacro make-64-bit-integer (high32 low32) - `(+ ,low32 (* ,high32 +2^32+))) + `(+ ,low32 (ash ,high32 32))) (defmacro split-64-bit-integer (int64) `(values (ash ,int64 -32) (logand ,int64 +2^32-1+))) (uffi:def-type char-ptr-def (* :unsigned-char)) -(defun char-ptr-points-to-null (char-ptr) - "Returns T if foreign character pointer refers to 'NULL' string. Only called for numeric entries" - ;; Uses short cut and returns T if first character is #\N. It should - ;; never be non-numeric - (declare (type char-ptr-def char-ptr)) - (char-equal #\N (uffi:ensure-char-character - (uffi:deref-pointer char-ptr :char)))) - (defun convert-raw-field (char-ptr types index) + (declare (optimize (speed 3) (safety 0) (space 0)) + (type char-ptr-def char-ptr)) (let ((type (if (listp types) (nth index types) types))) (cond - ((and (or (eq type :double) (eq type :int32) (eq type :int) - (eq type :int64)) - (char-ptr-points-to-null char-ptr)) + ((uffi:null-pointer-p char-ptr) nil) (t (case type