Ignore:
Timestamp:
May 6, 2004, 6:29:31 AM (15 years ago)
Author:
gb
Message:

incorporate 0.14.2 changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/library/parse-ffi.lisp

    r6 r812  
    5050(defvar *ffi-db-records* nil)
    5151(defvar *ffi-db-functions* nil)
     52(defvar *ffi-db-vars* nil)
    5253(defvar *ffi-typedefs*)
    5354(defvar *ffi-global-typedefs* nil)
     
    5960(defvar *ffi-global-functions* nil)
    6061(defvar *ffi-global-constants* nil)
     62(defvar *ffi-global-vars* nil)
    6163(defvar *ffi-macros*)
    6264(defvar *ffi-vars*)
     
    465467
    466468(defun process-ffi-var (form)
    467   (declare (ignore form)))
     469  (let* ((name (caddr form))
     470         (type (cadddr form)))
     471    (cons name (reference-ffi-type type))))
    468472
    469473(defun process-ffi-enum-ident (form)
     
    605609              (t "~s)~&"))
    606610            val)))
     611
     612(defun record-global-var (name type)
     613  (when *ffi-global-vars*
     614    (setf (gethash name *ffi-global-vars*) type)))
     615
     616(defun emit-global-var (name type)
     617  (when *ffi-db-vars*
     618    (db-define-var *ffi-db-vars* name type)))
     619
     620(defun emit-ffi-var (name type)
     621  (record-global-var name type))
     622
    607623
    608624(defun emit-type-reference (ref)
     
    685701           (defined-constants ())
    686702           (defined-macros ())
    687            (defined-functions ()))
     703           (defined-functions ())
     704           (defined-vars ()))
    688705      (with-open-file (in inpath)
    689706        (let* ((*ffi-ordinal* -1)
     
    701718                            (push m defined-macros))))
    702719                (:type (push (process-ffi-typedef form) defined-types))
    703                 (:var (process-ffi-var form))
     720                (:var (push (process-ffi-var form) defined-vars))
    704721                (:enum-ident (push (process-ffi-enum-ident form) defined-constants))
    705722                (:enum (process-ffi-enum form))
     
    723740                     (dolist (x (reverse new-constants))
    724741                       (emit-ffi-constant (car x) (cdr x)))
     742                     (dolist (x defined-vars)
     743                       (emit-ffi-var (car x) (cdr x)))
    725744                     (when *ffi-out*
    726745                       (terpri *ffi-out*)
     
    766785         (*ffi-global-structs* (make-hash-table :test 'string= :hash-function 'sxhash))
    767786         (*ffi-global-functions* (make-hash-table :test 'string= :hash-function 'sxhash))
    768          (*ffi-global-constants* (make-hash-table :test 'string= :hash-function 'sxhash)))
     787         (*ffi-global-constants* (make-hash-table :test 'string= :hash-function 'sxhash))
     788         (*ffi-global-vars* (make-hash-table :test 'string= :hash-function 'sxhash)))
    769789         
    770790    (dolist (f (directory (merge-pathnames ";C;**;*.ffi"
     
    806826                   (emit-global-function def))
    807827               *ffi-global-functions*))
     828    (with-new-db-file (*ffi-db-vars* (merge-pathnames
     829                                      "new-vars.cdb"
     830                                      interface-dir))
     831      (maphash #'(lambda (name type)
     832                   (emit-global-var name type))
     833               *ffi-global-vars*))
    808834    (install-new-db-files ftd d)))
    809835
     
    13931419              (interface-dir-types-interface-db-file d)
    13941420              "types.cdb"
    1395               "new-types.cdb")))))
     1421              "new-types.cdb"))
     1422              (setf (interface-dir-types-interface-db-file d)
     1423             (rename-and-reopen
     1424              (interface-dir-types-interface-db-file d)
     1425              "vars.cdb"
     1426              "new-vars.cdb")))))
    13961427  t)
    13971428   
Note: See TracChangeset for help on using the changeset viewer.