chiark / gitweb /
Changed the alloc argument to translate-from-alien to be one of :static, :reference...
authorespen <espen>
Wed, 23 Aug 2000 14:27:41 +0000 (14:27 +0000)
committerespen <espen>
Wed, 23 Aug 2000 14:27:41 +0000 (14:27 +0000)
glib/gforeign.lisp
glib/glib.lisp
glib/gtype.lisp

index c5afc5e3dbb0a8850fc6b40f62c93b3d69bd8ac7..87e9eeb73aeb2b13eb7997dcfc6aea8ca0b4fec1 100644 (file)
@@ -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))
index 4af0e940da36ddbba5c7f3c573b8e9b67b0beeba..edbbd16f7277b907310a7bcc1887e1ee9c12215c 100644 (file)
@@ -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))))
 
index fb6d73903ad72be833133bebe13485f08727ac0f..192e1218009f202f67f0ebf9f073f717b268bb38 100644 (file)
@@ -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