From 0fc2324c1cc28dd80b13d34a030576a20d887066 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 31 Jul 2008 12:48:11 +0200 Subject: Reader: Support #\. --- MLKRoot.m | 20 +++++++++++++++++++- init.lisp | 1 + sharpsign.lisp | 31 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 sharpsign.lisp diff --git a/MLKRoot.m b/MLKRoot.m index 4b8356f..f155733 100644 --- a/MLKRoot.m +++ b/MLKRoot.m @@ -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]; diff --git a/init.lisp b/init.lisp index 876ff74..7a57779 100644 --- a/init.lisp +++ b/init.lisp @@ -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 . + + +(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|)) -- cgit v1.2.3