summaryrefslogtreecommitdiff
path: root/Lisp/method-invocation.lisp
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2007-09-20 22:59:26 +0200
committerMatthias Benkard <code@mail.matthias.benkard.de>2007-09-20 22:59:26 +0200
commite95d66c3148a64b6fe1a6b2aa940ecc41867ce4a (patch)
tree3e0c8b6b4c450647284fc6dede17d82dfc4b9d7d /Lisp/method-invocation.lisp
parent07272baa7e714d2f1c2f1a7ba63bfc2317967fab (diff)
Fix the coercion rules for FLOAT and BOOLEAN values.
darcs-hash:d24e207d8f1e0357c8a63ec058ec61318675e89f
Diffstat (limited to 'Lisp/method-invocation.lisp')
-rw-r--r--Lisp/method-invocation.lisp36
1 files changed, 13 insertions, 23 deletions
diff --git a/Lisp/method-invocation.lisp b/Lisp/method-invocation.lisp
index 9f9e056..dbf6f33 100644
--- a/Lisp/method-invocation.lisp
+++ b/Lisp/method-invocation.lisp
@@ -1,12 +1,6 @@
(in-package #:mulk.objective-cl)
-(eval-when (:execute)
- (unless (boundp '+nil+)
- (defconstant +nil+
- (make-instance 'id :pointer (objcl-get-nil)))))
-
-
;;; (@* "Method invocation")
(defun invoke (receiver message-start &rest message-components)
"Send a message to an Objective C instance.
@@ -539,7 +533,7 @@ Returns: *result* --- the return value of the method invocation.
(defcoercion id ((x id))
x)
-(defcoercion id ((x class))
+(defcoercion id ((x objc-class))
x)
(defcoercion id ((x exception))
@@ -551,15 +545,13 @@ Returns: *result* --- the return value of the method invocation.
'id
x))
-(defcoercion id ((x double-float))
- (primitive-invoke (find-objc-class 'ns-number)
- :number-with-double
- 'id
- x))
-
-(defcoercion id ((x single-float))
+(defcoercion id ((x float))
(primitive-invoke (find-objc-class 'ns-number)
- :number-with-float
+ (etypecase x
+ (long-float :number-with-double)
+ (double-float :number-with-double)
+ (short-float :number-with-float)
+ (single-float :number-with-float))
'id
x))
@@ -589,7 +581,7 @@ Returns: *result* --- the return value of the method invocation.
(defcoercion class ((x exception))
(object-get-class x))
-(defcoercion class ((x class))
+(defcoercion class ((x objc-class))
x)
(defcoercion class ((x string))
@@ -649,15 +641,13 @@ Returns: *result* --- the return value of the method invocation.
(float x))
+;; Note that this refers to the Objective-C BOOL type, not the Lisp
+;; BOOLEAN type.
(defcoercion bool ((x null))
- x)
+ +no+)
-(defcoercion bool ((x symbol))
- (assert (eq 't x))
- x)
-
-(defcoercion bool ((x integer))
- x)
+(defcoercion bool (x)
+ +yes+)
(defcoercion string ((x string))