X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/4be970ba51e2527f3c2da82ef699b9104bf179f3..e3cdfeea6d0a346fa449e8050617f320b6d2c9f3:/gffi/basic-types.lisp diff --git a/gffi/basic-types.lisp b/gffi/basic-types.lisp index b2b0a89..c18890e 100644 --- a/gffi/basic-types.lisp +++ b/gffi/basic-types.lisp @@ -20,7 +20,7 @@ ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -;; $Id: basic-types.lisp,v 1.3 2006-09-06 09:45:26 espen Exp $ +;; $Id: basic-types.lisp,v 1.6 2007-02-19 14:42:24 espen Exp $ (in-package "GFFI") @@ -55,6 +55,11 @@ (deftype pointer () #+(or cmu sbcl) 'system-area-pointer #+clisp 'ffi:foreign-address) +(deftype pointer-data () + '(unsigned-byte #+sbcl #.(sb-sizeof-bits 'sb-alien:system-area-pointer) + #+clisp #.(ffi:bitsizeof 'ffi:c-pointer) + #-(or sbcl clisp) 32)) + (deftype bool (&optional (size '*)) (declare (ignore size)) 'boolean) (deftype copy-of (type) type) (deftype static (type) type) @@ -514,6 +519,12 @@ have been written as temporal.") #+(or cmu sbcl)(sap-ref-double location offset) #+clisp(ffi:memory-as location 'double-float offset))) +(deftype optimized-double-float () 'double-float) + +(define-type-method to-alien-form ((type optimized-double-float) form &optional copy-p) + (declare (ignore type copy-p)) + form) + ;;; Character @@ -570,6 +581,7 @@ have been written as temporal.") ;;; String (defun utf8-length (string) + "Returns the length including the trailing zero, of STRING encoded as UTF8" (1+ (loop for char across string as char-code = (char-code char) @@ -601,7 +613,7 @@ have been written as temporal.") ((< char-code #x800) (encode 11)) ((< char-code #x10000) (encode 16)) ((< char-code #x200000) (encode 21))))) - (setf (ref-byte location len) 0) + (setf (ref-byte location (1- len)) 0) location)) (defun decode-utf8-string (c-string)