Changed the alloc argument to translate-from-alien to be one of :static, :reference...
[clg] / glib / gforeign.lisp
index 3f004ae..87e9eeb 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.1 2000-08-14 16:44:38 espen Exp $
+;; $Id: gforeign.lisp,v 1.3 2000-08-23 14:27:41 espen Exp $
 
 (in-package "GLIB")
 
      `(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)
            (push doc/arg docs)
          (progn
            (destructuring-bind (expr type &optional (style :in)) doc/arg
-             (unless (member style '(:in :out))
+             (unless (member style '(:in :out :in-out))
                (error "Bogus argument style ~S in ~S." style doc/arg))
-             (when (and (not supplied-lambda-list) (namep expr) (eq style :in))
+             (when (and
+                    (not supplied-lambda-list)
+                    (namep expr) (member style '(:in :in-out)))
                (push expr lambda-list))
              (push
               (list (if (namep expr) expr (gensym)) expr type style) args)))))
        (let ((declaration (translate-type-spec type-spec))
              (deallocation (cleanup-alien type-spec expr)))
          (cond
-          ((eq style :out)
+          ((member style '(:out :in-out))
            (alien-types `(* ,declaration))
            (alien-parameters `(addr ,var))
-           (alien-bindings `(,var ,declaration))
+           (alien-bindings
+            `(,var ,declaration
+              ,@(when (eq style :in-out)
+                  (list (translate-to-alien type-spec expr)))))
            (alien-values (translate-from-alien type-spec var)))
          (deallocation
           (alien-types declaration)
     `(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))