1 | ;;;-*-Mode: LISP; Package: CCL -*- |
---|
2 | ;;; |
---|
3 | ;;; Copyright (C) 2002-2009 Clozure Associates |
---|
4 | ;;; This file is part of Clozure CL. |
---|
5 | ;;; |
---|
6 | ;;; Clozure CL is licensed under the terms of the Lisp Lesser GNU Public |
---|
7 | ;;; License , known as the LLGPL and distributed with Clozure CL as the |
---|
8 | ;;; file "LICENSE". The LLGPL consists of a preamble and the LGPL, |
---|
9 | ;;; which is distributed with Clozure CL as the file "LGPL". Where these |
---|
10 | ;;; conflict, the preamble takes precedence. |
---|
11 | ;;; |
---|
12 | ;;; Clozure CL is referenced in the preamble as the "LIBRARY." |
---|
13 | ;;; |
---|
14 | ;;; The LLGPL is also available online at |
---|
15 | ;;; http://opensource.franz.com/preamble.html |
---|
16 | |
---|
17 | (in-package "CCL") |
---|
18 | |
---|
19 | (eval-when (:compile-toplevel :load-toplevel :execute) |
---|
20 | (defvar *objc-readtable* (copy-readtable nil)) |
---|
21 | (set-syntax-from-char #\] #\) *objc-readtable*)) |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | ;;; We use the convention that [:super ....] denotes a send to the |
---|
26 | ;;; defining object's superclass's method, and that a return value |
---|
27 | ;;; specification of the form (:-> ... x) indicates a message send |
---|
28 | ;;; that returns a structure (by reference) via the pointer x. |
---|
29 | |
---|
30 | (set-macro-character |
---|
31 | #\[ |
---|
32 | (nfunction |
---|
33 | |objc-[-reader| |
---|
34 | (lambda (stream ignore) |
---|
35 | (declare (ignore ignore)) |
---|
36 | (let* ((tail (read-delimited-list #\] stream)) |
---|
37 | (structptr nil)) |
---|
38 | (unless *read-suppress* |
---|
39 | (let* ((return (car (last tail)))) |
---|
40 | (when (and (consp return) (eq (car return) :->)) |
---|
41 | (rplaca (last tail) :void) |
---|
42 | (setq structptr (car (last return))))) |
---|
43 | (if (eq (car tail) :super) |
---|
44 | (if structptr |
---|
45 | `(objc-message-send-super-stret ,structptr (super) ,@(cdr tail)) |
---|
46 | `(objc-message-send-super (super) ,@(cdr tail))) |
---|
47 | (if structptr |
---|
48 | `(objc-message-send-stret ,structptr ,@tail) |
---|
49 | `(objc-message-send ,@tail))))))) |
---|
50 | nil |
---|
51 | *objc-readtable*) |
---|
52 | |
---|
53 | (set-dispatch-macro-character |
---|
54 | #\# |
---|
55 | #\@ |
---|
56 | (nfunction |
---|
57 | |objc-#@-reader| |
---|
58 | (lambda (stream subchar numarg) |
---|
59 | (declare (ignore subchar numarg)) |
---|
60 | (let* ((string (read stream))) |
---|
61 | (unless *read-suppress* |
---|
62 | (check-type string string) |
---|
63 | `(@ ,string))))) |
---|
64 | *objc-readtable*) |
---|
65 | |
---|