summaryrefslogtreecommitdiff
path: root/gruel/src/scheme
diff options
context:
space:
mode:
Diffstat (limited to 'gruel/src/scheme')
-rw-r--r--gruel/src/scheme/gnuradio/Makefile.am10
-rw-r--r--gruel/src/scheme/gnuradio/gen-serial-tags.py53
-rwxr-xr-xgruel/src/scheme/gnuradio/gen-serial-tags.scm118
3 files changed, 59 insertions, 122 deletions
diff --git a/gruel/src/scheme/gnuradio/Makefile.am b/gruel/src/scheme/gnuradio/Makefile.am
index 0ce01f6f8..e7b6bf744 100644
--- a/gruel/src/scheme/gnuradio/Makefile.am
+++ b/gruel/src/scheme/gnuradio/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2007,2009 Free Software Foundation, Inc.
+# Copyright 2007,2009,2010,2011 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -18,12 +18,14 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
+include $(top_srcdir)/Makefile.common
+
#pkgdatadir = $(datadir)/gnuradio
-EXTRA_DIST = \
- gen-serial-tags.scm
+EXTRA_DIST += \
+ gen-serial-tags.py
-# really scheme source files
+# really scheme source files FIXME wrong location
dist_pkgdata_DATA = \
pmt-serial-tags.scm \
pmt-serialize.scm \
diff --git a/gruel/src/scheme/gnuradio/gen-serial-tags.py b/gruel/src/scheme/gnuradio/gen-serial-tags.py
new file mode 100644
index 000000000..18e927beb
--- /dev/null
+++ b/gruel/src/scheme/gnuradio/gen-serial-tags.py
@@ -0,0 +1,53 @@
+"""
+//
+// Copyright 2011 Free Software Foundation, Inc.
+//
+// This file is part of GNU Radio
+//
+// GNU Radio is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// GNU Radio is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+//
+// THIS FILE IS MACHINE GENERATED FROM %s. DO NOT EDIT BY HAND.
+// See %s for additional commentary.
+//
+
+#ifndef INCLUDED_PMT_SERIAL_TAGS_H
+#define INCLUDED_PMT_SERIAL_TAGS_H
+
+enum pst_tags {
+%s
+};
+#endif /* INCLUDED_PMT_SERIAL_TAGS_H */
+"""
+
+import sys, os, re
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print "Usage %s <input_scm_file> <output_hdr_file>"%__file__
+ exit()
+ input_scm_file, output_hdr_file = sys.argv[1:]
+ enums = list()
+ for line in open(input_scm_file).readlines():
+ match = re.match('^\s*\(define\s+([\w|-]+)\s+#x([0-9a-fA-F]+)\)', line)
+ if not match: continue
+ name, value = match.groups()
+ name = name.upper().replace('-', '_')
+ enums.append(' %s = 0x%s'%(name, value))
+ open(output_hdr_file, 'w').write(__doc__%(
+ os.path.basename(__file__),
+ os.path.basename(input_scm_file),
+ ',\n'.join(enums),
+ ))
diff --git a/gruel/src/scheme/gnuradio/gen-serial-tags.scm b/gruel/src/scheme/gnuradio/gen-serial-tags.scm
deleted file mode 100755
index 7b9087228..000000000
--- a/gruel/src/scheme/gnuradio/gen-serial-tags.scm
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/guile \
--e main -s
-!#
-;;; -*-scheme-*-
-;;;
-;;; Copyright 2007 Free Software Foundation, Inc.
-;;;
-;;; This file is part of GNU Radio
-;;;
-;;; GNU Radio is free software; you can redistribute it and/or modify
-;;; it under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3, or (at your option)
-;;; any later version.
-;;;
-;;; GNU Radio is distributed in the hope that it will be useful,
-;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License along
-;;; with this program; if not, write to the Free Software Foundation, Inc.,
-;;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-;;;
-
-(use-modules (ice-9 format))
-
-(defmacro when (pred . body)
- `(if ,pred (begin ,@body) #f))
-
-;; ----------------------------------------------------------------
-
-(define (main args)
-
- (define (usage)
- (format 0
- "usage: ~a <pmt-serial-tags.scm> <pmt_serial_tags.h>~%"
- (car args)))
-
- (when (not (= (length args) 3))
- (usage)
- (format 0 "args: ~s~%" args)
- (exit 1))
-
- (let ((i-file (open-input-file (cadr args)))
- (h-file (open-output-file (caddr args))))
-
- (write-header-comment h-file "// ")
- (display "#ifndef INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
- (display "#define INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
- (newline h-file)
- (display "enum pst_tags {\n" h-file)
-
- (for-each-in-file i-file
- (lambda (form)
- (let* ((name (cadr form))
- (c-name (string-upcase (c-ify name)))
- (value (caddr form)))
- ;;(format h-file "static const int ~a\t= 0x~x;~%" c-name value)
- (format h-file " ~a\t= 0x~x,~%" c-name value))))
-
- (display "};\n" h-file)
- (display "#endif\n" h-file)))
-
-(define (c-ify name)
- (list->string (map (lambda (c)
- (if (eqv? c #\-) #\_ c))
- (string->list (symbol->string name)))))
-
-
-(define (write-header-comment o-port prefix)
- (for-each (lambda (comment)
- (format o-port "~a~a~%" prefix comment))
- header-comment))
-
-(define header-comment
- '(
- ""
- "Copyright 2007 Free Software Foundation, Inc."
- ""
- "This file is part of GNU Radio"
- ""
- "GNU Radio is free software; you can redistribute it and/or modify"
- "it under the terms of the GNU General Public License as published by"
- "the Free Software Foundation; either version 3, or (at your option)"
- "any later version."
- ""
- "GNU Radio is distributed in the hope that it will be useful,"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
- "GNU General Public License for more details."
- ""
- "You should have received a copy of the GNU General Public License along"
- "with this program; if not, write to the Free Software Foundation, Inc.,"
- "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."
- ""
- ""
- "THIS FILE IS MACHINE GENERATED FROM pmt-serial-tags.scm. DO NOT EDIT BY HAND."
- "See pmt-serial-tags.scm for additional commentary."
- ""))
-
-
-
-(define (for-each-in-file file f)
- (let ((port (if (port? file)
- file
- (open-input-file file))))
- (letrec
- ((loop
- (lambda (port form)
- (cond ((eof-object? form)
- (when (not (eq? port file))
- (close-input-port port))
- #t)
- (else
- (f form)
- (set! form #f) ; for GC
- (loop port (read port)))))))
- (loop port (read port)))))