summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-07-31 12:48:11 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-07-31 12:48:11 +0200
commit0fc2324c1cc28dd80b13d34a030576a20d887066 (patch)
tree35ac1730ce580b5d94b5ecbecec659c711715cbc
parentc0f7fd07c3303f6928a42fe0ed41aefc8cf7fb2e (diff)
Reader: Support #\.
-rw-r--r--MLKRoot.m20
-rw-r--r--init.lisp1
-rw-r--r--sharpsign.lisp31
3 files changed, 51 insertions, 1 deletions
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 <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|))