Changeset 5827


Ignore:
Timestamp:
Jan 30, 2007, 4:42:50 PM (18 years ago)
Author:
Gary Byers
Message:

Bump *interface-abi-version*, but continue to support the old version.

Don't check the :struct-by-value flag when encoding function args/results.
(That decision's made above our pay grade now.)

When reading a :struct/:union definition, try to update an existing
defintion rather than consing up a new one (this matters if the
record is anonymous.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lib/db-io.lisp

    r5795 r5827  
    3838(in-package "CCL")
    3939
    40 (defparameter *interface-abi-version* 1)
     40(defparameter *interface-abi-version* 2)
     41(defparameter *min-interface-abi-version* 1)
    4142
    4243(defconstant cdb-hash-mask (1- (ash 1 29)))
     
    401402              (if (equal sig "OpenMCL Interface File")
    402403                (if (eq target (backend-name *target-backend*))
    403                   (if (eql version *interface-abi-version*)
     404                  (if (and version
     405                           (>= version *min-interface-abi-version*)
     406                           (<=  version *interface-abi-version*))
    404407                    cdb
    405408                    (error-with-cdb "Wrong interface ABI version. Expected ~d, got ~d" *interface-abi-version* version))
     
    12691272                      '(#\?)))))))))))
    12701273    ((:struct :union)
    1271      (if (getf (ftd-attributes *target-ftd*) :struct-by-value)
    1272        (if return-value-p `(#\a)
    1273                           `(,(if (eq (car spec) :struct)
    1274                                  #\r
    1275                                  #\u)
    1276                             ,@(encode-name (ffi-struct-reference (cadr spec)))))
    1277        `(#\a)))
     1274     `(,(if (eq (car spec) :struct)
     1275                #\r
     1276                #\u)
     1277           ,@(encode-name (ffi-struct-reference (cadr spec)))))
    12781278    (:typedef
    12791279     (let* ((typedef (cadr spec))
     
    16521652    rtype))
    16531653
    1654 (defun %decode-record-type (buf p ftd)
     1654(defun %decode-record-type (buf p ftd already)
    16551655  (declare (type macptr buf) (fixnum p))
    16561656  (let* ((rbyte (%get-unsigned-byte buf p))
     
    16671667           (%decode-name buf (1+ p))))
    16681668      (%determine-record-attributes
    1669        (if name
    1670          (if (eql rcode encoded-type-named-struct-ref)
    1671            (or (info-foreign-type-struct name)
    1672                (setf (info-foreign-type-struct name)
    1673                      (make-foreign-record-type :kind :struct :name name)))
    1674            (or (info-foreign-type-union name)
    1675                (setf (info-foreign-type-union name)
    1676                      (make-foreign-record-type :kind :union :name name))))
    1677          (make-foreign-record-type
    1678           :kind (if (eql rcode encoded-type-anon-struct-ref)
    1679                   :struct
    1680                   :union)
    1681           :name name))
     1669       (or already
     1670           (if name
     1671             (if (eql rcode encoded-type-named-struct-ref)
     1672               (or (info-foreign-type-struct name)
     1673                   (setf (info-foreign-type-struct name)
     1674                         (make-foreign-record-type :kind :struct :name name)))
     1675               (or (info-foreign-type-union name)
     1676                   (setf (info-foreign-type-union name)
     1677                         (make-foreign-record-type :kind :union :name name))))
     1678             (make-foreign-record-type
     1679              :kind (if (eql rcode encoded-type-anon-struct-ref)
     1680                      :struct
     1681                      :union)
     1682              :name name)))
    16821683       (%decode-field-list buf q ftd)
    16831684       alt-align))))
    16841685
    1685 (defun extract-db-record (datum ftd)
     1686(defun extract-db-record (datum ftd already)
    16861687  (let* ((data (pref datum :cdb-datum.data)))
    16871688    (unless (%null-ptr-p data)
    16881689      (prog1
    1689           (%decode-record-type data 0 ftd)
     1690          (%decode-record-type data 0 ftd already)
    16901691        (cdb-free data)))))
    16911692
    16921693
    1693 (defun %load-foreign-record (cdb name ftd)
     1694(defun %load-foreign-record (cdb name ftd already)
    16941695  (when cdb
    16951696    (with-cstrs ((string (string name)))
     
    17011702              (pref contents :cdb-datum.size) 0)
    17021703        (cdb-get cdb key contents)
    1703         (extract-db-record contents ftd)))))
     1704        (extract-db-record contents ftd already)))))
    17041705
    17051706(defun load-record (name &optional (ftd *target-ftd*))
    1706   (let* ((name (unescape-foreign-name name)))
     1707  ;; Try to destructively modify any info we already have.  Use the
     1708  ;; "escaped" name (keyword) for the lookup here.
     1709  (let* ((already (or (info-foreign-type-struct name ftd)
     1710                      (info-foreign-type-union name ftd)))
     1711         (name (unescape-foreign-name name)))
    17071712    (do-interface-dirs (d)
    1708       (let* ((r (%load-foreign-record (db-records d) name ftd)))
     1713      (let* ((r (%load-foreign-record (db-records d) name ftd already)))
    17091714        (when r (return r))))))
Note: See TracChangeset for help on using the changeset viewer.