X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/61b2bec616c4f0ae2e031fd94e790261143edb42..e3cdfeea6d0a346fa449e8050617f320b6d2c9f3:/gffi/proxy.lisp diff --git a/gffi/proxy.lisp b/gffi/proxy.lisp index 041670a..d67ee96 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.5 2006-09-29 13:14:19 espen Exp $ +;; $Id: proxy.lisp,v 1.7 2007-04-06 14:29:42 espen Exp $ (in-package "GFFI") @@ -87,7 +87,7 @@ (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)) @@ -499,6 +499,20 @@ object at the give location.")) (cache-instance instance) instance)) +;;;; Superclass for ref-counted objects + +(defclass ref-counted-object (proxy) + () + (:metaclass proxy-class)) + +(define-type-method from-alien-form ((type ref-counted-object) form + &key (ref :copy)) + (call-next-method type form :ref ref)) + +(define-type-method from-alien-function ((type ref-counted-object) + &key (ref :copy)) + (call-next-method type :ref ref)) + ;;;; Superclasses for wrapping of C structures