From fb754a8b75c03825b473e5f8cae357da13a5e88d Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Wed, 23 Aug 2000 14:27:41 +0000 Subject: [PATCH] Changed the alloc argument to translate-from-alien to be one of :static, :reference or :copy Organization: Straylight/Edgeware From: espen --- glib/gforeign.lisp | 8 ++++---- glib/glib.lisp | 6 +++--- glib/gtype.lisp | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/glib/gforeign.lisp b/glib/gforeign.lisp index c5afc5e..87e9eeb 100644 --- a/glib/gforeign.lisp +++ b/glib/gforeign.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: gforeign.lisp,v 1.2 2000-08-16 18:25:30 espen Exp $ +;; $Id: gforeign.lisp,v 1.3 2000-08-23 14:27:41 espen Exp $ (in-package "GLIB") @@ -182,7 +182,7 @@ (defun get-reader-function (type-spec) `(lambda (sap offset) (declare (ignorable sap offset)) ,(translate-from-alien - type-spec `(,(sap-ref-fname type-spec) sap offset) :copy)))))) + type-spec `(,(sap-ref-fname type-spec) sap offset) :reference)))))) (defun get-destroy-function (type-spec) @@ -516,13 +516,13 @@ (deftype-method translate-to-alien string (type-spec string &optional copy) `(make-pointer (1+ (kernel:get-lisp-obj-address ,string))))) (deftype-method - translate-from-alien string (type-spec sap &optional (alloc :dynamic)) + translate-from-alien string (type-spec sap &optional (alloc :copy)) (declare (ignore type-spec)) `(let ((sap ,sap)) (unless (null-pointer-p sap) (prog1 (c-call::%naturalize-c-string sap) - ,(when (eq alloc :dynamic) `(deallocate-memory ,sap)))))) + ,(when (eq alloc :copy) `(deallocate-memory ,sap)))))) (deftype-method cleanup-alien string (type-spec sap &optional copied) (declare (ignore type-spec)) diff --git a/glib/glib.lisp b/glib/glib.lisp index 4af0e94..edbbd16 100644 --- a/glib/glib.lisp +++ b/glib/glib.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: glib.lisp,v 1.3 2000-08-22 23:13:39 espen Exp $ +;; $Id: glib.lisp,v 1.4 2000-08-23 14:27:41 espen Exp $ (in-package "GLIB") @@ -119,7 +119,7 @@ (deftype-method translate-to-alien double-list (type-spec list &optional copy) (deftype-method translate-from-alien - double-list (type-spec glist &optional (alloc :dynamic)) + double-list (type-spec glist &optional (alloc :reference)) (let ((element-type-spec (second (type-expand-to 'double-list type-spec)))) `(let ((glist ,glist) (list nil)) @@ -129,7 +129,7 @@ (deftype-method ,(translate-from-alien element-type-spec `(glist-data tmp ,element-type-spec) alloc) list)) - ,(when (eq alloc :dynamic) + ,(when (eq alloc :reference) '(glist-free glist)) (nreverse list)))) diff --git a/glib/gtype.lisp b/glib/gtype.lisp index fb6d739..192e121 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.2 2000-08-15 14:42:34 espen Exp $ +;; $Id: gtype.lisp,v 1.3 2000-08-23 14:27:41 espen Exp $ (in-package "GLIB") @@ -469,7 +469,8 @@ (deftype-method translate-to-alien (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)))) @@ -536,16 +537,17 @@ (deftype-method translate-to-alien (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 -- [mdw]