diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-16 00:42:47 +0200 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-16 00:42:47 +0200 |
commit | 6a82b0dd5fd0f087ecda5923c6ae93fcea806141 (patch) | |
tree | fc4495093b9abe9ad2f6a96b3d080edb867df9ef | |
parent | d9ac18064cf40f6fbbb09ec8ca74de212c012326 (diff) |
Remember to pass self and _cmd to methods.
darcs-hash:1f832c3dba42782993127d480d2cb73aabf2406c
-rw-r--r-- | Lisp/libobjcl.lisp | 2 | ||||
-rw-r--r-- | Lisp/method-invocation.lisp | 10 | ||||
-rw-r--r-- | Objective-C/libobjcl.h | 4 | ||||
-rw-r--r-- | Objective-C/libobjcl.m | 11 |
4 files changed, 14 insertions, 13 deletions
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp index d1efe53..6cb9759 100644 --- a/Lisp/libobjcl.lisp +++ b/Lisp/libobjcl.lisp @@ -33,8 +33,6 @@ &rest) (defcfun ("objcl_invoke_with_types" %objcl-invoke-with-types) :pointer - (receiver (:pointer :void)) - (method_selector (:pointer :void)) (argc :int) (return_typespec (:pointer :char)) (arg_typespecs (:pointer (:pointer :char))) diff --git a/Lisp/method-invocation.lisp b/Lisp/method-invocation.lisp index 43a3365..c44fb04 100644 --- a/Lisp/method-invocation.lisp +++ b/Lisp/method-invocation.lisp @@ -189,11 +189,15 @@ Returns: *result* --- the return value of the method invocation. (type-name->type-id return-type))) (selector (selector method-name))) (cffi:with-foreign-objects ((arg-types '(:pointer :char) (length args)) - (objc-args '(:pointer :void) (length args)) + (objc-args '(:pointer :void) (+ (length args) 2)) (return-value-cell return-c-type)) (flet ((ad-hoc-arglist->objc-arglist! (args) + (setf (cffi:mem-aref objc-args '(:pointer :void) 0) + (pointer-to receiver) + (cffi:mem-aref objc-args '(:pointer :void) 1) + (pointer-to selector)) (loop for arg in args - for i from 0 + for i from 2 do (let* ((type-name (lisp-value->type-name arg)) #+(or) (cffi-type (type-name->lisp-type type-name))) @@ -220,7 +224,7 @@ Returns: *result* --- the return value of the method invocation. (dealloc-ad-hoc-objc-arglist () (dotimes (i (length args)) (cffi:foreign-free - (cffi:mem-aref objc-args '(:pointer :void) i)) + (cffi:mem-aref objc-args '(:pointer :void) (+ i 2))) (cffi:foreign-string-free (cffi:mem-aref arg-types '(:pointer :char) i))))) (ad-hoc-arglist->objc-arglist! args) diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h index b47ab17..d2f5e76 100644 --- a/Objective-C/libobjcl.h +++ b/Objective-C/libobjcl.h @@ -51,9 +51,7 @@ objcl_invoke_method (OBJCL_OBJ_DATA receiver, ...); id -objcl_invoke_with_types (void *receiver, - SEL method_selector, - int argc, +objcl_invoke_with_types (int argc, char *return_typespec, char *arg_typespecs[], void *return_value, diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index 7dc5de2..4fe4aef 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -268,9 +268,7 @@ objcl_invoke_method (OBJCL_OBJ_DATA receiver, #ifdef USE_LIBFFI id -objcl_invoke_with_types (void *receiver, - SEL method_selector, - int argc, +objcl_invoke_with_types (int argc, char *return_typespec, char *arg_typespecs[], void *return_value, @@ -283,6 +281,9 @@ objcl_invoke_with_types (void *receiver, ffi_type *arg_types[argc + 2]; ffi_status status; + id receiver = (id) argv[0]; + SEL method_selector = (SEL) argv[1]; + static ffi_type *id_type = NULL; static ffi_type *sel_type = NULL; @@ -294,7 +295,7 @@ objcl_invoke_with_types (void *receiver, NS_DURING { #ifdef __NEXT_RUNTIME__ - method = class_getInstanceMethod ([((id) receiver) class], method_selector)->method_imp; + method = class_getInstanceMethod ([receiver class], method_selector)->method_imp; #else method = objc_msg_lookup (receiver, method_selector); #endif @@ -319,7 +320,7 @@ objcl_invoke_with_types (void *receiver, userInfo: nil] raise]; } - ffi_call (&cif, (void *) method, return_value, argv); + ffi_call (&cif, FFI_FN (method), return_value, argv); } NS_HANDLER { |