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 5355ff1b8db31b4427a68f0e76110245abec7ee6..b8cc178275ab6c39d310e3fb1b45bd233ebb84f8 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 184ce5ab49e31e0e953b5cfec28c5ed921b92e0b..dead212f9219325ec2d9e4ba1df64f70ed3026e3 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 45514af67c82534abca99e81e532d34dbdbfd936..77116073e061f13b76ec3b9f952824877532e3cb 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