summaryrefslogtreecommitdiff
path: root/pmt/src/scheme/gnuradio/macros-etc.scm
diff options
context:
space:
mode:
authoreb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>2007-05-02 04:08:47 +0000
committereb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>2007-05-02 04:08:47 +0000
commit0bf2128a621ae84099f43744e1b81800f2b9d2d7 (patch)
tree1345b44ae9060e99ff236f983dd272c6d35a012e /pmt/src/scheme/gnuradio/macros-etc.scm
parent28259329a829f157fd877a1c14139eaf0117dabd (diff)
Merged features/inband -r4812:5218 into trunk. This group of changes
includes: * working stand-alone mblock code * work-in-progress on usrp inband signaling usrp now depends on mblock, and guile is a dependency. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@5221 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'pmt/src/scheme/gnuradio/macros-etc.scm')
-rw-r--r--pmt/src/scheme/gnuradio/macros-etc.scm50
1 files changed, 50 insertions, 0 deletions
diff --git a/pmt/src/scheme/gnuradio/macros-etc.scm b/pmt/src/scheme/gnuradio/macros-etc.scm
new file mode 100644
index 0000000000..518c1ffe11
--- /dev/null
+++ b/pmt/src/scheme/gnuradio/macros-etc.scm
@@ -0,0 +1,50 @@
+;;; -*- 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 2, 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.
+;;;
+
+(define-module (gnuradio macros-etc)
+ :export (atom? when unless for-each-in-file))
+
+(define (atom? obj)
+ (not (pair? obj)))
+
+(defmacro when (pred . body)
+ `(if ,pred (begin ,@body) #f))
+
+(defmacro unless (pred . body)
+ `(if (not ,pred) (begin ,@body) #f))
+
+
+(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)))))