r2907: *** empty log message ***
[uffi.git] / src / objects.cl
index 35003012b961d6a7a938f5818478209f78b2b74d..6f1e8cec7aa695607d072775b65c24723046c486 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: objects.cl,v 1.24 2002/09/30 07:51:01 kevin Exp $
+;;;; $Id: objects.cl,v 1.25 2002/09/30 08:50:00 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
 (in-package :uffi)
 
+(defun size-of-foreign-type (type)
+  #+lispworks (fli:size-of type)
+  #+allegro (ff:sizeof-fobject type)
+  #+cmu  (alien:alien-size type)
+  #+clisp  (values (ffi:size-of type))
+  #+(and mcl (not openmcl))
+  (let ((mcl-type (ccl:find-mactype type nil t)))
+    (if mcl-type 
+       (ccl::mactype-record-size mcl-type)
+      (ccl::record-descriptor-length (ccl:find-record-descriptor type t t)))) ;error if not a record
+  #+openmcl (ccl::%foreign-type-or-record-size type :bytes)
+  )
+
+
 (defmacro allocate-foreign-object (type &optional (size :unspecified))
   "Allocates an instance of TYPE. If size is specified, then allocate
 an array of TYPE with size SIZE. The TYPE parameter is evaluated."
@@ -62,20 +76,6 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated."
   #+mcl   `(ccl:%null-ptr-p ,obj)
   )
 
-(defmacro size-of-foreign-type (type)
-  #+lispworks `(fli:size-of ,type)
-  #+allegro `(ff:sizeof-fobject ,type)
-  #+cmu   `(alien:alien-size ,type)
-  #+clisp   `(values (ffi:size-of ,type))
-  #+(and mcl (not openmcl))
-  `(let ((mcl-type (ccl:find-mactype ,type nil t)))
-     (if mcl-type 
-        (ccl::mactype-record-size mcl-type)
-       (ccl::record-descriptor-length (ccl:find-record-descriptor ,type t t)))) ;error if not a record
-  #+opencml   `(ccl::%foreign-type-or-record-size ,type :bytes)
-  )
-
-
 (defmacro make-null-pointer (type)
   #+(or allegro cmu mcl) (declare (ignore type))
   
@@ -155,11 +155,6 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated."
     ,@body)
   )
 
-#+mcl
-(defmacro with-foreign-object ((var type) &rest body)
-  `(with-foreign-objects ((,var ,type)) 
-     ,@body))
-
 #-mcl
 (defmacro with-foreign-objects (bindings &rest body)
   (if bindings
@@ -181,3 +176,8 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated."
       (push (list (first spec) (* count (size-of-foreign-type type))) params))
     `(ccl:%stack-block ,params ,@body)))
                                 
+#+mcl
+(defmacro with-foreign-object ((var type) &rest body)
+  `(with-foreign-objects ((,var ,type)) 
+     ,@body))
+