6 ;;; Copyright 2007 Free Software Foundation, Inc.
8 ;;; This file is part of GNU Radio
10 ;;; GNU Radio is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3, or (at your option)
13 ;;; any later version.
15 ;;; GNU Radio is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License along
21 ;;; with this program; if not, write to the Free Software Foundation, Inc.,
22 ;;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 (use-modules (ice-9 format))
27 (defmacro when (pred . body)
28 `(if ,pred (begin ,@body) #f))
30 ;; ----------------------------------------------------------------
36 "usage: ~a <pmt-serial-tags.scm> <pmt_serial_tags.h>~%"
39 (when (not (= (length args) 3))
41 (format 0 "args: ~s~%" args)
44 (let ((i-file (open-input-file (cadr args)))
45 (h-file (open-output-file (caddr args))))
47 (write-header-comment h-file "// ")
48 (display "#ifndef INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
49 (display "#define INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
51 (display "enum pst_tags {\n" h-file)
53 (for-each-in-file i-file
55 (let* ((name (cadr form))
56 (c-name (string-upcase (c-ify name)))
58 ;;(format h-file "static const int ~a\t= 0x~x;~%" c-name value)
59 (format h-file " ~a\t= 0x~x,~%" c-name value))))
61 (display "};\n" h-file)
62 (display "#endif\n" h-file)))
65 (list->string (map (lambda (c)
66 (if (eqv? c #\-) #\_ c))
67 (string->list (symbol->string name)))))
70 (define (write-header-comment o-port prefix)
71 (for-each (lambda (comment)
72 (format o-port "~a~a~%" prefix comment))
75 (define header-comment
78 "Copyright 2007 Free Software Foundation, Inc."
80 "This file is part of GNU Radio"
82 "GNU Radio is free software; you can redistribute it and/or modify"
83 "it under the terms of the GNU General Public License as published by"
84 "the Free Software Foundation; either version 3, or (at your option)"
87 "GNU Radio is distributed in the hope that it will be useful,"
88 "but WITHOUT ANY WARRANTY; without even the implied warranty of"
89 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
90 "GNU General Public License for more details."
92 "You should have received a copy of the GNU General Public License along"
93 "with this program; if not, write to the Free Software Foundation, Inc.,"
94 "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."
97 "THIS FILE IS MACHINE GENERATED FROM pmt-serial-tags.scm. DO NOT EDIT BY HAND."
98 "See pmt-serial-tags.scm for additional commentary."
103 (define (for-each-in-file file f)
104 (let ((port (if (port? file)
106 (open-input-file file))))
110 (cond ((eof-object? form)
111 (when (not (eq? port file))
112 (close-input-port port))
116 (set! form #f) ; for GC
117 (loop port (read port)))))))
118 (loop port (read port)))))