summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-03-06 12:33:37 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-03-06 12:33:37 +0100
commitb9e7d47e24d862f4c80604cfa4e1b6dddf48d607 (patch)
tree63b0e985ce0f5ed806ddd0d63d27a6e1ff90cfd3
parentd4b607fba1a7481f7bef23b38495c591c2ba6e3e (diff)
Implement the rest of NS::MLK-LISP-STRING, NS::MLK-LISP-ARRAY, and NS::MLK-LISP-LIST.
darcs-hash:a08cc3c06aacbea697dd8f661480469cf2a1b9bb
-rw-r--r--Lisp/lisp-value-wrapping.lisp61
1 files changed, 44 insertions, 17 deletions
diff --git a/Lisp/lisp-value-wrapping.lisp b/Lisp/lisp-value-wrapping.lisp
index 67c72e6..b0a7794 100644
--- a/Lisp/lisp-value-wrapping.lisp
+++ b/Lisp/lisp-value-wrapping.lisp
@@ -40,22 +40,6 @@
(:metaclass ns::+ns-object))
-(define-objective-c-generic-function #/description (self))
-
-(define-objective-c-method #/description :id ((self ns::mlk-lisp-value ))
- (#/stringWithUTF8String: (find-objc-class 'ns-string)
- (format nil "<MLKLispValue: ~A>"
- (write-to-string (lisp-value self)
- :readably nil
- :escape t
- :circle t
- :length 50
- :level 5
- :pretty nil
- :radix nil
- :base 10))))
-
-
(defcoercion id ((x list))
(intern-lisp-value x))
@@ -127,9 +111,52 @@
;;
;; May usefully override, among others:
;; - description
-(defclass ns::mlk-lisp-list (ns::ns-array lisp-value-wrapper-mixin)
+(defclass ns::mlk-lisp-list (ns::mlk-lisp-array)
()
(:metaclass ns::+ns-object))
+
+(define-objective-c-generic-function #/description (self))
+(define-objective-c-method #/description :id ((self ns::mlk-lisp-value))
+ (#/stringWithUTF8String: (find-objc-class 'ns-string)
+ (format nil "<MLKLispValue: ~A>"
+ (write-to-string (lisp-value self)
+ :readably nil
+ :escape t
+ :circle t
+ :length 50
+ :level 5
+ :pretty nil
+ :radix nil
+ :base 10))))
+
+
+(define-objective-c-generic-function #/characterAtIndex: (self index))
+(define-objective-c-method #/characterAtIndex: :short ((self ns::mlk-lisp-string)
+ (index :unsigned-long))
+ ;; index is actually NSUInteger ==
+ ;; (:unsigned-long ((:nominally :unsigned-int))) on 32-bit architectures,
+ ;; but (:unsigned-long ()) on 64-bit architectures.
+ ;;
+ ;; That is, it's word-sized and labeled `unsigned int' on 32-bit.
+ (char-int (char (lisp-value self) index)))
+
+
+(define-objective-c-generic-function #/length (self))
+(define-objective-c-method #/length :unsigned-long ((self ns::mlk-lisp-string))
+ (length (lisp-value self)))
+
+
+(define-objective-c-generic-function #/objectAtIndex: (self index))
+(define-objective-c-method #/objectAtIndex: ((self ns::mlk-lisp-array)
+ (index :unsigned-long))
+ (aref (lisp-value self) index))
+
+
+(define-objective-c-generic-function #/count (self))
+(define-objective-c-method #/count ((self ns::mlk-lisp-array))
+ (length (lisp-value self)))
+
+
#.(disable-method-syntax)