diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2008-02-16 21:58:48 +0100 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2008-02-16 21:58:48 +0100 |
commit | c61f86dce1eb244fb775e74043070e32e6fdcaaf (patch) | |
tree | 7c6d0a4763921321c331462e8e9b925a8fa34beb /Lisp/instance-management.lisp | |
parent | 23aeccec01d4e888885cca03c6557f2f0542ab0c (diff) |
Add module: instance-management.
darcs-hash:79549f0b837006321061a524ad376df397a9ab5a
Diffstat (limited to 'Lisp/instance-management.lisp')
-rw-r--r-- | Lisp/instance-management.lisp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Lisp/instance-management.lisp b/Lisp/instance-management.lisp new file mode 100644 index 0000000..c8abb44 --- /dev/null +++ b/Lisp/instance-management.lisp @@ -0,0 +1,32 @@ +;;;; Objective-CL, an Objective-C bridge for Common Lisp. +;;;; Copyright (C) 2007, 2008 Matthias Andreas Benkard. +;;;; +;;;; This program is free software: you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public License +;;;; as published by the Free Software Foundation, either version 3 of +;;;; the License, or (at your option) any later version. +;;;; +;;;; This program is distributed in the hope that it will be useful, but +;;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this program. If not, see +;;;; <http://www.gnu.org/licenses/>. + +(in-package #:mulk.objective-cl) + + +(defvar *lisp-managed-instances* (make-hash-table :test 'eql)) + +(defun intern-lisp-managed-foreign-instance (&rest initargs &key pointer) + (let ((key (cffi:pointer-address pointer))) + (or (gethash key *lisp-managed-instances* nil) + (apply #'make-instance + (intern-pointer-wrapper (%objcl-object-get-class pointer)) + initargs)))) + +(defun unintern-lisp-managed-foreign-instance (instance) + (remhash (cffi:pointer-address (pointer-to instance)) + *lisp-managed-instances*)) |