diff options
Diffstat (limited to 'Lisp')
-rw-r--r-- | Lisp/libobjcl.lisp | 4 | ||||
-rw-r--r-- | Lisp/method-invocation.lisp | 22 |
2 files changed, 10 insertions, 16 deletions
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp index 38b244f..fab195e 100644 --- a/Lisp/libobjcl.lisp +++ b/Lisp/libobjcl.lisp @@ -731,10 +731,6 @@ separating parts by hyphens works nicely in all of the `:INVERT`, (%objcl-object-is-meta-class (pointer obj))) (defun object-get-class (obj) - ;; OPTIMISE: Both find-objc-class-by-name and %objcl-class-name are - ;; slow and mostly unneeded. We can simply retrieve classes by class - ;; pointer if they have already been registered in a hash table - ;; somewhere. (intern-pointer-wrapper 'objective-c-class :pointer (%objcl-object-get-class (pointer obj)))) diff --git a/Lisp/method-invocation.lisp b/Lisp/method-invocation.lisp index c4ba3fc..29ad3c6 100644 --- a/Lisp/method-invocation.lisp +++ b/Lisp/method-invocation.lisp @@ -215,17 +215,13 @@ easier to use with __apply__. ;; TODO: Support varargs. (let* ((selector (if (typep method-name 'selector) method-name - (find-selector method-name))) - (class (object-get-class receiver))) + (find-selector method-name)))) (multiple-value-bind (argc method-return-typestring method-return-type method-arg-typestrings method-arg-types) - (retrieve-method-signature-info class selector - (if (object-is-class-p receiver) - :class - :instance)) + (retrieve-method-signature-info receiver selector) (assert (= argc (+ 2 (length args))) (args) "Wrong number of arguments (expected ~A, got ~A)." @@ -296,17 +292,19 @@ easier to use with __apply__. (define-cached-function retrieve-method-signature-info - (class selector &optional (instance-or-class :instance)) - (cons (cffi:pointer-address (pointer-to class)) + (receiver selector + &aux (class-ptr (%objcl-object-get-class (pointer receiver)))) + (cons (cffi:pointer-address class-ptr) (cffi:pointer-address (pointer-to selector))) - (let* ((signature - (objc-or (if (eq instance-or-class :instance) + (let* ((class (object-get-class receiver)) + (signature + (objc-or (if (object-is-class-p receiver) (primitive-invoke class - "instanceMethodSignatureForSelector:" + "methodSignatureForSelector:" 'id selector) (primitive-invoke class - "methodSignatureForSelector:" + "instanceMethodSignatureForSelector:" 'id selector)) (error (make-condition 'message-not-understood |