Changeset 187


Ignore:
Timestamp:
Jan 3, 2004, 11:49:04 AM (21 years ago)
Author:
Gary Byers
Message:

(Mostly) work with gnu-objc; may have broken apple-objc ...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/examples/bridge.lisp

    r133 r187  
    351351   #'(lambda (m c)
    352352       (declare (ignore c))
    353        (ignore-errors
     353       (#+gnu-objc progn #+apple-objc ignore-errors
    354354         ;; Some libraries seem to have methods with bogus-looking
    355355         ;; type signatures
     
    368368  (cons
    369369   (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)))))
    375373
    376374
     
    475473
    476474(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))))
    481485    (nconc
    482486     (loop
     
    484488       for ftype in argtypes
    485489       do (ensure-foreign-type-bits (parse-foreign-type ftype))
    486        append (list (foo (translate-foreign-arg-type ftype))
     490       append (list (foo ftype)
    487491                    (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)))))
    491497 
    492498
     
    576582
    577583(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))
    579585    (error "Incorrect number of arguments (~S) to ObjC message ~S"
    580586           (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))))))
    582588
    583589
     
    715721                ;; Regular stret send
    716722                `(progn
    717                    (external-call
    718                     "_objc_msgSend_stret"
    719                     :address ,s :id ,o :<SEL> ,sel
     723                   (objc-message-send-stret ,s ,o ,(cadr sel)
    720724                    ,@(append (butlast argspecs) (list :void)))
    721725                   ,s)
    722726                ;; Super stret send
    723727                `(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)
    727729                    ,@(append (butlast argspecs) (list :void)))
    728730                   ,s)))
     
    734736                         (not (returns-boolean-exception-p msg)))
    735737                  `(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))
    738740                ;; Super send
    739741                (if (and (eq rspec :signed-byte)
    740742                         (not (returns-boolean-exception-p msg)))
    741743                  `(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)))
    746746              ;; STRET not required but provided
    747747              (error "The message ~S must be sent using SEND" msg)))))))
Note: See TracChangeset for help on using the changeset viewer.