Changeset 5733
- Timestamp:
- Jan 18, 2007, 3:17:16 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/examples/bridge.lisp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/bridge.lisp
r2132 r5733 78 78 ;; (STRING-with-N-colons ARG1 ... ARGN {LIST}) 79 79 (let* ((n (count #\: (the simple-string f))) 80 (message-info ( get-objc-message-info f))80 (message-info (need-objc-message-info f)) 81 81 (args (rest args)) 82 82 (nargs (length args))) … … 92 92 (let ((nargs (length args))) 93 93 (cond ((and (= nargs 2) (consp l) 94 (let* ((info ( get-objc-message-info94 (let* ((info (need-objc-message-info 95 95 (lisp-to-objc-message (list f))))) 96 96 (getf (objc-message-info-flags info) … … 218 218 (if (numberp rspec) 219 219 (> rspec 1) 220 (> (ensure-foreign-type-bits (parse-foreign-type rspec)) 32)))220 (> (ensure-foreign-type-bits (parse-foreign-type rspec)) target::nbits-in-word))) 221 221 222 222 … … 375 375 (objc-method-info-arglist m))))))) 376 376 (let* ((methods (objc-message-info-methods message-info)) 377 (signatures ()) 378 (protocol-methods) 377 379 (signature-alist ())) 378 380 (dolist (m methods) 379 (let* ((signature (ensure-method-signature m)) 380 (pair (assoc signature signature-alist :test #'equal))) 381 (if pair 382 (push m (cdr pair)) 383 (push (cons signature (list m)) signature-alist)))) 381 (let* ((signature (ensure-method-signature m))) 382 (pushnew signature signatures :test #'equal) 383 (if (getf (objc-method-info-flags m) :protocol) 384 (push m protocol-methods) 385 (let* ((pair (assoc signature signature-alist :test #'equal))) 386 (if pair 387 (push m (cdr pair)) 388 (push (cons signature (list m)) signature-alist)))))) 384 389 (setf (objc-message-info-ambiguous-methods message-info) 385 390 (mapcar #'cdr … … 389 394 (length (cdr y))))))) 390 395 (setf (objc-message-info-flags message-info) nil) 391 (when (cdr (objc-message-info-ambiguous-methods message-info)) 396 (setf (objc-message-info-protocol-methods message-info) 397 protocol-methods) 398 (when (cdr signatures) 392 399 (setf (getf (objc-message-info-flags message-info) :ambiguous) t)) 393 400 (let* ((first-method (car methods)) … … 438 445 info)))) 439 446 447 (defun need-objc-message-info (message-name) 448 (or (get-objc-message-info message-name) 449 (error "Undeclared message: ~s" message-name))) 450 440 451 ;;; Should be called after using new interfaces that may define 441 452 ;;; new methods on existing messages. … … 558 569 (if (and (consp translated) (eq (first translated) :record)) 559 570 #+apple-objc 560 ( / (second translated) 32)571 (ceiling (second translated) target::nbits-in-word) 561 572 #+gnu-objc `(:* ,ftype) 562 573 translated)))) … … 615 626 (methods (objc-message-info-methods message-info)) 616 627 (method (if (not ambiguous) (car methods)))) 617 ( ifambiguous628 (when ambiguous 618 629 (let* ((class (if sclassname 619 630 (find-objc-class sclassname) … … 621 632 (if class 622 633 (dolist (m methods) 623 (let* ((mclass (or (get-objc-method-info-class m) 624 (error "Can't find ObjC class named ~s" 625 (objc-method-info-class-name m))))) 626 (when (and class (subtypep class mclass)) 627 (return (setq method m)))))))) 634 (unless (getf (objc-method-info-flags m) :protocol) 635 (let* ((mclass (or (get-objc-method-info-class m) 636 (error "Can't find ObjC class named ~s" 637 (objc-method-info-class-name m))))) 638 (when (and class (subtypep class mclass)) 639 (return (setq method m))))))))) 628 640 (if method 629 641 (build-call-from-method-info method … … 746 758 msg 747 759 s 748 super) 760 super 761 protocol-methods) 749 762 (flet ((method-class-name (m) 750 763 (let* ((mclass (get-objc-method-info-class m))) … … 754 767 (class-name mclass)))) 755 768 (collect ((clauses)) 769 (let* ((protocol (gensym))) 770 (dolist (method protocol-methods) 771 (let* ((protocol-name (objc-method-info-class-name method))) 772 (clauses `((let* ((,protocol (lookup-objc-protocol ,protocol-name))) 773 (and ,protocol 774 (not (zerop (objc-message-send ,receiver 775 "conformsToProtocol:" 776 :address ,protocol 777 :<BOOL>))))) 778 ,(build-internal-call-from-method-info 779 method args vargs receiver msg s super)))))) 756 780 (do* ((methods ambiguous-methods (cdr methods))) 757 781 ((null (cdr methods)) 782 (when ambiguous-methods 758 783 (clauses `(t 759 784 ,(build-internal-call-from-method-info 760 (caar methods) args vargs receiver msg s super)))) 785 (caar methods) args vargs receiver msg s super))))) 761 786 (clauses `(,(if (cdar methods) 762 787 `(or ,@(mapcar #'(lambda (m) … … 780 805 msg 781 806 s 782 super))) 807 super 808 (objc-message-info-protocol-methods message-info)))) 783 809 `(with-ns-exceptions-as-errors 784 810 (rlet ,svarforms
Note:
See TracChangeset
for help on using the changeset viewer.
