summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lisp/libobjcl.lisp9
-rw-r--r--Lisp/type-conversion.lisp12
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)