Changeset 10649


Ignore:
Timestamp:
Sep 8, 2008, 8:22:57 AM (11 years ago)
Author:
gb
Message:

New scheme for canonical foreign ordinals. Hopefully less messy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/foreign-types.lisp

    r10519 r10649  
    4646
    4747(defconstant max-canonical-foreign-type-ordinal 100)
     48
     49;;; Some foreign types are "common" (POSIXy things that're available
     50;;; on most platforms; some are very platform-specific.  It's getting
     51;;; to be a mess to keep those separate by reader conditionalization,
     52;;; so use the first 50 ordinals for "common" foreign types and the
     53;;; next 50 for platform-specific stuff.
     54
     55(defconstant max-common-foreign-type-ordinal 50)
    4856
    4957;;; This is intended to try to encapsulate foreign type stuff, to
     
    7280  (ordinal-types (make-hash-table :test #'eq :weak :value))
    7381  (pointer-types (make-hash-table :test #'eq))
    74   (array-types (make-hash-table :test #'equal)))
     82  (array-types (make-hash-table :test #'equal))
     83  (platform-ordinal-types ()))
    7584
    7685
     
    16831692               (return t)))))))
    16841693
    1685 
     1694(defparameter *canonical-unix-foreign-types*
     1695  '((:struct :timespec)
     1696    (:struct :timeval)
     1697    (:struct :stat)
     1698    (:struct :passwd)
     1699    #>Dl_info))
     1700   
    16861701(defun canonicalize-foreign-type-ordinals (ftd)
    16871702  (let* ((canonical-ordinal 0))          ; used for :VOID
     
    17001715      (canonicalize-foreign-type-ordinal #+64-bit-target :long #-64-bit-target nil)
    17011716      (canonicalize-foreign-type-ordinal :address)
    1702       (canonicalize-foreign-type-ordinal #-darwin-target
    1703                                          :<D>l_info
    1704                                          #+darwin-target nil)
    1705       (canonicalize-foreign-type-ordinal '(:struct :timespec))
    1706       (canonicalize-foreign-type-ordinal '(:struct :timeval))
    17071717      (canonicalize-foreign-type-ordinal '(:struct :sockaddr_in))
    17081718      (canonicalize-foreign-type-ordinal '(:struct :sockaddr_un))
     
    17111721      (canonicalize-foreign-type-ordinal '(:array :unsigned-long 3))
    17121722      (canonicalize-foreign-type-ordinal '(:* :char))
    1713       (canonicalize-foreign-type-ordinal '(:struct :stat))
    1714       (canonicalize-foreign-type-ordinal '(:struct :passwd))
    17151723      (canonicalize-foreign-type-ordinal #+darwin-target '(:struct :host_basic_info) #-darwin-target nil)
    17161724      (canonicalize-foreign-type-ordinal '(:struct :in_addr))
     
    17241732      (canonicalize-foreign-type-ordinal #+solaris-target '(:struct :lifnum) #-solaris-target nil)
    17251733      (canonicalize-foreign-type-ordinal #+solaris-target '(:struct :lifconf) #-solaris-target nil)
    1726       )))
     1734      (setq canonical-ordinal (1- max-common-foreign-type-ordinal))
     1735      ;; We don't use foreign type ordinals when cross-compiling,
     1736      ;; so the read-time conditionalization is OK here.
     1737      #+(or linux-target darwin-target solaris-target freebsd-target)
     1738      (dolist (spec *canonical-unix-foreign-types)
     1739        (canonicalize-foreign-type-ordinal spec))
     1740      (dolist (spec (ftd-platform-ordinal-types ftd))
     1741        (canonicalize-foreign-type-ordinal spec)))))
    17271742
    17281743(defun install-standard-foreign-types (ftd)
Note: See TracChangeset for help on using the changeset viewer.