X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Faggregates.lisp;h=523bd4f72983eadee80b0aa91ef86c6e3bae09ca;hb=0dbc9821c1d1f665a914585dcef97199e8334bf3;hp=5080222aa0862c7b92bf708eca85370378746018;hpb=77378d36f07fe1f11893444217716b01628a329f;p=uffi.git diff --git a/src/aggregates.lisp b/src/aggregates.lisp index 5080222..523bd4f 100644 --- a/src/aggregates.lisp +++ b/src/aggregates.lisp @@ -2,12 +2,12 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; Name: aggregates.cl +;;;; Name: aggregates.lisp ;;;; Purpose: UFFI source to handle aggregate types ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: aggregates.lisp,v 1.6 2002/12/02 13:21:43 kevin Exp $ +;;;; $Id$ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -16,8 +16,7 @@ ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* -(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))) -(in-package :uffi) +(in-package #:uffi) (defmacro def-enum (enum-name args &key (separator-string "#")) "Creates a constants for a C type enum list, symbols are created @@ -81,7 +80,8 @@ of the enum-name name, separator-string, and field-name" #+(or cmu scl) `((* (alien:struct ,name))) #+sbcl `((* (sb-alien:struct ,name))) #+mcl `((:* (:struct ,name))) - #-(or cmu sbcl scl mcl) `((* ,name)) + #+lispworks `((:pointer ,name)) + #-(or cmu sbcl scl mcl lispworks) `((* ,name)) `(,(convert-from-uffi-type type :struct)))))) (if variant (push (list def) processed) @@ -162,19 +162,28 @@ of the enum-name name, separator-string, and field-name" #+(or lispworks cmu sbcl scl) (declare (ignore type)) #+(or cmu scl) `(alien:deref ,obj ,i) #+sbcl `(sb-alien:deref ,obj ,i) - #+lispworks `(fli:dereference ,obj :index ,i) + #+lispworks `(fli:dereference ,obj :index ,i :copy-foreign-object nil) #+allegro `(ff:fslot-value-typed (quote ,(convert-from-uffi-type type :type)) :c ,obj ,i) - #+mcl + #+openmcl (let* ((array-type (array-type type)) (local-type (convert-from-uffi-type array-type :allocation)) - (accessor (first (macroexpand `(ccl:pref obj ,local-type))))) - `(,accessor + (element-size-in-bits (ccl::%foreign-type-or-record-size local-type :bits))) + (ccl::%foreign-access-form + obj + (ccl::%foreign-type-or-record local-type) + `(* ,i ,element-size-in-bits) + nil)) + #+(and mcl (not openmcl)) + (let* ((array-type (array-type type)) + (local-type (convert-from-uffi-type array-type :allocation)) + (accessor (first (macroexpand `(ccl:pref obj ,local-type))))) + `(,accessor ,obj (* (the fixnum ,i) ,(size-of-foreign-type local-type)))) ) ; this expands to the %set-xx functions which has different params than %put-xx -#+mcl +#+(and mcl (not openmcl)) (defmacro deref-array-set (obj type i value) (let* ((array-type (array-type type)) (local-type (convert-from-uffi-type array-type :allocation)) @@ -185,7 +194,7 @@ of the enum-name name, separator-string, and field-name" (* (the fixnum ,i) ,(size-of-foreign-type local-type)) ,value))) -#+mcl +#+(and mcl (not openmcl)) (defsetf deref-array deref-array-set) (defmacro def-union (name &rest fields)