Changeset 6063


Ignore:
Timestamp:
Mar 18, 2007, 8:06:01 AM (13 years ago)
Author:
gb
Message:

In DECODE-ARGUMENTS (used to decode "regular" function arguments/return
value), make sure that a foreign typedef name is escaped.

When decoding ObjC method arguments/result types, tell %DECODE-TYPE
not to expand typedefs. (This helps to canonicalize things if the
typedef refers to an anonymous type, e.g., the :<NSD>ecimal case
in the ObjC bridge.)

In ENCODE-FFI-ARG-TYPE, handle return values the same as arguments.
Don't expand typedefs, just encode the name in the signature.

%DECODE-TYPE takes an extra SUPPRESS-TYPEDEF-EXPANSION argument.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/objc-gf/ccl/lib/db-io.lisp

    r6053 r6063  
    567567                          (setf (schar name k)
    568568                                (schar string (incf i))))
     569                        (setq name (escape-foreign-name name))
    569570                        (if (eql ch #\r)
    570                           `(:struct ,(escape-foreign-name name))
     571                          `(:struct ,name)
    571572                          (if (eql ch #\u)
    572                             `(:union ,(escape-foreign-name name))
     573                            `(:union ,name)
    573574                            name)))
    574575                      (cdr (assoc ch *arg-spec-encoding*)))))
     
    894895                 (arg-type ()))
    895896            (multiple-value-setq (class-name p) (%decode-name buf p t))
    896             (multiple-value-setq (result-type p) (%decode-type buf p ftd))
     897            (multiple-value-setq (result-type p) (%decode-type buf p ftd t))
    897898            (dotimes (i nargs)
    898               (multiple-value-setq (arg-type p) (%decode-type buf p ftd))
     899              (multiple-value-setq (arg-type p) (%decode-type buf p ftd t))
    899900              (push arg-type arg-types))
    900901            (unless (dolist (m (objc-message-info-methods info))
     
    12361237      (break "Type spec = ~s" spec))))
    12371238
    1238 (defun encode-ffi-arg-type (spec &optional return-value-p)
     1239(defun encode-ffi-arg-type (spec)
    12391240  (case (car spec)
    12401241    (:primitive
     
    12811282           ,@(encode-name (ffi-struct-reference (cadr spec)))))
    12821283    (:typedef
    1283      (let* ((typedef (cadr spec))
    1284             (type (ffi-typedef-type typedef)))
    1285        (if (or return-value-p
    1286                (not (member (car type) '(:struct :union)))
    1287                #+eabi-target t)
    1288          (encode-ffi-arg-type type)
    1289          `(#\t ,@(encode-name (ffi-typedef-name typedef))))))
     1284     `(#\t ,@(encode-name (ffi-typedef-name (cadr spec)))))
    12901285    (:pointer
    12911286      `(#\a))
     
    13091304    `(,min-args
    13101305      ,@(encode-name name t)            ; verbatim
    1311       ,@(encode-ffi-arg-type result t)
     1306      ,@(encode-ffi-arg-type result)
    13121307      ,@(encode-ffi-arg-list args))))
    13131308
     
    15001495 
    15011496;; Should return a FOREIGN-TYPE structure.
    1502 (defun %decode-type (buf p ftd)
     1497(defun %decode-type (buf p ftd &optional suppress-typedef-expansion)
    15031498  (declare (type macptr buf) (fixnum p))
    15041499  (let* ((q (1+ p)))
     
    15511546                     qqq)))))
    15521547      (#.encoded-type-named-type-ref
    1553        (multiple-value-bind (name qq) (%decode-name buf q)
    1554          (values (%parse-foreign-type name) qq)))
     1548       (multiple-value-bind (name qq) (%decode-name buf q)         
     1549         (values (if suppress-typedef-expansion
     1550                   name
     1551                   (%parse-foreign-type name))
     1552                 qq)))
    15551553      (#.encoded-type-named-struct-ref
    15561554       (multiple-value-bind (name qq) (%decode-name buf q)
Note: See TracChangeset for help on using the changeset viewer.