From b9e7d47e24d862f4c80604cfa4e1b6dddf48d607 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Thu, 6 Mar 2008 12:33:37 +0100 Subject: Implement the rest of NS::MLK-LISP-STRING, NS::MLK-LISP-ARRAY, and NS::MLK-LISP-LIST. darcs-hash:a08cc3c06aacbea697dd8f661480469cf2a1b9bb --- Lisp/lisp-value-wrapping.lisp | 61 +++++++++++++++++++++++++++++++------------ 1 file 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 "" - (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 "" + (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) -- cgit v1.2.3