Changeset 6136


Ignore:
Timestamp:
Apr 5, 2007, 3:38:56 PM (13 years ago)
Author:
gb
Message:

Functions to check a record-type's fields: are all fields floats ? Are
any fields floats ?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/objc-gf/ccl/lib/foreign-types.lisp

    r6101 r6136  
    16321632          (accessors field-name))))))
    16331633
     1634;;; Are all (scalar) fields in the field-list FIELDS floats ?'
     1635(defun all-floats-in-field-list (fields)
     1636  (dolist (field fields t)
     1637    (let* ((field-type (foreign-record-field-type field)))
     1638      (cond ((typep field-type 'foreign-record-type)
     1639             (unless (all-floats-in-field-list (foreign-record-type-fields field-type))
     1640                                     (return nil)))
     1641            ((typep field-type 'foreign-array-type)
     1642             (unless (typep (foreign-array-type-element-type field-type) 'foreign-float-type)
     1643               (return nil)))
     1644            (t (unless (typep field-type 'foreign-float-type)
     1645                 (return nil)))))))
     1646
     1647;;; Are any (scalar) fields in the field-list FIELDS floats ?
     1648(defun some-floats-in-field-list (fields)
     1649  (dolist (field fields)
     1650    (let* ((field-type (foreign-record-field-type field)))
     1651      (cond ((typep field-type 'foreign-float-type)
     1652             (return t))
     1653            ((typep field-type 'foreign-record-type)
     1654             (if (some-floats-in-field-list (foreign-record-type-fields field-type))
     1655               (return t)))
     1656            ((typep field-type 'foreign-array-type)
     1657             (if (typep (foreign-array-type-element-type field-type)
     1658                        'foreign-float-type)
     1659               (return t)))))))
     1660
    16341661
    16351662(defun canonicalize-foreign-type-ordinals (ftd)
Note: See TracChangeset for help on using the changeset viewer.