diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-08-06 17:44:07 +0200 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-08-06 17:44:07 +0200 |
commit | e562ec45a61b6b60fdbacf609ece03d998452b95 (patch) | |
tree | d99d9d1cd257c7d0d46fba9c508741de12cca5c0 | |
parent | c191d8f49e58bbc5b769780a0a17b5cec82174f1 (diff) |
Minor cleanups.
darcs-hash:ee74b33660af9dc6b1e0207285907211dd7e600a
-rw-r--r-- | Lisp/libobjcl.lisp | 9 | ||||
-rw-r--r-- | Lisp/type-conversion.lisp | 12 |
2 files changed, 15 insertions, 6 deletions
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp index fff0963..9591f8f 100644 --- a/Lisp/libobjcl.lisp +++ b/Lisp/libobjcl.lisp @@ -147,26 +147,25 @@ conventional case for namespace identifiers in Objective C." (defun find-objc-class-by-name (class-name) - (let ((obj-data (%objcl-find-class class-name))) + (with-foreign-objects ((obj-data (%objcl-find-class class-name))) (unwind-protect (if (null-pointer-p (foreign-slot-value (foreign-slot-value obj-data 'obj-data 'data) 'obj-data-union 'class-val)) nil - (obj-data->lisp obj-data)) - (dealloc-obj-data obj-data)))) + (obj-data->lisp obj-data))))) (defun objcl-class-name (class) (declare (type (or objc-class id exception) class)) - (with-foreign-objects ((obj-data class)) + (with-foreign-conversion ((obj-data class)) (%objcl-class-name obj-data))) (defun selector-name (selector) (declare (type selector selector)) - (with-foreign-objects ((obj-data selector)) + (with-foreign-conversion ((obj-data selector)) (%objcl-selector-name obj-data))) diff --git a/Lisp/type-conversion.lisp b/Lisp/type-conversion.lisp index 3ac1ce6..066fdd9 100644 --- a/Lisp/type-conversion.lisp +++ b/Lisp/type-conversion.lisp @@ -35,11 +35,21 @@ (otherwise value))))) +(defmacro with-foreign-conversion (bindings &body body) + `(with-foreign-objects + ,(mapcar #'(lambda (name-value-pair) + (destructuring-bind (name value) + name-value-pair + `(,name (lisp->obj-data ,value)))) + bindings) + ,@body)) + + (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)))) + `(,name ,value))) bindings) (unwind-protect (progn ,@body) |