;;;; chicken-bind.scm - Standalone wrapper generator (module chicken-bind () (import scheme (chicken port)) (import srfi-1) (import bind-translator) (import (chicken pathname) (chicken io) (chicken base) (chicken port)) (import (chicken irregex) (chicken process-context)) (import (chicken pretty-print)) (define (usage #!optional (status 0)) (print #< (string-length arg) 1) (char=? #\- (string-ref arg 0)) ) (usage 1) ) (else (set! files (cons arg files)) (loop rest)))))) (when (null? files) (usage 1)) (when (and output (not (string=? "-" output))) (set! output (open-output-file output))) (for-each (lambda (f) (define (read-from-file-or-stdin) (if (string=? f "-") (read-string #f (current-input-port)) (call-with-input-file f (lambda (p) (read-string #f p))))) (define (process) (print "\n;;; GENERATED BY CHICKEN-BIND FROM " f #\newline) (pp `(begin ,@(parse-easy-ffi (read-from-file-or-stdin) identity chunkify-only f))) (print "\n;;; END OF FILE")) (cond ((equal? "-" output) (process)) ((port? output) (with-output-to-port output process)) (else (with-output-to-file (pathname-replace-extension f "scm") process) ) )) (reverse files) ) ) ) (main (command-line-arguments)) )