Changeset 6648


Ignore:
Timestamp:
Jun 3, 2007, 2:44:54 AM (17 years ago)
Author:
Gary Byers
Message:

DEFCALLBACK: if error-return, use HANDLER-BIND, not HANDLER-CASE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ide-1.0/ccl/lib/macros.lisp

    r6562 r6648  
    24272427                       (%setf-macptr-to-object ,stack-ptr ,stack-word)
    24282428                       (with-macptrs (,@(when fp-args-form
    2429                                              `((,fp-args-ptr ,fp-args-form))))
    2430                          ,(defcallback-body  stack-ptr
    2431                                              fp-args-ptr
    2432                                              lets
    2433                                              rlets
    2434                                              inits
    2435                                              `(declare (dynamic-extent ,@dynamic-extent-names))
    2436                                              decls
    2437                                              body
    2438                                              foreign-return-type
    2439                                              struct-return-arg-name
    2440                                              error-return
    2441                                              error-return-offset
    2442                                              ))))))
     2429                                              `((,fp-args-ptr ,fp-args-form))))
     2430                         ,(defcallback-body stack-ptr
     2431                                            fp-args-ptr
     2432                                            lets
     2433                                            rlets
     2434                                            inits
     2435                                            `(declare (dynamic-extent ,@dynamic-extent-names))
     2436                                            decls
     2437                                            body
     2438                                            foreign-return-type
     2439                                            struct-return-arg-name
     2440                                            error-return
     2441                                            error-return-offset
     2442                                            ))))))
    24432443                ,doc
    24442444              ,woi
     
    24492449  (declare (dynamic-extent args))
    24502450  (destructuring-bind (stack-ptr fp-args-ptr lets rlets inits dynamic-extent-decls other-decls body return-type struct-return-arg error-return error-delta) args
    2451       (let* ((result (gensym))
    2452          (condition-name (if (atom error-return) 'error (car error-return)))
    2453          (error-return-function (if (atom error-return) error-return (cadr error-return)))
    2454          (body
    2455           `(rlet ,rlets
    2456             (let ,lets
    2457               ,dynamic-extent-decls
    2458               ,@other-decls
    2459               ,@inits
    2460               (let ((,result (progn ,@body)))
    2461                 (declare (ignorable ,result))
    2462                 ,@(progn
    2463                    ;; Coerce SINGLE-FLOAT result to DOUBLE-FLOAT
    2464                    (when (typep return-type 'foreign-single-float-type)
    2465                      (setq result `(float ,result 0.0d0)))
    2466                    nil)
    2467                 ,(funcall (ftd-callback-return-value-function *target-ftd*)
    2468                           stack-ptr
    2469                           fp-args-ptr
    2470                           result
    2471                           return-type
    2472                           struct-return-arg))))))
    2473     (if error-return
    2474       (let* ((cond (gensym)))
    2475         `(handler-case ,body
    2476           (,condition-name (,cond) (,error-return-function ,cond ,stack-ptr (%inc-ptr ,stack-ptr ,error-delta)))))
    2477       body))))
     2451    (declare (ignorable dynamic-extent-decls))
     2452    (let* ((result (gensym))
     2453           (condition-name (if (atom error-return) 'error (car error-return)))
     2454           (error-return-function (if (atom error-return) error-return (cadr error-return)))
     2455           (body
     2456            `(rlet ,rlets
     2457              (let ,lets
     2458                ,dynamic-extent-decls
     2459                ,@other-decls
     2460                ,@inits
     2461                (let ((,result (progn ,@body)))
     2462                  (declare (ignorable ,result))
     2463                  ,@(progn
     2464                     ;; Coerce SINGLE-FLOAT result to DOUBLE-FLOAT
     2465                     (when (typep return-type 'foreign-single-float-type)
     2466                       (setq result `(float ,result 0.0d0)))
     2467                     nil)
     2468                  ,(funcall (ftd-callback-return-value-function *target-ftd*)
     2469                            stack-ptr
     2470                            fp-args-ptr
     2471                            result
     2472                            return-type
     2473                            struct-return-arg))))))
     2474      (if error-return
     2475        (let* ((cond (gensym))
     2476               (block (gensym)))
     2477          `(block ,block (handler-bind ((,condition-name
     2478                                         (lambda (,cond)
     2479                                           (,error-return-function ,cond ,stack-ptr (%inc-ptr ,stack-ptr ,error-delta))
     2480                                           (return-from ,block
     2481                                             nil))))
     2482                           ,body)))
     2483        body))))
    24782484
    24792485
Note: See TracChangeset for help on using the changeset viewer.