summaryrefslogtreecommitdiff
path: root/Lisp
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-03-05 01:29:07 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-03-05 01:29:07 +0100
commit1b2b509cd214ce604ce6ac58ef38ac6b5aec81e1 (patch)
tree556831552a0cfef35dd5a447959a8956ddf4da08 /Lisp
parentd16f69d260753ff706aab52b6990012441fce2a6 (diff)
Collect selectors in package OBJECTIVE-C-SELECTORS.
darcs-hash:f8184992f82c34b07e6a89745593b8daec17fc61
Diffstat (limited to 'Lisp')
-rw-r--r--Lisp/data-types.lisp11
-rw-r--r--Lisp/defpackage.lisp5
-rw-r--r--Lisp/reader-syntax.lisp24
3 files changed, 29 insertions, 11 deletions
diff --git a/Lisp/data-types.lisp b/Lisp/data-types.lisp
index 2c309e7..18f2611 100644
--- a/Lisp/data-types.lisp
+++ b/Lisp/data-types.lisp
@@ -130,6 +130,17 @@ The following calls are all equivalent:
(apply #'invoke-by-name receiver selector args))))
+(defmethod initialize-instance :after ((selector selector)
+ &rest initargs
+ &key
+ &allow-other-keys)
+ (declare (ignore initargs))
+ ;; Register the selector.
+ (let ((symbol (intern (selector-name selector) '#:objective-c-selectors)))
+ (setf (fdefinition symbol) selector)
+ (export symbol '#:objective-c-selectors)))
+
+
(defmethod make-load-form ((selector selector) &optional environment)
(declare (ignore environment))
`(intern-pointer-wrapper 'selector
diff --git a/Lisp/defpackage.lisp b/Lisp/defpackage.lisp
index 59aa041..3cacf12 100644
--- a/Lisp/defpackage.lisp
+++ b/Lisp/defpackage.lisp
@@ -32,6 +32,7 @@
#:invoke
#:find-objc-class
#:find-selector
+ #:intern-selector
#:objc-class-name
#:selector-name
#:selector
@@ -96,4 +97,8 @@
(:use))
+(defpackage #:objective-c-selectors
+ (:nicknames #:objc-selectors #:objc-sels #:objcs)
+ (:use))
+
#-(or cmu sbcl) (declaim (declaration values))
diff --git a/Lisp/reader-syntax.lisp b/Lisp/reader-syntax.lisp
index 7a79fb0..9f0bcb7 100644
--- a/Lisp/reader-syntax.lisp
+++ b/Lisp/reader-syntax.lisp
@@ -46,12 +46,10 @@ alongside Lisp code by placing the method name in front. At the same
time, it is a more conservative syntax enhancement than that provided by
__enable-objective-c-syntax__.
-The reader macro transforms any sequence of alphanumeric characters and
-characters that are __eql__ to one of #\:, #\- and #\_ into a symbol
-with that sequence as the **symbol name** and _objective-c-methods__ as
-the **symbol package**. It also takes care to make a __selector__
-available as the __fdefinition__ of that symbol unless the symbol is
-already **fbound**.
+The **reader macro** transforms any **string** of alphanumeric
+characters and **character**s that are __eql__ to one of #\:, #\- and
+#\_ into a **symbol** with that **string** as the **symbol name** and
+_objective-c-selectors__ as the **symbol package**.
## Examples:
@@ -73,10 +71,14 @@ already **fbound**.
## Note:
-Absent manual changes by the user, the __fdefinition__ of any symbol
-read by this reader macro may point to either a __selector__ or an
-__objective-c-generic-function__, depending on whether a corresponding
-__defgeneric__ form has been executed.
+Absent manual changes by the user, the __fdefinition__ of any **fbound**
+**symbol** read by this **reader macro** will be a __selector__.
+
+Method __selector__s have to be interned prior to use. As this reader
+macro is not capable of interning new __selector__s, you have to ensure
+that __intern-selector__ is called before the respective __selector__ is
+used. This is not a problem for __selector__s known at load-time nor for
+__selector__s registered by way of __collect-selectors__.
## See also:
@@ -109,7 +111,7 @@ __defgeneric__ form has been executed.
finally (progn
(when char (unread-char char stream))
(let ((symbol (intern (format nil "~{~A~}" constituents)
- '#:objective-c-methods)))
+ '#:objective-c-selectors)))
(return symbol)))))