Changeset 6157


Ignore:
Timestamp:
Apr 7, 2007, 12:47:42 PM (12 years ago)
Author:
gb
Message:

Get struct return working in objc:defmethod.
Define OBJC:LOAD-FRAMEWORK, to simplify ... framework loading.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/objc-gf/ccl/examples/objc-runtime.lisp

    r6140 r6157  
    13181318      (funcall (ftd-ff-call-expand-function *target-ftd*)
    13191319               `(%ff-call (%reference-external-entry-point (load-time-value (external ,entry-name))))
    1320                `(,structptr :address ,super :<SEL> (%get-selector ,selector) ,@argspecs)
     1320               `(,structptr :address ,super :<SEL> ,selector ,@argspecs)
    13211321               :arg-coerce 'objc-arg-coerce
    13221322               :result-coerce 'objc-result-coerce))
     
    13261326         (imp (gensym)))
    13271327    `(with-macptrs ((,sup ,super)
    1328                     (,sel (%get-selector ,selector))
     1328                    (,sel ,selector)
    13291329                    (,imp (external-call "objc_msg_lookup_super"
    13301330                                         :<S>uper_t ,sup
     
    26242624
    26252625
    2626 
    2627 
     2626(declaim (inline %objc-struct-return))
     2627
     2628(defun %objc-struct-return (return-temp size value)
     2629  (unless (eq return-temp value)
     2630    (#_bcopy value return-temp size)))
    26282631
    26292632(defmacro objc:defmethod (name (self-arg &rest other-args) &body body &environment env)
     
    26342637            (type-assertions))
    26352638    (let* ((result-type nil)
     2639           (struct-return-var nil)
     2640           (struct-return-size nil)
    26362641           (selector nil)
    26372642           (cmd (intern "_CMD"))
     
    26492654            (setq class-p t lisp-class-name (subseq lisp-class-name 1)))
    26502655          (setq objc-class-name (lisp-to-objc-classname lisp-class-name)))
     2656        (let* ((rtype (parse-foreign-type result-type)))
     2657          (when (typep rtype 'foreign-record-type)
     2658            (setq struct-return-var (gensym))
     2659            (setq struct-return-size (ceiling (foreign-type-bits rtype) 8))
     2660            (arglist struct-return-var)))
    26512661        (arg-types :<SEL>)
    26522662        (arg-names cmd)
     
    26902700              (if (eq result-type :<BOOL>)
    26912701                (setq body `((%coerce-to-bool ,@body))))
     2702              (when struct-return-var
     2703                (setq body `((%objc-struct-return ,struct-return-var ,struct-return-size ,@body)))
     2704                (setq body `((flet ((struct-return-var-function ()
     2705                                      ,struct-return-var))
     2706                               (declaim (inline struct-return-var-function))
     2707                               ,@body)))
     2708                (setq body `((macrolet ((objc:returning-foreign-struct ((var) &body body)
     2709                                          `(let* ((,var (struct-return-var-function)))
     2710                                            ,@body)))
     2711                               ,@body))))
    26922712              (setq body `((flet ((call-next-method (&rest args)
    26932713                                  (declare (dynamic-extent args))
Note: See TracChangeset for help on using the changeset viewer.