12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- (define-module (cffi)
- #:export (defcstruct define-foreign-type defctype
- with-foreign-pointer with-foreign-object
- foreign-enum-value defbitfield defcenum defcfun)
- #:use-module (system reader library)
- #:use-module (oop goops)
- #:use-module (rnrs base)
- #:use-module (hurd-cl-compat))
- ;; XXX use guile-reader for temporarily
- ;; changing the reader.
- (eval-when (expand)
- (use-modules (system base target)
- (srfi srfi-1))
- (define (clisp-features)
- `(,(case (target-endianness)
- (big 'big-endian)
- (little 'little-endian))
- ,(case (target-word-size)
- (16 '128-bit)
- (8 '64-bit)
- (4 '32-bit))
- guile))
- (define (has-features? features condition)
- (cond ((symbol? condition)
- (memq condition features))
- ((and (pair? condition)
- (eq? (car condition) 'and))
- (lset<= eq? (cdr condition) features))
- ((and (pair? condition)
- (eq? (car condition) 'or))
- (not (null? (lset-intersection eq? (cdr condition) features))))
- (#t (pk 'c condition)
- TODO)))
- (define (parse-path c port)
- (let ((path (read port)))
- (assert (string? path))
- path))
- ;; XXX features
- ;; XXX these cannot be used before a #\)
- (define (parse-unless c port)
- (let ((condition (read port))
- (code (read port)))
- (if (has-features? (clisp-features) condition)
- (read port)
- code)))
- (define (parse-when c port)
- (let ((condition (read port))
- (code (read port)))
- (if (has-features? (clisp-features) condition)
- code
- (read port))))
- (read-hash-extend #\p parse-path)
- (read-hash-extend #\- parse-unless)
- (read-hash-extend #\+ parse-when))
- (read-set! keywords 'prefix)
- (define-syntax-rule (include-from-paths x ...)
- (begin (include-from-path x)
- ...))
- (define-syntax-rule (in-package anything)
- (begin #f))
- (eval-when (expand load eval)
- (include-from-paths
- "cffi/src/utils.lisp"
- "cffi/src/early-types.lisp"))
- #;
- (include-from-paths
- "cffi/src/cffi-guile.lisp"
- ;; "cffi/src/package.lisp"
- "cffi/src/libraries.lisp"
- "cffi/src/types.lisp"
- "cffi/src/enum.lisp"
- "cffi/src/strings.lisp"
- "cffi/src/structures.lisp"
- "cffi/src/functions.lisp"
- "cffi/src/foreign-vars.lisp"
- "cffi/src/features.lisp")
- (eval-when (expand)
- (read-hash-extend #\p #f)
- (read-hash-extend #\- #f)
- (read-hash-extend #\+ #f))
|