X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/0d07716fe78436ae6c9c324cabdd401c25e336af..597999f9e53ddc420f0c435916b459275bc539c2:/glib/gtype.lisp?ds=sidebyside diff --git a/glib/gtype.lisp b/glib/gtype.lisp index 5cb1a7c..851a2e9 100644 --- a/glib/gtype.lisp +++ b/glib/gtype.lisp @@ -15,7 +15,7 @@ ;; License along with this library; if not, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -;; $Id: gtype.lisp,v 1.1 2000/08/14 16:44:34 espen Exp $ +;; $Id: gtype.lisp,v 1.5 2000/10/01 17:20:43 espen Exp $ (in-package "GLIB") @@ -234,7 +234,11 @@ (deftype-method translate-type-spec alien-instance (type-spec) (declare (ignore type-spec)) - 'system-area-pointer) + (translate-type-spec 'pointer)) + +(deftype-method size-of alien-instance (type-spec) + (declare (ignore type-spec)) + (size-of 'pointer)) @@ -273,11 +277,6 @@ (declare (ignore initargs)) (call-next-method) - ;; For some reason I can't figure out, accessors for only the - ;; first direct slot in an alien class gets defined by - ;; PCL. Therefore it has to be done here. - (pcl::fix-slot-accessors class (class-direct-slots class) 'pcl::add) - (when alien-name (setf (alien-type-name (or name (class-name class))) (first alien-name))) (when size @@ -365,7 +364,7 @@ (alien::make-heap-alien-info :type (alien::parse-alien-type `(function - void ,alien-type system-area-pointer)) + void system-area-pointer ,alien-type)) :sap-form (system:foreign-symbol-address writer)))) (to-alien (get-to-alien-function type)) (cleanup (get-cleanup-function type))) @@ -397,7 +396,11 @@ ;; Reverse the direct slot definitions so the effective slots ;; will be in correct order. - (setf direct-slots (nreverse direct-slots))) + (setf direct-slots (reverse direct-slots)) + ;; This nreverse caused me so much frustration that I leave it + ;; here just as a reminder of what not to do. +; (setf direct-slots (nreverse direct-slots)) + ) (call-next-method)) @@ -470,7 +473,8 @@ (deftype-method translate-from-alien alien-object (type-spec location &optional alloc) - (declare (ignore alloc)) + ;; Reference counted objects are always treated as if alloc were :reference + (declare (ignore alloc)) `(let ((location ,location)) (unless (null-pointer-p location) (ensure-alien-instance ',type-spec location)))) @@ -537,16 +541,17 @@ (alien-instance-location object)))) (deftype-method translate-from-alien - alien-structure (type-spec location &optional (alloc :dynamic)) + alien-structure (type-spec location &optional (alloc :reference)) `(let ((location ,location)) (unless (null-pointer-p location) ,(ecase alloc - (:dynamic `(ensure-alien-instance ',type-spec location)) + (:copy `(ensure-alien-instance ',type-spec location)) (:static `(ensure-alien-instance ',type-spec location :static t)) - (:copy `(ensure-alien-instance - ',type-spec - `(,(alien-copier type-spec) - location ,(alien-class-size (find-class type-spec))))))))) + (:reference + `(ensure-alien-instance + ',type-spec + (,(alien-copier type-spec) + location ,(alien-class-size (find-class type-spec))))))))) (deftype-method cleanup-alien alien-structure (type-spec sap &optional copied) (when copied