Changeset 187
- Timestamp:
- Jan 3, 2004, 11:49:04 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/ccl/examples/bridge.lisp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/bridge.lisp
r133 r187 351 351 #'(lambda (m c) 352 352 (declare (ignore c)) 353 ( ignore-errors353 (#+gnu-objc progn #+apple-objc ignore-errors 354 354 ;; Some libraries seem to have methods with bogus-looking 355 355 ;; type signatures … … 368 368 (cons 369 369 (objc-foreign-arg-type (method-typestring m)) 370 (%stack-block ((type 4) (offset 4)) 371 (loop for i from 2 below (method-get-number-of-arguments m) 372 do (#_method_getArgumentInfo m i type offset) 373 collect 374 (objc-foreign-arg-type (%get-cstring (%get-ptr type))))))) 370 (loop for i from 2 below (method-get-number-of-arguments m) 371 collect 372 (objc-foreign-arg-type (objc-get-method-argument-info m i))))) 375 373 376 374 … … 475 473 476 474 (defun convert-to-argspecs (argtypes result-ftype args evalargs) 477 (flet ((foo (tftype) 478 (if (and (consp tftype) (eq (first tftype) :record)) 479 (/ (second tftype) 32) 480 tftype))) 475 (flet ((foo (ftype &optional for-result) 476 (let* ((translated 477 (if for-result 478 (translate-foreign-result-type ftype) 479 (translate-foreign-arg-type ftype)))) 480 (if (and (consp translated) (eq (first translated) :record)) 481 #+apple-objc 482 (/ (second translated) 32) 483 #+gnu-objc `(:* ,ftype) 484 translated)))) 481 485 (nconc 482 486 (loop … … 484 488 for ftype in argtypes 485 489 do (ensure-foreign-type-bits (parse-foreign-type ftype)) 486 append (list (foo (translate-foreign-arg-type ftype))490 append (list (foo ftype) 487 491 (if evalargs 488 (coerce-to-foreign-type a ftype) 489 `(coerce-to-foreign-type ,a ,ftype)))) 490 (list (foo (translate-foreign-result-type result-ftype)))))) 492 (coerce-to-foreign-type a 493 #+apple-objc ftype 494 #+gnu-objc (foo ftype)) 495 `(coerce-to-foreign-type ,a #+apple-objc ,ftype #+gnu-objc ,(foo ftype))))) 496 (list (foo result-ftype t))))) 491 497 492 498 … … 576 582 577 583 (defun check-method-arg-count (m args) 578 (unless (= (length args) (- ( #_method_getNumberOfArguments m) 2))584 (unless (= (length args) (- (method-get-number-of-arguments m) 2)) 579 585 (error "Incorrect number of arguments (~S) to ObjC message ~S" 580 586 (length args) 581 (%get-cstring ( #_sel_getName(pref m :objc_method.method_name))))))587 (%get-cstring (lisp-string-from-sel (pref m :objc_method.method_name)))))) 582 588 583 589 … … 715 721 ;; Regular stret send 716 722 `(progn 717 (external-call 718 "_objc_msgSend_stret" 719 :address ,s :id ,o :<SEL> ,sel 723 (objc-message-send-stret ,s ,o ,(cadr sel) 720 724 ,@(append (butlast argspecs) (list :void))) 721 725 ,s) 722 726 ;; Super stret send 723 727 `(progn 724 (external-call 725 "_objc_msgSendSuper_stret" 726 :address ,s :address ,super :<SEL> ,sel 728 (objc-message-send-super-stret ,s ,super ,(cadr sel) 727 729 ,@(append (butlast argspecs) (list :void))) 728 730 ,s))) … … 734 736 (not (returns-boolean-exception-p msg))) 735 737 `(coerce-from-bool 736 ( external-call "_objc_msgSend" :id ,o :<SEL> ,sel,@argspecs))737 `( external-call "_objc_msgSend" :id ,o :<SEL> ,sel,@argspecs))738 (objc-message-send ,o ,(cadr sel) ,@argspecs)) 739 `(objc-message-send ,o ,(cadr sel) ,@argspecs)) 738 740 ;; Super send 739 741 (if (and (eq rspec :signed-byte) 740 742 (not (returns-boolean-exception-p msg))) 741 743 `(coerce-from-bool 742 (external-call "_objc_msgSendSuper" 743 :address ,super :<SEL> ,sel ,@argspecs)) 744 `(external-call "_objc_msgSendSuper" 745 :address ,super :<SEL> ,sel ,@argspecs))) 744 (objc-message-send-super ,super ,(cadr sel) ,@argspecs)) 745 `(objc-message-send-super ,super ,(cadr sel) ,@argspecs))) 746 746 ;; STRET not required but provided 747 747 (error "The message ~S must be sent using SEND" msg)))))))
Note:
See TracChangeset
for help on using the changeset viewer.
