diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-17 23:29:58 +0200 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-17 23:29:58 +0200 |
commit | f98c79811e81eff07f967f28c108b76a4a7d1343 (patch) | |
tree | 9ad511a4309f00306e0f4bea95001c85578b0868 /Lisp/method-invocation.lisp | |
parent | 909b52ce5a0c7a9beca639b830f5f57380af64ff (diff) |
INVOKE-WITH-CONVERSION: Support classes as message receivers.
darcs-hash:f27d973190d6ada1ef35ab041229d1c0b88ee11c
Diffstat (limited to 'Lisp/method-invocation.lisp')
-rw-r--r-- | Lisp/method-invocation.lisp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/Lisp/method-invocation.lisp b/Lisp/method-invocation.lisp index 40d1d5d..bc6cc2d 100644 --- a/Lisp/method-invocation.lisp +++ b/Lisp/method-invocation.lisp @@ -266,22 +266,32 @@ Returns: *result* --- the return value of the method invocation. ((id objc-class exception selector) (let ((*skip-retaining* (or *skip-retaining* - (constructor-name-p (selector-name selector))))) - (make-instance return-type - :pointer (cffi:mem-ref return-value-cell - return-c-type)))) + (constructor-name-p (selector-name selector)))) + (pointer (cffi:mem-ref return-value-cell + return-c-type))) + (if (cffi:null-pointer-p pointer) + nil + (make-instance return-type + :pointer pointer)))) ((:void) (values)) (otherwise (cffi:mem-ref return-value-cell return-c-type))))))))))) -(define-cached-function retrieve-method-signature-info (class selector) +(define-cached-function retrieve-method-signature-info + (class selector &optional (instance-or-class :instance)) (cons (cffi:pointer-address (pointer-to class)) (cffi:pointer-address (pointer-to selector))) - (let* ((signature (primitive-invoke class - :instance-method-signature-for-selector - 'id - selector)) + (let* ((signature + (if (eq instance-or-class :instance) + (primitive-invoke class + :instance-method-signature-for-selector + 'id + selector) + (primitive-invoke class + :method-signature-for-selector + 'id + selector))) (argc (primitive-invoke signature 'number-of-arguments :unsigned-int)) (method-return-typestring (primitive-invoke signature 'method-return-type @@ -388,7 +398,11 @@ Returns: *result* --- the return value of the method invocation. method-return-type method-arg-typestrings method-arg-types) - (retrieve-method-signature-info class selector) + (retrieve-method-signature-info class selector + (if (cffi:pointer-eq (pointer-to receiver) + (pointer-to class)) + :class + :instance)) (assert (= argc (+ 2 (length args))) (args) "Wrong number of arguments (expected ~A, got ~A)." |