diff options
Diffstat (limited to 'Lisp/type-conversion.lisp')
-rw-r--r-- | Lisp/type-conversion.lisp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lisp/type-conversion.lisp b/Lisp/type-conversion.lisp index 8839b3b..3ac1ce6 100644 --- a/Lisp/type-conversion.lisp +++ b/Lisp/type-conversion.lisp @@ -32,4 +32,17 @@ ((id objc-class selector exception) (make-instance lisp-type :pointer value)) ((string) (foreign-string-to-lisp value)) - (otherwise value)))))
\ No newline at end of file + (otherwise value))))) + + +(defmacro with-foreign-objects (bindings &body body) + `(let ,(mapcar #'(lambda (name-value-pair) + (destructuring-bind (name value) + name-value-pair + `(,name (lisp->obj-data ,value)))) + bindings) + (unwind-protect + (progn ,@body) + ,@(mapcar #'(lambda (name-value-pair) + `(dealloc-obj-data ,(first name-value-pair))) + bindings)))) |