X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/clg/blobdiff_plain/65a7f9a08e971053faebd8540bf39f2cb7b05b80..8f49b7a10a9717890ca98dff2b01799b80ce2761:/gffi/proxy.lisp diff --git a/gffi/proxy.lisp b/gffi/proxy.lisp index 4173a1c..7ce9f05 100644 --- a/gffi/proxy.lisp +++ b/gffi/proxy.lisp @@ -20,7 +20,7 @@ ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -;; $Id: proxy.lisp,v 1.6 2007-01-12 10:26:44 espen Exp $ +;; $Id: proxy.lisp,v 1.10 2007-12-11 14:26:11 espen Exp $ (in-package "GFFI") @@ -87,7 +87,7 @@ (defun list-invalidated-instances () (defvar *foreign-instance-locations* (make-hash-table #+clisp :weak #+sbcl :weakness :key)) -;; TODO: add a ref-counted-proxy subclass + (eval-when (:compile-toplevel :load-toplevel :execute) (defclass proxy (virtual-slots-object) (#?-(or (sbcl>= 0 9 17) (featurep :clisp))(%location :special t :type pointer)) @@ -167,6 +167,7 @@ (defmethod instance-finalizer ((instance proxy)) ;; :FINALZIE given to MAKE-PROXY-INSTANCE or non NIL if the proxy was ;; created with MAKE-INSTANCE (defmethod invalidate-instance ((instance proxy) &optional finalize-p) + #+clisp(declare (ignore finalize-p)) (remove-cached-instance (foreign-location instance)) #+(or sbcl cmu) (progn @@ -301,6 +302,8 @@ (defmethod compute-slot-writer-function ((slotd effective-virtual-alien-slot-d #'(lambda (value object) (unless writer (setq writer (mkbinding setter nil 'pointer type))) + ;; First argument in foreign setters is the object and second + ;; is value (funcall writer (foreign-location object) value))) (call-next-method))) @@ -596,7 +599,7 @@ (defmethod compute-slots :around ((class struct-class)) (define-type-method callback-wrapper ((type struct) var arg form) (let ((class (type-expand type))) - `(let ((,var (ensure-proxy-instance ',class ,arg :finalize nil))) + `(let ((,var (ensure-proxy-instance ',class ,arg :reference nil :finalize nil))) (unwind-protect ,form (invalidate-instance ,var)))))