Changeset 11486


Ignore:
Timestamp:
Dec 9, 2008, 12:15:19 AM (11 years ago)
Author:
gb
Message:

Provide a mechanism for overriding C macros that contain constructs
that we can't make sense of (see ticket:342).

In the local function PARSE-CONDITIONAL in PARSE-C-EXPRESSION, expect
the token C::|:|, not |:|.

File:
1 edited

Legend:

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

    r11474 r11486  
    5454(defvar *ffi-global-objc-classes* nil)
    5555(defvar *ffi-global-objc-messages* nil)
    56 (defvar *ffi-macros*)
    57 (defvar *ffi-vars*)
     56;;; Some things are just too hard to parse, but are important.
     57;;; Override those things with simpler versions.
     58(defvar *ffi-macro-overrides*
     59  '((:macro ("{override}" 0) "_IOC_TYPECHECK ( t )" "sizeof(t)")))
    5860
    5961(defvar *ffi-void-reference* '(:primitive :void))
     
    717719    (ensure-referenced-type-defined retval)
    718720    (record-global-function ffi-function)))
    719  
     721
     722
     723
    720724(defun parse-ffi (inpath)
    721725  (let* ((*ffi-typedefs* (make-hash-table :test 'string= :hash-function 'sxhash))
     
    749753                          (if args
    750754                            (setf (gethash (string (ffi-macro-name m)) argument-macros) args)
    751                             (push m defined-macros))))
     755                            (push m defined-macros))))
    752756                (:type (push (process-ffi-typedef form) defined-types))
    753757                (:var (push (process-ffi-var form) defined-vars))
     
    756760                (:union (push (process-ffi-union form) defined-types))
    757761                (:transparent-union (push (process-ffi-transparent-union form) defined-types)))))
     762          (dolist (override *ffi-macro-overrides*)
     763            (let* ((m (process-ffi-macro override))
     764                   (args (ffi-macro-args m)))
     765              (if args
     766                (setf (gethash (string (ffi-macro-name m)) argument-macros) args)
     767                (push m defined-macros))))
    758768          (multiple-value-bind (new-constants new-macros)
    759769              (process-defined-macros defined-macros (reverse defined-constants) argument-macros)
     
    11771187               (if (eq (peek) 'c::|?|)
    11781188                 (let ((then (progn (next) (parse-expression)))
    1179                        (else (if (eq (peek) '|:|)
     1189                       (else (if (eq (peek) 'c::|:|)
    11801190                               (progn (next) (parse-conditional))
    11811191                               (fail "~A where : was expected" (peek)))))
Note: See TracChangeset for help on using the changeset viewer.