diff options
Diffstat (limited to 'Lisp')
-rw-r--r-- | Lisp/lisp-value-wrapping.lisp | 61 |
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) |