summaryrefslogtreecommitdiff
path: root/Lisp
diff options
context:
space:
mode:
Diffstat (limited to 'Lisp')
-rw-r--r--Lisp/defpackage.lisp1
-rw-r--r--Lisp/libobjcl.lisp26
-rw-r--r--Lisp/method-definition.lisp6
-rw-r--r--Lisp/reader-syntax.lisp2
4 files changed, 32 insertions, 3 deletions
diff --git a/Lisp/defpackage.lisp b/Lisp/defpackage.lisp
index 3cacf12..da289ee 100644
--- a/Lisp/defpackage.lisp
+++ b/Lisp/defpackage.lisp
@@ -39,6 +39,7 @@
#:define-returns-boolean-exception
#:undefine-returns-boolean-exception
#:collect-classes
+ #:collect-methods
;; Generic functions
#:objc-eql
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp
index d038c62..af8b66c 100644
--- a/Lisp/libobjcl.lisp
+++ b/Lisp/libobjcl.lisp
@@ -196,6 +196,13 @@
(defcfun ("objcl_test_foo" objcl-test-foo) :void)
+(defcfun ("objcl_method_selector" %objcl-method-selector) :pointer
+ (method :pointer))
+
+(defcfun ("objcl_class_methods" %objcl-class-methods) :pointer
+ (class :pointer)
+ (count-out :pointer))
+
(defcvar *objcl-current-exception-lock* :pointer)
(defcvar *objcl-current-exception* :pointer)
@@ -920,6 +927,25 @@ separating parts by hyphens works nicely in all of the `:INVERT`,
(not (zerop (%objcl-objc2-p))))
+;;;; (@* "Registry update and maintenance")
+(defcallback collect-class-methods :void ((class :pointer))
+ (flet ((collect-methods (class)
+ (with-foreign-object (count-buf :unsigned-int)
+ (let ((method-array (%objcl-class-methods class count-buf)))
+ (unwind-protect
+ (dotimes (i (mem-ref count-buf :unsigned-int))
+ (intern-pointer-wrapper 'selector
+ :pointer
+ (%objcl-method-selector
+ (mem-aref method-array :void i))))
+ (foreign-free method-array))))))
+ (collect-methods class)
+ (collect-methods (%objcl-class-metaclass class))))
+
+(defun collect-methods ()
+ (%objcl-for-each-class-do (callback collect-class-methods)))
+
+
;;;; (@* "Slot access")
(defun objcl-slot-type (slot)
(%objcl-slot-type slot))
diff --git a/Lisp/method-definition.lisp b/Lisp/method-definition.lisp
index 41f1f84..cbfc344 100644
--- a/Lisp/method-definition.lisp
+++ b/Lisp/method-definition.lisp
@@ -69,7 +69,8 @@
else
collect :id into type-specifiers
finally (return
- `(defmethod ,name
+ `(defmethod ,(intern (symbol-name name)
+ '#:objective-c-methods)
argtypes-start ,@type-specifiers argtypes-end
,@qualifiers ,lambda-list
,@body)))))))
@@ -80,7 +81,8 @@
(defmacro define-objective-c-generic-function (name lambda-list &body options)
- `(defgeneric ,name ,lambda-list
+ `(defgeneric ,(intern (symbol-name name) '#:objective-c-methods)
+ ,lambda-list
,@(unless (position :generic-function-class
options
:key #'car)
diff --git a/Lisp/reader-syntax.lisp b/Lisp/reader-syntax.lisp
index 9f0bcb7..ddf9edc 100644
--- a/Lisp/reader-syntax.lisp
+++ b/Lisp/reader-syntax.lisp
@@ -78,7 +78,7 @@ 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__.
+__selector__s registered by way of __collect-methods__.
## See also: