diff options
-rw-r--r-- | MLKRoot.m | 20 | ||||
-rw-r--r-- | init.lisp | 1 | ||||
-rw-r--r-- | sharpsign.lisp | 31 |
3 files changed, 51 insertions, 1 deletions
@@ -523,7 +523,25 @@ static id truify (BOOL value) for (i = 2; i < [args count]; i++) { id argument = denullify ([args objectAtIndex:i]); - [invocation setArgument:&argument atIndex:i]; + const char *type = [signature getArgumentTypeAtIndex:i]; + + if (strcmp (type, @encode(unichar)) == 0) + { + unichar arg; + if ([argument isKindOfClass:[MLKCharacter class]]) + arg = [argument unicharValue]; + else if ([argument isKindOfClass:[MLKInteger class]]) + arg = [argument intValue]; + else + [NSException raise:@"MLKInvalidArgumentError" + format:@"Don't know how to coerce %@ into type \"%s\".", + argument, type]; + [invocation setArgument:&arg atIndex:i]; + } + else + { + [invocation setArgument:&argument atIndex:i]; + } } [invocation invoke]; @@ -25,6 +25,7 @@ (load "defun-1.lisp") (load "list-functions.lisp") (load "reader.lisp") +(load "sharpsign.lisp") (load "control-flow.lisp") (load "types.lisp") (load "list-functions-2.lisp") diff --git a/sharpsign.lisp b/sharpsign.lisp new file mode 100644 index 0000000..93b2f4c --- /dev/null +++ b/sharpsign.lisp @@ -0,0 +1,31 @@ +;;; -*- mode: lisp; coding: utf-8 -*- +;;; Étoilisp/Mulklisp, a Common Lisp subset for the Étoilé runtime. +;;; Copyright (C) 2008 Matthias Andreas Benkard. +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see <http://www.gnu.org/licenses/>. + + +(in-package #:common-lisp) + +(defun |#\-READER| (stream char &optional arg) + ;; FIXME: Handle #\Newline etc.. + (send-by-name stream "readChar")) + +(set-dispatch-macro-character (send-by-name (find-objc-class "MLKCharacter") + "characterWithUnichar:" + 35) + (send-by-name (find-objc-class "MLKCharacter") + "characterWithUnichar:" + 92) + (function |#\-READER|)) |