diff options
Diffstat (limited to 'gnuradio-core/src')
103 files changed, 4503 insertions, 1480 deletions
diff --git a/gnuradio-core/src/Makefile.am b/gnuradio-core/src/Makefile.am index eb979fe58..1717d373a 100644 --- a/gnuradio-core/src/Makefile.am +++ b/gnuradio-core/src/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2004,2009 Free Software Foundation, Inc. +# Copyright 2001,2004,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,9 +21,6 @@ include $(top_srcdir)/Makefile.common -SUBDIRS = gen_interpolator_taps lib tests -if PYTHON -SUBDIRS += python -endif +SUBDIRS = gen_interpolator_taps lib tests python guile -DIST_SUBDIRS = gen_interpolator_taps lib tests python utils +DIST_SUBDIRS = gen_interpolator_taps lib tests python guile utils diff --git a/gnuradio-core/src/gen_interpolator_taps/Makefile.am b/gnuradio-core/src/gen_interpolator_taps/Makefile.am index d244e7f54..1b54af5e7 100644 --- a/gnuradio-core/src/gen_interpolator_taps/Makefile.am +++ b/gnuradio-core/src/gen_interpolator_taps/Makefile.am @@ -21,7 +21,13 @@ include $(top_srcdir)/Makefile.common -EXTRA_DIST = praxis.txt simpson.h objective_fct.c gen_interpolator_taps.c simpson.c praxis.f +EXTRA_DIST += \ + praxis.txt \ + simpson.h \ + objective_fct.c \ + gen_interpolator_taps.c \ + simpson.c \ + praxis.f # if ENABLE_FORTRAN # noinst_PROGRAMS = gen_interpolator_taps diff --git a/gnuradio-core/src/guile/.gitignore b/gnuradio-core/src/guile/.gitignore new file mode 100644 index 000000000..82a29a907 --- /dev/null +++ b/gnuradio-core/src/guile/.gitignore @@ -0,0 +1,4 @@ +/Makefile +/Makefile.in +/run_guile_tests +/guile.log diff --git a/gnuradio-core/src/guile/Makefile.am b/gnuradio-core/src/guile/Makefile.am new file mode 100644 index 000000000..447500b46 --- /dev/null +++ b/gnuradio-core/src/guile/Makefile.am @@ -0,0 +1,63 @@ +# +# Copyright 2010 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, see <http://www.gnu.org/licenses/>. +# + +include $(top_srcdir)/Makefile.common + +if GUILE + +TESTS = run_guile_tests + +EXTRA_DIST += \ + run_guile_tests.in \ + $(nobase_guile_DATA) \ + $(GUILE_TESTS) + + +SUBDIRS = example-waveforms + +# These are the hand-coded guile files for gnuradio-core. +# +# Swig/common.scm is glue that's required for the goops wrappers. +# gnuradio/export-safely.scm works around some problems in the goops generated wrappers. +# gnuradio/core.scm glues the 5 pieces of gnuradio_core_* into a single module. +# gnuradio/runtime-shim implements "guile friendly" versions of connect & disconnect. + +nobase_guile_DATA = \ + Swig/common.scm \ + gnuradio/core.scm \ + gnuradio/export-safely.scm \ + gnuradio/runtime-shim.scm \ + gnuradio/waveform.scm \ + gnuradio/run-waveform.scm \ + gnuradio/scripts/gr-run-waveform \ + gnuradio/test-suite/guile-test \ + gnuradio/test-suite/lib.scm + +GUILE_TESTS = \ + tests/00_runtime_basics.test \ + tests/00_runtime_ctors.test \ + tests/filter_ctors.test \ + tests/general_ctors.test \ + tests/gengen_ctors.test \ + tests/hier_ctors.test \ + tests/io_ctors.test + +CLEANFILES = guile.log + +endif diff --git a/gnuradio-core/src/guile/Swig/common.scm b/gnuradio-core/src/guile/Swig/common.scm new file mode 100644 index 000000000..a51d3a71d --- /dev/null +++ b/gnuradio-core/src/guile/Swig/common.scm @@ -0,0 +1,76 @@ +;;;************************************************************************ +;;;*common.scm +;;;* +;;;* This file contains generic SWIG GOOPS classes for generated +;;;* GOOPS file support +;;;* +;;;* Copyright (C) 2003 John Lenz (jelenz@wisc.edu) +;;;* Copyright (C) 2004 Matthias Koeppe (mkoeppe@mail.math.uni-magdeburg.de) +;;;* +;;;* This file may be freely redistributed without license or fee provided +;;;* this copyright message remains intact. +;;;************************************************************************ + +(define-module (Swig swigrun)) + +(define-module (Swig common) + #:use-module (oop goops) + #:use-module (Swig swigrun)) + +(define-class <swig-metaclass> (<class>) + (new-function #:init-value #f)) + +(define-method (initialize (class <swig-metaclass>) initargs) + (slot-set! class 'new-function (get-keyword #:new-function initargs #f)) + (next-method)) + +(define-class <swig> () + (swig-smob #:init-value #f) + #:metaclass <swig-metaclass> +) + +(define-method (initialize (obj <swig>) initargs) + (next-method) + (slot-set! obj 'swig-smob + (let ((arg (get-keyword #:init-smob initargs #f))) + (if arg + arg + (let ((ret (apply (slot-ref (class-of obj) 'new-function) (get-keyword #:args initargs '())))) + ;; if the class is registered with runtime environment, + ;; new-Function will return a <swig> goops class. In that case, extract the smob + ;; from that goops class and set it as the current smob. + (if (slot-exists? ret 'swig-smob) + (slot-ref ret 'swig-smob) + ret)))))) + +(define (display-address o file) + (display (number->string (object-address o) 16) file)) + +(define (display-pointer-address o file) + ;; Don't fail if the function SWIG-PointerAddress is not present. + (let ((address (false-if-exception (SWIG-PointerAddress o)))) + (if address + (begin + (display " @ " file) + (display (number->string address 16) file))))) + +(define-method (write (o <swig>) file) + ;; We display _two_ addresses to show the object's identity: + ;; * first the address of the GOOPS proxy object, + ;; * second the pointer address. + ;; The reason is that proxy objects are created and discarded on the + ;; fly, so different proxy objects for the same C object will appear. + (let ((class (class-of o))) + (if (slot-bound? class 'name) + (begin + (display "#<" file) + (display (class-name class) file) + (display #\space file) + (display-address o file) + (display-pointer-address o file) + (display ">" file)) + (next-method)))) + +(export <swig-metaclass> <swig>) + +;;; common.scm ends here diff --git a/gnuradio-core/src/guile/example-waveforms/.gitignore b/gnuradio-core/src/guile/example-waveforms/.gitignore new file mode 100644 index 000000000..16c984055 --- /dev/null +++ b/gnuradio-core/src/guile/example-waveforms/.gitignore @@ -0,0 +1,6 @@ +/Makefile +/Makefile.in +/.deps +/.libs +/*.la +/*.lo diff --git a/gnuradio-core/src/guile/example-waveforms/Makefile.am b/gnuradio-core/src/guile/example-waveforms/Makefile.am new file mode 100644 index 000000000..277b4ad0b --- /dev/null +++ b/gnuradio-core/src/guile/example-waveforms/Makefile.am @@ -0,0 +1,28 @@ +# +# Copyright 2010 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, see <http://www.gnu.org/licenses/>. +# + +include $(top_srcdir)/Makefile.common + +waveformdir=$(datarootdir)/gnuradio/example-waveforms + +waveform_DATA = \ + dial-tone.wfd + +EXTRA_DIST += \ + dial-tone.wfd diff --git a/gnuradio-core/src/guile/example-waveforms/dial-tone.wfd b/gnuradio-core/src/guile/example-waveforms/dial-tone.wfd new file mode 100644 index 000000000..ced3df572 --- /dev/null +++ b/gnuradio-core/src/guile/example-waveforms/dial-tone.wfd @@ -0,0 +1,40 @@ +;;; Emacs, format this using -*-scheme-*- mode. +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; This example waveform outputs a signal to an audio_alsa_sink +;;; that sounds like North American dial tone. + +(use-modules (gnuradio audio_alsa)) + + +(define-waveform (dial-tone cmd-line-args) + (vars + (sample-rate 48000) + (ampl 0.1)) + + (blocks + (src0 (gr:sig-source-f sample-rate (gr:GR-SIN-WAVE) 350 ampl)) + (src1 (gr:sig-source-f sample-rate (gr:GR-SIN-WAVE) 440 ampl)) + (sink (gr:audio-alsa-sink sample-rate "plughw:0,0")) + ) + + (connections + (src0 (list sink 0)) ; src0 to left input + (src1 (list sink 1)))) ; src1 to right input diff --git a/gnuradio-core/src/guile/gnuradio/core.scm b/gnuradio-core/src/guile/gnuradio/core.scm new file mode 100644 index 000000000..9c69cea42 --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/core.scm @@ -0,0 +1,32 @@ +;;; Glue the separate pieces of gnuradio-core into a single module + +(define-module (gnuradio core) + #:use-module (oop goops) + #:use-module (gnuradio gnuradio_core_runtime) + #:use-module (gnuradio runtime-shim) + #:use-module (gnuradio gnuradio_core_filter) + #:use-module (gnuradio gnuradio_core_io) + #:use-module (gnuradio gnuradio_core_general) + #:use-module (gnuradio gnuradio_core_gengen) + #:use-module (gnuradio gnuradio_core_hier) + #:duplicates (merge-generics replace check)) + +(re-export-all '(gnuradio gnuradio_core_runtime)) +(re-export-all '(gnuradio runtime-shim)) +(re-export-all '(gnuradio gnuradio_core_filter)) +(re-export-all '(gnuradio gnuradio_core_io)) +(re-export-all '(gnuradio gnuradio_core_general)) +(re-export-all '(gnuradio gnuradio_core_gengen)) +(re-export-all '(gnuradio gnuradio_core_hier)) + +;; Work around problem with gr:message-source +(define-generic gr:message-source) +(define-method (gr:message-source itemsize (msgq <gr-msg-queue-sptr>)) + (gr:message-source-msgq-ctor itemsize msgq)) +(define-method (gr:message-source itemsize (limit <integer>)) + (gr:message-source-limit-ctor itemsize limit)) +(export gr:message-source) + +;;; Return #t if x is not #f +(define-public (true? x) + (and x #t)) diff --git a/gnuradio-core/src/guile/gnuradio/export-safely.scm b/gnuradio-core/src/guile/gnuradio/export-safely.scm new file mode 100644 index 000000000..664292d2b --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/export-safely.scm @@ -0,0 +1,90 @@ +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; This module implements a macro, export-safely, that avoids +;;; exporting symbols that are actually generic-functions imported +;;; (explicity or implicitly) from elsewhere. +;;; +;;; This hackery is required so that the swig generated goops wrappers +;;; don't stomp on each other. For background on what this is about +;;; see this thread: +;;; +;;; http://lists.gnu.org/archive/html/guile-user/2006-05/msg00007.html +;;; +;;; Don't expect to understand what's going on here without looking at +;;; the guts of the module system (implemented in ice-9/boot-9.scm) and +;;; having a pretty good understanding of goops and generic-functions. + + +(define-module (gnuradio export-safely) + #:use-module (oop goops) + #:use-module (srfi srfi-1) + #:export-syntax (export-safely)) + +(define-public (generics-in-module module) + (let ((lst '())) + (module-for-each (lambda (sym var) + (if (variable-bound? var) + (let ((v (variable-ref var))) + (cond ((is-a? v <generic>) + (set! lst (cons v lst))))))) + module) + lst)) + +(define-public (generic-function-names-in-module module) + (map generic-function-name (generics-in-module module))) + +(define-public (generic-function-names-in-imported-modules module) + (concatenate (map generic-function-names-in-module (module-uses module)))) + +(define-public (export-syms-if-not-imported-gf list-of-syms) + (let ((gf-names (generic-function-names-in-imported-modules (current-module)))) + (let ((to-export (filter (lambda (sym) + (not (memq sym gf-names))) + (delete-duplicates list-of-syms)))) + (module-export! (current-module) to-export)))) + +(defmacro export-safely names + `(export-syms-if-not-imported-gf ',names)) + + +(define-public (names-in-module module) + (let ((lst '())) + (module-for-each (lambda (sym var) + (if (variable-bound? var) + (set! lst (cons sym lst)))) + module) + lst)) + +(define-public (names-in-imported-modules module) + (delete-duplicates (concatenate (map names-in-module (module-uses module))))) + +(define-public (re-export-all src-module-name) + (let ((current (current-module)) + (src-module (resolve-interface src-module-name))) + + (define (ok-to-re-export? name) + (let ((var (module-variable current name))) + (cond ((not var) #f) ; Undefined var + ((eq? var (module-local-variable current name)) #f) ; local var + (else #t)))) ; OK + + (module-re-export! current + (filter ok-to-re-export? + (names-in-module src-module))))) diff --git a/gnuradio-core/src/guile/gnuradio/run-waveform.scm b/gnuradio-core/src/guile/gnuradio/run-waveform.scm new file mode 100644 index 000000000..01930521c --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/run-waveform.scm @@ -0,0 +1,55 @@ +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; Load and run a waveform defined with define-waveform + + +;; I don't seem to be able to make this work... +;; I think it's some kind of interaction with the syntax-case +;; macro, define-waveform, and the module system. +;; +;;(define-module (gnuradio run-waveform) +;; #:use-module (oop goops) +;; #:use-module (gnuradio core) +;; #:use-module (gnuradio waveform) +;; #:duplicates (merge-generics replace check)) + +(use-modules (oop goops) + (gnuradio core) + (gnuradio waveform)) + + +(define (load-into-module filename module) + (let ((f (open-file filename "r"))) + (let loop ((form (read f))) + (cond ((eof-object? form) #t) + (else (eval form module) + (loop (read f))))))) + + +(define-public (run-waveform waveform-filename . args) + (debug-enable 'backtrace 'debug) + (load waveform-filename) + ;;(load-into-module waveform-filename (current-module)) + (let ((f (waveform-last-registered))) + (if (not f) + (error "No define-waveform found in file \n" filename)) + (gr:run (f args)) + ;; Attempt to get block destructors called now. + (gc))) diff --git a/gnuradio-core/src/guile/gnuradio/runtime-shim.scm b/gnuradio-core/src/guile/gnuradio/runtime-shim.scm new file mode 100644 index 000000000..bba702670 --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/runtime-shim.scm @@ -0,0 +1,129 @@ +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +(define-module (gnuradio runtime-shim) + #:use-module (oop goops) + #:use-module (ice-9 threads) + #:use-module (gnuradio gnuradio_core_runtime) + #:duplicates (merge-generics replace check)) + +(define-class <gr-endpoint> (<object>) + (block #:accessor block #:init-keyword #:block) + (port #:init-value 0 #:accessor port #:init-keyword #:port)) + +(define (gr:ep block port) + (make <gr-endpoint> + #:block (coerce-to-basic-block block) #:port port)) + +(define (coerce-to-endpoint ep) + (cond ((is-a? ep <gr-endpoint>) ep) + ((false-if-exception (gr:to-basic-block ep)) + => (lambda (x) (gr:ep x 0))) + ((and (pair? ep) (= 2 (length ep)) + (false-if-exception (gr:to-basic-block (car ep)))) + => (lambda (x) (gr:ep x (cadr ep)))) + (else (error "Cannot coerce to an endpoint: " ep)))) + +(define (coerce-to-basic-block block) + (cond ((is-a? block <gr-basic-block-sptr>) block) + ((false-if-exception (gr:to-basic-block block)) => (lambda (x) x)) + (else (error "Cannot coerce to a gr_basic_block: " block)))) + +(define (coerce-to-top-block block) + (cond ((is-a? block <gr-top-block-sptr>) block) + ((false-if-exception (gr:to-top-block block)) => (lambda (x) x)) + (else (error "Cannot coerce to a gr_top_block: " block)))) + +(define (coerce-to-hier-block2 block) + (cond ((is-a? block <gr-hier-block2-sptr>) block) + ((false-if-exception (gr:to-hier-block2 block)) => (lambda (x) x)) + (else (error "Cannot coerce to a gr_hier_block2: " block)))) + + +;;; Connect one or more block endpoints. An endpoint is either a <gr-endpoint>, +;;; a 2-list (block port), or a block instance. In the latter case, the port number +;;; is assumed to be zero. +;;; +;;; If multiple arguments are provided, connect will attempt to wire them in series, +;;; interpreting the endpoints as inputs or outputs as appropriate. +(define-method (gr:connect hb . points) + (dis/connect "connect" gr:primitive-connect hb points)) + +;;; Disconnect one or more block endpoints... +(define-method (gr:disconnect hb . points) + (dis/connect "disconnect" gr:primitive-disconnect hb points)) + +(define (dis/connect name gf hb points) + (let ((hb (coerce-to-hier-block2 hb)) + (points (list->vector (map coerce-to-endpoint points)))) + + (define (op2 p0 p1) + (gf hb (block p0) (port p0) (block p1) (port p1))) + + (let ((len (vector-length points))) + (case len + ((0) (error (string-append name " requires at least 1 endpoint; None provided."))) + ((1) (gf hb (vector-ref points 0))) + (else + (let loop ((n 1)) + (cond ((< n len) + (op2 (vector-ref points (1- n)) (vector-ref points n)) + (loop (1+ n)))))))))) + + + + +(define-method (gr:run (self <gr-top-block-sptr>)) + (gr:start self) + (gr:wait self)) + + +(define-method (gr:wait (tb <gr-top-block-sptr>)) + + (define (sigint-handler sig) + ;;(display "\nSIGINT!\n" (current-error-port)) + ;; tell flow graph to stop + (gr:stop tb)) + + (let ((old-handler #f)) + (dynamic-wind + + ;; Called at entry + (lambda () + ;; Install SIGINT handler + (set! old-handler (sigaction SIGINT sigint-handler))) + + ;; Protected thunk + (lambda () + (let ((waiter (begin-thread (gr:top-block-wait-unlocked tb)))) + (join-thread waiter) + ;;(display "\nAfter join-thread\n" (current-error-port)) + )) + + ;; Called at exit + (lambda () + ;; Restore SIGINT handler + (if (not (car old-handler)) + ;; restore original C handler + (sigaction SIGINT #f) + ;; restore Scheme handler, SIG_IGN or SIG_DFL + (sigaction SIGINT (car old-handler) (cdr old-handler))))))) + + +(export-safely <gr-endpoint> gr:ep gr:connect gr:disconnect gr:run gr:wait) diff --git a/gnuradio-core/src/guile/gnuradio/scripts/.gitignore b/gnuradio-core/src/guile/gnuradio/scripts/.gitignore new file mode 100644 index 000000000..64cbdbc0e --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/scripts/.gitignore @@ -0,0 +1 @@ +gr-run-waveform diff --git a/gnuradio-core/src/guile/gnuradio/scripts/gr-run-waveform.in b/gnuradio-core/src/guile/gnuradio/scripts/gr-run-waveform.in new file mode 100755 index 000000000..8186d2e09 --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/scripts/gr-run-waveform.in @@ -0,0 +1,40 @@ +#!@GUILE@ \ +-e main -s +!# +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; Load and run a waveform defined with define-waveform +;;; +;;; usage: gr-run-waveform filename.wfd [args...] + +(load-from-path "gnuradio/run-waveform") + +(define (main args) + (if (not (>= (length args) 2)) + (let ((port (current-error-port))) + (display "usage: " port) + (display (car args) port) + (display " filename.wfd [args...]\n" port) + (exit 1))) + (apply run-waveform (cdr args))) + +;;; Local Variables: +;;; mode: scheme +;;; End: diff --git a/gnuradio-core/src/guile/gnuradio/test-suite/guile-test b/gnuradio-core/src/guile/gnuradio/test-suite/guile-test new file mode 100644 index 000000000..6dc1a9658 --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/test-suite/guile-test @@ -0,0 +1,241 @@ +#!/usr/bin/guile \ +-e main -s +!# + +;;;; guile-test --- run the Guile test suite +;;;; Jim Blandy <jimb@red-bean.com> --- May 1999 +;;;; +;;;; Copyright (C) 1999, 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This program 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. +;;;; +;;;; This program 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 software; see the file COPYING. If not, write to +;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;;;; Boston, MA 02110-1301 USA + + +;;;; Usage: [guile -e main -s] guile-test [OPTIONS] [TEST ...] +;;;; +;;;; Run tests from the Guile test suite. Report failures and +;;;; unexpected passes to the standard output, along with a summary of +;;;; all the results. Record each reported test outcome in the log +;;;; file, `guile.log'. The exit status is #f if any of the tests +;;;; fail or pass unexpectedly. +;;;; +;;;; Normally, guile-test scans the test directory, and executes all +;;;; files whose names end in `.test'. (It assumes they contain +;;;; Scheme code.) However, you can have it execute specific tests by +;;;; listing their filenames on the command line. +;;;; +;;;; The option `--test-suite' can be given to specify the test +;;;; directory. If no such option is given, the test directory is +;;;; taken from the environment variable TEST_SUITE_DIR (if defined), +;;;; otherwise a default directory that is hardcoded in this file is +;;;; used (see "Installation" below). +;;;; +;;;; If present, the `--log-file LOG' option tells `guile-test' to put +;;;; the log output in a file named LOG. +;;;; +;;;; If present, the `--debug' option will enable a debugging mode. +;;;; +;;;; If present, the `--flag-unresolved' option will cause guile-test +;;;; to exit with failure status if any tests are UNRESOLVED. +;;;; +;;;; +;;;; Installation: +;;;; +;;;; If you change the #! line at the top of this script to point at +;;;; the Guile interpreter you want to test, you can call this script +;;;; as an executable instead of having to pass it as a parameter to +;;;; guile via "guile -e main -s guile-test". Further, you can edit +;;;; the definition of default-test-suite to point to the parent +;;;; directory of the `tests' tree, which makes it unnecessary to set +;;;; the environment variable `TEST_SUITE_DIR'. +;;;; +;;;; +;;;; Shortcomings: +;;;; +;;;; At the moment, due to a simple-minded implementation, test files +;;;; must live in the test directory, and you must specify their names +;;;; relative to the top of the test directory. If you want to send +;;;; me a patch that fixes this, but still leaves sane test names in +;;;; the log file, that would be great. At the moment, all the tests +;;;; I care about are in the test directory, though. +;;;; +;;;; It would be nice if you could specify the Guile interpreter you +;;;; want to test on the command line. As it stands, if you want to +;;;; change which Guile interpreter you're testing, you need to edit +;;;; the #! line at the top of this file, which is stupid. + +(define (main . args) + (let ((module (resolve-module '(gnuradio test-suite guile-test)))) + (apply (module-ref module 'main) args))) + +(define-module (gnuradio test-suite guile-test) + :use-module (gnuradio test-suite lib) + :use-module (ice-9 getopt-long) + :use-module (ice-9 and-let-star) + :use-module (ice-9 rdelim) + :export (main data-file-name test-file-name)) + + +;;; User configurable settings: +(define default-test-suite + (string-append (getenv "HOME") "/bogus-path/test-suite")) + + +;;; Variables that will receive their actual values later. +(define test-suite default-test-suite) + +(define tmp-dir #f) + + +;;; General utilities, that probably should be in a library somewhere. + +;;; Enable debugging +(define (enable-debug-mode) + (write-line %load-path) + (set! %load-verbosely #t) + (debug-enable 'backtrace 'debug)) + +;;; Traverse the directory tree at ROOT, applying F to the name of +;;; each file in the tree, including ROOT itself. For a subdirectory +;;; SUB, if (F SUB) is true, we recurse into SUB. Do not follow +;;; symlinks. +(define (for-each-file f root) + + ;; A "hard directory" is a path that denotes a directory and is not a + ;; symlink. + (define (file-is-hard-directory? filename) + (eq? (stat:type (lstat filename)) 'directory)) + + (let visit ((root root)) + (let ((should-recur (f root))) + (if (and should-recur (file-is-hard-directory? root)) + (let ((dir (opendir root))) + (let loop () + (let ((entry (readdir dir))) + (cond + ((eof-object? entry) #f) + ((or (string=? entry ".") + (string=? entry "..") + (string=? entry "CVS") + (string=? entry "RCS")) + (loop)) + (else + (visit (string-append root "/" entry)) + (loop)))))))))) + + +;;; The test driver. + + +;;; Localizing test files and temporary data files. + +(define (data-file-name filename) + (in-vicinity tmp-dir filename)) + +(define (test-file-name test) + (in-vicinity test-suite test)) + +;;; Return a list of all the test files in the test tree. +(define (enumerate-tests test-dir) + (let ((root-len (+ 1 (string-length test-dir))) + (tests '())) + (for-each-file (lambda (file) + (if (has-suffix? file ".test") + (let ((short-name + (substring file root-len))) + (set! tests (cons short-name tests)))) + #t) + test-dir) + + ;; for-each-file presents the files in whatever order it finds + ;; them in the directory. We sort them here, so they'll always + ;; appear in the same order. This makes it easier to compare test + ;; log files mechanically. + (sort tests string<?))) + +(define (main args) + (let ((options (getopt-long args + `((test-suite + (single-char #\t) + (value #t)) + (flag-unresolved + (single-char #\u)) + (log-file + (single-char #\l) + (value #t)) + (debug + (single-char #\d)))))) + (define (opt tag default) + (let ((pair (assq tag options))) + (if pair (cdr pair) default))) + + (if (opt 'debug #f) + (enable-debug-mode)) + + (set! test-suite + (or (opt 'test-suite #f) + (getenv "TEST_SUITE_DIR") + default-test-suite)) + + ;; directory where temporary files are created. + ;; when run from "make check", this must be under the build-dir, + ;; not the src-dir. + (set! tmp-dir (getcwd)) + + (let* ((tests + (let ((foo (opt '() '()))) + (if (null? foo) + (enumerate-tests test-suite) + foo))) + (log-file + (opt 'log-file "guile.log"))) + + ;; Open the log file. + (let ((log-port (open-output-file log-file))) + + ;; Register some reporters. + (let ((global-pass #t) + (counter (make-count-reporter))) + (register-reporter (car counter)) + (register-reporter (make-log-reporter log-port)) + (register-reporter user-reporter) + (register-reporter (lambda results + (case (car results) + ((unresolved) + (and (opt 'flag-unresolved #f) + (set! global-pass #f))) + ((fail upass error) + (set! global-pass #f))))) + + ;; Run the tests. + (for-each (lambda (test) + (display (string-append "Running " test "\n")) + (with-test-prefix test + (load (test-file-name test)))) + tests) + + ;; Display the final counts, both to the user and in the log + ;; file. + (let ((counts ((cadr counter)))) + (print-counts counts) + (print-counts counts log-port)) + + (close-port log-port) + (quit global-pass)))))) + + +;;; Local Variables: +;;; mode: scheme +;;; End: diff --git a/gnuradio-core/src/guile/gnuradio/test-suite/lib.scm b/gnuradio-core/src/guile/gnuradio/test-suite/lib.scm new file mode 100644 index 000000000..abdc89632 --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/test-suite/lib.scm @@ -0,0 +1,627 @@ +;;;; test-suite/lib.scm --- generic support for testing +;;;; Copyright (C) 1999, 2000, 2001, 2004, 2006, 2007 Free Software Foundation, Inc. +;;;; +;;;; This program 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. +;;;; +;;;; This program 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 software; see the file COPYING. If not, write to +;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;;;; Boston, MA 02110-1301 USA + +(define-module (gnuradio test-suite lib) + :use-module (ice-9 stack-catch) + :use-module (ice-9 regex) + :use-module (ice-9 syncase) + :use-module (ice-9 format) + :export ( + + ;; Exceptions which are commonly being tested for. + exception:bad-variable + exception:missing-expression + exception:out-of-range exception:unbound-var + exception:used-before-defined + exception:wrong-num-args exception:wrong-type-arg + exception:numerical-overflow + exception:struct-set!-denied + exception:system-error + exception:miscellaneous-error + exception:string-contains-nul + + ;; Reporting passes and failures. + run-test + pass-if expect-fail + pass-if-exception expect-fail-exception + pass-if-throw expect-fail-throw + + ;; Naming groups of tests in a regular fashion. + with-test-prefix with-test-prefix* current-test-prefix + format-test-name + + ;; Using the debugging evaluator. + with-debugging-evaluator with-debugging-evaluator* + + ;; Reporting results in various ways. + register-reporter unregister-reporter reporter-registered? + make-count-reporter print-counts + make-log-reporter + full-reporter + user-reporter + + ;; srfi-64 compatibility macros + test-equal + test-eqv + test-eq +)) + + +;;;; If you're using Emacs's Scheme mode: +;;;; (put 'with-test-prefix 'scheme-indent-function 1) + + +;;;; CORE FUNCTIONS +;;;; +;;;; The function (run-test name expected-result thunk) is the heart of the +;;;; testing environment. The first parameter NAME is a unique name for the +;;;; test to be executed (for an explanation of this parameter see below under +;;;; TEST NAMES). The second parameter EXPECTED-RESULT is a boolean value +;;;; that indicates whether the corresponding test is expected to pass. If +;;;; EXPECTED-RESULT is #t the test is expected to pass, if EXPECTED-RESULT is +;;;; #f the test is expected to fail. Finally, THUNK is the function that +;;;; actually performs the test. For example: +;;;; +;;;; (run-test "integer addition" #t (lambda () (= 2 (+ 1 1)))) +;;;; +;;;; To report success, THUNK should either return #t or throw 'pass. To +;;;; report failure, THUNK should either return #f or throw 'fail. If THUNK +;;;; returns a non boolean value or throws 'unresolved, this indicates that +;;;; the test did not perform as expected. For example the property that was +;;;; to be tested could not be tested because something else went wrong. +;;;; THUNK may also throw 'untested to indicate that the test was deliberately +;;;; not performed, for example because the test case is not complete yet. +;;;; Finally, if THUNK throws 'unsupported, this indicates that this test +;;;; requires some feature that is not available in the configured testing +;;;; environment. All other exceptions thrown by THUNK are considered as +;;;; errors. +;;;; +;;;; +;;;; Convenience macros for tests expected to pass or fail +;;;; +;;;; * (pass-if name body) is a short form for +;;;; (run-test name #t (lambda () body)) +;;;; * (expect-fail name body) is a short form for +;;;; (run-test name #f (lambda () body)) +;;;; +;;;; For example: +;;;; +;;;; (pass-if "integer addition" (= 2 (+ 1 1))) +;;;; +;;;; +;;;; Convenience macros to test for exceptions +;;;; +;;;; The following macros take exception parameters which are pairs +;;;; (type . message), where type is a symbol that denotes an exception type +;;;; like 'wrong-type-arg or 'out-of-range, and message is a string holding a +;;;; regular expression that describes the error message for the exception +;;;; like "Argument .* out of range". +;;;; +;;;; * (pass-if-exception name exception body) will pass if the execution of +;;;; body causes the given exception to be thrown. If no exception is +;;;; thrown, the test fails. If some other exception is thrown, is is an +;;;; error. +;;;; * (expect-fail-exception name exception body) will pass unexpectedly if +;;;; the execution of body causes the given exception to be thrown. If no +;;;; exception is thrown, the test fails expectedly. If some other +;;;; exception is thrown, it is an error. + + +;;;; TEST NAMES +;;;; +;;;; Every test in the test suite has a unique name, to help +;;;; developers find tests that are failing (or unexpectedly passing), +;;;; and to help gather statistics. +;;;; +;;;; A test name is a list of printable objects. For example: +;;;; ("ports.scm" "file" "read and write back list of strings") +;;;; ("ports.scm" "pipe" "read") +;;;; +;;;; Test names may contain arbitrary objects, but they always have +;;;; the following properties: +;;;; - Test names can be compared with EQUAL?. +;;;; - Test names can be reliably stored and retrieved with the standard WRITE +;;;; and READ procedures; doing so preserves their identity. +;;;; +;;;; For example: +;;;; +;;;; (pass-if "simple addition" (= 4 (+ 2 2))) +;;;; +;;;; In that case, the test name is the list ("simple addition"). +;;;; +;;;; In the case of simple tests the expression that is tested would often +;;;; suffice as a test name by itself. Therefore, the convenience macros +;;;; pass-if and expect-fail provide a shorthand notation that allows to omit +;;;; a test name in such cases. +;;;; +;;;; * (pass-if expression) is a short form for +;;;; (run-test 'expression #t (lambda () expression)) +;;;; * (expect-fail expression) is a short form for +;;;; (run-test 'expression #f (lambda () expression)) +;;;; +;;;; For example: +;;;; +;;;; (pass-if (= 2 (+ 1 1))) +;;;; +;;;; The WITH-TEST-PREFIX syntax and WITH-TEST-PREFIX* procedure establish +;;;; a prefix for the names of all tests whose results are reported +;;;; within their dynamic scope. For example: +;;;; +;;;; (begin +;;;; (with-test-prefix "basic arithmetic" +;;;; (pass-if "addition" (= (+ 2 2) 4)) +;;;; (pass-if "subtraction" (= (- 4 2) 2))) +;;;; (pass-if "multiplication" (= (* 2 2) 4))) +;;;; +;;;; In that example, the three test names are: +;;;; ("basic arithmetic" "addition"), +;;;; ("basic arithmetic" "subtraction"), and +;;;; ("multiplication"). +;;;; +;;;; WITH-TEST-PREFIX can be nested. Each WITH-TEST-PREFIX postpends +;;;; a new element to the current prefix: +;;;; +;;;; (with-test-prefix "arithmetic" +;;;; (with-test-prefix "addition" +;;;; (pass-if "integer" (= (+ 2 2) 4)) +;;;; (pass-if "complex" (= (+ 2+3i 4+5i) 6+8i))) +;;;; (with-test-prefix "subtraction" +;;;; (pass-if "integer" (= (- 2 2) 0)) +;;;; (pass-if "complex" (= (- 2+3i 1+2i) 1+1i)))) +;;;; +;;;; The four test names here are: +;;;; ("arithmetic" "addition" "integer") +;;;; ("arithmetic" "addition" "complex") +;;;; ("arithmetic" "subtraction" "integer") +;;;; ("arithmetic" "subtraction" "complex") +;;;; +;;;; To print a name for a human reader, we DISPLAY its elements, +;;;; separated by ": ". So, the last set of test names would be +;;;; reported as: +;;;; +;;;; arithmetic: addition: integer +;;;; arithmetic: addition: complex +;;;; arithmetic: subtraction: integer +;;;; arithmetic: subtraction: complex +;;;; +;;;; The Guile benchmarks use with-test-prefix to include the name of +;;;; the source file containing the test in the test name, to help +;;;; developers to find failing tests, and to provide each file with its +;;;; own namespace. + + +;;;; REPORTERS +;;;; +;;;; A reporter is a function which we apply to each test outcome. +;;;; Reporters can log results, print interesting results to the +;;;; standard output, collect statistics, etc. +;;;; +;;;; A reporter function takes two mandatory arguments, RESULT and TEST, and +;;;; possibly additional arguments depending on RESULT; its return value +;;;; is ignored. RESULT has one of the following forms: +;;;; +;;;; pass - The test named TEST passed. +;;;; Additional arguments are ignored. +;;;; upass - The test named TEST passed unexpectedly. +;;;; Additional arguments are ignored. +;;;; fail - The test named TEST failed. +;;;; Additional arguments are ignored. +;;;; xfail - The test named TEST failed, as expected. +;;;; Additional arguments are ignored. +;;;; unresolved - The test named TEST did not perform as expected, for +;;;; example the property that was to be tested could not be +;;;; tested because something else went wrong. +;;;; Additional arguments are ignored. +;;;; untested - The test named TEST was not actually performed, for +;;;; example because the test case is not complete yet. +;;;; Additional arguments are ignored. +;;;; unsupported - The test named TEST requires some feature that is not +;;;; available in the configured testing environment. +;;;; Additional arguments are ignored. +;;;; error - An error occurred while the test named TEST was +;;;; performed. Since this result means that the system caught +;;;; an exception it could not handle, the exception arguments +;;;; are passed as additional arguments. +;;;; +;;;; This library provides some standard reporters for logging results +;;;; to a file, reporting interesting results to the user, and +;;;; collecting totals. +;;;; +;;;; You can use the REGISTER-REPORTER function and friends to add +;;;; whatever reporting functions you like. If you don't register any +;;;; reporters, the library uses FULL-REPORTER, which simply writes +;;;; all results to the standard output. + + +;;;; MISCELLANEOUS +;;;; + +;;; Define some exceptions which are commonly being tested for. +(define exception:bad-variable + (cons 'syntax-error "Bad variable")) +(define exception:missing-expression + (cons 'misc-error "^missing or extra expression")) +(define exception:out-of-range + (cons 'out-of-range "^.*out of range")) +(define exception:unbound-var + (cons 'unbound-variable "^Unbound variable")) +(define exception:used-before-defined + (cons 'unbound-variable "^Variable used before given a value")) +(define exception:wrong-num-args + (cons 'wrong-number-of-args "^Wrong number of arguments")) +(define exception:wrong-type-arg + (cons 'wrong-type-arg "^Wrong type")) +(define exception:numerical-overflow + (cons 'numerical-overflow "^Numerical overflow")) +(define exception:struct-set!-denied + (cons 'misc-error "^set! denied for field")) +(define exception:system-error + (cons 'system-error ".*")) +(define exception:miscellaneous-error + (cons 'misc-error "^.*")) + +;; as per throw in scm_to_locale_stringn() +(define exception:string-contains-nul + (cons 'misc-error "^string contains #\\\\nul character")) + + +;;; Display all parameters to the default output port, followed by a newline. +(define (display-line . objs) + (for-each display objs) + (newline)) + +;;; Display all parameters to the given output port, followed by a newline. +(define (display-line-port port . objs) + (for-each (lambda (obj) (display obj port)) objs) + (newline port)) + + +;;;; CORE FUNCTIONS +;;;; + +;;; The central testing routine. +;;; The idea is taken from Greg, the GNUstep regression test environment. +(define run-test #f) +(let ((test-running #f)) + (define (local-run-test name expect-pass thunk) + (if test-running + (error "Nested calls to run-test are not permitted.") + (let ((test-name (full-name name))) + (set! test-running #t) + (catch #t + (lambda () + (let ((result (thunk))) + (if (eq? result #t) (throw 'pass)) + (if (eq? result #f) (throw 'fail)) + (throw 'unresolved))) + (lambda (key . args) + (case key + ((pass) + (report (if expect-pass 'pass 'upass) test-name)) + ((fail) + (report (if expect-pass 'fail 'xfail) test-name)) + ((unresolved untested unsupported) + (report key test-name)) + ((quit) + (report 'unresolved test-name) + (quit)) + (else + (report 'error test-name (cons key args)))))) + (set! test-running #f)))) + (set! run-test local-run-test)) + +;;; A short form for tests that are expected to pass, taken from Greg. +(defmacro pass-if (name . rest) + (if (and (null? rest) (pair? name)) + ;; presume this is a simple test, i.e. (pass-if (even? 2)) + ;; where the body should also be the name. + `(run-test ',name #t (lambda () ,name)) + `(run-test ,name #t (lambda () ,@rest)))) + +;;; A short form for tests that are expected to fail, taken from Greg. +(defmacro expect-fail (name . rest) + (if (and (null? rest) (pair? name)) + ;; presume this is a simple test, i.e. (expect-fail (even? 2)) + ;; where the body should also be the name. + `(run-test ',name #f (lambda () ,name)) + `(run-test ,name #f (lambda () ,@rest)))) + +;;; A helper function to implement the macros that test for exceptions. +;;; +;;; This doesn't work for all exceptions, just those that were +;;; raised by scm-error or error. This doesn't include those +;;; raised by throw in the general case, or SWIG in particular. +;;; +;;; See also run-raise-exception, pass-if-throw and expect-fail-throw +;;; for alternatives that work with all exceptions. +(define (run-test-exception name exception expect-pass thunk) + (run-test name expect-pass + (lambda () + (stack-catch (car exception) + (lambda () (thunk) #f) + (lambda (key proc message . rest) + (cond + ;; handle explicit key + ((string-match (cdr exception) message) + #t) + ;; handle `(error ...)' which uses `misc-error' for key and doesn't + ;; yet format the message and args (we have to do it here). + ((and (eq? 'misc-error (car exception)) + (list? rest) + (string-match (cdr exception) + (apply simple-format #f message (car rest)))) + #t) + ;; handle syntax errors which use `syntax-error' for key and don't + ;; yet format the message and args (we have to do it here). + ((and (eq? 'syntax-error (car exception)) + (list? rest) + (string-match (cdr exception) + (apply simple-format #f message (car rest)))) + #t) + ;; unhandled; throw again + (else + (apply throw key proc message rest)))))))) + +;;; A short form for tests that expect a certain exception to be thrown. +(defmacro pass-if-exception (name exception body . rest) + `(,run-test-exception ,name ,exception #t (lambda () ,body ,@rest))) + +;;; A short form for tests expected to fail to throw a certain exception. +(defmacro expect-fail-exception (name exception body . rest) + `(,run-test-exception ,name ,exception #f (lambda () ,body ,@rest))) + + +;;; Helper for macros below +(define (run-test-throw name exception-key expect-pass thunk) + (run-test name expect-pass + (lambda () + (stack-catch exception-key + (lambda () (thunk) #f) + (lambda (key . rest) #t))))) + +;;; A short form for tests that expect a certain exception to be thrown, +;;; where the exception is specified only by the exception-key symbol. +(defmacro pass-if-throw (name exception-key body . rest) + `(,run-test-throw ,name ,exception-key #t (lambda () ,body ,@rest))) + +;;; A short form for tests that expect a certain exception to be thrown, +;;; where the exception is specified only by the exception-key symbol. +(defmacro expect-fail-throw (name exception-key body . rest) + `(,run-test-throw ,name ,exception-key #f (lambda () ,body ,@rest))) + +;;;; TEST NAMES +;;;; + +;;;; Turn a test name into a nice human-readable string. +(define (format-test-name name) + (call-with-output-string + (lambda (port) + (let loop ((name name) + (separator "")) + (if (pair? name) + (begin + (display separator port) + (display (car name) port) + (loop (cdr name) ": "))))))) + +;;;; For a given test-name, deliver the full name including all prefixes. +(define (full-name name) + (append (current-test-prefix) (list name))) + +;;; A fluid containing the current test prefix, as a list. +(define prefix-fluid (make-fluid)) +(fluid-set! prefix-fluid '()) +(define (current-test-prefix) + (fluid-ref prefix-fluid)) + +;;; Postpend PREFIX to the current name prefix while evaluting THUNK. +;;; The name prefix is only changed within the dynamic scope of the +;;; call to with-test-prefix*. Return the value returned by THUNK. +(define (with-test-prefix* prefix thunk) + (with-fluids ((prefix-fluid + (append (fluid-ref prefix-fluid) (list prefix)))) + (thunk))) + +;;; (with-test-prefix PREFIX BODY ...) +;;; Postpend PREFIX to the current name prefix while evaluating BODY ... +;;; The name prefix is only changed within the dynamic scope of the +;;; with-test-prefix expression. Return the value returned by the last +;;; BODY expression. +(defmacro with-test-prefix (prefix . body) + `(with-test-prefix* ,prefix (lambda () ,@body))) + +;;; Call THUNK using the debugging evaluator. +(define (with-debugging-evaluator* thunk) + (let ((dopts #f)) + (dynamic-wind + (lambda () + (set! dopts (debug-options)) + (debug-enable 'debug)) + thunk + (lambda () + (debug-options dopts))))) + +;;; Evaluate BODY... using the debugging evaluator. +(define-macro (with-debugging-evaluator . body) + `(with-debugging-evaluator* (lambda () ,@body))) + + + +;;;; REPORTERS +;;;; + +;;; The global list of reporters. +(define reporters '()) + +;;; The default reporter, to be used only if no others exist. +(define default-reporter #f) + +;;; Add the procedure REPORTER to the current set of reporter functions. +;;; Signal an error if that reporter procedure object is already registered. +(define (register-reporter reporter) + (if (memq reporter reporters) + (error "register-reporter: reporter already registered: " reporter)) + (set! reporters (cons reporter reporters))) + +;;; Remove the procedure REPORTER from the current set of reporter +;;; functions. Signal an error if REPORTER is not currently registered. +(define (unregister-reporter reporter) + (if (memq reporter reporters) + (set! reporters (delq! reporter reporters)) + (error "unregister-reporter: reporter not registered: " reporter))) + +;;; Return true iff REPORTER is in the current set of reporter functions. +(define (reporter-registered? reporter) + (if (memq reporter reporters) #t #f)) + +;;; Send RESULT to all currently registered reporter functions. +(define (report . args) + (if (pair? reporters) + (for-each (lambda (reporter) (apply reporter args)) + reporters) + (apply default-reporter args))) + + +;;;; Some useful standard reporters: +;;;; Count reporters count the occurrence of each test result type. +;;;; Log reporters write all test results to a given log file. +;;;; Full reporters write all test results to the standard output. +;;;; User reporters write interesting test results to the standard output. + +;;; The complete list of possible test results. +(define result-tags + '((pass "PASS" "passes: ") + (fail "FAIL" "failures: ") + (upass "UPASS" "unexpected passes: ") + (xfail "XFAIL" "expected failures: ") + (unresolved "UNRESOLVED" "unresolved test cases: ") + (untested "UNTESTED" "untested test cases: ") + (unsupported "UNSUPPORTED" "unsupported test cases: ") + (error "ERROR" "errors: "))) + +;;; The list of important test results. +(define important-result-tags + '(fail upass unresolved error)) + +;;; Display a single test result in formatted form to the given port +(define (print-result port result name . args) + (let* ((tag (assq result result-tags)) + (label (if tag (cadr tag) #f))) + (if label + (begin + (display label port) + (display ": " port) + (display (format-test-name name) port) + (if (pair? args) + (begin + (display " - arguments: " port) + (write args port))) + (newline port)) + (error "(test-suite lib) FULL-REPORTER: unrecognized result: " + result)))) + +;;; Return a list of the form (COUNTER RESULTS), where: +;;; - COUNTER is a reporter procedure, and +;;; - RESULTS is a procedure taking no arguments which returns the +;;; results seen so far by COUNTER. The return value is an alist +;;; mapping outcome symbols (`pass', `fail', etc.) onto counts. +(define (make-count-reporter) + (let ((counts (map (lambda (tag) (cons (car tag) 0)) result-tags))) + (list + (lambda (result name . args) + (let ((pair (assq result counts))) + (if pair + (set-cdr! pair (+ 1 (cdr pair))) + (error "count-reporter: unexpected test result: " + (cons result (cons name args)))))) + (lambda () + (append counts '()))))) + +;;; Print a count reporter's results nicely. Pass this function the value +;;; returned by a count reporter's RESULTS procedure. +(define (print-counts results . port?) + (let ((port (if (pair? port?) + (car port?) + (current-output-port)))) + (newline port) + (display-line-port port "Totals for this test run:") + (for-each + (lambda (tag) + (let ((result (assq (car tag) results))) + (if result + (display-line-port port (caddr tag) (cdr result)) + (display-line-port port + "Test suite bug: " + "no total available for `" (car tag) "'")))) + result-tags) + (newline port))) + +;;; Return a reporter procedure which prints all results to the file +;;; FILE, in human-readable form. FILE may be a filename, or a port. +(define (make-log-reporter file) + (let ((port (if (output-port? file) file + (open-output-file file)))) + (lambda args + (apply print-result port args) + (force-output port)))) + +;;; A reporter that reports all results to the user. +(define (full-reporter . args) + (apply print-result (current-output-port) args)) + +;;; A reporter procedure which shows interesting results (failures, +;;; unexpected passes etc.) to the user. +(define (user-reporter result name . args) + (if (memq result important-result-tags) + (apply full-reporter result name args))) + +(set! default-reporter full-reporter) + + +;;; Macros for a bit of compatibility with srfi-64 +;;; (test-equal [name] expected test-expr) +(define-syntax test-equal + (syntax-rules () + ((_ expected test-expr) + (pass-if (verbose-equal? expected test-expr))) + ((_ name expected test-exprt) + (pass-if name (verbose-equal? expected test-expr))))) + +;;; (test-eqv [name] expected test-expr) +(define-syntax test-eqv + (syntax-rules () + ((_ expected test-expr) + (pass-if (eqv? expected test-expr))) + ((_ name expected test-exprt) + (pass-if name (eqv? expected test-expr))))) + +;;; (test-eq [name] expected test-expr) +(define-syntax test-eq + (syntax-rules () + ((_ expected test-expr) + (pass-if (eq? expected test-expr))) + ((_ name expected test-exprt) + (pass-if name (eq? expected test-expr))))) + + +(define-public (verbose-equal? expected actual) + (cond ((equal? expected actual) #t) + (else + (format #t "Expected:\n~y\n" expected) + (format #t "Actual:\n~y\n" actual) + #f))) diff --git a/gnuradio-core/src/guile/gnuradio/waveform.scm b/gnuradio-core/src/guile/gnuradio/waveform.scm new file mode 100644 index 000000000..0031be931 --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/waveform.scm @@ -0,0 +1,54 @@ +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +(define-module (gnuradio waveform) + #:use-module (ice-9 syncase) + #:export-syntax (define-waveform)) + + +(define *registry* '()) ; alist +(define *last-registered* #f) + + +(define-syntax define-waveform + (syntax-rules (vars blocks connections) + ((_ (name cmd-line-args) + (vars (v-name v-val) ...) + (blocks (b-name b-val) ...) + (connections (endpoint1 endpoint2 ...) ...)) + (waveform-register 'name + (lambda (cmd-line-args) + (let* ((v-name v-val) ... + (b-name b-val) ... + (tb (gr:top-block-swig "waveform-top-block"))) + (gr:connect tb endpoint1 endpoint2 ...) ... + tb)))))) + + +(define-public (waveform-register name thunk) + (set! *registry* (assoc-set! *registry* name thunk)) + (set! *last-registered* thunk) + #t) + +(define-public (waveform-lookup name) + (let ((r (assoc name *registry*))) + (and r (cdr r)))) + +(define-public (waveform-last-registered) + *last-registered*) diff --git a/gnuradio-core/src/guile/run_guile_tests.in b/gnuradio-core/src/guile/run_guile_tests.in new file mode 100644 index 000000000..61968065e --- /dev/null +++ b/gnuradio-core/src/guile/run_guile_tests.in @@ -0,0 +1,17 @@ +#!/bin/sh + +. @top_builddir@/setup_guile_test_env + +# Since we're in gnuradio-core, we don't need to add anything, +# but we do need to call add_local_paths to set everything up + +# 1st argument is absolute path to hand coded guile source directory +# 2nd argument is absolute path to component C++ shared library build directory +# 3nd argument is absolute path to component SWIG build directory + +add_local_paths \ + "" \ + "" \ + "" + +@GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@/tests diff --git a/gnuradio-core/src/guile/tests/00_runtime_basics.test b/gnuradio-core/src/guile/tests/00_runtime_basics.test new file mode 100644 index 000000000..18b298f22 --- /dev/null +++ b/gnuradio-core/src/guile/tests/00_runtime_basics.test @@ -0,0 +1,158 @@ +;;; -*- Scheme -*- +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; If you're using Emacs's Scheme mode: +;;; (put 'with-test-prefix 'scheme-indent-function 1) + +;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. +;;; See also the very end of the file, where the test-equal, test-eqv +;;; and test-eq macros are defined. + +(use-modules (gnuradio test-suite lib)) +(use-modules (gnuradio core)) +(use-modules (oop goops)) + +(define (vector-map f v) + (list->vector (map f (vector->list v)))) + + +(with-test-prefix "connect-1" + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "QA top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + ;; using gr:ep to create endpoints + (gr:connect tb (gr:ep src 0) (gr:ep op 0)) + (gr:connect tb (gr:ep op 0) (gr:ep dst 0)) + + (gr:run tb) + ;;(pass-if (equal? expected-result (gr:data dst))) + (test-equal expected-result (gr:data dst)) + )) + +(with-test-prefix "connect-2" + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "QA top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + ;; using just blocks + (gr:connect tb src op) + (gr:connect tb op dst) + + (gr:run tb) + (test-equal expected-result (gr:data dst)))) + + +(with-test-prefix "connect-3" + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "QA top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + ;; using lists to represent endpoints + (gr:connect tb `(,src 0) `(,op 0)) + (gr:connect tb `(,op 0) `(,dst 0)) + + (gr:run tb) + (test-equal expected-result (gr:data dst)))) + + +(with-test-prefix "connect-4" + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "QA top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + ;; using multiple endpoints + (gr:connect tb src op dst) + + (gr:run tb) + (test-equal expected-result (gr:data dst)))) + +(with-test-prefix "connect-5" + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "QA top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + (pass-if-throw "bad port exception" 'swig-exception + (gr:connect tb src op (gr:ep dst 1))) + )) + +(with-test-prefix "gr_top_block::start throw" + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "QA top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + ;; We deliberately don't connect op's output + (gr:connect tb src op) + + ;; Which will lead to an exception here... + (pass-if-throw "throws std::runtime_error" 'swig-exception + (gr:run tb)) + )) + +(with-test-prefix "io-signature-1" + (let ((ios1 (gr:io-signature 1 2 8)) + (ios2 (gr:io-signature2 1 2 16 32)) + (ios3 (gr:io-signature3 1 -1 14 32 48)) + (iosv (gr:io-signaturev 1 4 '(1 2 3)))) + + (test-equal 1 (gr:min-streams ios1)) + (test-equal 2 (gr:max-streams ios1)) + (test-equal 8 (gr:sizeof-stream-item ios1 0)) + (test-equal 8 (gr:sizeof-stream-item ios1 1)) + + (test-equal 1 (gr:min-streams ios2)) + (test-equal 2 (gr:max-streams ios2)) + (test-equal 16 (gr:sizeof-stream-item ios2 0)) + (test-equal 32 (gr:sizeof-stream-item ios2 1)) + + (test-equal 1 (gr:min-streams ios3)) + (test-equal -1 (gr:max-streams ios3)) + (test-equal 14 (gr:sizeof-stream-item ios3 0)) + (test-equal 32 (gr:sizeof-stream-item ios3 1)) + (test-equal 48 (gr:sizeof-stream-item ios3 2)) + (test-equal '#(14 32 48) (gr:sizeof-stream-items ios3)) + + (test-equal 1 (gr:min-streams iosv)) + (test-equal 4 (gr:max-streams iosv)) + (test-equal 1 (gr:sizeof-stream-item iosv 0)) + (test-equal 2 (gr:sizeof-stream-item iosv 1)) + (test-equal 3 (gr:sizeof-stream-item iosv 2)) + (test-equal 3 (gr:sizeof-stream-item iosv 3)) + (test-equal '#(1 2 3) (gr:sizeof-stream-items iosv)) + )) + diff --git a/gnuradio-core/src/guile/tests/00_runtime_ctors.test b/gnuradio-core/src/guile/tests/00_runtime_ctors.test new file mode 100644 index 000000000..966d8c909 --- /dev/null +++ b/gnuradio-core/src/guile/tests/00_runtime_ctors.test @@ -0,0 +1,54 @@ +;;; -*- Scheme -*- +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; If you're using Emacs's Scheme mode: +;;; (put 'with-test-prefix 'scheme-indent-function 1) + +;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. +;;; See also the very end of the file where the test-equal, test-eqv +;;; and test-eq macros are defined. + +(use-modules (gnuradio test-suite lib)) +(use-modules (gnuradio core)) +(use-modules (oop goops)) + +;;; Add test code for all constructors in these files +;;; +;;; ./runtime/gr_hier_block2.h + +;;; ./runtime/gr_msg_queue.h + +(define (equal-message? a b) + (equal? (gr:to-string a) (gr:to-string b))) + +(with-test-prefix "gr:message/gr:msg-queue" + (let ((msg1 (gr:message-from-string "Hello")) + (msg2 (gr:message-from-string "World!")) + (q (gr:msg-queue))) + (pass-if (equal? "Hello" (gr:to-string msg1))) + (pass-if (equal? "World!" (gr:to-string msg2))) + (pass-if (gr:empty-p q)) + (gr:insert-tail q msg1) + (pass-if (not (gr:empty-p q))) + (gr:insert-tail q msg2) + (let ((r1 (gr:delete-head q)) + (r2 (gr:delete-head q))) + (pass-if (equal-message? r1 msg1)) + (pass-if (equal-message? r2 msg2))))) diff --git a/gnuradio-core/src/guile/tests/filter_ctors.test b/gnuradio-core/src/guile/tests/filter_ctors.test new file mode 100644 index 000000000..4dd0bc187 --- /dev/null +++ b/gnuradio-core/src/guile/tests/filter_ctors.test @@ -0,0 +1,248 @@ +;;; -*- Scheme -*- +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; If you're using Emacs's Scheme mode: +;;; (put 'with-test-prefix 'scheme-indent-function 1) + +;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. +;;; See also the very end of the file, where the test-equal, test-eqv +;;; and test-eq macros are defined. + +(use-modules (gnuradio test-suite lib)) +(use-modules (gnuradio core)) +(use-modules (oop goops)) + +;;; Add test code for all constructors in these files +;;; + +;;; ./filter/gr_adaptive_fir_ccf.h WONTFIX: not wrapped +;; gr_adaptive_fir_ccf(char *name, int decimation, const std::vector<float> &taps); +;; (pass-if (true? (gr:adaptive-fir-ccf "foo" 0 #(1.0 2.0 3.0 4.0)))) + +;;; ./filter/gr_cma_equalizer_cc.h +(pass-if (true? (gr:cma-equalizer-cc 0 0 0))) + +;;; ./filter/gr_fft_filter_ccc.h +(pass-if (true? (gr:fft-filter-ccc 0 #(1+3i 23+5i)))) + +;;; ./filter/gr_fft_filter_fff.h +(pass-if (true? (gr:fft-filter-fff 0 #(1.0 2.0)))) + +;;; ./filter/gr_filter_delay_fc.h +(pass-if (true? (gr:filter-delay-fc #(1.0 2.0)))) + +;;; ./filter/gr_fir_ccc_generic. FIXME: Unbound variable: ~S" (gr:fir-ccc-generic) #f)) +;; (pass-if (true? (gr:fir-ccc-generic))) +;; (pass-if (true? (gr:fir-ccc-generic #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_ccc_simd.h FIXME: not found +;; (pass-if (true? (gr:fir-ccc-simd))) +;; (pass-if (true? (gr:fir-ccc-simd #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_ccc_x86.h FIXME: not found +;; (pass-if (true? (gr:fir-ccc-x86))) +;; (pass-if (true? (gr:fir-ccc-x86 #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_ccf_generic.h FIXME: not found +;; (pass-if (true? (gr:fir-ccf-generic))) +;; (pass-if (true? (gr:fir-ccf-generic #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_ccf_simd.h FIXME: not found +;; (pass-if (true? (gr:fir-ccf-simd 0 0 0 0))) + +;;; ./filter/gr_fir_ccf_x86.h FIXME: not found +;; (pass-if (true? (gr:fir-ccf-x86))) +;; (pass-if (true? (gr:fir-ccf-x86 #(1.0 2.0)))) + +;;; ./filter/gr_fir_fcc_generic.h FIXME: not found +;; (pass-if (true? (gr:fir-fcc-generic))) +;; (pass-if (true? (gr:fir-fcc-generic #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_fcc_simd.h FIXME: not found +;; (pass-if (true? (gr:fir-fcc-simd 0 0 0 0))) + +;;; ./filter/gr_fir_fcc_x86.h FIXME: not found +;; (pass-if (true? (gr:fir-fcc-x86))) +;; (pass-if (true? (gr:fir-fcc-x86 #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_fff_altivec.h FIXME: not found +;; (pass-if (true? (gr:fir-fff-altivec))) +;; (pass-if (true? (gr:fir-fff-altivec #(1.0 2.0)))) + +;;; ./filter/gr_fir_fff_armv7_a.h FIXME: not found +;; (pass-if (true? (gr:fir-fff-armv7-a))) +;; (pass-if (true? (gr:fir-fff-armv7-a #(1.0 2.0)))) + +;;; ./filter/gr_fir_fff_generic.h FIXME: not found +;; (pass-if (true? (gr:fir-fff-generic))) +;; (pass-if (true? (gr:fir-fff-generic #(1.0 2.0)))) + +;;; ./filter/gr_fir_fff_simd.h FIXME: not found +;; (pass-if (true? (gr:fir-fff-simd 0 0 0))) + +;;; ./filter/gr_fir_fff_x86.h FIXME: not found +;; (pass-if (true? (gr:fir-fff-x86))) +;; (pass-if (true? (gr:fir-fff-x86 #(1.0 2.0)))) + +;;; ./filter/gr_fir_filter_ccc.h FIXME: not found +;; (pass-if (true? (gr:fir-filter-ccc 1 #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_filter_ccf.h +(pass-if (true? (gr:fir-filter-ccf 1 #(1.0 2.0)))) + +;;; ./filter/gr_fir_filter_fcc.h +(pass-if (true? (gr:fir-filter-fcc 1 #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_filter_fff.h +(pass-if (true? (gr:fir-filter-fff 1 #(1.0 2.0)))) + +;;; ./filter/gr_fir_filter_fsf.h +(pass-if (true? (gr:fir-filter-fsf 1 #(1.0 2.0)))) + +;;; ./filter/gr_fir_filter_scc.h +(pass-if (true? (gr:fir-filter-scc 1 #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_fsf_generic.h FIXME: "Unbound variable: ~S" (gr:fir-fsf-generic) #f)) +;; (pass-if (true? (gr:fir-fsf-generic))) +;; (pass-if (true? (gr:fir-fsf-generic #(1.0 2.0)))) + +;;; ./filter/gr_fir_fsf_simd.h FIXME: not found +;; (pass-if (true? (gr:fir-fsf-simd 0 0 0))) + +;;; ./filter/gr_fir_fsf_x86.h FIXME: "Unbound variable: ~S" (gr:fir-fsf-x86) #f)) +;; (pass-if (true? (gr:fir-fsf-x86))) +;; (pass-if (true? (gr:fir-fsf-x86 #(1.0 2.0)))) + +;;; ./filter/gr_fir_scc_generic.h FIXME: file not found +;; (pass-if (true? (gr:fir-scc-generic))) +;; (pass-if (true? (gr:fir-scc-generic #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_scc_simd.h FIXME: Unbound variable: ~S" (gr:fir-scc-simd) #f)) +;; (pass-if (true? (gr:fir-scc-simd))) +;; (pass-if (true? (gr:fir-scc-simd #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_scc_x86.h FIXME: "Unbound variable: ~S" (gr:fir-scc-x86) #f)) +;; (pass-if (true? (gr:fir-scc-x86))) +;; (pass-if (true? (gr:fir-scc-x86 #(1+3i 23+5i)))) + +;;; ./filter/gr_fir_sysconfig_armv7_a.h FIXME: virtual methods +;; (pass-if (true? (gr:fir-sysconfig-armv7-a ))) + +;;; ./filter/gr_fir_sysconfig_generic.h FIXME: virtual methods +;; (pass-if (true? (gr:fir-sysconfig-generic ))) + +;;; ./filter/gr_fir_sysconfig_powerpc.h FIXME: virtual methods +;; (pass-if (true? (gr:fir-sysconfig-powerpc ))) + +;;; ./filter/gr_fir_sysconfig_x86.h FIXME: virtual methods +;; (pass-if (true? (gr:fir-sysconfig-x86 #(1+3i 23+5i)))) + +;;; ./filter/gr_fractional_interpolator_cc.h +(pass-if (true? (gr:fractional-interpolator-cc 1.0 1.0))) + +;;; ./filter/gr_fractional_interpolator_ff.h +(pass-if (true? (gr:fractional-interpolator-ff 1.0 1.0))) + +;;; ./filter/gr_freq_xlating_fir_filter_ccc.h +(pass-if (true? (gr:freq-xlating-fir-filter-ccc 1 #(1+3i 23+5i) 1.0 1.0))) + +;;; ./filter/gr_freq_xlating_fir_filter_ccf.h +(pass-if (true? (gr:freq-xlating-fir-filter-ccf 1 #(1.0 2.0) 1.0 1.0))) + +;;; ./filter/gr_freq_xlating_fir_filter_fcc.h +(pass-if (true? (gr:freq-xlating-fir-filter-fcc 1 #(1.0 2.0) 1.0 1.0))) + +;;; ./filter/gr_freq_xlating_fir_filter_fcf.h +(pass-if (true? (gr:freq-xlating-fir-filter-fcf 1 #(1.0 2.0) 1.0 1.0))) + +;;; ./filter/gr_freq_xlating_fir_filter_scc.h +(pass-if (true? (gr:freq-xlating-fir-filter-scc 1 #(1.0 2.0) 1.0 1.0))) + +;;; ./filter/gr_freq_xlating_fir_filter_scf.h +(pass-if (true? (gr:freq-xlating-fir-filter-scf 1 #(1.0 2.0) 1.0 1.0))) + +;;; ./filter/gr_goertzel_fc.h +(pass-if (true? (gr:goertzel-fc 1 1 1))) + +;;; ./filter/gr_hilbert_fc.h +(pass-if (true? (gr:hilbert-fc 1))) + +;;; ./filter/gr_iir_filter_ffd.h +(pass-if (true? (gr:iir-filter-ffd #(1.0 2.0) #(1.0 2.0)))) + +;;; ./filter/gr_interp_fir_filter_ccc.h FIXME: not found +;; (pass-if (true? (gr:interp-fir-filter-ccc #(1+3i 23+5i)))) + +;;; ./filter/gr_interp_fir_filter_ccf.h FIXME: not found +;; (pass-if (true? (gr:interp-fir-filter-ccf ))) + +;;; ./filter/gr_interp_fir_filter_fcc.h FIXME: not found +;; (pass-if (true? (gr:interp-fir-filter-fcc ))) + +;;; ./filter/gr_interp_fir_filter_fff.h FIXME: not found +;; (pass-if (true? (gr:interp-fir-filter-fff ))) + +;;; ./filter/gr_interp_fir_filter_fsf.h FIXME: not found +;; (pass-if (true? (gr:interp-fir-filter-fsf ))) + +;;; ./filter/gr_interp_fir_filter_scc.h FIXME: not found +;; (pass-if (true? (gr:interp-fir-filter-scc ))) + +;;; ./filter/gr_pfb_arb_resampler_ccf.h +(pass-if (true? (gr:pfb-arb-resampler-ccf 1.0 #(1.0 2.0) 32))) + +;;; ./filter/gr_pfb_channelizer_ccf.h +(pass-if (true? (gr:pfb-channelizer-ccf 1 #(1.0 2.0) 1))) + +;;; ./filter/gr_pfb_clock_sync_ccf.h +(pass-if (true? (gr:pfb-clock-sync-ccf 1.0 1.0 #(1.0 2.0) 32 0 1.5))) + +;;; ./filter/gr_pfb_clock_sync_fff.h +(pass-if (true? (gr:pfb-clock-sync-fff 1.0 1.0 #(1.0 2.0) 32 0 1.5))) + +;;; ./filter/gr_pfb_decimator_ccf.h +(pass-if (true? (gr:pfb-decimator-ccf 1 #(1.0 2.0) 0))) + +;;; ./filter/gr_pfb_interpolator_ccf.h +(pass-if (true? (gr:pfb-interpolator-ccf 1 #(1.0 2.0)))) + +;;; ./filter/gr_rational_resampler_base_ccc.h FIXME: not found +;; (pass-if (true? (gr:rational-resampler-base-ccc 1 1 #(1+3i 23+5i)))) + +;;; ./filter/gr_rational_resampler_base_ccf.h FIXME: not found +;; (pass-if (true? (gr:rational-resampler-base-ccf ))) + +;;; ./filter/gr_rational_resampler_base_fcc.h FIXME: not found +;; (pass-if (true? (gr:rational-resampler-base-fcc ))) + +;;; ./filter/gr_rational_resampler_base_fff.h FIXME: not found +;; (pass-if (true? (gr:rational-resampler-base-fff ))) + +;;; ./filter/gr_rational_resampler_base_fsf.h FIXME: not found +;; (pass-if (true? (gr:rational-resampler-base-fsf ))) + +;;; ./filter/gr_rational_resampler_base_scc.h FIXME: not found +;; (pass-if (true? (gr:rational-resampler-base-scc ))) + +;;; ./filter/gr_single_pole_iir_filter_cc.h +(pass-if (true? (gr:single-pole-iir-filter-cc 1.0 1))) + +;;; ./filter/gr_single_pole_iir_filter_ff.h +(pass-if (true? (gr:single-pole-iir-filter-ff 1.0 1))) diff --git a/gnuradio-core/src/guile/tests/general_ctors.test b/gnuradio-core/src/guile/tests/general_ctors.test new file mode 100644 index 000000000..244249dd8 --- /dev/null +++ b/gnuradio-core/src/guile/tests/general_ctors.test @@ -0,0 +1,406 @@ +;;; -*- Scheme -*- +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; If you're using Emacs's Scheme mode: +;;; (put 'with-test-prefix 'scheme-indent-function 1) + +;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. +;;; See also the very end of the file, where the test-equal, test-eqv +;;; and test-eq macros are defined. + +(use-modules (gnuradio test-suite lib)) +(use-modules (gnuradio core)) +(use-modules (oop goops)) +(use-modules (ice-9 format)) + + +;;; Test complex<float> scalars +(pass-if (equal? 5.0+5.0i (gr:complex-scalar-test0))) +(pass-if (equal? 1.5+0.5i (gr:complex-scalar-test1 1+1i))) + +;;; Test complex<float> vectors +(pass-if (verbose-equal? #(0+0i 1+1i 2+2i 3+3i 4+4i) + (gr:complex-vec-test0))) + +(pass-if (verbose-equal? #(1.5+0.5i 2.5+1.5i 3.5+2.5i) + (gr:complex-vec-test1 #(1+1i 2+2i 3+3i)))) + + +;;; Add test code for all constructors in these files + +;;; ./general/gr_additive_scrambler_bb.h +(pass-if (true? (gr:additive-scrambler-bb 0 0 0 0))) + +;; Here's one that will throw if its arg is 0 +(pass-if (true? (gr:unpack-k-bits-bb 10))) +(pass-if-throw "confirm throw gr:unpack-k-bits-bb" #t (true? (gr:unpack-k-bits-bb 0))) + +;;; ./general/gr_agc2_cc.h +(pass-if (true? (gr:agc2-cc 1e-1 1e-2 1.0 1.0 0.0))) + +;;; ./general/gr_agc2_ff.h +(pass-if (true? (gr:agc2-ff 0 0 0 0 0))) + +;;; ./general/gr_agc_cc.h +(pass-if (true? (gr:agc-cc 0 0 0 0))) + +;;; ./general/gr_agc_ff.h +(pass-if (true? (gr:agc-ff 0 0 0 0))) + +;;; ./general/gr_align_on_samplenumbers_ss.h +(pass-if (true? (gr:align-on-samplenumbers-ss 2 128))) +(pass-if-throw "confirm throw gr:align-on-samplenumbers-ss" #t (true? (gr:align-on-samplenumbers-ss 0 0))) + +;;; ./general/gr_bin_statistics_f.h WONTFIX: requires gr_feval_dd & swig directors +;;;(pass-if (true? (gr:bin-statistics-f 1 (gr:msg-queue) 0 0 0))) + +;;; ./general/gr_binary_slicer_fb.h +(pass-if (true? (gr:binary-slicer-fb))) + +;;; ./general/gr_bytes_to_syms.h +(pass-if (true? (gr:bytes-to-syms))) + +;;; ./general/gr_char_to_float.h +(pass-if (true? (gr:char-to-float))) + +;;; ./general/gr_check_counting_s.h +(pass-if (true? (gr:check-counting-s #f))) + +;;; ./general/gr_check_lfsr_32k_s.h +(pass-if (true? (gr:check-lfsr-32k-s))) + +;;; ./general/gr_clock_recovery_mm_cc.h +(pass-if (true? (gr:clock-recovery-mm-cc 1 1 1 1 1))) +(pass-if-throw "confirm throw gr:clock-recovery-mm-cc" #t (true? (gr:clock-recovery-mm-cc -1 1 1 1 1))) + +;;; ./general/gr_clock_recovery_mm_ff.h +(pass-if (true? (gr:clock-recovery-mm-ff 1 1 1 1 1))) +(pass-if-throw "confirm throw gr:clock-recovery-mm-ff" #t (true? (gr:clock-recovery-mm-ff -1 1 1 1 1))) + +;;; ./general/gr_complex_to_interleaved_short.h +(pass-if (true? (gr:complex-to-interleaved-short))) + +;;; ./general/gr_complex_to_xxx.h +(pass-if (true? (gr:complex-to-float 1))) +(pass-if (true? (gr:complex-to-real 1))) +(pass-if (true? (gr:complex-to-imag 1))) +(pass-if (true? (gr:complex-to-mag 1))) +(pass-if (true? (gr:complex-to-mag-squared 1))) +(pass-if (true? (gr:complex-to-arg 1))) + +;;; ./general/gr_conjugate_cc.h +(pass-if (true? (gr:conjugate-cc))) + +;;; ./general/gr_constellation_decoder_cb.h +(pass-if (true? (gr:constellation-decoder-cb #(2+3i 23+5i) #(0 1)))) + +;;; ./general/gr_copy.h +(pass-if (true? (gr:copy 1))) + +;;; ./general/gr_correlate_access_code_bb.h +(pass-if (true? (gr:correlate-access-code-bb "foo" 0))) +(pass-if-throw "confirm throw correlate-access-code-bb" #t + (true? (gr:correlate-access-code-bb + "00000000000000000000000000000000000000000000000000000000000000000" 0))) + +;;; ./general/gr_costas_loop_cc.h +(pass-if (true? (gr:costas-loop-cc 0 0 0 0 2))) +(pass-if-throw "confirm throw gr:costas-loop-cc" #t (true? (gr:costas-loop-cc 0 0 0 0 3))) + +;;; ./general/gr_cpfsk_bc.h +(pass-if (true? (gr:cpfsk-bc 1 1 1))) + +;;; ./general/gr_ctcss_squelch_ff.h +(pass-if (true? (gr:ctcss-squelch-ff 0 0 0 0 0 #t))) + +;;; ./general/gr_decode_ccsds_27_fb.h +(pass-if (true? (gr:decode-ccsds-27-fb))) + +;;; ./general/gr_deinterleave.h +(pass-if (true? (gr:deinterleave 1))) + +;;; ./general/gr_delay.h +(pass-if (true? (gr:delay 1 1))) + +;;; ./general/gr_descrambler_bb.h +(pass-if (true? (gr:descrambler-bb 0 0 0))) + +;;; ./general/gr_diff_decoder_bb.h +(pass-if (true? (gr:diff-decoder-bb 0))) + +;;; ./general/gr_diff_encoder_bb.h +(pass-if (true? (gr:diff-encoder-bb 0))) + +;;; ./general/gr_diff_phasor_cc.h +(pass-if (true? (gr:diff-phasor-cc))) + +;;; ./general/gr_dpll_bb.h +(pass-if (true? (gr:dpll-bb 0 0))) + +;;; ./general/gr_encode_ccsds_27_bb.h +(pass-if (true? (gr:encode-ccsds-27-bb))) + +;;; ./general/gr_fake_channel_coder_pp.h +(pass-if (true? (gr:fake-channel-encoder-pp 1 1))) +(pass-if-throw "confirm throw" #t (true? (gr:fake-channel-encoder-pp -1 1))) + +;;; ./general/gr_feedforward_agc_cc.h +(pass-if (true? (gr:feedforward-agc-cc 1 1))) + +;;; ./general/gr_fft_vcc.h +(pass-if (true? (gr:fft-vcc 1 #f #(1.0 2.0) #t))) + +;;; ./general/gr_fft_vfc.h +(pass-if (true? (gr:fft-vfc 4 #t #(1.0 2.0 3.0 4.0)))) +(pass-if-throw "confirm throw gr:fft-vfc" #t (true? (gr:fft-vfc 4 #f #(1.0 2.0 3.0 4.0)))) + +;;; ./general/gr_fll_band_edge_cc.h +(pass-if (true? (gr:fll-band-edge-cc 0 0 0 0 0))) + +;; ;;; ./general/gr_float_to_char.h +(pass-if (true? (gr:float-to-char))) + +;; ;;; ./general/gr_float_to_complex.h +(pass-if (true? (gr:float-to-complex 1))) + +;;; ./general/gr_float_to_short.h +(pass-if (true? (gr:float-to-short))) + +;;; ./general/gr_float_to_uchar.h +(pass-if (true? (gr:float-to-uchar))) + +;;; ./general/gr_fmdet_cf.h +(pass-if (true? (gr:fmdet-cf 0 0 0 0))) + +;;; ./general/gr_framer_sink_1.h +(pass-if (true? (gr:framer-sink-1 (gr:msg-queue)))) + +;;; ./general/gr_frequency_modulator_fc.h +(pass-if (true? (gr:frequency-modulator-fc 0))) + +;;; ./general/gr_glfsr_source_b.h +(pass-if (true? (gr:glfsr-source-b 1 #t 0 1))) +(pass-if-throw "confirm throw" #t (true? (gr:glfsr_source_b 33 #t 0 0))) + +;;; ./general/gr_glfsr_source_f.h +(pass-if (true? (gr:glfsr-source-f 1 #t 1 1))) +(pass-if-throw "confirm throw" #t (true? (gr:glfsr_source_f 33 #t 0 0))) + +;;; ./general/gr_head.h +(pass-if (true? (gr:head 1 1))) + +;;; ./general/gr_interleave.h +(pass-if (true? (gr:interleave 1))) + +;;; ./general/gr_interleaved_short_to_complex.h +(pass-if (true? (gr:interleaved-short-to-complex))) + +;;; ./general/gr_keep_one_in_n.h +(pass-if (true? (gr:keep-one-in-n 1 1))) + +;;; ./general/gr_kludge_copy.h +(pass-if (true? (gr:kludge-copy 1))) + +;;; ./general/gr_lfsr_32k_source_s.h +(pass-if (true? (gr:lfsr-32k-source-s))) + +;;; ./general/gr_lms_dfe_cc.h +(pass-if (true? (gr:lms-dfe-ff 1 1 1 1))) + +;;; ./general/gr_lms_dfe_ff.h +(pass-if (true? (gr:lms-dfe-ff 1 1 1 1))) + +;;; ./general/gr_map_bb.h +(pass-if (true? (gr:map-bb #(1 2)))) + +;;; ./general/gr_mpsk_receiver_cc.h +(pass-if (true? (gr:mpsk-receiver-cc 1 1 1 1 1 1 1 1 1 1 1))) + +;;; ./general/gr_nlog10_ff.h +(pass-if (true? (gr:nlog10-ff 1 1 1))) + +;;; ./general/gr_nop.h +(pass-if (true? (gr:nop 1))) + +;;; ./general/gr_null_sink.h +(pass-if (true? (gr:null-sink 1))) + +;;; ./general/gr_null_source.h +(pass-if (true? (gr:null-source 1))) + +;;; ./general/gr_ofdm_cyclic_prefixer.h +(pass-if (true? (gr:ofdm-cyclic-prefixer 1 1))) + +;;; ./general/gr_ofdm_frame_acquisition.h +(pass-if (true? (gr:ofdm-frame-acquisition 1 1 1 #(1+3i 23+5i) 1))) + +;;; ./general/gr_ofdm_frame_sink.h +(pass-if (true? (gr:ofdm-frame-sink #(1+3i 23+5i) #(0 1) (gr:msg-queue) 128 0.25 0))) + +;;; ./general/gr_ofdm_insert_preamble.h FIXME: "Wrong type argument in position ~A: ~S" +;;; WONTFIX: Need vector<vector<complex<float>>> +;;(pass-if (true? (gr:ofdm-insert-preamble 2 #(#(1+3i 23+5i) #(1+3i 23+5i))))) + +;;; ./general/gr_ofdm_mapper_bcv.h +(pass-if (true? (gr:ofdm-mapper-bcv #(0+1i 0-1i) 1 100 128))) +(pass-if-throw "confirm throw gr:ofdm-mapper-bcv" #t + (true? (gr:ofdm-mapper-bcv #(0+1i 0-1i) 1 10 128))) + + +;;; ./general/gr_ofdm_sampler.h +(pass-if (true? (gr:ofdm-sampler 1 1 1))) + +;;; ./general/gr_pa_2x2_phase_combiner.h +(pass-if (true? (gr:pa-2x2-phase-combiner))) + +;;; ./general/gr_packet_sink.h +(pass-if (true? (gr:packet-sink #(1 2) (gr:msg-queue) -1))) + +;;; ./general/gr_peak_detector2_fb.h +(pass-if (true? (gr:peak-detector2-fb 0 0 0))) + +;;; ./general/gr_phase_modulator_fc.h +(pass-if (true? (gr:phase-modulator-fc 0))) + +;;; ./general/gr_pll_carriertracking_cc.h +(pass-if (true? (gr:pll-carriertracking-cc 0 0 0 0))) + +;;; ./general/gr_pll_freqdet_cf.h +(pass-if (true? (gr:pll-freqdet-cf 0 0 0 0))) + +;;; ./general/gr_pll_refout_cc.h +(pass-if (true? (gr:pll-refout-cc 0 0 0 0))) + +;;; ./general/gr_pn_correlator_cc.h +(pass-if (true? (gr:pn-correlator-cc 1 1 1))) + +;;; ./general/gr_probe_avg_mag_sqrd_c.h +(pass-if (true? (gr:probe-avg-mag-sqrd-c 0 0))) + +;;; ./general/gr_probe_avg_mag_sqrd_cf.h +(pass-if (true? (gr:probe-avg-mag-sqrd-cf 0 0))) + +;;; ./general/gr_probe_avg_mag_sqrd_f.h +(pass-if (true? (gr:probe-avg-mag-sqrd-f 0 0))) + +;;; ./general/gr_probe_density_b.h +(pass-if (true? (gr:probe-density-b 0))) + +;;; ./general/gr_probe_mpsk_snr_c.h +(pass-if (true? (gr:probe-mpsk-snr-c 0))) + +;;; ./general/gr_probe_signal_f.h +(pass-if (true? (gr:probe-signal-f))) + +;;; ./general/gr_pwr_squelch_cc.h +(pass-if (true? (gr:pwr-squelch-cc 0 0 0 #f))) + +;;; ./general/gr_pwr_squelch_ff.h +(pass-if (true? (gr:pwr-squelch-ff 0.0 0.0 0 #f))) + +;;; ./general/gr_quadrature_demod_cf.h +(pass-if (true? (gr:quadrature-demod-cf 0))) + +;;; ./general/gr_rail_ff.h +(pass-if (true? (gr:rail-ff 0 0))) + +;;; ./general/gr_regenerate_bb.h +(pass-if (true? (gr:regenerate-bb 0 0))) + +;;; ./general/gr_repeat.h +(pass-if (true? (gr:repeat 1 1))) + +;;; ./general/gr_rms_cf.h +(pass-if (true? (gr:rms-cf 0))) + +;;; ./general/gr_rms_ff.h +(pass-if (true? (gr:rms-ff 0))) + +;;; ./general/gr_scrambler_bb.h +(pass-if (true? (gr:scrambler-bb 0 0 0))) + +;;; ./general/gr_short_to_float.h +(pass-if (true? (gr:short-to-float))) + +;;; ./general/gr_simple_correlator.h +(pass-if (true? (gr:simple-correlator 0))) + +;;; ./general/gr_simple_framer.h +(pass-if (true? (gr:simple-framer 0))) + +;;; ./general/gr_simple_squelch_cc.h +(pass-if (true? (gr:simple-squelch-cc 0 0))) + +;;; ./general/gr_skiphead.h +(pass-if (true? (gr:skiphead 1 1))) + +;;; ./general/gr_squash_ff.h +(pass-if (true? (gr:squash-ff #(1.0 2.0 3.0 4.0 5.0) #(1.0 2.0 3.0 4.0 5.0)))) + +;;; ./general/gr_squelch_base_cc.h WONTFIX: not wrapped +;;; (pass-if (true? (gr:squelch-base-cc "foo" 0 #f))) + +;;; ./general/gr_squelch_base_ff.h WONTFIX: not wrapped +;; (pass-if (true? (gr:squelch-base-ff "foo" 0 #f))) + +;;; ./general/gr_stream_mux.h +(pass-if (true? (gr:stream-mux 1 #(1 2)))) + +;;; ./general/gr_stream_to_streams.h +(pass-if (true? (gr:stream-to-streams 1 1))) + +;;; ./general/gr_stream_to_vector.h +(pass-if (true? (gr:stream-to-vector 1 1))) + +;;; ./general/gr_streams_to_stream.h +(pass-if (true? (gr:streams-to-stream 1 1))) + +;;; ./general/gr_streams_to_vector.h +(pass-if (true? (gr:streams-to-vector 1 1))) + +;;; ./general/gr_stretch_ff.h +(pass-if (true? (gr:stretch-ff 1 1))) + +;;; ./general/gr_test.h +(pass-if (true? (gr:test "foo" 1 1 1 1 1 1 1 1))) + +;;; ./general/gr_threshold_ff.h +(pass-if (true? (gr:threshold-ff 0 0))) + +;;; ./general/gr_throttle.h +(pass-if (true? (gr:throttle 1 1))) + +;;; ./general/gr_uchar_to_float.h +(pass-if (true? (gr:uchar-to-float))) + +;;; ./general/gr_vco_f.h +(pass-if (true? (gr:vco-f 0 0 0))) + +;;; ./general/gr_vector_to_stream.h +(pass-if (true? (gr:vector-to-stream 1 1))) + +;;; ./general/gr_vector_to_streams.h +(pass-if (true? (gr:vector-to-streams 1 1))) + +;;; ./general/gr_wavelet_ff.h +(pass-if (true? (gr:wavelet-ff 1024 20 #t))) + +;;; ./general/gr_wvps_ff.h +(pass-if (true? (gr:wvps-ff 2))) diff --git a/gnuradio-core/src/guile/tests/gengen_ctors.test b/gnuradio-core/src/guile/tests/gengen_ctors.test new file mode 100644 index 000000000..6e1213c63 --- /dev/null +++ b/gnuradio-core/src/guile/tests/gengen_ctors.test @@ -0,0 +1,342 @@ +;;; -*- Scheme -*- +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; If you're using Emacs's Scheme mode: +;;; (put 'with-test-prefix 'scheme-indent-function 1) + +;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. +;;; See also the very end of the file, where the test-equal, test-eqv +;;; and test-eq macros are defined. + +(use-modules (gnuradio test-suite lib)) +(use-modules (gnuradio core)) +(use-modules (oop goops)) + +;;; Add test code for all constructors in these files +;;; + +;;; ./gengen/gr_add_cc.h +(pass-if (true? (gr:add-cc 1))) + +;;; ./gengen/gr_add_const_cc.h +(pass-if (true? (gr:add-const-cc 0))) + +;;; ./gengen/gr_add_const_ff.h +(pass-if (true? (gr:add-const-ff 0))) + +;;; ./gengen/gr_add_const_ii.h +(pass-if (true? (gr:add-const-ii 0))) + +;;; ./gengen/gr_add_const_sf.h +(pass-if (true? (gr:add-const-sf 0))) + +;;; ./gengen/gr_add_const_ss.h +(pass-if (true? (gr:add-const-ss 0))) + +;;; ./gengen/gr_add_const_vcc.h +(pass-if (true? (gr:add-const-vcc #(1+3i 23+5i)))) + +;;; ./gengen/gr_add_const_vff.h +(pass-if (true? (gr:add-const-vff #(1.0 2.0)))) + +;;; ./gengen/gr_add_const_vii.h +(pass-if (true? (gr:add-const-vii #(1 2)))) + +;;; ./gengen/gr_add_const_vss.h +(pass-if (true? (gr:add-const-vss #(1 2)))) + +;;; ./gengen/gr_add_ff.h +(pass-if (true? (gr:add-ff 1))) + +;;; ./gengen/gr_add_ii.h +(pass-if (true? (gr:add-ii 1))) + +;;; ./gengen/gr_add_ss.h +(pass-if (true? (gr:add-ss 1))) + +;;; ./gengen/gr_and_bb.h +(pass-if (true? (gr:and-bb))) + +;;; ./gengen/gr_and_const_bb.h +(pass-if (true? (gr:and-const-bb 0))) + +;;; ./gengen/gr_and_const_ii.h +(pass-if (true? (gr:and-const-ii 0))) + +;;; ./gengen/gr_and_const_ss.h +(pass-if (true? (gr:and-const-ss 0))) + +;;; ./gengen/gr_and_ii.h +(pass-if (true? (gr:and-ii))) + +;;; ./gengen/gr_and_ss.h +(pass-if (true? (gr:and-ss))) + +;;; ./gengen/gr_argmax_fs.h +(pass-if (true? (gr:argmax-fs 1))) + +;;; ./gengen/gr_argmax_is.h +(pass-if (true? (gr:argmax-is 1))) + +;;; ./gengen/gr_argmax_ss.h +(pass-if (true? (gr:argmax-ss 1))) + +;;; ./gengen/gr_chunks_to_symbols_bc.h +(pass-if (true? (gr:chunks-to-symbols-bc #(1+3i 23+5i) 1))) + +;;; ./gengen/gr_chunks_to_symbols_bf.h +(pass-if (true? (gr:chunks-to-symbols-bf #(1.0 2.0) 1))) + +;;; ./gengen/gr_chunks_to_symbols_ic.h +(pass-if (true? (gr:chunks-to-symbols-ic #(1+3i 23+5i) 1))) + +;;; ./gengen/gr_chunks_to_symbols_if.h +(pass-if (true? (gr:chunks-to-symbols-if #(1.0 2.0) 1))) + +;;; ./gengen/gr_chunks_to_symbols_sc.h +(pass-if (true? (gr:chunks-to-symbols-sc #(1.0 2.0) 1))) + +;;; ./gengen/gr_chunks_to_symbols_sf.h +(pass-if (true? (gr:chunks-to-symbols-sf #(1.0 2.0) 1))) + +;;; ./gengen/gr_divide_cc.h +(pass-if (true? (gr:divide-cc 1))) + +;;; ./gengen/gr_divide_ff.h +(pass-if (true? (gr:divide-ff 1))) + +;;; ./gengen/gr_divide_ii.h +(pass-if (true? (gr:divide-ii 1))) + +;;; ./gengen/gr_divide_ss.h +(pass-if (true? (gr:divide-ss 1))) + +;;; ./gengen/gr_integrate_cc.h +(pass-if (true? (gr:integrate-cc 0))) + +;;; ./gengen/gr_integrate_ff.h +(pass-if (true? (gr:integrate-ff 0))) + +;;; ./gengen/gr_integrate_ii.h +(pass-if (true? (gr:integrate-ii 0))) + +;;; ./gengen/gr_integrate_ss.h +(pass-if (true? (gr:integrate-ss 0))) + +;;; ./gengen/gr_max_ff.h +(pass-if (true? (gr:max-ff 1))) + +;;; ./gengen/gr_max_ii.h +(pass-if (true? (gr:max-ii 1))) + +;;; ./gengen/gr_max_ss.h +(pass-if (true? (gr:max-ss 1))) + +;;; ./gengen/gr_moving_average_cc.h +(pass-if (true? (gr:moving-average-cc 1 1+3i 4096))) + +;;; ./gengen/gr_moving_average_ff.h +(pass-if (true? (gr:moving-average-ff 1 0 4096))) + +;;; ./gengen/gr_moving_average_ii.h +(pass-if (true? (gr:moving-average-ii 1 0 4096))) + +;;; ./gengen/gr_moving_average_ss.h +(pass-if (true? (gr:moving-average-ss 1 0 4096))) + +;;; ./gengen/gr_multiply_cc.h +(pass-if (true? (gr:multiply-cc 1))) + +;;; ./gengen/gr_multiply_const_cc.h +(pass-if (true? (gr:multiply-const-cc 1))) + +;;; ./gengen/gr_multiply_const_ff.h +(pass-if (true? (gr:multiply-const-ff 1))) + +;;; ./gengen/gr_multiply_const_ii.h +(pass-if (true? (gr:multiply-const-ii 1))) + +;;; ./gengen/gr_multiply_const_ss.h +(pass-if (true? (gr:multiply-const-ss 1))) + +;;; ./gengen/gr_multiply_const_vcc.h +(pass-if (true? (gr:multiply-const-vcc #(1+3i 23+5i)))) + +;;; ./gengen/gr_multiply_const_vff.h +(pass-if (true? (gr:multiply-const-vff #(1.0 2.0)))) + +;;; ./gengen/gr_multiply_const_vii.h +(pass-if (true? (gr:multiply-const-vii #(1 2)))) + +;;; ./gengen/gr_multiply_const_vss.h +(pass-if (true? (gr:multiply-const-vss #(1 2)))) + +;;; ./gengen/gr_multiply_ff.h +(pass-if (true? (gr:multiply-ff 1))) + +;;; ./gengen/gr_multiply_ii.h +(pass-if (true? (gr:multiply-ii 1))) + +;;; ./gengen/gr_multiply_ss.h +(pass-if (true? (gr:multiply-ss 1))) + +;;; ./gengen/gr_mute_cc.h FIXME: not found +(pass-if (true? (gr:mute-cc #f))) + +;;; ./gengen/gr_mute_ff.h FIXME: not found +(pass-if (true? (gr:mute-ff #f))) + +;;; ./gengen/gr_mute_ii.h FIXME: not found +(pass-if (true? (gr:mute-ii #f))) + +;;; ./gengen/gr_mute_ss.h FIXME: not found +(pass-if (true? (gr:mute-ss #f))) + +;;; ./gengen/gr_noise_source_c.h +(pass-if (true? (gr:noise-source-c 1 0 3021))) + +;;; ./gengen/gr_noise_source_f.h +(pass-if (true? (gr:noise-source-f 1 0 3021))) + +;;; ./gengen/gr_noise_source_i.h +(pass-if (true? (gr:noise-source-i 1 0 3021))) + +;;; ./gengen/gr_noise_source_s.h +(pass-if (true? (gr:noise-source-s 1 0 3021))) + +;;; ./gengen/gr_not_bb.h +(pass-if (true? (gr:not-bb))) + +;;; ./gengen/gr_not_ii.h +(pass-if (true? (gr:not-ii))) + +;;; ./gengen/gr_not_ss.h +(pass-if (true? (gr:not-ss))) + +;;; ./gengen/gr_or_bb.h +(pass-if (true? (gr:or-bb))) + +;;; ./gengen/gr_or_ii.h +(pass-if (true? (gr:or-ii))) + +;;; ./gengen/gr_or_ss.h +(pass-if (true? (gr:or-ss))) + +;;; ./gengen/gr_packed_to_unpacked_bb.h +(pass-if (true? (gr:packed-to-unpacked-bb 1 1))) + +;;; ./gengen/gr_packed_to_unpacked_ii.h +(pass-if (true? (gr:packed-to-unpacked-ii 1 1))) + +;;; ./gengen/gr_packed_to_unpacked_ss.h +(pass-if (true? (gr:packed-to-unpacked-ss 1 1))) + +;;; ./gengen/gr_peak_detector_fb.h +(pass-if (true? (gr:peak-detector-fb 0.25 0.40 10 0.001))) + +;;; ./gengen/gr_peak_detector_ib.h +(pass-if (true? (gr:peak-detector-ib 0.25 0.40 10 0.001))) + +;;; ./gengen/gr_peak_detector_sb.h +(pass-if (true? (gr:peak-detector-sb 0.25 0.40 10 0.001))) + +;;; ./gengen/gr_sample_and_hold_bb.h +(pass-if (true? (gr:sample-and-hold-bb))) + +;;; ./gengen/gr_sample_and_hold_ff.h +(pass-if (true? (gr:sample-and-hold-ff))) + +;;; ./gengen/gr_sample_and_hold_ii.h +(pass-if (true? (gr:sample-and-hold-ii))) + +;;; ./gengen/gr_sample_and_hold_ss.h +(pass-if (true? (gr:sample-and-hold-ss))) + +;;; ./gengen/gr_sig_source_c.h +(pass-if (true? (gr:sig-source-c 0 0 0 0 0))) + +;;; ./gengen/gr_sig_source_f.h +(pass-if (true? (gr:sig-source-f 0 0 0 0 0))) + +;;; ./gengen/gr_sig_source_i.h +(pass-if (true? (gr:sig-source-i 0 0 0 0 0))) + +;;; ./gengen/gr_sig_source_s.h +(pass-if (true? (gr:sig-source-s 0 0 0 0 0))) + +;;; ./gengen/gr_sub_cc.h +(pass-if (true? (gr:sub-cc 1))) + +;;; ./gengen/gr_sub_ff.h +(pass-if (true? (gr:sub-ff 1))) + +;;; ./gengen/gr_sub_ii.h +(pass-if (true? (gr:sub-ii 1))) + +;;; ./gengen/gr_sub_ss.h +(pass-if (true? (gr:sub-ss 1))) + +;;; ./gengen/gr_unpacked_to_packed_bb.h +(pass-if (true? (gr:unpacked-to-packed-bb 1 1))) + +;;; ./gengen/gr_unpacked_to_packed_ii.h +(pass-if (true? (gr:unpacked-to-packed-ii 1 1))) + +;;; ./gengen/gr_unpacked_to_packed_ss.h +(pass-if (true? (gr:unpacked-to-packed-ss 1 1))) + +;;; ./gengen/gr_vector_sink_b.h +(pass-if (true? (gr:vector-sink-b 1))) + +;;; ./gengen/gr_vector_sink_c.h +(pass-if (true? (gr:vector-sink-c 1))) + +;;; ./gengen/gr_vector_sink_f.h +(pass-if (true? (gr:vector-sink-f 1))) + +;;; ./gengen/gr_vector_sink_i.h +(pass-if (true? (gr:vector-sink-i 1))) + +;;; ./gengen/gr_vector_sink_s.h +(pass-if (true? (gr:vector-sink-s 1))) + +;;; ./gengen/gr_vector_source_b.h +;; (pass-if (true? (gr:vector-source-b #(1 2) #f 1))) + +;; ;;; ./gengen/gr_vector_source_c.h +;; (pass-if (true? (gr:vector-source-c #(1+3i 23+5i) #f 1))) + +;; ;;; ./gengen/gr_vector_source_f.h +;; (pass-if (true? (gr:vector-source-f #(1.0 2.0) #f 1))) + +;;; ./gengen/gr_vector_source_i.h +;; (pass-if (true? (gr:vector-source-i #(1 2) #f 1))) + +;;; ./gengen/gr_vector_source_s.h FIXME: not found +;; (pass-if (true? (gr:vector-source-s #(1 2) #f 1))) + +;;; ./gengen/gr_xor_bb.h +(pass-if (true? (gr:xor-bb))) + +;;; ./gengen/gr_xor_ii.h +(pass-if (true? (gr:xor-ii))) + +;;; ./gengen/gr_xor_ss.h +(pass-if (true? (gr:xor-ss))) diff --git a/gnuradio-core/src/guile/tests/hier_ctors.test b/gnuradio-core/src/guile/tests/hier_ctors.test new file mode 100644 index 000000000..b79ee0f15 --- /dev/null +++ b/gnuradio-core/src/guile/tests/hier_ctors.test @@ -0,0 +1,40 @@ +;;; -*- Scheme -*- +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; If you're using Emacs's Scheme mode: +;;; (put 'with-test-prefix 'scheme-indent-function 1) + +;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. +;;; See also the very end of the file, where the test-equal, test-eqv +;;; and test-eq macros are defined. + +(use-modules (gnuradio test-suite lib)) +(use-modules (gnuradio core)) +(use-modules (oop goops)) + +;;; Add test code for all constructors in these files +;;; + +;;; ./hier/gr_channel_model.h FIXME: Unbound variable: ~S" (gr:channel_model) #f)) +;; gr_make_channel_model(double noise_voltage=0.0, double frequency_offset=0.0, +;; double epsilon=1.0, +;; const std::vector<gr_complex> &taps=std::vector<gr_complex>(1, 1), +;; double noise_seed=3021); +;; (pass-if (true? (gr:channel_model 0.0 0.0 1.0 #(1 1) 3021))) diff --git a/gnuradio-core/src/guile/tests/io_ctors.test b/gnuradio-core/src/guile/tests/io_ctors.test new file mode 100644 index 000000000..1c5c9a771 --- /dev/null +++ b/gnuradio-core/src/guile/tests/io_ctors.test @@ -0,0 +1,82 @@ +;;; -*- Scheme -*- +;;; +;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>. +;;; + +;;; If you're using Emacs's Scheme mode: +;;; (put 'with-test-prefix 'scheme-indent-function 1) + +;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. +;;; See also the very end of the file, where the test-equal, test-eqv +;;; and test-eq macros are defined. + +(use-modules (gnuradio test-suite lib)) +(use-modules (gnuradio core)) +(use-modules (oop goops)) + + +(define (rm-foo) + (false-if-exception (delete-file "foo"))) + +;;; Add test code for all constructors in these files +;;; + +;;; ./io/gr_file_descriptor_sink.h +(pass-if (true? (gr:file-descriptor-sink 1 (dup 1)))) + +;;; ./io/gr_file_descriptor_source.h +(pass-if (true? (gr:file-descriptor-source 1 (dup 0) #f))) + +;;; ./io/gr_file_sink.h +(pass-if (true? (gr:file-sink 1 "foo"))) + +;;; ./io/gr_file_source.h +(pass-if (true? (gr:file-source 1 "foo" #f))) +(rm-foo) + +;;; ./io/gr_histo_sink_f.h +;; gr_make_histo_sink_f (gr_msg_queue_sptr msgq); +(pass-if (true? (gr:histo-sink-f (gr:msg-queue)))) + +;;; ./io/gr_message_sink.h +(pass-if (true? (gr:message-sink 1 (gr:msg-queue) #f))) + +;;; ./io/gr_message_source.h +(pass-if (true? (gr:message-source 1 1))) +(pass-if (true? (gr:message-source 1 (gr:msg-queue)))) + +;;; ./io/gr_oscope_sink_f.h +(pass-if (true? (gr:oscope-sink-f 1000 (gr:msg-queue)))) + +;;; ./io/gr_udp_sink.h +(pass-if (true? (gr:udp-sink 4 "localhost" 80 1472 #f))) +(pass-if-throw "confirm throw gr:udp-sink" #t + (true? (gr:udp-sink 4 "localhostx" 80 1472 #f))) + +;;; ./io/gr_udp_source.h +(pass-if (true? (gr:udp-source 4 "localhost" 0 1472 #f #t))) +(pass-if-throw "confirm throw gr:udp-sink" #t + (true? (gr:udp-source 4 "localhostx" 0 1472 #f #t))) + +;;; ./io/gr_wavfile_sink.h +(pass-if (true? (gr:wavfile-sink "foo" 2 48000 16))) + +;;; ./io/gr_wavfile_source.h WONTFIX: buggy source won't accept file +;;; created immediately above. +;;(pass-if (true? (gr:wavfile-source "foo" #f))) +(rm-foo) diff --git a/gnuradio-core/src/lib/.gitignore b/gnuradio-core/src/lib/.gitignore index e3bc1ee6a..0d5077da5 100644 --- a/gnuradio-core/src/lib/.gitignore +++ b/gnuradio-core/src/lib/.gitignore @@ -1,7 +1,5 @@ /Makefile /Makefile.in -/.la -/.lo /.deps /.libs /*.la diff --git a/gnuradio-core/src/lib/Makefile.am b/gnuradio-core/src/lib/Makefile.am index f3a3accdb..1281b4aa6 100644 --- a/gnuradio-core/src/lib/Makefile.am +++ b/gnuradio-core/src/lib/Makefile.am @@ -24,10 +24,7 @@ include $(top_srcdir)/Makefile.common ## Process this file with automake to produce Makefile.in # We've got to build . before swig -SUBDIRS = missing runtime filter viterbi general gengen g72x reed-solomon io hier . -if PYTHON -SUBDIRS += swig -endif +SUBDIRS = missing runtime filter viterbi general gengen g72x reed-solomon io hier . swig AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) diff --git a/gnuradio-core/src/lib/filter/Makefile.am b/gnuradio-core/src/lib/filter/Makefile.am index 6d2ec1c7e..38edee3d5 100644 --- a/gnuradio-core/src/lib/filter/Makefile.am +++ b/gnuradio-core/src/lib/filter/Makefile.am @@ -67,7 +67,7 @@ code_generator = \ # Source built by Python into $(builddir) -BUILT_SOURCES = \ +BUILT_SOURCES += \ $(GENERATED_H) \ $(GENERATED_I) \ $(GENERATED_CC) \ @@ -178,7 +178,7 @@ EXTRA_libfilter_la_SOURCES = \ $(armv7_a_qa_CODE) -EXTRA_DIST = \ +EXTRA_DIST += \ 3dnow_float_dotprod_really_simple.S \ 3dnow_float_dotprod_simple.S \ $(code_generator) diff --git a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc b/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc index 8252509bb..f80bfd518 100644 --- a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc +++ b/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc @@ -36,6 +36,7 @@ gr_cma_equalizer_cc::gr_cma_equalizer_cc(int num_taps, float modulus, float mu) : gr_adaptive_fir_ccf("cma_equalizer_cc", 1, std::vector<float>(num_taps)), d_modulus(modulus), d_mu(mu) { - d_taps[0] = 1.0; + if (num_taps > 0) + d_taps[0] = 1.0; } diff --git a/gnuradio-core/src/lib/g72x/Makefile.am b/gnuradio-core/src/lib/g72x/Makefile.am index 6c41f1911..d2700376f 100644 --- a/gnuradio-core/src/lib/g72x/Makefile.am +++ b/gnuradio-core/src/lib/g72x/Makefile.am @@ -24,4 +24,4 @@ include $(top_srcdir)/Makefile.common noinst_LTLIBRARIES = libccitt.la libccitt_la_SOURCES = g711.c g72x.c g721.c g723_24.c g723_40.c g72x.h -EXTRA_DIST = encode.c decode.c +EXTRA_DIST += encode.c decode.c diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index 0e9109d6c..c6440506d 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -29,11 +29,12 @@ BUILT_SOURCES = # ---------------------------------------------------------------- -EXTRA_DIST = \ +EXTRA_DIST += \ gen_sine_table.py \ gr_constants.cc.in libgeneral_la_SOURCES = \ + complex_vec_test.cc \ gr_additive_scrambler_bb.cc \ gr_agc_cc.cc \ gr_agc_ff.cc \ @@ -191,6 +192,7 @@ libgeneral_qa_la_SOURCES = \ qa_gri_lfsr.cc grinclude_HEADERS = \ + complex_vec_test.h \ gr_additive_scrambler_bb.h \ gr_agc_cc.h \ gr_agc_ff.h \ @@ -365,6 +367,7 @@ noinst_HEADERS = \ if PYTHON swiginclude_HEADERS = \ + complex_vec_test.i \ general.i \ gr_additive_scrambler_bb.i \ gr_agc_cc.i \ diff --git a/gnuradio-core/src/lib/general/complex_vec_test.cc b/gnuradio-core/src/lib/general/complex_vec_test.cc new file mode 100644 index 000000000..df25c325e --- /dev/null +++ b/gnuradio-core/src/lib/general/complex_vec_test.cc @@ -0,0 +1,82 @@ +#include <complex_vec_test.h> +#include <stddef.h> + +std::vector<std::complex<float> > +complex_vec_test0() +{ + std::vector<std::complex<float> > r(5); + + for (size_t i = 0; i < r.size(); i++) + r[i] = std::complex<float>(i, i); + + return r; +} + +std::vector<std::complex<float> > +complex_vec_test1(const std::vector<std::complex<float> > &input) +{ + std::vector<std::complex<float> > r(input.size()); + + for (size_t i = 0; i < input.size(); i++) + r[i] = std::complex<float>(input[i].real()+0.5, input[i].imag()-0.5); + + return r; +} + +std::complex<float> +complex_scalar_test0() +{ + return std::complex<float>(5, 5); +} + +std::complex<float> +complex_scalar_test1(std::complex<float> input) +{ + return std::complex<float>(input.real()+0.5, input.imag()-0.5); +} + + +std::vector<float> +float_vec_test0() +{ + std::vector<float> r(5); + + for (size_t i = 0; i < r.size(); i++) + r[i] = (float) i; + + return r; +} + +std::vector<float> +float_vec_test1(const std::vector<float> &input) +{ + std::vector<float> r(input.size()); + + for (size_t i = 0; i < input.size(); i++) + r[i] = input[i] + 0.5; + + return r; +} + +std::vector<int> +int_vec_test0() +{ + std::vector<int> r(5); + + for (size_t i = 0; i < r.size(); i++) + r[i] = (int) i; + + return r; +} + +std::vector<int> +int_vec_test1(const std::vector<int> &input) +{ + std::vector<int> r(input.size()); + + for (size_t i = 0; i < input.size(); i++) + r[i] = input[i] + 1; + + return r; +} + diff --git a/gnuradio-core/src/lib/general/complex_vec_test.h b/gnuradio-core/src/lib/general/complex_vec_test.h new file mode 100644 index 000000000..d13dedf63 --- /dev/null +++ b/gnuradio-core/src/lib/general/complex_vec_test.h @@ -0,0 +1,27 @@ +#include <vector> +#include <complex> + +std::vector<std::complex<float> > +complex_vec_test0(); + +std::vector<std::complex<float> > +complex_vec_test1(const std::vector<std::complex<float> > &input); + +std::complex<float> +complex_scalar_test0(); + +std::complex<float> +complex_scalar_test1(std::complex<float> input); + +std::vector<int> +int_vec_test0(); + +std::vector<int> +int_vec_test1(const std::vector<int> &input); + +std::vector<float> +float_vec_test0(); + +std::vector<float> +float_vec_test1(const std::vector<float> &input); + diff --git a/gnuradio-core/src/lib/general/complex_vec_test.i b/gnuradio-core/src/lib/general/complex_vec_test.i new file mode 100644 index 000000000..4b95633be --- /dev/null +++ b/gnuradio-core/src/lib/general/complex_vec_test.i @@ -0,0 +1,25 @@ + +std::vector<std::complex<float> > +complex_vec_test0(); + +std::vector<std::complex<float> > +complex_vec_test1(const std::vector<std::complex<float> > &input); + +std::complex<float> +complex_scalar_test0(); + +std::complex<float> +complex_scalar_test1(std::complex<float> input); + +std::vector<int> +int_vec_test0(); + +std::vector<int> +int_vec_test1(const std::vector<int> &input); + +std::vector<float> +float_vec_test0(); + +std::vector<float> +float_vec_test1(const std::vector<float> &input); + diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 0f8b57a44..fb9c4c0f2 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -53,7 +53,7 @@ #include <gr_complex_to_xxx.h> #include <gr_complex_to_interleaved_short.h> #include <gr_interleaved_short_to_complex.h> -#include <gr_endianness.h> +//#include <gr_endianness.h> #include <gr_firdes.h> #include <gr_interleave.h> #include <gr_deinterleave.h> @@ -141,6 +141,7 @@ #include <gr_copy.h> #include <gr_fll_band_edge_cc.h> #include <gr_additive_scrambler_bb.h> +#include <complex_vec_test.h> #include <gr_annotator_alltoall.h> #include <gr_annotator_1to1.h> #include <gr_burst_tagger.h> @@ -176,7 +177,7 @@ %include "gr_align_on_samplenumbers_ss.i" %include "gr_complex_to_xxx.i" %include "gr_complex_to_interleaved_short.i" -%include "gr_endianness.i" +//%include "gr_endianness.i" %include "gr_interleaved_short_to_complex.i" %include "gr_firdes.i" %include "gr_interleave.i" @@ -265,6 +266,7 @@ %include "gr_copy.i" %include "gr_fll_band_edge_cc.i" %include "gr_additive_scrambler_bb.i" +%include "complex_vec_test.i" %include "gr_annotator_alltoall.i" %include "gr_annotator_1to1.i" %include "gr_burst_tagger.i" diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i index 841613ca6..ea73dd46d 100644 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i +++ b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i @@ -22,7 +22,8 @@ GR_SWIG_BLOCK_MAGIC(gr,align_on_samplenumbers_ss); -gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss(int nchan=2, int align_interval=128); +gr_align_on_samplenumbers_ss_sptr +gr_make_align_on_samplenumbers_ss(int nchan=2, int align_interval=128) throw (std::exception); class gr_align_on_samplenumbers_ss : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.i b/gnuradio-core/src/lib/general/gr_bin_statistics_f.i index 5cec882f0..be98a464b 100644 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.i +++ b/gnuradio-core/src/lib/general/gr_bin_statistics_f.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,6 +19,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +// Directors are only supported in Python, Java and C#. gr_feval_dd uses directors +#ifdef SWIGPYTHON + GR_SWIG_BLOCK_MAGIC(gr,bin_statistics_f); gr_bin_statistics_f_sptr @@ -40,3 +43,5 @@ private: public: ~gr_bin_statistics_f(); }; + +#endif diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i index 98d326b28..27eb70b95 100644 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i +++ b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i @@ -22,9 +22,10 @@ GR_SWIG_BLOCK_MAGIC(gr,clock_recovery_mm_cc); -gr_clock_recovery_mm_cc_sptr gr_make_clock_recovery_mm_cc (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit); +gr_clock_recovery_mm_cc_sptr +gr_make_clock_recovery_mm_cc (float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limit) throw(std::exception); class gr_clock_recovery_mm_cc : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i index 4f08aa760..1b2437000 100644 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i +++ b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i @@ -22,9 +22,10 @@ GR_SWIG_BLOCK_MAGIC(gr,clock_recovery_mm_ff); -gr_clock_recovery_mm_ff_sptr gr_make_clock_recovery_mm_ff (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit=0.001); +gr_clock_recovery_mm_ff_sptr +gr_make_clock_recovery_mm_ff (float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limit=0.001) throw(std::exception); class gr_clock_recovery_mm_ff : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_feval.i b/gnuradio-core/src/lib/general/gr_feval.i index 8594a6fa1..c5522805d 100644 --- a/gnuradio-core/src/lib/general/gr_feval.i +++ b/gnuradio-core/src/lib/general/gr_feval.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -43,6 +43,9 @@ */ +// Directors are only supported in Python, Java and C# +#ifdef SWIGPYTHON + // Enable SWIG directors for these classes %feature("director") gr_py_feval_dd; %feature("director") gr_py_feval_cc; @@ -197,3 +200,5 @@ long gr_feval_ll_example(gr_feval_ll *f, long x); %rename(feval_example) gr_feval_example; void gr_feval_example(gr_feval *f); + +#endif // SWIGPYTHON diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.i b/gnuradio-core/src/lib/general/gr_fft_vcc.i index 247571374..f35316e70 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vcc.i +++ b/gnuradio-core/src/lib/general/gr_fft_vcc.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2007,2008 Free Software Foundation, Inc. + * Copyright 2004,2007,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,7 +23,7 @@ GR_SWIG_BLOCK_MAGIC(gr, fft_vcc) gr_fft_vcc_sptr -gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift=false); +gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift=false); class gr_fft_vcc : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.cc b/gnuradio-core/src/lib/general/gr_fft_vfc.cc index 608161efe..561c63740 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.cc +++ b/gnuradio-core/src/lib/general/gr_fft_vfc.cc @@ -40,12 +40,12 @@ gr_fft_vfc_sptr -gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> window) +gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window) { return gnuradio::get_initial_sptr(new gr_fft_vfc (fft_size, forward, window)); } -gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward, const std::vector<float> window) +gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &window) : gr_sync_block ("fft_vfc", gr_make_io_signature (1, 1, fft_size * sizeof (float)), gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))), @@ -107,7 +107,7 @@ gr_fft_vfc::work (int noutput_items, } bool -gr_fft_vfc::set_window(const std::vector<float> window) +gr_fft_vfc::set_window(const std::vector<float> &window) { if(window.size()==0 || window.size()==d_fft_size) { d_window=window; diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.h b/gnuradio-core/src/lib/general/gr_fft_vfc.h index 054a383ef..074574477 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.h +++ b/gnuradio-core/src/lib/general/gr_fft_vfc.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ class gr_fft_vfc; typedef boost::shared_ptr<gr_fft_vfc> gr_fft_vfc_sptr; gr_fft_vfc_sptr -gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float>); +gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window); /*! * \brief Compute forward FFT. float vector in / complex vector out. @@ -41,13 +41,13 @@ gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float>); class gr_fft_vfc : public gr_sync_block { friend gr_fft_vfc_sptr - gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> window); + gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window); unsigned int d_fft_size; std::vector<float> d_window; gri_fft_complex *d_fft; - gr_fft_vfc (int fft_size, bool forward, const std::vector<float> window); + gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &window); public: ~gr_fft_vfc (); @@ -55,7 +55,7 @@ class gr_fft_vfc : public gr_sync_block int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - bool set_window(const std::vector<float> window); + bool set_window(const std::vector<float> &window); }; diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.i b/gnuradio-core/src/lib/general/gr_fft_vfc.i index 90c368fe6..149745b58 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.i +++ b/gnuradio-core/src/lib/general/gr_fft_vfc.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,13 +23,14 @@ GR_SWIG_BLOCK_MAGIC(gr, fft_vfc) gr_fft_vfc_sptr -gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> window); +gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window) +throw(std::exception); class gr_fft_vfc : public gr_sync_block { protected: - gr_fft_vfc (int fft_size, bool forward, const std::vector<float> window); + gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &window); public: - bool set_window(const std::vector<float> window); + bool set_window(const std::vector<float> &window); }; diff --git a/gnuradio-core/src/lib/general/gr_nop.cc b/gnuradio-core/src/lib/general/gr_nop.cc index e69c8b340..950ef878e 100644 --- a/gnuradio-core/src/lib/general/gr_nop.cc +++ b/gnuradio-core/src/lib/general/gr_nop.cc @@ -33,7 +33,7 @@ gr_nop::gr_nop (size_t sizeof_stream_item) { } -gr_block_sptr +gr_nop_sptr gr_make_nop (size_t sizeof_stream_item) { return gnuradio::get_initial_sptr (new gr_nop (sizeof_stream_item)); diff --git a/gnuradio-core/src/lib/general/gr_nop.h b/gnuradio-core/src/lib/general/gr_nop.h index 60b20c5ab..4f18c9183 100644 --- a/gnuradio-core/src/lib/general/gr_nop.h +++ b/gnuradio-core/src/lib/general/gr_nop.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -26,14 +26,19 @@ #include <gr_block.h> #include <stddef.h> // size_t +class gr_nop; +typedef boost::shared_ptr<gr_nop> gr_nop_sptr; + +gr_nop_sptr +gr_make_nop (size_t sizeof_stream_item); + /*! * \brief Does nothing. Used for testing only. * \ingroup misc_blk */ class gr_nop : public gr_block { - friend gr_block_sptr gr_make_nop (size_t sizeof_stream_item); - + friend gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); gr_nop (size_t sizeof_stream_item); public: @@ -43,7 +48,4 @@ class gr_nop : public gr_block gr_vector_void_star &output_items); }; -gr_block_sptr -gr_make_nop (size_t sizeof_stream_item); - #endif /* INCLUDED_GR_NOP_H */ diff --git a/gnuradio-core/src/lib/general/gr_nop.i b/gnuradio-core/src/lib/general/gr_nop.i index 8220e5c6c..85354d421 100644 --- a/gnuradio-core/src/lib/general/gr_nop.i +++ b/gnuradio-core/src/lib/general/gr_nop.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,11 +20,12 @@ * Boston, MA 02110-1301, USA. */ -%ignore gr_nop; +GR_SWIG_BLOCK_MAGIC(gr,nop) + +gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); + class gr_nop : public gr_block { - friend gr_block_sptr gr_make_nop (size_t sizeof_stream_item); +private: gr_nop (size_t sizeof_stream_item); }; -%rename(nop) gr_make_nop; -gr_block_sptr gr_make_nop (size_t sizeof_stream_item); diff --git a/gnuradio-core/src/lib/general/gr_null_sink.cc b/gnuradio-core/src/lib/general/gr_null_sink.cc index 0b7f2d9e8..67ef57a46 100644 --- a/gnuradio-core/src/lib/general/gr_null_sink.cc +++ b/gnuradio-core/src/lib/general/gr_null_sink.cc @@ -34,7 +34,7 @@ gr_null_sink::gr_null_sink (size_t sizeof_stream_item) { } -gr_block_sptr +gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item) { return gnuradio::get_initial_sptr (new gr_null_sink (sizeof_stream_item)); diff --git a/gnuradio-core/src/lib/general/gr_null_sink.h b/gnuradio-core/src/lib/general/gr_null_sink.h index 66df5d138..6d00382a5 100644 --- a/gnuradio-core/src/lib/general/gr_null_sink.h +++ b/gnuradio-core/src/lib/general/gr_null_sink.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -26,15 +26,20 @@ #include <gr_sync_block.h> #include <stddef.h> // size_t +class gr_null_sink; +typedef boost::shared_ptr<gr_null_sink> gr_null_sink_sptr; + +gr_null_sink_sptr +gr_make_null_sink (size_t sizeof_stream_item); + + /*! * \brief Bit bucket * \ingroup sink_blk */ - class gr_null_sink : public gr_sync_block { - friend gr_block_sptr gr_make_null_sink (size_t sizeof_stream_item); - + friend gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); gr_null_sink (size_t sizeof_stream_item); public: @@ -45,7 +50,4 @@ class gr_null_sink : public gr_sync_block }; -gr_block_sptr -gr_make_null_sink (size_t sizeof_stream_item); - #endif /* INCLUDED_GR_NULL_SINK_H */ diff --git a/gnuradio-core/src/lib/general/gr_null_sink.i b/gnuradio-core/src/lib/general/gr_null_sink.i index fc4bcffda..e739ce118 100644 --- a/gnuradio-core/src/lib/general/gr_null_sink.i +++ b/gnuradio-core/src/lib/general/gr_null_sink.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,11 +20,12 @@ * Boston, MA 02110-1301, USA. */ -%ignore gr_null_sink; +GR_SWIG_BLOCK_MAGIC(gr,null_sink) + +gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); + class gr_null_sink : public gr_sync_block { - friend gr_block_sptr gr_make_null_sink (size_t sizeof_stream_item); +private: gr_null_sink (size_t sizeof_stream_item); }; -%rename(null_sink) gr_make_null_sink; -gr_block_sptr gr_make_null_sink (size_t sizeof_stream_item); diff --git a/gnuradio-core/src/lib/general/gr_null_source.cc b/gnuradio-core/src/lib/general/gr_null_source.cc index b65c39035..85fd2db4b 100644 --- a/gnuradio-core/src/lib/general/gr_null_source.cc +++ b/gnuradio-core/src/lib/general/gr_null_source.cc @@ -35,7 +35,7 @@ gr_null_source::gr_null_source (size_t sizeof_stream_item) { } -gr_block_sptr +gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item) { return gnuradio::get_initial_sptr (new gr_null_source (sizeof_stream_item)); diff --git a/gnuradio-core/src/lib/general/gr_null_source.h b/gnuradio-core/src/lib/general/gr_null_source.h index 63b1939bf..b1a46a195 100644 --- a/gnuradio-core/src/lib/general/gr_null_source.h +++ b/gnuradio-core/src/lib/general/gr_null_source.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,14 +25,19 @@ #include <gr_sync_block.h> +class gr_null_source; +typedef boost::shared_ptr<gr_null_source> gr_null_source_sptr; + +gr_null_source_sptr +gr_make_null_source (size_t sizeof_stream_item); + /*! * \brief A source of zeros. * \ingroup source_blk */ - class gr_null_source : public gr_sync_block { - friend gr_block_sptr gr_make_null_source (size_t sizeof_stream_item); + friend gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); gr_null_source (size_t sizeof_stream_item); @@ -43,7 +48,4 @@ class gr_null_source : public gr_sync_block }; -gr_block_sptr -gr_make_null_source (size_t sizeof_stream_item); - #endif /* INCLUDED_GR_NULL_SOURCE_H */ diff --git a/gnuradio-core/src/lib/general/gr_null_source.i b/gnuradio-core/src/lib/general/gr_null_source.i index f9ddef86f..133161d0a 100644 --- a/gnuradio-core/src/lib/general/gr_null_source.i +++ b/gnuradio-core/src/lib/general/gr_null_source.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,11 +20,12 @@ * Boston, MA 02110-1301, USA. */ -%ignore gr_null_source; +GR_SWIG_BLOCK_MAGIC(gr,null_source) + +gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); + class gr_null_source : public gr_sync_block { - friend gr_block_sptr gr_make_null_source (size_t sizeof_stream_item); +private: gr_null_source (size_t sizeof_stream_item); }; -%rename(null_source) gr_make_null_source; -gr_block_sptr gr_make_null_source (size_t sizeof_stream_item); diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i index 30c692926..3850220ba 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i +++ b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i @@ -26,7 +26,7 @@ gr_ofdm_mapper_bcv_sptr gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, unsigned int bits_per_symbol, - unsigned int fft_length); + unsigned int fft_length) throw(std::exception); class gr_ofdm_mapper_bcv : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i index 5f9a8f134..2e9aa406b 100644 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i +++ b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i @@ -22,7 +22,7 @@ GR_SWIG_BLOCK_MAGIC(gr,unpack_k_bits_bb) -gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (int k); +gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (int k) throw(std::exception); class gr_unpack_k_bits_bb : public gr_sync_interpolator { diff --git a/gnuradio-core/src/lib/gengen/Makefile.am b/gnuradio-core/src/lib/gengen/Makefile.am index 4978ad1c5..cfa043b67 100644 --- a/gnuradio-core/src/lib/gengen/Makefile.am +++ b/gnuradio-core/src/lib/gengen/Makefile.am @@ -115,7 +115,7 @@ core_generator = \ gr_moving_average_XX.i.t # Source built by Python into $(builddir) -BUILT_SOURCES = \ +BUILT_SOURCES += \ $(GENERATED_H) \ $(GENERATED_I) \ $(GENERATED_CC) \ @@ -123,7 +123,7 @@ BUILT_SOURCES = \ # ---------------------------------------------------------------- -EXTRA_DIST = \ +EXTRA_DIST += \ $(core_generator) libgengen_la_SOURCES = \ diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t index 2a0a3ba3f..f49be062e 100755 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t @@ -30,12 +30,12 @@ #include <gr_io_signature.h> @SPTR_NAME@ -gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k) +gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k) { return gnuradio::get_initial_sptr (new @NAME@ (k)); } -@NAME@::@NAME@ (const std::vector<@I_TYPE@> k) +@NAME@::@NAME@ (const std::vector<@I_TYPE@> &k) : gr_sync_block ("@BASE_NAME@", gr_make_io_signature (1, 1, sizeof(@I_TYPE@)*k.size()), gr_make_io_signature (1, 1, sizeof(@O_TYPE@)*k.size())) diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t index 33b6fc396..574fc686c 100755 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k); +@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); /*! * \brief output vector = input vector + constant vector @@ -38,14 +38,14 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; */ class @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k); + friend @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); std::vector<@I_TYPE@> d_k; // the constant - @NAME@ (const std::vector<@I_TYPE@> k); + @NAME@ (const std::vector<@I_TYPE@> &k); public: const std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> k) { d_k = k; } + void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } int work (int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t index a2e7dd70b..ad1643a7e 100755 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t +++ b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.i.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,14 +24,14 @@ GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k); +@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); class @NAME@ : public gr_sync_block { private: - @NAME@ (const std::vector<@I_TYPE@> k); + @NAME@ (const std::vector<@I_TYPE@> &k); public: std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> k) { d_k = k; } + void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } }; diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t index 8286453f1..5725c1c46 100755 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t @@ -30,12 +30,12 @@ #include <gr_io_signature.h> @SPTR_NAME@ -gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k) +gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k) { return gnuradio::get_initial_sptr (new @NAME@ (k)); } -@NAME@::@NAME@ (const std::vector<@I_TYPE@> k) +@NAME@::@NAME@ (const std::vector<@I_TYPE@> &k) : gr_sync_block ("@BASE_NAME@", gr_make_io_signature (1, 1, sizeof(@I_TYPE@)*k.size()), gr_make_io_signature (1, 1, sizeof(@O_TYPE@)*k.size())) diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t index 22334505a..81e781895 100755 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k); +@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); /*! * \brief output vector = input vector * constant vector (element-wise) @@ -38,14 +38,14 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; */ class @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k); + friend @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); std::vector<@I_TYPE@> d_k; // the constant - @NAME@ (const std::vector<@I_TYPE@> k); + @NAME@ (const std::vector<@I_TYPE@> &k); public: const std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> k) { d_k = k; } + void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } int work (int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t index a2e7dd70b..ad1643a7e 100755 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.i.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,14 +24,14 @@ GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k); +@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); class @NAME@ : public gr_sync_block { private: - @NAME@ (const std::vector<@I_TYPE@> k); + @NAME@ (const std::vector<@I_TYPE@> &k); public: std::vector<@I_TYPE@> k () const { return d_k; } - void set_k (const std::vector<@I_TYPE@> k) { d_k = k; } + void set_k (const std::vector<@I_TYPE@> &k) { d_k = k; } }; diff --git a/gnuradio-core/src/lib/io/gr_message_source.i b/gnuradio-core/src/lib/io/gr_message_source.i index 8a9c762d0..e4e2016d0 100644 --- a/gnuradio-core/src/lib/io/gr_message_source.i +++ b/gnuradio-core/src/lib/io/gr_message_source.i @@ -22,6 +22,14 @@ GR_SWIG_BLOCK_MAGIC(gr,message_source); +#ifdef SWIGGUILE +// Rename these. Without this, the primitive bindings are OK, but the +// goops bindings try to create a bogus generic-function... +// See core.scm for the second part of the workaround. +%rename(message_source_limit_ctor) gr_make_message_source(size_t itemsize, int msgq_limit); +%rename(message_source_msgq_ctor) gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq); +#endif + gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0); gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq); diff --git a/gnuradio-core/src/lib/missing/Makefile.am b/gnuradio-core/src/lib/missing/Makefile.am index 238370910..bd18cf143 100644 --- a/gnuradio-core/src/lib/missing/Makefile.am +++ b/gnuradio-core/src/lib/missing/Makefile.am @@ -23,7 +23,7 @@ include $(top_srcdir)/Makefile.common AM_CPPFLAGS = $(GNURADIO_INCLUDES) $(WITH_INCLUDES) -EXTRA_DIST = \ +EXTRA_DIST += \ getopt.h \ getopt.c \ gettimeofday.c \ diff --git a/gnuradio-core/src/lib/reed-solomon/Makefile.am b/gnuradio-core/src/lib/reed-solomon/Makefile.am index b7bd939b0..5548f4280 100644 --- a/gnuradio-core/src/lib/reed-solomon/Makefile.am +++ b/gnuradio-core/src/lib/reed-solomon/Makefile.am @@ -29,7 +29,7 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) TESTS = rstest -EXTRA_DIST = \ +EXTRA_DIST += \ README.karn noinst_LTLIBRARIES = librs.la diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.cc b/gnuradio-core/src/lib/runtime/gr_basic_block.cc index 2fa1066cb..0e0dad16b 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.cc @@ -56,7 +56,7 @@ gr_basic_block::~gr_basic_block() } gr_basic_block_sptr -gr_basic_block::basic_block() +gr_basic_block::to_basic_block() { return shared_from_this(); } diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h index b8797fdc6..d059a4bd3 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.h +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h @@ -81,7 +81,7 @@ public: std::string name() const { return d_name; } gr_io_signature_sptr input_signature() const { return d_input_signature; } gr_io_signature_sptr output_signature() const { return d_output_signature; } - gr_basic_block_sptr basic_block(); // Needed for Python type coercion + gr_basic_block_sptr to_basic_block(); // Needed for Python/Guile type coercion /*! * \brief Confirm that ninputs and noutputs is an acceptable combination. diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.i b/gnuradio-core/src/lib/runtime/gr_basic_block.i index 60e08aac3..03d4725d5 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.i +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -40,13 +40,15 @@ public: gr_io_signature_sptr input_signature() const; gr_io_signature_sptr output_signature() const; long unique_id() const; - gr_basic_block_sptr basic_block(); + gr_basic_block_sptr to_basic_block(); bool check_topology (int ninputs, int noutputs); }; %rename(block_ncurrently_allocated) gr_basic_block_ncurrently_allocated; long gr_basic_block_ncurrently_allocated(); +#ifdef SWIGPYTHON %pythoncode %{ gr_basic_block_sptr.__repr__ = lambda self: "<gr_basic_block %s (%d)>" % (self.name(), self.unique_id ()) %} +#endif diff --git a/gnuradio-core/src/lib/runtime/gr_block.i b/gnuradio-core/src/lib/runtime/gr_block.i index 2de354878..bb0c5f221 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.i +++ b/gnuradio-core/src/lib/runtime/gr_block.i @@ -56,8 +56,3 @@ class gr_block : public gr_basic_block { gr_block_detail_sptr detail () const { return d_detail; } void set_detail (gr_block_detail_sptr detail) { d_detail = detail; } }; - -%pythoncode %{ -gr_block_sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id ()) -gr_block_sptr.block = lambda self: self -%} diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2.cc b/gnuradio-core/src/lib/runtime/gr_hier_block2.cc index e3a25e1a8..d6e317136 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2.cc +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2.cc @@ -61,6 +61,11 @@ gr_hier_block2::self() return shared_from_this(); } +gr_hier_block2_sptr +gr_hier_block2::to_hier_block2() +{ + return cast_to_hier_block2_sptr(shared_from_this()); +} void gr_hier_block2::connect(gr_basic_block_sptr block) diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2.h b/gnuradio-core/src/lib/runtime/gr_hier_block2.h index f50b1cb94..0a40c36b7 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2.h +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2.h @@ -147,6 +147,8 @@ public: // This is a public method for ease of code organization, but should be // ignored by the user. gr_flat_flowgraph_sptr flatten() const; + + gr_hier_block2_sptr to_hier_block2(); // Needed for Python/Guile type coercion }; inline gr_hier_block2_sptr cast_to_hier_block2_sptr(gr_basic_block_sptr block) { diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2.i b/gnuradio-core/src/lib/runtime/gr_hier_block2.i index a62f50e84..32b656e24 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2.i +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2.i @@ -34,6 +34,11 @@ gr_hier_block2_sptr gr_make_hier_block2(const std::string name, gr_io_signature_sptr output_signature) throw (std::runtime_error); +// Rename connect and disconnect so that we can more easily build a +// better interface in scripting land. +%rename(primitive_connect) gr_hier_block2::connect; +%rename(primitive_disconnect) gr_hier_block2::disconnect; + class gr_hier_block2 : public gr_basic_block { private: @@ -57,4 +62,6 @@ public: void disconnect_all(); void lock(); void unlock(); + + gr_hier_block2_sptr to_hier_block2(); // Needed for Python/Guile type coercion }; diff --git a/gnuradio-core/src/lib/runtime/gr_msg_queue.i b/gnuradio-core/src/lib/runtime/gr_msg_queue.i index 9ca92b6ec..c9214bef3 100644 --- a/gnuradio-core/src/lib/runtime/gr_msg_queue.i +++ b/gnuradio-core/src/lib/runtime/gr_msg_queue.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2009 Free Software Foundation, Inc. + * Copyright 2005,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -81,6 +81,7 @@ public: * functions into the gr.msg_queue wrapper class, so that everything * appears normal. (An evil laugh is heard in the distance...) */ +#ifdef SWIGPYTHON %inline %{ gr_message_sptr gr_py_msg_queue__delete_head(gr_msg_queue_sptr q) { gr_message_sptr msg; @@ -103,3 +104,65 @@ gr_msg_queue_sptr.delete_head = gr_py_msg_queue__delete_head gr_msg_queue_sptr.insert_tail = gr_py_msg_queue__insert_tail gr_msg_queue_sptr.handle = gr_py_msg_queue__insert_tail %} +#endif // SWIGPYTHON + +/* + * Similar trickery as above, only this time for Guile + */ +#ifdef SWIGGUILE + +%{ + struct arg_holder { + gr_msg_queue_sptr q; + gr_message_sptr msg; + }; + + static void * + insert_tail_shim(void *arg) + { + arg_holder *a = (arg_holder *)arg; + a->q->insert_tail(a->msg); + return 0; + } + + static void * + delete_head_shim(void *arg) + { + arg_holder *a = (arg_holder *)arg; + a->msg = a->q->delete_head(); + return 0; + } +%} + +%inline %{ + + // handle and insert_tail are equivalent + static void + handle(gr_msg_queue_sptr q, gr_message_sptr msg) + { + arg_holder a; + a.q = q; + a.msg = msg; + scm_without_guile(insert_tail_shim, (void *) &a); + } + + static void + insert_tail(gr_msg_queue_sptr q, gr_message_sptr msg) + { + arg_holder a; + a.q = q; + a.msg = msg; + scm_without_guile(insert_tail_shim, (void *) &a); + } + + static gr_message_sptr + delete_head(gr_msg_queue_sptr q) + { + arg_holder a; + a.q = q; + scm_without_guile(delete_head_shim, (void *) &a); + return a.msg; + } +%} + +#endif // SWIGGUILE diff --git a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.i b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.i index 5e9032449..2378a1880 100644 --- a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.i +++ b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.i @@ -42,6 +42,7 @@ class gr_single_threaded_scheduler { gr_single_threaded_scheduler (const std::vector<gr_block_sptr> &modules); }; +#ifdef SWIGPYTHON %inline %{ void sts_pyrun (gr_single_threaded_scheduler_sptr s) { Py_BEGIN_ALLOW_THREADS; // release global interpreter lock @@ -49,3 +50,5 @@ class gr_single_threaded_scheduler { Py_END_ALLOW_THREADS; // acquire global interpreter lock } %} +#endif + diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.cc b/gnuradio-core/src/lib/runtime/gr_top_block.cc index 09e46dfbb..f341525c0 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_top_block.cc @@ -95,3 +95,9 @@ gr_top_block::dump() { d_impl->dump(); } + +gr_top_block_sptr +gr_top_block::to_top_block() +{ + return cast_to_top_block_sptr(shared_from_this()); +} diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h index 8052954e3..ed244cb7c 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block.h @@ -105,6 +105,13 @@ public: * Displays flattened flowgraph edges and block connectivity */ void dump(); + + gr_top_block_sptr to_top_block(); // Needed for Python/Guile type coercion }; +inline gr_top_block_sptr cast_to_top_block_sptr(gr_basic_block_sptr block) { + return boost::dynamic_pointer_cast<gr_top_block, gr_basic_block>(block); +} + + #endif /* INCLUDED_GR_TOP_BLOCK_H */ diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.i b/gnuradio-core/src/lib/runtime/gr_top_block.i index 670e5b5e5..90fa18b94 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.i +++ b/gnuradio-core/src/lib/runtime/gr_top_block.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -42,13 +42,17 @@ public: void start() throw (std::runtime_error); void stop(); - void wait(); - void run(); + //void wait(); + //void run() throw (std::runtime_error); void lock(); void unlock() throw (std::runtime_error); void dump(); + + gr_top_block_sptr to_top_block(); // Needed for Python/Guile type coercion }; +#ifdef SWIGPYTHON + %inline %{ void top_block_run_unlocked(gr_top_block_sptr r) throw (std::runtime_error) { @@ -64,3 +68,36 @@ void top_block_wait_unlocked(gr_top_block_sptr r) throw (std::runtime_error) Py_END_ALLOW_THREADS; // acquire global interpreter lock } %} + +#endif + +#ifdef SWIGGUILE + +%{ + struct tb_arg_holder { + gr_top_block_sptr tb; + }; + + static void * + tb_wait_shim(void *arg) + { + tb_arg_holder *a = (tb_arg_holder *)arg; + a->tb->wait(); + return 0; + } + +%} + +%inline %{ + + static void + top_block_wait_unlocked(gr_top_block_sptr r) throw (std::runtime_error) + { + tb_arg_holder a; + a.tb = r; + scm_without_guile(tb_wait_shim, (void *) &a); + } + +%} + +#endif diff --git a/gnuradio-core/src/lib/runtime/runtime.i b/gnuradio-core/src/lib/runtime/runtime.i index 20cf68a03..ca89b8fbd 100644 --- a/gnuradio-core/src/lib/runtime/runtime.i +++ b/gnuradio-core/src/lib/runtime/runtime.i @@ -40,6 +40,13 @@ #include <gr_top_block.h> %} +%constant int sizeof_char = sizeof(char); +%constant int sizeof_short = sizeof(short); +%constant int sizeof_int = sizeof(int); +%constant int sizeof_float = sizeof(float); +%constant int sizeof_double = sizeof(double); +%constant int sizeof_gr_complex = sizeof(gr_complex); + %include <gr_io_signature.i> %include <gr_buffer.i> %include <gr_basic_block.i> diff --git a/gnuradio-core/src/lib/swig/.gitignore b/gnuradio-core/src/lib/swig/.gitignore index 9d7d01056..a6f145618 100644 --- a/gnuradio-core/src/lib/swig/.gitignore +++ b/gnuradio-core/src/lib/swig/.gitignore @@ -10,27 +10,40 @@ /swigrun.py /swigrun_wrap.c /Makefile.swigdeps.new -/gnuradio_swig_py_runtime.d -/gnuradio_swig_py_general.d -/gnuradio_swig_py_gengen.d -/gnuradio_swig_py_filter.d -/gnuradio_swig_py_io.d -/gnuradio_swig_bug_workaround.h -/gnuradio_swig_py_runtime.cc -/gnuradio_swig_py_runtime.h -/gnuradio_swig_py_runtime.py -/gnuradio_swig_py_general.cc -/gnuradio_swig_py_general.h -/gnuradio_swig_py_general.py -/gnuradio_swig_py_gengen.cc -/gnuradio_swig_py_gengen.h -/gnuradio_swig_py_gengen.py -/gnuradio_swig_py_filter.cc -/gnuradio_swig_py_filter.h -/gnuradio_swig_py_filter.py -/gnuradio_swig_py_io.cc -/gnuradio_swig_py_io.h -/gnuradio_swig_py_io.py -/gnuradio_swig_py_hier.cc -/gnuradio_swig_py_hier.h -/gnuradio_swig_py_hier.py +gnuradio_core_filter.cc +gnuradio_core_filter.d +gnuradio_core_filter.h +gnuradio_core_filter.py +gnuradio_core_filter.scm +gnuradio_core_filter-primitive.scm +gnuradio_core_general.cc +gnuradio_core_general.d +gnuradio_core_general.h +gnuradio_core_general.py +gnuradio_core_general.scm +gnuradio_core_general-primitive.scm +gnuradio_core_gengen.cc +gnuradio_core_gengen.d +gnuradio_core_gengen.h +gnuradio_core_gengen.py +gnuradio_core_gengen.scm +gnuradio_core_gengen-primitive.scm +gnuradio_core_hier.cc +gnuradio_core_hier.d +gnuradio_core_hier.h +gnuradio_core_hier.py +gnuradio_core_hier.scm +gnuradio_core_hier-primitive.scm +gnuradio_core_io.cc +gnuradio_core_io.d +gnuradio_core_io.h +gnuradio_core_io.py +gnuradio_core_io.scm +gnuradio_core_io-primitive.scm +gnuradio_core_runtime.cc +gnuradio_core_runtime.d +gnuradio_core_runtime.h +gnuradio_core_runtime.py +gnuradio_core_runtime.scm +gnuradio_core_runtime-primitive.scm + diff --git a/gnuradio-core/src/lib/swig/Makefile.am b/gnuradio-core/src/lib/swig/Makefile.am index 1a50b8c8e..f8e7640ae 100644 --- a/gnuradio-core/src/lib/swig/Makefile.am +++ b/gnuradio-core/src/lib/swig/Makefile.am @@ -20,12 +20,26 @@ # include $(top_srcdir)/Makefile.common +include $(top_srcdir)/Makefile.swig -if PYTHON AM_CPPFLAGS = -I$(srcdir) $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ $(WITH_INCLUDES) -EXTRA_DIST = gen-swig-bug-fix +# ---------------------------------------------------------------- +# We've split the previously monstrous gnuradio_core into 6 +# smaller pieces. This reduces compile time coupling and creates +# smaller pieces for the compiler to digest. prior to this change, on +# X86_64, g++'s resident set size was 650MB! +# ---------------------------------------------------------------- + +TOP_SWIG_IFILES = \ + gnuradio_core_runtime.i \ + gnuradio_core_general.i \ + gnuradio_core_gengen.i \ + gnuradio_core_filter.i \ + gnuradio_core_io.i \ + gnuradio_core_hier.i + # SWIG headers get installed in ${prefix}/include/gnuradio/swig swiginclude_HEADERS = \ @@ -33,71 +47,45 @@ swiginclude_HEADERS = \ gr_swig_block_magic.i \ gr_shared_ptr.i +# SWIG headers that get installed in ${prefix}/include/gnuradio/swig/... +nobase_swiginclude_HEADERS = \ + guile/std_complex.i \ + guile/std_vector.i + + # special install for this top-level Python script which includes all # of the split Python libraries. ourpythondir = $(grpythondir)/gr -ourpython_PYTHON = gnuradio_swig_python.py +ourpython_PYTHON = gnuradio_core.py # ---------------------------------------------------------------- # FIXME As of swig 1.3.31, this still seems to be required... +# gnuradio_swig_bug_workaround.h : gnuradio_core_runtime.py $(srcdir)/gen-swig-bug-fix +# $(PYTHON) $(srcdir)/gen-swig-bug-fix python/gnuradio_core_runtime.cc $@ -gnuradio_swig_bug_workaround.h : gnuradio_swig_py_runtime.cc $(srcdir)/gen-swig-bug-fix - $(PYTHON) $(srcdir)/gen-swig-bug-fix gnuradio_swig_py_runtime.cc $@ +EXTRA_DIST += gen-swig-bug-fix # C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - gnuradio_swig_bug_workaround.h +grinclude_HEADERS = gnuradio_swig_bug_workaround.h -# ---------------------------------------------------------------- -# We've split the previously monstrous gnuradio_swig_python into 6 -# smaller pieces. This reduces compile time coupling and creates -# smaller pieces for the compiler to digest. prior to this change, on -# X86_64, g++'s resident set size was 650MB! -# ---------------------------------------------------------------- - -TOP_SWIG_IFILES = \ - gnuradio_swig_py_runtime.i \ - gnuradio_swig_py_general.i \ - gnuradio_swig_py_gengen.i \ - gnuradio_swig_py_filter.i \ - gnuradio_swig_py_io.i \ - gnuradio_swig_py_hier.i # Install so that they end up available as: # import gnuradio.gr # This ends up at: # ${prefix}/lib/python${python_version}/site-packages/gnuradio/gr -gnuradio_swig_py_runtime_pythondir_category = gnuradio/gr -gnuradio_swig_py_general_pythondir_category = gnuradio/gr -gnuradio_swig_py_gengen_pythondir_category = gnuradio/gr -gnuradio_swig_py_filter_pythondir_category = gnuradio/gr -gnuradio_swig_py_io_pythondir_category = gnuradio/gr -gnuradio_swig_py_hier_pythondir_category = gnuradio/gr +gnuradio_core_runtime_pythondir_category = gnuradio/gr +gnuradio_core_general_pythondir_category = gnuradio/gr +gnuradio_core_gengen_pythondir_category = gnuradio/gr +gnuradio_core_filter_pythondir_category = gnuradio/gr +gnuradio_core_io_pythondir_category = gnuradio/gr +gnuradio_core_hier_pythondir_category = gnuradio/gr # additional libraries for linking with each SWIG-generated library -gnuradio_swig_py_runtime_la_swig_libadd = $(GNURADIO_CORE_LA) -gnuradio_swig_py_general_la_swig_libadd = $(GNURADIO_CORE_LA) -gnuradio_swig_py_gengen_la_swig_libadd = $(GNURADIO_CORE_LA) -gnuradio_swig_py_filter_la_swig_libadd = $(GNURADIO_CORE_LA) -gnuradio_swig_py_io_la_swig_libadd = $(GNURADIO_CORE_LA) -gnuradio_swig_py_hier_la_swig_libadd = $(GNURADIO_CORE_LA) - -include $(top_srcdir)/Makefile.swig - -# add some of the variables generated inside the Makefile.swig - -# include the SWIG-generated .h files in the BUILT SOURCES, since they -# aren't by default when using Makefile.swig; order doesn't matter. -BUILT_SOURCES = \ - gnuradio_swig_py_runtime.h \ - gnuradio_swig_py_general.h \ - gnuradio_swig_py_gengen.h \ - gnuradio_swig_py_filter.h \ - gnuradio_swig_py_io.h \ - gnuradio_swig_py_hier.h \ - $(grinclude_HEADERS) \ - $(swig_built_sources) - -# Do not distribute the output of SWIG -no_dist_files = $(swig_built_sources) -endif +gnuradio_core_runtime_la_swig_libadd = $(GNURADIO_CORE_LA) +gnuradio_core_general_la_swig_libadd = $(GNURADIO_CORE_LA) +gnuradio_core_gengen_la_swig_libadd = $(GNURADIO_CORE_LA) +gnuradio_core_filter_la_swig_libadd = $(GNURADIO_CORE_LA) +gnuradio_core_io_la_swig_libadd = $(GNURADIO_CORE_LA) +gnuradio_core_hier_la_swig_libadd = $(GNURADIO_CORE_LA) + +SWIG_GUILE_FLAGS += -DIN_GNURADIO_CORE diff --git a/gnuradio-core/src/lib/swig/Makefile.swig.gen b/gnuradio-core/src/lib/swig/Makefile.swig.gen index e24ba5a96..0c3247565 100644 --- a/gnuradio-core/src/lib/swig/Makefile.swig.gen +++ b/gnuradio-core/src/lib/swig/Makefile.swig.gen @@ -20,27 +20,37 @@ # Boston, MA 02110-1301, USA. # -# Makefile.swig.gen for gnuradio_swig_py_runtime.i +# Makefile.swig.gen for gnuradio_core_runtime.i ## Default install locations for these files: ## ## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_runtime +## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_runtime ## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_runtime +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_runtime ## ## The following can be overloaded to change the install location, but ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -gnuradio_swig_py_runtime_pythondir_category ?= gnuradio/gnuradio_swig_py_runtime -gnuradio_swig_py_runtime_pylibdir_category ?= $(gnuradio_swig_py_runtime_pythondir_category) -gnuradio_swig_py_runtime_pythondir = $(pythondir)/$(gnuradio_swig_py_runtime_pythondir_category) -gnuradio_swig_py_runtime_pylibdir = $(pyexecdir)/$(gnuradio_swig_py_runtime_pylibdir_category) +gnuradio_core_runtime_pythondir_category ?= gnuradio/gnuradio_core_runtime +gnuradio_core_runtime_pylibdir_category ?= $(gnuradio_core_runtime_pythondir_category) +gnuradio_core_runtime_pythondir = $(pythondir)/$(gnuradio_core_runtime_pythondir_category) +gnuradio_core_runtime_pylibdir = $(pyexecdir)/$(gnuradio_core_runtime_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_runtime_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/gnuradio_core_runtime +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_runtime_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -gnuradio_swig_py_runtime_swigincludedir = $(swigincludedir) +gnuradio_core_runtime_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -57,205 +67,81 @@ gnuradio_swig_py_runtime_swigincludedir = $(swigincludedir) ## right thing. For more info, see < ## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > -## Stamps used to ensure parallel make does the right thing. These -## are removed by "make clean", but otherwise unused except during the -## parallel built. These will not be included in a tarball, because -## the SWIG-generated files will be removed from the distribution. - -STAMPS += $(DEPDIR)/gnuradio_swig_py_runtime-generate-* - ## Other cleaned files: dependency files generated by SWIG or this Makefile MOSTLYCLEANFILES += $(DEPDIR)/*.S* -## Add the .py and .cc files to the list of SWIG built sources. The -## .h file is sometimes built, but not always ... so that one has to -## be added manually by the including Makefile.am . - -swig_built_sources += gnuradio_swig_py_runtime.py gnuradio_swig_py_runtime.cc - ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . -gnuradio_swig_py_runtime_swiginclude_HEADERS = \ - gnuradio_swig_py_runtime.i \ - $(gnuradio_swig_py_runtime_swiginclude_headers) +gnuradio_core_runtime_swiginclude_HEADERS = \ + gnuradio_core_runtime.i \ + $(gnuradio_core_runtime_swiginclude_headers) + +if PYTHON +gnuradio_core_runtime_pylib_LTLIBRARIES = \ + _gnuradio_core_runtime.la -gnuradio_swig_py_runtime_pylib_LTLIBRARIES = \ - _gnuradio_swig_py_runtime.la +_gnuradio_core_runtime_la_SOURCES = \ + python/gnuradio_core_runtime.cc \ + $(gnuradio_core_runtime_la_swig_sources) -_gnuradio_swig_py_runtime_la_SOURCES = \ - gnuradio_swig_py_runtime.cc \ - $(gnuradio_swig_py_runtime_la_swig_sources) +gnuradio_core_runtime_python_PYTHON = \ + gnuradio_core_runtime.py \ + $(gnuradio_core_runtime_python) -_gnuradio_swig_py_runtime_la_LIBADD = \ +_gnuradio_core_runtime_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ - $(gnuradio_swig_py_runtime_la_swig_libadd) + $(gnuradio_core_runtime_la_swig_libadd) -_gnuradio_swig_py_runtime_la_LDFLAGS = \ +_gnuradio_core_runtime_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ - $(gnuradio_swig_py_runtime_la_swig_ldflags) + $(gnuradio_core_runtime_la_swig_ldflags) -_gnuradio_swig_py_runtime_la_CXXFLAGS = \ +_gnuradio_core_runtime_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ - $(gnuradio_swig_py_runtime_la_swig_cxxflags) + -I$(top_builddir) \ + $(gnuradio_core_runtime_la_swig_cxxflags) -gnuradio_swig_py_runtime_python_PYTHON = \ - gnuradio_swig_py_runtime.py \ - $(gnuradio_swig_py_runtime_python) +python/gnuradio_core_runtime.cc: gnuradio_core_runtime.py +gnuradio_core_runtime.py: gnuradio_core_runtime.i -## Entry rule for running SWIG +# Include the python dependencies for this file +-include python/gnuradio_core_runtime.d -gnuradio_swig_py_runtime.h gnuradio_swig_py_runtime.py gnuradio_swig_py_runtime.cc: gnuradio_swig_py_runtime.i -## This rule will get called only when MAKE decides that one of the -## targets needs to be created or re-created, because: -## -## * The .i file is newer than any or all of the generated files; -## -## * Any or all of the .cc, .h, or .py files does not exist and is -## needed (in the case this file is not needed, the rule for it is -## ignored); or -## -## * Some SWIG-based dependecy of the .cc file isn't met and hence the -## .cc file needs be be regenerated. Explanation: Because MAKE -## knows how to handle dependencies for .cc files (regardless of -## their name or extension), then the .cc file is used as a target -## instead of the .i file -- but with the dependencies of the .i -## file. It is this last reason why the line: -## -## if test -f $@; then :; else -## -## cannot be used in this case: If a .i file dependecy is not met, -## then the .cc file needs to be rebuilt. But if the stamp is newer -## than the .cc file, and the .cc file exists, then in the original -## version (with the 'test' above) the internal MAKE call will not -## be issued and hence the .cc file will not be rebuilt. -## -## Once execution gets to here, it should always proceed no matter the -## state of a stamp (as discussed in link above). The -## $(DEPDIR)/gnuradio_swig_py_runtime-generate stuff is used to allow for parallel -## builds to "do the right thing". The stamp has no relationship with -## either the target files or dependency file; it is used solely for -## the protection of multiple builds during a given call to MAKE. -## -## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM -## (15). At a caught signal, the quoted command will be issued before -## exiting. In this case, remove any stamp, whether temporary of not. -## The trap is valid until the process exits; the process includes all -## commands appended via "\"s. -## - trap 'rm -rf $(DEPDIR)/gnuradio_swig_py_runtime-generate-*' 1 2 13 15; \ -## -## Create a temporary directory, which acts as a lock. The first -## process to create the directory will succeed and issue the MAKE -## command to do the actual work, while all subsequent processes will -## fail -- leading them to wait for the first process to finish. -## - if mkdir $(DEPDIR)/gnuradio_swig_py_runtime-generate-lock 2>/dev/null; then \ -## -## This code is being executed by the first process to succeed in -## creating the directory lock. -## -## Remove the stamp associated with this filename. -## - rm -f $(DEPDIR)/gnuradio_swig_py_runtime-generate-stamp; \ -## -## Tell MAKE to run the rule for creating this stamp. -## - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/gnuradio_swig_py_runtime-generate-stamp WHAT=$<; \ -## -## Now that the .cc, .h, and .py files have been (re)created from the -## .i file, future checking of this rule during the same MAKE -## execution will come back that the rule doesn't need to be executed -## because none of the conditions mentioned at the start of this rule -## will be positive. Remove the the directory lock, which frees up -## any waiting process(es) to continue. -## - rmdir $(DEPDIR)/gnuradio_swig_py_runtime-generate-lock; \ - else \ -## -## This code is being executed by any follower processes while the -## directory lock is in place. -## -## Wait until the first process is done, testing once per second. -## - while test -d $(DEPDIR)/gnuradio_swig_py_runtime-generate-lock; do \ - sleep 1; \ - done; \ -## -## Succeed if and only if the first process succeeded; exit this -## process returning the status of the generated stamp. -## - test -f $(DEPDIR)/gnuradio_swig_py_runtime-generate-stamp; \ - exit $$?; \ - fi; - -$(DEPDIR)/gnuradio_swig_py_runtime-generate-stamp: -## This rule will be called only by the first process issuing the -## above rule to succeed in creating the lock directory, after -## removing the actual stamp file in order to guarantee that MAKE will -## execute this rule. -## -## Call SWIG to generate the various output files; special -## post-processing on 'mingw32' host OS for the dependency file. -## - if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(gnuradio_swig_py_runtime_swig_args) \ - -MD -MF $(DEPDIR)/gnuradio_swig_py_runtime.Std \ - -module gnuradio_swig_py_runtime -o gnuradio_swig_py_runtime.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/gnuradio_swig_py_runtime.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/gnuradio_swig_py_runtime.Std \ - > $(DEPDIR)/gnuradio_swig_py_runtime.Sd; \ - $(RM) $(DEPDIR)/gnuradio_swig_py_runtime.Std; \ - $(MV) $(DEPDIR)/gnuradio_swig_py_runtime.Sd $(DEPDIR)/gnuradio_swig_py_runtime.Std; \ - fi; \ - else \ - $(RM) $(DEPDIR)/gnuradio_swig_py_runtime.S*; exit 1; \ - fi; -## -## Mess with the SWIG output .Std dependency file, to create a -## dependecy file valid for the input .i file: Basically, simulate the -## dependency file created for libraries by GNU's libtool for C++, -## where all of the dependencies for the target are first listed, then -## each individual dependency is listed as a target with no further -## dependencies. -## -## (1) remove the current dependency file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_runtime.d -## -## (2) Copy the whole SWIG file: -## - cp $(DEPDIR)/gnuradio_swig_py_runtime.Std $(DEPDIR)/gnuradio_swig_py_runtime.d -## -## (3) all a carriage return to the end of the dependency file. -## - echo "" >> $(DEPDIR)/gnuradio_swig_py_runtime.d -## -## (4) from the SWIG file, remove the first line (the target); remove -## trailing " \" and " " from each line. Append ":" to each line, -## followed by 2 carriage returns, then append this to the end of -## the dependency file. -## - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/gnuradio_swig_py_runtime.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/gnuradio_swig_py_runtime.d -## -## (5) remove the SWIG-generated file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_runtime.Std -## -## Create the stamp for this filename generation, to signal success in -## executing this rule; allows other threads waiting on this process -## to continue. -## - touch $(DEPDIR)/gnuradio_swig_py_runtime-generate-stamp +endif # end of if python + +if GUILE + +gnuradio_core_runtime_scmlib_LTLIBRARIES = \ + libguile-gnuradio-gnuradio_core_runtime.la +libguile_gnuradio_gnuradio_core_runtime_la_SOURCES = \ + guile/gnuradio_core_runtime.cc \ + $(gnuradio_core_runtime_la_swig_sources) +nobase_gnuradio_core_runtime_scm_DATA = \ + gnuradio/gnuradio_core_runtime.scm \ + gnuradio/gnuradio_core_runtime-primitive.scm +libguile_gnuradio_gnuradio_core_runtime_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(gnuradio_core_runtime_la_swig_libadd) +libguile_gnuradio_gnuradio_core_runtime_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(gnuradio_core_runtime_la_swig_ldflags) +libguile_gnuradio_gnuradio_core_runtime_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(gnuradio_core_runtime_la_swig_cxxflags) -# KLUDGE: Force runtime include of a SWIG dependency file. This is -# not guaranteed to be portable, but will probably work. If it works, -# we have accurate dependencies for our swig stuff, which is good. +guile/gnuradio_core_runtime.cc: gnuradio/gnuradio_core_runtime.scm +gnuradio/gnuradio_core_runtime.scm: gnuradio_core_runtime.i +gnuradio/gnuradio_core_runtime-primitive.scm: gnuradio/gnuradio_core_runtime.scm + +# Include the guile dependencies for this file +-include guile/gnuradio_core_runtime.d + +endif # end of GUILE -@am__include@ @am__quote@./$(DEPDIR)/gnuradio_swig_py_runtime.d@am__quote@ # -*- Makefile -*- # @@ -279,27 +165,37 @@ $(DEPDIR)/gnuradio_swig_py_runtime-generate-stamp: # Boston, MA 02110-1301, USA. # -# Makefile.swig.gen for gnuradio_swig_py_general.i +# Makefile.swig.gen for gnuradio_core_general.i ## Default install locations for these files: ## ## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_general +## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_general ## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_general +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_general ## ## The following can be overloaded to change the install location, but ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -gnuradio_swig_py_general_pythondir_category ?= gnuradio/gnuradio_swig_py_general -gnuradio_swig_py_general_pylibdir_category ?= $(gnuradio_swig_py_general_pythondir_category) -gnuradio_swig_py_general_pythondir = $(pythondir)/$(gnuradio_swig_py_general_pythondir_category) -gnuradio_swig_py_general_pylibdir = $(pyexecdir)/$(gnuradio_swig_py_general_pylibdir_category) +gnuradio_core_general_pythondir_category ?= gnuradio/gnuradio_core_general +gnuradio_core_general_pylibdir_category ?= $(gnuradio_core_general_pythondir_category) +gnuradio_core_general_pythondir = $(pythondir)/$(gnuradio_core_general_pythondir_category) +gnuradio_core_general_pylibdir = $(pyexecdir)/$(gnuradio_core_general_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_general_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/gnuradio_core_general +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_general_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -gnuradio_swig_py_general_swigincludedir = $(swigincludedir) +gnuradio_core_general_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -316,205 +212,81 @@ gnuradio_swig_py_general_swigincludedir = $(swigincludedir) ## right thing. For more info, see < ## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > -## Stamps used to ensure parallel make does the right thing. These -## are removed by "make clean", but otherwise unused except during the -## parallel built. These will not be included in a tarball, because -## the SWIG-generated files will be removed from the distribution. - -STAMPS += $(DEPDIR)/gnuradio_swig_py_general-generate-* - ## Other cleaned files: dependency files generated by SWIG or this Makefile MOSTLYCLEANFILES += $(DEPDIR)/*.S* -## Add the .py and .cc files to the list of SWIG built sources. The -## .h file is sometimes built, but not always ... so that one has to -## be added manually by the including Makefile.am . - -swig_built_sources += gnuradio_swig_py_general.py gnuradio_swig_py_general.cc - ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . -gnuradio_swig_py_general_swiginclude_HEADERS = \ - gnuradio_swig_py_general.i \ - $(gnuradio_swig_py_general_swiginclude_headers) +gnuradio_core_general_swiginclude_HEADERS = \ + gnuradio_core_general.i \ + $(gnuradio_core_general_swiginclude_headers) + +if PYTHON +gnuradio_core_general_pylib_LTLIBRARIES = \ + _gnuradio_core_general.la -gnuradio_swig_py_general_pylib_LTLIBRARIES = \ - _gnuradio_swig_py_general.la +_gnuradio_core_general_la_SOURCES = \ + python/gnuradio_core_general.cc \ + $(gnuradio_core_general_la_swig_sources) -_gnuradio_swig_py_general_la_SOURCES = \ - gnuradio_swig_py_general.cc \ - $(gnuradio_swig_py_general_la_swig_sources) +gnuradio_core_general_python_PYTHON = \ + gnuradio_core_general.py \ + $(gnuradio_core_general_python) -_gnuradio_swig_py_general_la_LIBADD = \ +_gnuradio_core_general_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ - $(gnuradio_swig_py_general_la_swig_libadd) + $(gnuradio_core_general_la_swig_libadd) -_gnuradio_swig_py_general_la_LDFLAGS = \ +_gnuradio_core_general_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ - $(gnuradio_swig_py_general_la_swig_ldflags) + $(gnuradio_core_general_la_swig_ldflags) -_gnuradio_swig_py_general_la_CXXFLAGS = \ +_gnuradio_core_general_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ - $(gnuradio_swig_py_general_la_swig_cxxflags) + -I$(top_builddir) \ + $(gnuradio_core_general_la_swig_cxxflags) -gnuradio_swig_py_general_python_PYTHON = \ - gnuradio_swig_py_general.py \ - $(gnuradio_swig_py_general_python) +python/gnuradio_core_general.cc: gnuradio_core_general.py +gnuradio_core_general.py: gnuradio_core_general.i -## Entry rule for running SWIG +# Include the python dependencies for this file +-include python/gnuradio_core_general.d -gnuradio_swig_py_general.h gnuradio_swig_py_general.py gnuradio_swig_py_general.cc: gnuradio_swig_py_general.i -## This rule will get called only when MAKE decides that one of the -## targets needs to be created or re-created, because: -## -## * The .i file is newer than any or all of the generated files; -## -## * Any or all of the .cc, .h, or .py files does not exist and is -## needed (in the case this file is not needed, the rule for it is -## ignored); or -## -## * Some SWIG-based dependecy of the .cc file isn't met and hence the -## .cc file needs be be regenerated. Explanation: Because MAKE -## knows how to handle dependencies for .cc files (regardless of -## their name or extension), then the .cc file is used as a target -## instead of the .i file -- but with the dependencies of the .i -## file. It is this last reason why the line: -## -## if test -f $@; then :; else -## -## cannot be used in this case: If a .i file dependecy is not met, -## then the .cc file needs to be rebuilt. But if the stamp is newer -## than the .cc file, and the .cc file exists, then in the original -## version (with the 'test' above) the internal MAKE call will not -## be issued and hence the .cc file will not be rebuilt. -## -## Once execution gets to here, it should always proceed no matter the -## state of a stamp (as discussed in link above). The -## $(DEPDIR)/gnuradio_swig_py_general-generate stuff is used to allow for parallel -## builds to "do the right thing". The stamp has no relationship with -## either the target files or dependency file; it is used solely for -## the protection of multiple builds during a given call to MAKE. -## -## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM -## (15). At a caught signal, the quoted command will be issued before -## exiting. In this case, remove any stamp, whether temporary of not. -## The trap is valid until the process exits; the process includes all -## commands appended via "\"s. -## - trap 'rm -rf $(DEPDIR)/gnuradio_swig_py_general-generate-*' 1 2 13 15; \ -## -## Create a temporary directory, which acts as a lock. The first -## process to create the directory will succeed and issue the MAKE -## command to do the actual work, while all subsequent processes will -## fail -- leading them to wait for the first process to finish. -## - if mkdir $(DEPDIR)/gnuradio_swig_py_general-generate-lock 2>/dev/null; then \ -## -## This code is being executed by the first process to succeed in -## creating the directory lock. -## -## Remove the stamp associated with this filename. -## - rm -f $(DEPDIR)/gnuradio_swig_py_general-generate-stamp; \ -## -## Tell MAKE to run the rule for creating this stamp. -## - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/gnuradio_swig_py_general-generate-stamp WHAT=$<; \ -## -## Now that the .cc, .h, and .py files have been (re)created from the -## .i file, future checking of this rule during the same MAKE -## execution will come back that the rule doesn't need to be executed -## because none of the conditions mentioned at the start of this rule -## will be positive. Remove the the directory lock, which frees up -## any waiting process(es) to continue. -## - rmdir $(DEPDIR)/gnuradio_swig_py_general-generate-lock; \ - else \ -## -## This code is being executed by any follower processes while the -## directory lock is in place. -## -## Wait until the first process is done, testing once per second. -## - while test -d $(DEPDIR)/gnuradio_swig_py_general-generate-lock; do \ - sleep 1; \ - done; \ -## -## Succeed if and only if the first process succeeded; exit this -## process returning the status of the generated stamp. -## - test -f $(DEPDIR)/gnuradio_swig_py_general-generate-stamp; \ - exit $$?; \ - fi; - -$(DEPDIR)/gnuradio_swig_py_general-generate-stamp: -## This rule will be called only by the first process issuing the -## above rule to succeed in creating the lock directory, after -## removing the actual stamp file in order to guarantee that MAKE will -## execute this rule. -## -## Call SWIG to generate the various output files; special -## post-processing on 'mingw32' host OS for the dependency file. -## - if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(gnuradio_swig_py_general_swig_args) \ - -MD -MF $(DEPDIR)/gnuradio_swig_py_general.Std \ - -module gnuradio_swig_py_general -o gnuradio_swig_py_general.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/gnuradio_swig_py_general.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/gnuradio_swig_py_general.Std \ - > $(DEPDIR)/gnuradio_swig_py_general.Sd; \ - $(RM) $(DEPDIR)/gnuradio_swig_py_general.Std; \ - $(MV) $(DEPDIR)/gnuradio_swig_py_general.Sd $(DEPDIR)/gnuradio_swig_py_general.Std; \ - fi; \ - else \ - $(RM) $(DEPDIR)/gnuradio_swig_py_general.S*; exit 1; \ - fi; -## -## Mess with the SWIG output .Std dependency file, to create a -## dependecy file valid for the input .i file: Basically, simulate the -## dependency file created for libraries by GNU's libtool for C++, -## where all of the dependencies for the target are first listed, then -## each individual dependency is listed as a target with no further -## dependencies. -## -## (1) remove the current dependency file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_general.d -## -## (2) Copy the whole SWIG file: -## - cp $(DEPDIR)/gnuradio_swig_py_general.Std $(DEPDIR)/gnuradio_swig_py_general.d -## -## (3) all a carriage return to the end of the dependency file. -## - echo "" >> $(DEPDIR)/gnuradio_swig_py_general.d -## -## (4) from the SWIG file, remove the first line (the target); remove -## trailing " \" and " " from each line. Append ":" to each line, -## followed by 2 carriage returns, then append this to the end of -## the dependency file. -## - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/gnuradio_swig_py_general.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/gnuradio_swig_py_general.d -## -## (5) remove the SWIG-generated file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_general.Std -## -## Create the stamp for this filename generation, to signal success in -## executing this rule; allows other threads waiting on this process -## to continue. -## - touch $(DEPDIR)/gnuradio_swig_py_general-generate-stamp +endif # end of if python + +if GUILE -# KLUDGE: Force runtime include of a SWIG dependency file. This is -# not guaranteed to be portable, but will probably work. If it works, -# we have accurate dependencies for our swig stuff, which is good. +gnuradio_core_general_scmlib_LTLIBRARIES = \ + libguile-gnuradio-gnuradio_core_general.la +libguile_gnuradio_gnuradio_core_general_la_SOURCES = \ + guile/gnuradio_core_general.cc \ + $(gnuradio_core_general_la_swig_sources) +nobase_gnuradio_core_general_scm_DATA = \ + gnuradio/gnuradio_core_general.scm \ + gnuradio/gnuradio_core_general-primitive.scm +libguile_gnuradio_gnuradio_core_general_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(gnuradio_core_general_la_swig_libadd) +libguile_gnuradio_gnuradio_core_general_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(gnuradio_core_general_la_swig_ldflags) +libguile_gnuradio_gnuradio_core_general_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(gnuradio_core_general_la_swig_cxxflags) + +guile/gnuradio_core_general.cc: gnuradio/gnuradio_core_general.scm +gnuradio/gnuradio_core_general.scm: gnuradio_core_general.i +gnuradio/gnuradio_core_general-primitive.scm: gnuradio/gnuradio_core_general.scm + +# Include the guile dependencies for this file +-include guile/gnuradio_core_general.d + +endif # end of GUILE -@am__include@ @am__quote@./$(DEPDIR)/gnuradio_swig_py_general.d@am__quote@ # -*- Makefile -*- # @@ -538,27 +310,37 @@ $(DEPDIR)/gnuradio_swig_py_general-generate-stamp: # Boston, MA 02110-1301, USA. # -# Makefile.swig.gen for gnuradio_swig_py_gengen.i +# Makefile.swig.gen for gnuradio_core_gengen.i ## Default install locations for these files: ## ## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_gengen +## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_gengen ## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_gengen +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_gengen ## ## The following can be overloaded to change the install location, but ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -gnuradio_swig_py_gengen_pythondir_category ?= gnuradio/gnuradio_swig_py_gengen -gnuradio_swig_py_gengen_pylibdir_category ?= $(gnuradio_swig_py_gengen_pythondir_category) -gnuradio_swig_py_gengen_pythondir = $(pythondir)/$(gnuradio_swig_py_gengen_pythondir_category) -gnuradio_swig_py_gengen_pylibdir = $(pyexecdir)/$(gnuradio_swig_py_gengen_pylibdir_category) +gnuradio_core_gengen_pythondir_category ?= gnuradio/gnuradio_core_gengen +gnuradio_core_gengen_pylibdir_category ?= $(gnuradio_core_gengen_pythondir_category) +gnuradio_core_gengen_pythondir = $(pythondir)/$(gnuradio_core_gengen_pythondir_category) +gnuradio_core_gengen_pylibdir = $(pyexecdir)/$(gnuradio_core_gengen_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_gengen_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/gnuradio_core_gengen +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_gengen_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -gnuradio_swig_py_gengen_swigincludedir = $(swigincludedir) +gnuradio_core_gengen_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -575,205 +357,81 @@ gnuradio_swig_py_gengen_swigincludedir = $(swigincludedir) ## right thing. For more info, see < ## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > -## Stamps used to ensure parallel make does the right thing. These -## are removed by "make clean", but otherwise unused except during the -## parallel built. These will not be included in a tarball, because -## the SWIG-generated files will be removed from the distribution. - -STAMPS += $(DEPDIR)/gnuradio_swig_py_gengen-generate-* - ## Other cleaned files: dependency files generated by SWIG or this Makefile MOSTLYCLEANFILES += $(DEPDIR)/*.S* -## Add the .py and .cc files to the list of SWIG built sources. The -## .h file is sometimes built, but not always ... so that one has to -## be added manually by the including Makefile.am . - -swig_built_sources += gnuradio_swig_py_gengen.py gnuradio_swig_py_gengen.cc - ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . -gnuradio_swig_py_gengen_swiginclude_HEADERS = \ - gnuradio_swig_py_gengen.i \ - $(gnuradio_swig_py_gengen_swiginclude_headers) +gnuradio_core_gengen_swiginclude_HEADERS = \ + gnuradio_core_gengen.i \ + $(gnuradio_core_gengen_swiginclude_headers) + +if PYTHON +gnuradio_core_gengen_pylib_LTLIBRARIES = \ + _gnuradio_core_gengen.la -gnuradio_swig_py_gengen_pylib_LTLIBRARIES = \ - _gnuradio_swig_py_gengen.la +_gnuradio_core_gengen_la_SOURCES = \ + python/gnuradio_core_gengen.cc \ + $(gnuradio_core_gengen_la_swig_sources) -_gnuradio_swig_py_gengen_la_SOURCES = \ - gnuradio_swig_py_gengen.cc \ - $(gnuradio_swig_py_gengen_la_swig_sources) +gnuradio_core_gengen_python_PYTHON = \ + gnuradio_core_gengen.py \ + $(gnuradio_core_gengen_python) -_gnuradio_swig_py_gengen_la_LIBADD = \ +_gnuradio_core_gengen_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ - $(gnuradio_swig_py_gengen_la_swig_libadd) + $(gnuradio_core_gengen_la_swig_libadd) -_gnuradio_swig_py_gengen_la_LDFLAGS = \ +_gnuradio_core_gengen_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ - $(gnuradio_swig_py_gengen_la_swig_ldflags) + $(gnuradio_core_gengen_la_swig_ldflags) -_gnuradio_swig_py_gengen_la_CXXFLAGS = \ +_gnuradio_core_gengen_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ - $(gnuradio_swig_py_gengen_la_swig_cxxflags) + -I$(top_builddir) \ + $(gnuradio_core_gengen_la_swig_cxxflags) -gnuradio_swig_py_gengen_python_PYTHON = \ - gnuradio_swig_py_gengen.py \ - $(gnuradio_swig_py_gengen_python) +python/gnuradio_core_gengen.cc: gnuradio_core_gengen.py +gnuradio_core_gengen.py: gnuradio_core_gengen.i -## Entry rule for running SWIG +# Include the python dependencies for this file +-include python/gnuradio_core_gengen.d -gnuradio_swig_py_gengen.h gnuradio_swig_py_gengen.py gnuradio_swig_py_gengen.cc: gnuradio_swig_py_gengen.i -## This rule will get called only when MAKE decides that one of the -## targets needs to be created or re-created, because: -## -## * The .i file is newer than any or all of the generated files; -## -## * Any or all of the .cc, .h, or .py files does not exist and is -## needed (in the case this file is not needed, the rule for it is -## ignored); or -## -## * Some SWIG-based dependecy of the .cc file isn't met and hence the -## .cc file needs be be regenerated. Explanation: Because MAKE -## knows how to handle dependencies for .cc files (regardless of -## their name or extension), then the .cc file is used as a target -## instead of the .i file -- but with the dependencies of the .i -## file. It is this last reason why the line: -## -## if test -f $@; then :; else -## -## cannot be used in this case: If a .i file dependecy is not met, -## then the .cc file needs to be rebuilt. But if the stamp is newer -## than the .cc file, and the .cc file exists, then in the original -## version (with the 'test' above) the internal MAKE call will not -## be issued and hence the .cc file will not be rebuilt. -## -## Once execution gets to here, it should always proceed no matter the -## state of a stamp (as discussed in link above). The -## $(DEPDIR)/gnuradio_swig_py_gengen-generate stuff is used to allow for parallel -## builds to "do the right thing". The stamp has no relationship with -## either the target files or dependency file; it is used solely for -## the protection of multiple builds during a given call to MAKE. -## -## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM -## (15). At a caught signal, the quoted command will be issued before -## exiting. In this case, remove any stamp, whether temporary of not. -## The trap is valid until the process exits; the process includes all -## commands appended via "\"s. -## - trap 'rm -rf $(DEPDIR)/gnuradio_swig_py_gengen-generate-*' 1 2 13 15; \ -## -## Create a temporary directory, which acts as a lock. The first -## process to create the directory will succeed and issue the MAKE -## command to do the actual work, while all subsequent processes will -## fail -- leading them to wait for the first process to finish. -## - if mkdir $(DEPDIR)/gnuradio_swig_py_gengen-generate-lock 2>/dev/null; then \ -## -## This code is being executed by the first process to succeed in -## creating the directory lock. -## -## Remove the stamp associated with this filename. -## - rm -f $(DEPDIR)/gnuradio_swig_py_gengen-generate-stamp; \ -## -## Tell MAKE to run the rule for creating this stamp. -## - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/gnuradio_swig_py_gengen-generate-stamp WHAT=$<; \ -## -## Now that the .cc, .h, and .py files have been (re)created from the -## .i file, future checking of this rule during the same MAKE -## execution will come back that the rule doesn't need to be executed -## because none of the conditions mentioned at the start of this rule -## will be positive. Remove the the directory lock, which frees up -## any waiting process(es) to continue. -## - rmdir $(DEPDIR)/gnuradio_swig_py_gengen-generate-lock; \ - else \ -## -## This code is being executed by any follower processes while the -## directory lock is in place. -## -## Wait until the first process is done, testing once per second. -## - while test -d $(DEPDIR)/gnuradio_swig_py_gengen-generate-lock; do \ - sleep 1; \ - done; \ -## -## Succeed if and only if the first process succeeded; exit this -## process returning the status of the generated stamp. -## - test -f $(DEPDIR)/gnuradio_swig_py_gengen-generate-stamp; \ - exit $$?; \ - fi; - -$(DEPDIR)/gnuradio_swig_py_gengen-generate-stamp: -## This rule will be called only by the first process issuing the -## above rule to succeed in creating the lock directory, after -## removing the actual stamp file in order to guarantee that MAKE will -## execute this rule. -## -## Call SWIG to generate the various output files; special -## post-processing on 'mingw32' host OS for the dependency file. -## - if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(gnuradio_swig_py_gengen_swig_args) \ - -MD -MF $(DEPDIR)/gnuradio_swig_py_gengen.Std \ - -module gnuradio_swig_py_gengen -o gnuradio_swig_py_gengen.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/gnuradio_swig_py_gengen.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/gnuradio_swig_py_gengen.Std \ - > $(DEPDIR)/gnuradio_swig_py_gengen.Sd; \ - $(RM) $(DEPDIR)/gnuradio_swig_py_gengen.Std; \ - $(MV) $(DEPDIR)/gnuradio_swig_py_gengen.Sd $(DEPDIR)/gnuradio_swig_py_gengen.Std; \ - fi; \ - else \ - $(RM) $(DEPDIR)/gnuradio_swig_py_gengen.S*; exit 1; \ - fi; -## -## Mess with the SWIG output .Std dependency file, to create a -## dependecy file valid for the input .i file: Basically, simulate the -## dependency file created for libraries by GNU's libtool for C++, -## where all of the dependencies for the target are first listed, then -## each individual dependency is listed as a target with no further -## dependencies. -## -## (1) remove the current dependency file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_gengen.d -## -## (2) Copy the whole SWIG file: -## - cp $(DEPDIR)/gnuradio_swig_py_gengen.Std $(DEPDIR)/gnuradio_swig_py_gengen.d -## -## (3) all a carriage return to the end of the dependency file. -## - echo "" >> $(DEPDIR)/gnuradio_swig_py_gengen.d -## -## (4) from the SWIG file, remove the first line (the target); remove -## trailing " \" and " " from each line. Append ":" to each line, -## followed by 2 carriage returns, then append this to the end of -## the dependency file. -## - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/gnuradio_swig_py_gengen.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/gnuradio_swig_py_gengen.d -## -## (5) remove the SWIG-generated file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_gengen.Std -## -## Create the stamp for this filename generation, to signal success in -## executing this rule; allows other threads waiting on this process -## to continue. -## - touch $(DEPDIR)/gnuradio_swig_py_gengen-generate-stamp +endif # end of if python + +if GUILE + +gnuradio_core_gengen_scmlib_LTLIBRARIES = \ + libguile-gnuradio-gnuradio_core_gengen.la +libguile_gnuradio_gnuradio_core_gengen_la_SOURCES = \ + guile/gnuradio_core_gengen.cc \ + $(gnuradio_core_gengen_la_swig_sources) +nobase_gnuradio_core_gengen_scm_DATA = \ + gnuradio/gnuradio_core_gengen.scm \ + gnuradio/gnuradio_core_gengen-primitive.scm +libguile_gnuradio_gnuradio_core_gengen_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(gnuradio_core_gengen_la_swig_libadd) +libguile_gnuradio_gnuradio_core_gengen_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(gnuradio_core_gengen_la_swig_ldflags) +libguile_gnuradio_gnuradio_core_gengen_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(gnuradio_core_gengen_la_swig_cxxflags) + +guile/gnuradio_core_gengen.cc: gnuradio/gnuradio_core_gengen.scm +gnuradio/gnuradio_core_gengen.scm: gnuradio_core_gengen.i +gnuradio/gnuradio_core_gengen-primitive.scm: gnuradio/gnuradio_core_gengen.scm + +# Include the guile dependencies for this file +-include guile/gnuradio_core_gengen.d -# KLUDGE: Force runtime include of a SWIG dependency file. This is -# not guaranteed to be portable, but will probably work. If it works, -# we have accurate dependencies for our swig stuff, which is good. +endif # end of GUILE -@am__include@ @am__quote@./$(DEPDIR)/gnuradio_swig_py_gengen.d@am__quote@ # -*- Makefile -*- # @@ -797,27 +455,37 @@ $(DEPDIR)/gnuradio_swig_py_gengen-generate-stamp: # Boston, MA 02110-1301, USA. # -# Makefile.swig.gen for gnuradio_swig_py_filter.i +# Makefile.swig.gen for gnuradio_core_filter.i ## Default install locations for these files: ## ## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_filter +## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_filter ## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_filter +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_filter ## ## The following can be overloaded to change the install location, but ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -gnuradio_swig_py_filter_pythondir_category ?= gnuradio/gnuradio_swig_py_filter -gnuradio_swig_py_filter_pylibdir_category ?= $(gnuradio_swig_py_filter_pythondir_category) -gnuradio_swig_py_filter_pythondir = $(pythondir)/$(gnuradio_swig_py_filter_pythondir_category) -gnuradio_swig_py_filter_pylibdir = $(pyexecdir)/$(gnuradio_swig_py_filter_pylibdir_category) +gnuradio_core_filter_pythondir_category ?= gnuradio/gnuradio_core_filter +gnuradio_core_filter_pylibdir_category ?= $(gnuradio_core_filter_pythondir_category) +gnuradio_core_filter_pythondir = $(pythondir)/$(gnuradio_core_filter_pythondir_category) +gnuradio_core_filter_pylibdir = $(pyexecdir)/$(gnuradio_core_filter_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_filter_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/gnuradio_core_filter +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_filter_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -gnuradio_swig_py_filter_swigincludedir = $(swigincludedir) +gnuradio_core_filter_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -834,205 +502,81 @@ gnuradio_swig_py_filter_swigincludedir = $(swigincludedir) ## right thing. For more info, see < ## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > -## Stamps used to ensure parallel make does the right thing. These -## are removed by "make clean", but otherwise unused except during the -## parallel built. These will not be included in a tarball, because -## the SWIG-generated files will be removed from the distribution. - -STAMPS += $(DEPDIR)/gnuradio_swig_py_filter-generate-* - ## Other cleaned files: dependency files generated by SWIG or this Makefile MOSTLYCLEANFILES += $(DEPDIR)/*.S* -## Add the .py and .cc files to the list of SWIG built sources. The -## .h file is sometimes built, but not always ... so that one has to -## be added manually by the including Makefile.am . - -swig_built_sources += gnuradio_swig_py_filter.py gnuradio_swig_py_filter.cc - ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . -gnuradio_swig_py_filter_swiginclude_HEADERS = \ - gnuradio_swig_py_filter.i \ - $(gnuradio_swig_py_filter_swiginclude_headers) +gnuradio_core_filter_swiginclude_HEADERS = \ + gnuradio_core_filter.i \ + $(gnuradio_core_filter_swiginclude_headers) + +if PYTHON +gnuradio_core_filter_pylib_LTLIBRARIES = \ + _gnuradio_core_filter.la -gnuradio_swig_py_filter_pylib_LTLIBRARIES = \ - _gnuradio_swig_py_filter.la +_gnuradio_core_filter_la_SOURCES = \ + python/gnuradio_core_filter.cc \ + $(gnuradio_core_filter_la_swig_sources) -_gnuradio_swig_py_filter_la_SOURCES = \ - gnuradio_swig_py_filter.cc \ - $(gnuradio_swig_py_filter_la_swig_sources) +gnuradio_core_filter_python_PYTHON = \ + gnuradio_core_filter.py \ + $(gnuradio_core_filter_python) -_gnuradio_swig_py_filter_la_LIBADD = \ +_gnuradio_core_filter_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ - $(gnuradio_swig_py_filter_la_swig_libadd) + $(gnuradio_core_filter_la_swig_libadd) -_gnuradio_swig_py_filter_la_LDFLAGS = \ +_gnuradio_core_filter_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ - $(gnuradio_swig_py_filter_la_swig_ldflags) + $(gnuradio_core_filter_la_swig_ldflags) -_gnuradio_swig_py_filter_la_CXXFLAGS = \ +_gnuradio_core_filter_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ - $(gnuradio_swig_py_filter_la_swig_cxxflags) + -I$(top_builddir) \ + $(gnuradio_core_filter_la_swig_cxxflags) -gnuradio_swig_py_filter_python_PYTHON = \ - gnuradio_swig_py_filter.py \ - $(gnuradio_swig_py_filter_python) +python/gnuradio_core_filter.cc: gnuradio_core_filter.py +gnuradio_core_filter.py: gnuradio_core_filter.i -## Entry rule for running SWIG +# Include the python dependencies for this file +-include python/gnuradio_core_filter.d -gnuradio_swig_py_filter.h gnuradio_swig_py_filter.py gnuradio_swig_py_filter.cc: gnuradio_swig_py_filter.i -## This rule will get called only when MAKE decides that one of the -## targets needs to be created or re-created, because: -## -## * The .i file is newer than any or all of the generated files; -## -## * Any or all of the .cc, .h, or .py files does not exist and is -## needed (in the case this file is not needed, the rule for it is -## ignored); or -## -## * Some SWIG-based dependecy of the .cc file isn't met and hence the -## .cc file needs be be regenerated. Explanation: Because MAKE -## knows how to handle dependencies for .cc files (regardless of -## their name or extension), then the .cc file is used as a target -## instead of the .i file -- but with the dependencies of the .i -## file. It is this last reason why the line: -## -## if test -f $@; then :; else -## -## cannot be used in this case: If a .i file dependecy is not met, -## then the .cc file needs to be rebuilt. But if the stamp is newer -## than the .cc file, and the .cc file exists, then in the original -## version (with the 'test' above) the internal MAKE call will not -## be issued and hence the .cc file will not be rebuilt. -## -## Once execution gets to here, it should always proceed no matter the -## state of a stamp (as discussed in link above). The -## $(DEPDIR)/gnuradio_swig_py_filter-generate stuff is used to allow for parallel -## builds to "do the right thing". The stamp has no relationship with -## either the target files or dependency file; it is used solely for -## the protection of multiple builds during a given call to MAKE. -## -## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM -## (15). At a caught signal, the quoted command will be issued before -## exiting. In this case, remove any stamp, whether temporary of not. -## The trap is valid until the process exits; the process includes all -## commands appended via "\"s. -## - trap 'rm -rf $(DEPDIR)/gnuradio_swig_py_filter-generate-*' 1 2 13 15; \ -## -## Create a temporary directory, which acts as a lock. The first -## process to create the directory will succeed and issue the MAKE -## command to do the actual work, while all subsequent processes will -## fail -- leading them to wait for the first process to finish. -## - if mkdir $(DEPDIR)/gnuradio_swig_py_filter-generate-lock 2>/dev/null; then \ -## -## This code is being executed by the first process to succeed in -## creating the directory lock. -## -## Remove the stamp associated with this filename. -## - rm -f $(DEPDIR)/gnuradio_swig_py_filter-generate-stamp; \ -## -## Tell MAKE to run the rule for creating this stamp. -## - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/gnuradio_swig_py_filter-generate-stamp WHAT=$<; \ -## -## Now that the .cc, .h, and .py files have been (re)created from the -## .i file, future checking of this rule during the same MAKE -## execution will come back that the rule doesn't need to be executed -## because none of the conditions mentioned at the start of this rule -## will be positive. Remove the the directory lock, which frees up -## any waiting process(es) to continue. -## - rmdir $(DEPDIR)/gnuradio_swig_py_filter-generate-lock; \ - else \ -## -## This code is being executed by any follower processes while the -## directory lock is in place. -## -## Wait until the first process is done, testing once per second. -## - while test -d $(DEPDIR)/gnuradio_swig_py_filter-generate-lock; do \ - sleep 1; \ - done; \ -## -## Succeed if and only if the first process succeeded; exit this -## process returning the status of the generated stamp. -## - test -f $(DEPDIR)/gnuradio_swig_py_filter-generate-stamp; \ - exit $$?; \ - fi; - -$(DEPDIR)/gnuradio_swig_py_filter-generate-stamp: -## This rule will be called only by the first process issuing the -## above rule to succeed in creating the lock directory, after -## removing the actual stamp file in order to guarantee that MAKE will -## execute this rule. -## -## Call SWIG to generate the various output files; special -## post-processing on 'mingw32' host OS for the dependency file. -## - if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(gnuradio_swig_py_filter_swig_args) \ - -MD -MF $(DEPDIR)/gnuradio_swig_py_filter.Std \ - -module gnuradio_swig_py_filter -o gnuradio_swig_py_filter.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/gnuradio_swig_py_filter.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/gnuradio_swig_py_filter.Std \ - > $(DEPDIR)/gnuradio_swig_py_filter.Sd; \ - $(RM) $(DEPDIR)/gnuradio_swig_py_filter.Std; \ - $(MV) $(DEPDIR)/gnuradio_swig_py_filter.Sd $(DEPDIR)/gnuradio_swig_py_filter.Std; \ - fi; \ - else \ - $(RM) $(DEPDIR)/gnuradio_swig_py_filter.S*; exit 1; \ - fi; -## -## Mess with the SWIG output .Std dependency file, to create a -## dependecy file valid for the input .i file: Basically, simulate the -## dependency file created for libraries by GNU's libtool for C++, -## where all of the dependencies for the target are first listed, then -## each individual dependency is listed as a target with no further -## dependencies. -## -## (1) remove the current dependency file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_filter.d -## -## (2) Copy the whole SWIG file: -## - cp $(DEPDIR)/gnuradio_swig_py_filter.Std $(DEPDIR)/gnuradio_swig_py_filter.d -## -## (3) all a carriage return to the end of the dependency file. -## - echo "" >> $(DEPDIR)/gnuradio_swig_py_filter.d -## -## (4) from the SWIG file, remove the first line (the target); remove -## trailing " \" and " " from each line. Append ":" to each line, -## followed by 2 carriage returns, then append this to the end of -## the dependency file. -## - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/gnuradio_swig_py_filter.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/gnuradio_swig_py_filter.d -## -## (5) remove the SWIG-generated file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_filter.Std -## -## Create the stamp for this filename generation, to signal success in -## executing this rule; allows other threads waiting on this process -## to continue. -## - touch $(DEPDIR)/gnuradio_swig_py_filter-generate-stamp +endif # end of if python + +if GUILE + +gnuradio_core_filter_scmlib_LTLIBRARIES = \ + libguile-gnuradio-gnuradio_core_filter.la +libguile_gnuradio_gnuradio_core_filter_la_SOURCES = \ + guile/gnuradio_core_filter.cc \ + $(gnuradio_core_filter_la_swig_sources) +nobase_gnuradio_core_filter_scm_DATA = \ + gnuradio/gnuradio_core_filter.scm \ + gnuradio/gnuradio_core_filter-primitive.scm +libguile_gnuradio_gnuradio_core_filter_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(gnuradio_core_filter_la_swig_libadd) +libguile_gnuradio_gnuradio_core_filter_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(gnuradio_core_filter_la_swig_ldflags) +libguile_gnuradio_gnuradio_core_filter_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(gnuradio_core_filter_la_swig_cxxflags) -# KLUDGE: Force runtime include of a SWIG dependency file. This is -# not guaranteed to be portable, but will probably work. If it works, -# we have accurate dependencies for our swig stuff, which is good. +guile/gnuradio_core_filter.cc: gnuradio/gnuradio_core_filter.scm +gnuradio/gnuradio_core_filter.scm: gnuradio_core_filter.i +gnuradio/gnuradio_core_filter-primitive.scm: gnuradio/gnuradio_core_filter.scm + +# Include the guile dependencies for this file +-include guile/gnuradio_core_filter.d + +endif # end of GUILE -@am__include@ @am__quote@./$(DEPDIR)/gnuradio_swig_py_filter.d@am__quote@ # -*- Makefile -*- # @@ -1056,27 +600,37 @@ $(DEPDIR)/gnuradio_swig_py_filter-generate-stamp: # Boston, MA 02110-1301, USA. # -# Makefile.swig.gen for gnuradio_swig_py_io.i +# Makefile.swig.gen for gnuradio_core_io.i ## Default install locations for these files: ## ## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_io +## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_io ## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_io +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_io ## ## The following can be overloaded to change the install location, but ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -gnuradio_swig_py_io_pythondir_category ?= gnuradio/gnuradio_swig_py_io -gnuradio_swig_py_io_pylibdir_category ?= $(gnuradio_swig_py_io_pythondir_category) -gnuradio_swig_py_io_pythondir = $(pythondir)/$(gnuradio_swig_py_io_pythondir_category) -gnuradio_swig_py_io_pylibdir = $(pyexecdir)/$(gnuradio_swig_py_io_pylibdir_category) +gnuradio_core_io_pythondir_category ?= gnuradio/gnuradio_core_io +gnuradio_core_io_pylibdir_category ?= $(gnuradio_core_io_pythondir_category) +gnuradio_core_io_pythondir = $(pythondir)/$(gnuradio_core_io_pythondir_category) +gnuradio_core_io_pylibdir = $(pyexecdir)/$(gnuradio_core_io_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_io_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/gnuradio_core_io +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_io_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -gnuradio_swig_py_io_swigincludedir = $(swigincludedir) +gnuradio_core_io_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -1093,205 +647,81 @@ gnuradio_swig_py_io_swigincludedir = $(swigincludedir) ## right thing. For more info, see < ## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > -## Stamps used to ensure parallel make does the right thing. These -## are removed by "make clean", but otherwise unused except during the -## parallel built. These will not be included in a tarball, because -## the SWIG-generated files will be removed from the distribution. - -STAMPS += $(DEPDIR)/gnuradio_swig_py_io-generate-* - ## Other cleaned files: dependency files generated by SWIG or this Makefile MOSTLYCLEANFILES += $(DEPDIR)/*.S* -## Add the .py and .cc files to the list of SWIG built sources. The -## .h file is sometimes built, but not always ... so that one has to -## be added manually by the including Makefile.am . - -swig_built_sources += gnuradio_swig_py_io.py gnuradio_swig_py_io.cc - ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . -gnuradio_swig_py_io_swiginclude_HEADERS = \ - gnuradio_swig_py_io.i \ - $(gnuradio_swig_py_io_swiginclude_headers) +gnuradio_core_io_swiginclude_HEADERS = \ + gnuradio_core_io.i \ + $(gnuradio_core_io_swiginclude_headers) + +if PYTHON +gnuradio_core_io_pylib_LTLIBRARIES = \ + _gnuradio_core_io.la -gnuradio_swig_py_io_pylib_LTLIBRARIES = \ - _gnuradio_swig_py_io.la +_gnuradio_core_io_la_SOURCES = \ + python/gnuradio_core_io.cc \ + $(gnuradio_core_io_la_swig_sources) -_gnuradio_swig_py_io_la_SOURCES = \ - gnuradio_swig_py_io.cc \ - $(gnuradio_swig_py_io_la_swig_sources) +gnuradio_core_io_python_PYTHON = \ + gnuradio_core_io.py \ + $(gnuradio_core_io_python) -_gnuradio_swig_py_io_la_LIBADD = \ +_gnuradio_core_io_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ - $(gnuradio_swig_py_io_la_swig_libadd) + $(gnuradio_core_io_la_swig_libadd) -_gnuradio_swig_py_io_la_LDFLAGS = \ +_gnuradio_core_io_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ - $(gnuradio_swig_py_io_la_swig_ldflags) + $(gnuradio_core_io_la_swig_ldflags) -_gnuradio_swig_py_io_la_CXXFLAGS = \ +_gnuradio_core_io_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ - $(gnuradio_swig_py_io_la_swig_cxxflags) + -I$(top_builddir) \ + $(gnuradio_core_io_la_swig_cxxflags) -gnuradio_swig_py_io_python_PYTHON = \ - gnuradio_swig_py_io.py \ - $(gnuradio_swig_py_io_python) +python/gnuradio_core_io.cc: gnuradio_core_io.py +gnuradio_core_io.py: gnuradio_core_io.i -## Entry rule for running SWIG +# Include the python dependencies for this file +-include python/gnuradio_core_io.d -gnuradio_swig_py_io.h gnuradio_swig_py_io.py gnuradio_swig_py_io.cc: gnuradio_swig_py_io.i -## This rule will get called only when MAKE decides that one of the -## targets needs to be created or re-created, because: -## -## * The .i file is newer than any or all of the generated files; -## -## * Any or all of the .cc, .h, or .py files does not exist and is -## needed (in the case this file is not needed, the rule for it is -## ignored); or -## -## * Some SWIG-based dependecy of the .cc file isn't met and hence the -## .cc file needs be be regenerated. Explanation: Because MAKE -## knows how to handle dependencies for .cc files (regardless of -## their name or extension), then the .cc file is used as a target -## instead of the .i file -- but with the dependencies of the .i -## file. It is this last reason why the line: -## -## if test -f $@; then :; else -## -## cannot be used in this case: If a .i file dependecy is not met, -## then the .cc file needs to be rebuilt. But if the stamp is newer -## than the .cc file, and the .cc file exists, then in the original -## version (with the 'test' above) the internal MAKE call will not -## be issued and hence the .cc file will not be rebuilt. -## -## Once execution gets to here, it should always proceed no matter the -## state of a stamp (as discussed in link above). The -## $(DEPDIR)/gnuradio_swig_py_io-generate stuff is used to allow for parallel -## builds to "do the right thing". The stamp has no relationship with -## either the target files or dependency file; it is used solely for -## the protection of multiple builds during a given call to MAKE. -## -## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM -## (15). At a caught signal, the quoted command will be issued before -## exiting. In this case, remove any stamp, whether temporary of not. -## The trap is valid until the process exits; the process includes all -## commands appended via "\"s. -## - trap 'rm -rf $(DEPDIR)/gnuradio_swig_py_io-generate-*' 1 2 13 15; \ -## -## Create a temporary directory, which acts as a lock. The first -## process to create the directory will succeed and issue the MAKE -## command to do the actual work, while all subsequent processes will -## fail -- leading them to wait for the first process to finish. -## - if mkdir $(DEPDIR)/gnuradio_swig_py_io-generate-lock 2>/dev/null; then \ -## -## This code is being executed by the first process to succeed in -## creating the directory lock. -## -## Remove the stamp associated with this filename. -## - rm -f $(DEPDIR)/gnuradio_swig_py_io-generate-stamp; \ -## -## Tell MAKE to run the rule for creating this stamp. -## - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/gnuradio_swig_py_io-generate-stamp WHAT=$<; \ -## -## Now that the .cc, .h, and .py files have been (re)created from the -## .i file, future checking of this rule during the same MAKE -## execution will come back that the rule doesn't need to be executed -## because none of the conditions mentioned at the start of this rule -## will be positive. Remove the the directory lock, which frees up -## any waiting process(es) to continue. -## - rmdir $(DEPDIR)/gnuradio_swig_py_io-generate-lock; \ - else \ -## -## This code is being executed by any follower processes while the -## directory lock is in place. -## -## Wait until the first process is done, testing once per second. -## - while test -d $(DEPDIR)/gnuradio_swig_py_io-generate-lock; do \ - sleep 1; \ - done; \ -## -## Succeed if and only if the first process succeeded; exit this -## process returning the status of the generated stamp. -## - test -f $(DEPDIR)/gnuradio_swig_py_io-generate-stamp; \ - exit $$?; \ - fi; - -$(DEPDIR)/gnuradio_swig_py_io-generate-stamp: -## This rule will be called only by the first process issuing the -## above rule to succeed in creating the lock directory, after -## removing the actual stamp file in order to guarantee that MAKE will -## execute this rule. -## -## Call SWIG to generate the various output files; special -## post-processing on 'mingw32' host OS for the dependency file. -## - if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(gnuradio_swig_py_io_swig_args) \ - -MD -MF $(DEPDIR)/gnuradio_swig_py_io.Std \ - -module gnuradio_swig_py_io -o gnuradio_swig_py_io.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/gnuradio_swig_py_io.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/gnuradio_swig_py_io.Std \ - > $(DEPDIR)/gnuradio_swig_py_io.Sd; \ - $(RM) $(DEPDIR)/gnuradio_swig_py_io.Std; \ - $(MV) $(DEPDIR)/gnuradio_swig_py_io.Sd $(DEPDIR)/gnuradio_swig_py_io.Std; \ - fi; \ - else \ - $(RM) $(DEPDIR)/gnuradio_swig_py_io.S*; exit 1; \ - fi; -## -## Mess with the SWIG output .Std dependency file, to create a -## dependecy file valid for the input .i file: Basically, simulate the -## dependency file created for libraries by GNU's libtool for C++, -## where all of the dependencies for the target are first listed, then -## each individual dependency is listed as a target with no further -## dependencies. -## -## (1) remove the current dependency file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_io.d -## -## (2) Copy the whole SWIG file: -## - cp $(DEPDIR)/gnuradio_swig_py_io.Std $(DEPDIR)/gnuradio_swig_py_io.d -## -## (3) all a carriage return to the end of the dependency file. -## - echo "" >> $(DEPDIR)/gnuradio_swig_py_io.d -## -## (4) from the SWIG file, remove the first line (the target); remove -## trailing " \" and " " from each line. Append ":" to each line, -## followed by 2 carriage returns, then append this to the end of -## the dependency file. -## - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/gnuradio_swig_py_io.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/gnuradio_swig_py_io.d -## -## (5) remove the SWIG-generated file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_io.Std -## -## Create the stamp for this filename generation, to signal success in -## executing this rule; allows other threads waiting on this process -## to continue. -## - touch $(DEPDIR)/gnuradio_swig_py_io-generate-stamp +endif # end of if python + +if GUILE -# KLUDGE: Force runtime include of a SWIG dependency file. This is -# not guaranteed to be portable, but will probably work. If it works, -# we have accurate dependencies for our swig stuff, which is good. +gnuradio_core_io_scmlib_LTLIBRARIES = \ + libguile-gnuradio-gnuradio_core_io.la +libguile_gnuradio_gnuradio_core_io_la_SOURCES = \ + guile/gnuradio_core_io.cc \ + $(gnuradio_core_io_la_swig_sources) +nobase_gnuradio_core_io_scm_DATA = \ + gnuradio/gnuradio_core_io.scm \ + gnuradio/gnuradio_core_io-primitive.scm +libguile_gnuradio_gnuradio_core_io_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(gnuradio_core_io_la_swig_libadd) +libguile_gnuradio_gnuradio_core_io_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(gnuradio_core_io_la_swig_ldflags) +libguile_gnuradio_gnuradio_core_io_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(gnuradio_core_io_la_swig_cxxflags) + +guile/gnuradio_core_io.cc: gnuradio/gnuradio_core_io.scm +gnuradio/gnuradio_core_io.scm: gnuradio_core_io.i +gnuradio/gnuradio_core_io-primitive.scm: gnuradio/gnuradio_core_io.scm + +# Include the guile dependencies for this file +-include guile/gnuradio_core_io.d + +endif # end of GUILE -@am__include@ @am__quote@./$(DEPDIR)/gnuradio_swig_py_io.d@am__quote@ # -*- Makefile -*- # @@ -1315,27 +745,37 @@ $(DEPDIR)/gnuradio_swig_py_io-generate-stamp: # Boston, MA 02110-1301, USA. # -# Makefile.swig.gen for gnuradio_swig_py_hier.i +# Makefile.swig.gen for gnuradio_core_hier.i ## Default install locations for these files: ## ## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_hier +## ${prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_hier ## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_swig_py_hier +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/gnuradio_core_hier ## ## The following can be overloaded to change the install location, but ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -gnuradio_swig_py_hier_pythondir_category ?= gnuradio/gnuradio_swig_py_hier -gnuradio_swig_py_hier_pylibdir_category ?= $(gnuradio_swig_py_hier_pythondir_category) -gnuradio_swig_py_hier_pythondir = $(pythondir)/$(gnuradio_swig_py_hier_pythondir_category) -gnuradio_swig_py_hier_pylibdir = $(pyexecdir)/$(gnuradio_swig_py_hier_pylibdir_category) +gnuradio_core_hier_pythondir_category ?= gnuradio/gnuradio_core_hier +gnuradio_core_hier_pylibdir_category ?= $(gnuradio_core_hier_pythondir_category) +gnuradio_core_hier_pythondir = $(pythondir)/$(gnuradio_core_hier_pythondir_category) +gnuradio_core_hier_pylibdir = $(pyexecdir)/$(gnuradio_core_hier_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_hier_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/gnuradio_core_hier +# FIXME: determince whether these should be installed with gnuradio. +gnuradio_core_hier_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -gnuradio_swig_py_hier_swigincludedir = $(swigincludedir) +gnuradio_core_hier_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -1352,203 +792,79 @@ gnuradio_swig_py_hier_swigincludedir = $(swigincludedir) ## right thing. For more info, see < ## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > -## Stamps used to ensure parallel make does the right thing. These -## are removed by "make clean", but otherwise unused except during the -## parallel built. These will not be included in a tarball, because -## the SWIG-generated files will be removed from the distribution. - -STAMPS += $(DEPDIR)/gnuradio_swig_py_hier-generate-* - ## Other cleaned files: dependency files generated by SWIG or this Makefile MOSTLYCLEANFILES += $(DEPDIR)/*.S* -## Add the .py and .cc files to the list of SWIG built sources. The -## .h file is sometimes built, but not always ... so that one has to -## be added manually by the including Makefile.am . - -swig_built_sources += gnuradio_swig_py_hier.py gnuradio_swig_py_hier.cc - ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . -gnuradio_swig_py_hier_swiginclude_HEADERS = \ - gnuradio_swig_py_hier.i \ - $(gnuradio_swig_py_hier_swiginclude_headers) +gnuradio_core_hier_swiginclude_HEADERS = \ + gnuradio_core_hier.i \ + $(gnuradio_core_hier_swiginclude_headers) + +if PYTHON +gnuradio_core_hier_pylib_LTLIBRARIES = \ + _gnuradio_core_hier.la -gnuradio_swig_py_hier_pylib_LTLIBRARIES = \ - _gnuradio_swig_py_hier.la +_gnuradio_core_hier_la_SOURCES = \ + python/gnuradio_core_hier.cc \ + $(gnuradio_core_hier_la_swig_sources) -_gnuradio_swig_py_hier_la_SOURCES = \ - gnuradio_swig_py_hier.cc \ - $(gnuradio_swig_py_hier_la_swig_sources) +gnuradio_core_hier_python_PYTHON = \ + gnuradio_core_hier.py \ + $(gnuradio_core_hier_python) -_gnuradio_swig_py_hier_la_LIBADD = \ +_gnuradio_core_hier_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ - $(gnuradio_swig_py_hier_la_swig_libadd) + $(gnuradio_core_hier_la_swig_libadd) -_gnuradio_swig_py_hier_la_LDFLAGS = \ +_gnuradio_core_hier_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ - $(gnuradio_swig_py_hier_la_swig_ldflags) + $(gnuradio_core_hier_la_swig_ldflags) -_gnuradio_swig_py_hier_la_CXXFLAGS = \ +_gnuradio_core_hier_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ - $(gnuradio_swig_py_hier_la_swig_cxxflags) + -I$(top_builddir) \ + $(gnuradio_core_hier_la_swig_cxxflags) -gnuradio_swig_py_hier_python_PYTHON = \ - gnuradio_swig_py_hier.py \ - $(gnuradio_swig_py_hier_python) +python/gnuradio_core_hier.cc: gnuradio_core_hier.py +gnuradio_core_hier.py: gnuradio_core_hier.i -## Entry rule for running SWIG +# Include the python dependencies for this file +-include python/gnuradio_core_hier.d -gnuradio_swig_py_hier.h gnuradio_swig_py_hier.py gnuradio_swig_py_hier.cc: gnuradio_swig_py_hier.i -## This rule will get called only when MAKE decides that one of the -## targets needs to be created or re-created, because: -## -## * The .i file is newer than any or all of the generated files; -## -## * Any or all of the .cc, .h, or .py files does not exist and is -## needed (in the case this file is not needed, the rule for it is -## ignored); or -## -## * Some SWIG-based dependecy of the .cc file isn't met and hence the -## .cc file needs be be regenerated. Explanation: Because MAKE -## knows how to handle dependencies for .cc files (regardless of -## their name or extension), then the .cc file is used as a target -## instead of the .i file -- but with the dependencies of the .i -## file. It is this last reason why the line: -## -## if test -f $@; then :; else -## -## cannot be used in this case: If a .i file dependecy is not met, -## then the .cc file needs to be rebuilt. But if the stamp is newer -## than the .cc file, and the .cc file exists, then in the original -## version (with the 'test' above) the internal MAKE call will not -## be issued and hence the .cc file will not be rebuilt. -## -## Once execution gets to here, it should always proceed no matter the -## state of a stamp (as discussed in link above). The -## $(DEPDIR)/gnuradio_swig_py_hier-generate stuff is used to allow for parallel -## builds to "do the right thing". The stamp has no relationship with -## either the target files or dependency file; it is used solely for -## the protection of multiple builds during a given call to MAKE. -## -## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM -## (15). At a caught signal, the quoted command will be issued before -## exiting. In this case, remove any stamp, whether temporary of not. -## The trap is valid until the process exits; the process includes all -## commands appended via "\"s. -## - trap 'rm -rf $(DEPDIR)/gnuradio_swig_py_hier-generate-*' 1 2 13 15; \ -## -## Create a temporary directory, which acts as a lock. The first -## process to create the directory will succeed and issue the MAKE -## command to do the actual work, while all subsequent processes will -## fail -- leading them to wait for the first process to finish. -## - if mkdir $(DEPDIR)/gnuradio_swig_py_hier-generate-lock 2>/dev/null; then \ -## -## This code is being executed by the first process to succeed in -## creating the directory lock. -## -## Remove the stamp associated with this filename. -## - rm -f $(DEPDIR)/gnuradio_swig_py_hier-generate-stamp; \ -## -## Tell MAKE to run the rule for creating this stamp. -## - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/gnuradio_swig_py_hier-generate-stamp WHAT=$<; \ -## -## Now that the .cc, .h, and .py files have been (re)created from the -## .i file, future checking of this rule during the same MAKE -## execution will come back that the rule doesn't need to be executed -## because none of the conditions mentioned at the start of this rule -## will be positive. Remove the the directory lock, which frees up -## any waiting process(es) to continue. -## - rmdir $(DEPDIR)/gnuradio_swig_py_hier-generate-lock; \ - else \ -## -## This code is being executed by any follower processes while the -## directory lock is in place. -## -## Wait until the first process is done, testing once per second. -## - while test -d $(DEPDIR)/gnuradio_swig_py_hier-generate-lock; do \ - sleep 1; \ - done; \ -## -## Succeed if and only if the first process succeeded; exit this -## process returning the status of the generated stamp. -## - test -f $(DEPDIR)/gnuradio_swig_py_hier-generate-stamp; \ - exit $$?; \ - fi; - -$(DEPDIR)/gnuradio_swig_py_hier-generate-stamp: -## This rule will be called only by the first process issuing the -## above rule to succeed in creating the lock directory, after -## removing the actual stamp file in order to guarantee that MAKE will -## execute this rule. -## -## Call SWIG to generate the various output files; special -## post-processing on 'mingw32' host OS for the dependency file. -## - if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(gnuradio_swig_py_hier_swig_args) \ - -MD -MF $(DEPDIR)/gnuradio_swig_py_hier.Std \ - -module gnuradio_swig_py_hier -o gnuradio_swig_py_hier.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/gnuradio_swig_py_hier.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/gnuradio_swig_py_hier.Std \ - > $(DEPDIR)/gnuradio_swig_py_hier.Sd; \ - $(RM) $(DEPDIR)/gnuradio_swig_py_hier.Std; \ - $(MV) $(DEPDIR)/gnuradio_swig_py_hier.Sd $(DEPDIR)/gnuradio_swig_py_hier.Std; \ - fi; \ - else \ - $(RM) $(DEPDIR)/gnuradio_swig_py_hier.S*; exit 1; \ - fi; -## -## Mess with the SWIG output .Std dependency file, to create a -## dependecy file valid for the input .i file: Basically, simulate the -## dependency file created for libraries by GNU's libtool for C++, -## where all of the dependencies for the target are first listed, then -## each individual dependency is listed as a target with no further -## dependencies. -## -## (1) remove the current dependency file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_hier.d -## -## (2) Copy the whole SWIG file: -## - cp $(DEPDIR)/gnuradio_swig_py_hier.Std $(DEPDIR)/gnuradio_swig_py_hier.d -## -## (3) all a carriage return to the end of the dependency file. -## - echo "" >> $(DEPDIR)/gnuradio_swig_py_hier.d -## -## (4) from the SWIG file, remove the first line (the target); remove -## trailing " \" and " " from each line. Append ":" to each line, -## followed by 2 carriage returns, then append this to the end of -## the dependency file. -## - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/gnuradio_swig_py_hier.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/gnuradio_swig_py_hier.d -## -## (5) remove the SWIG-generated file -## - $(RM) $(DEPDIR)/gnuradio_swig_py_hier.Std -## -## Create the stamp for this filename generation, to signal success in -## executing this rule; allows other threads waiting on this process -## to continue. -## - touch $(DEPDIR)/gnuradio_swig_py_hier-generate-stamp +endif # end of if python + +if GUILE + +gnuradio_core_hier_scmlib_LTLIBRARIES = \ + libguile-gnuradio-gnuradio_core_hier.la +libguile_gnuradio_gnuradio_core_hier_la_SOURCES = \ + guile/gnuradio_core_hier.cc \ + $(gnuradio_core_hier_la_swig_sources) +nobase_gnuradio_core_hier_scm_DATA = \ + gnuradio/gnuradio_core_hier.scm \ + gnuradio/gnuradio_core_hier-primitive.scm +libguile_gnuradio_gnuradio_core_hier_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(gnuradio_core_hier_la_swig_libadd) +libguile_gnuradio_gnuradio_core_hier_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(gnuradio_core_hier_la_swig_ldflags) +libguile_gnuradio_gnuradio_core_hier_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(gnuradio_core_hier_la_swig_cxxflags) + +guile/gnuradio_core_hier.cc: gnuradio/gnuradio_core_hier.scm +gnuradio/gnuradio_core_hier.scm: gnuradio_core_hier.i +gnuradio/gnuradio_core_hier-primitive.scm: gnuradio/gnuradio_core_hier.scm + +# Include the guile dependencies for this file +-include guile/gnuradio_core_hier.d -# KLUDGE: Force runtime include of a SWIG dependency file. This is -# not guaranteed to be portable, but will probably work. If it works, -# we have accurate dependencies for our swig stuff, which is good. +endif # end of GUILE -@am__include@ @am__quote@./$(DEPDIR)/gnuradio_swig_py_hier.d@am__quote@ diff --git a/gnuradio-core/src/lib/swig/gnuradio.i b/gnuradio-core/src/lib/swig/gnuradio.i index e15a0059c..1601cca12 100644 --- a/gnuradio-core/src/lib/swig/gnuradio.i +++ b/gnuradio-core/src/lib/swig/gnuradio.i @@ -32,6 +32,7 @@ #include "gnuradio_swig_bug_workaround.h" // mandatory bug fix #include <gr_types.h> #include <stddef.h> // size_t +#include <complex> %} %feature("autodoc","1"); @@ -40,8 +41,21 @@ %include <gr_shared_ptr.i> // non-local SWIG files -%include <stl.i> +#ifdef SWIGGUILE // Local overrides to support complex +// It's kind of screwy, but the target language subdir isn't +// searched automatically except for under ./swig_lib which +// doesn't really help us since we run swig in many directories +%include <guile/std_complex.i> +%include <guile/std_vector.i> +%include <std_common.i> +%include <std_string.i> +%include <std_map.i> +%include <std_pair.i> +#else %include <std_complex.i> +%include <std_vector.i> +%include <stl.i> +#endif %include <std_except.i> typedef std::complex<float> gr_complex; @@ -59,6 +73,7 @@ namespace std { %template() vector<int>; %template() vector<float>; %template() vector<double>; + // %template() std::complex<float>; %template() vector< std::complex<float> >; %template() vector< std::vector< unsigned char > >; @@ -72,15 +87,6 @@ namespace std { //////////////////////////////////////////////////////////////////////// -%constant int sizeof_char = sizeof(char); -%constant int sizeof_short = sizeof(short); -%constant int sizeof_int = sizeof(int); -%constant int sizeof_float = sizeof(float); -%constant int sizeof_double = sizeof(double); -%constant int sizeof_gr_complex = sizeof(gr_complex); - -//////////////////////////////////////////////////////////////////////// - #ifndef SW_RUNTIME // import runtime.i for all but sw_runtime, since it needs to %include %import <runtime.i> diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_python.py b/gnuradio-core/src/lib/swig/gnuradio_core.py index 5324b2309..172051013 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_swig_python.py +++ b/gnuradio-core/src/lib/swig/gnuradio_core.py @@ -1,5 +1,5 @@ # -# Copyright 2006,2009 Free Software Foundation, Inc. +# Copyright 2006,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -18,11 +18,11 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -# This file implements the old gnuradio_swig_python namespace +# This file implements the old gnuradio_core namespace -from gnuradio_swig_py_runtime import * -from gnuradio_swig_py_general import * -from gnuradio_swig_py_gengen import * -from gnuradio_swig_py_filter import * -from gnuradio_swig_py_io import * -from gnuradio_swig_py_hier import * +from gnuradio_core_runtime import * +from gnuradio_core_general import * +from gnuradio_core_gengen import * +from gnuradio_core_filter import * +from gnuradio_core_io import * +from gnuradio_core_hier import * diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_py_filter.i b/gnuradio-core/src/lib/swig/gnuradio_core_filter.i index 6396a97d0..d7262f140 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_swig_py_filter.i +++ b/gnuradio-core/src/lib/swig/gnuradio_core_filter.i @@ -1,26 +1,26 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009 Free Software Foundation, Inc. - * + * Copyright 2006,2009,2010 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. */ #ifndef SWIGIMPORTED -%module(directors="1") gnuradio_swig_py_filter +%module(directors="1") gnuradio_core_filter #endif //%feature("autodoc", "1"); // generate python docstrings @@ -28,3 +28,13 @@ %include "gnuradio.i" // the common stuff %include "filter.i" + +#if SWIGGUILE +%scheme %{ +(load-extension "libguile-gnuradio-gnuradio_core_filter" "scm_init_gnuradio_gnuradio_core_filter_module") +%} + +%goops %{ + (use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_py_general.i b/gnuradio-core/src/lib/swig/gnuradio_core_general.i index 3ab1b056a..e381f3509 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_swig_py_general.i +++ b/gnuradio-core/src/lib/swig/gnuradio_core_general.i @@ -1,26 +1,26 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009 Free Software Foundation, Inc. - * + * Copyright 2006,2009,2010 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. */ #ifndef SWIGIMPORTED -%module(directors="1") gnuradio_swig_py_general +%module(directors="1") gnuradio_core_general #endif //%feature("autodoc", "1"); // generate python docstrings @@ -28,3 +28,33 @@ %include "gnuradio.i" // the common stuff %include "general.i" + + // Simple test case for complex input and output +%inline +%{ + std::complex<float> complexf_add_2j(std::complex<float> x) + { + return std::complex<float>(x.real(), x.imag() + 2); + } + + std::complex<double> complexd_add_2j(std::complex<double> x) + { + return std::complex<double>(x.real(), x.imag() + 2); + } + + std::complex<float> complexf_add_x_2j(float x, std::complex<float> y) + { + return std::complex<float>(x + y.real(), y.imag() + 2); + } + +%} + +#if SWIGGUILE +%scheme %{ +(load-extension "libguile-gnuradio-gnuradio_core_general" "scm_init_gnuradio_gnuradio_core_general_module") +%} + +%goops %{ +(use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_py_gengen.i b/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i index 95e85cf6b..d9fe6672a 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_swig_py_gengen.i +++ b/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i @@ -1,26 +1,26 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009 Free Software Foundation, Inc. - * + * Copyright 2006,2009,2010 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. */ #ifndef SWIGIMPORTED -%module(directors="1") gnuradio_swig_py_gengen +%module(directors="1") gnuradio_core_gengen #endif //%feature("autodoc", "1"); // generate python docstrings @@ -28,3 +28,13 @@ %include "gnuradio.i" // the common stuff %include "gengen.i" + +#if SWIGGUILE +%scheme %{ +(load-extension "libguile-gnuradio-gnuradio_core_gengen" "scm_init_gnuradio_gnuradio_core_gengen_module") +%} + +%goops %{ + (use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_py_hier.i b/gnuradio-core/src/lib/swig/gnuradio_core_hier.i index a82b5ae41..2869fd56b 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_swig_py_hier.i +++ b/gnuradio-core/src/lib/swig/gnuradio_core_hier.i @@ -1,26 +1,26 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. - * + * Copyright 2009,2010 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. */ #ifndef SWIGIMPORTED -%module(directors="1") gnuradio_swig_py_hier +%module(directors="1") gnuradio_hier_hier #endif //%feature("autodoc", "1"); // generate python docstrings @@ -28,3 +28,13 @@ %include "gnuradio.i" // the common stuff %include "hier.i" + +#if SWIGGUILE +%scheme %{ +(load-extension "libguile-gnuradio-gnuradio_core_hier" "scm_init_gnuradio_gnuradio_core_hier_module") +%} + +%goops %{ + (use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_py_io.i b/gnuradio-core/src/lib/swig/gnuradio_core_io.i index 9318f5d86..c8d818660 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_swig_py_io.i +++ b/gnuradio-core/src/lib/swig/gnuradio_core_io.i @@ -1,26 +1,26 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009 Free Software Foundation, Inc. - * + * Copyright 2006,2009,2010 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. */ #ifndef SWIGIMPORTED -%module(directors="1") gnuradio_swig_py_io +%module(directors="1") gnuradio_core_io #endif //%feature("autodoc", "1"); // generate python docstrings @@ -28,3 +28,13 @@ %include "gnuradio.i" // the common stuff %include "io.i" + +#if SWIGGUILE +%scheme %{ +(load-extension "libguile-gnuradio-gnuradio_core_io" "scm_init_gnuradio_gnuradio_core_io_module") +%} + +%goops %{ + (use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_py_runtime.i b/gnuradio-core/src/lib/swig/gnuradio_core_runtime.i index 8f444f9c5..78b717d22 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_swig_py_runtime.i +++ b/gnuradio-core/src/lib/swig/gnuradio_core_runtime.i @@ -1,19 +1,19 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. - * + * Copyright 2009,2010 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 GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -21,7 +21,7 @@ */ #ifndef SWIGIMPORTED -%module(directors="1") gnuradio_swig_py_runtime +%module(directors="1") gnuradio_core_runtime #endif //%feature("autodoc", "1"); // generate python docstrings @@ -30,3 +30,17 @@ %include "gnuradio.i" // the common stuff %include "runtime.i" + + +#if SWIGGUILE +%scheme %{ +(load-extension "libguile-gnuradio-gnuradio_core_runtime" "scm_init_gnuradio_gnuradio_core_runtime_module") +%} + +%goops %{ +(use-modules (gnuradio export-safely)) +(re-export export-syms-if-not-imported-gf) +(re-export-syntax export-safely) +(re-export re-export-all) +%} +#endif diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h b/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h new file mode 100644 index 000000000..8f7eea0bf --- /dev/null +++ b/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 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 GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H +#define INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H + +/* + * This include files works around a bug in SWIG 1.3.21 and 22 + * where it fails to emit these declarations when doing + * %import "gnuradio.i" + */ + +class gr_base_error_handler; +class gr_basic_block; +class gr_block; +class gr_error_handler; +class gr_file_error_handler; +class gr_hier_block2; +class gr_msg_handler; +class gr_msg_queue; +class gr_sync_block; +class gr_sync_decimator; +class gr_sync_interpolator; +class gr_top_block; + +#endif /* INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H */ diff --git a/gnuradio-core/src/lib/swig/gr_swig_block_magic.i b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i index 78e838012..a080c2b27 100644 --- a/gnuradio-core/src/lib/swig/gr_swig_block_magic.i +++ b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,19 +21,40 @@ */ %define GR_SWIG_BLOCK_MAGIC(PKG, BASE_NAME) -_GR_SWIG_BLOCK_MAGIC_HELPER(PKG, PKG ## _ ## BASE_NAME, BASE_NAME) +_GR_SWIG_BLOCK_MAGIC_HELPER(PKG, BASE_NAME, PKG ## _ ## BASE_NAME) %enddef -%define _GR_SWIG_BLOCK_MAGIC_HELPER(PKG, NAME, BASE_NAME) -class NAME; -typedef boost::shared_ptr<NAME> NAME ## _sptr; -%template(NAME ## _sptr) boost::shared_ptr<NAME>; +%define _GR_SWIG_BLOCK_MAGIC_HELPER_COMMON(PKG, BASE_NAME, FULL_NAME) +class FULL_NAME; +typedef boost::shared_ptr<FULL_NAME> FULL_NAME ## _sptr; +%template(FULL_NAME ## _sptr) boost::shared_ptr<FULL_NAME>; %rename(BASE_NAME) PKG ## _make_ ## BASE_NAME; +%ignore FULL_NAME; +%enddef +#ifdef SWIGPYTHON +%define _GR_SWIG_BLOCK_MAGIC_HELPER(PKG, BASE_NAME, FULL_NAME) +_GR_SWIG_BLOCK_MAGIC_HELPER_COMMON(PKG, BASE_NAME, FULL_NAME) %pythoncode %{ -NAME ## _sptr.block = lambda self: NAME ## _block (self) -NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id ()) +FULL_NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id ()) %} +%enddef +#endif -%ignore NAME; +#ifdef SWIGGUILE +#ifdef IN_GNURADIO_CORE // normal behavior +%define _GR_SWIG_BLOCK_MAGIC_HELPER(PKG, BASE_NAME, FULL_NAME) +_GR_SWIG_BLOCK_MAGIC_HELPER_COMMON(PKG, BASE_NAME, FULL_NAME) +/* FIXME May want to add something here to get a friendlier printed representation */ +%enddef +#else // Don't strip PKG from name +%define _GR_SWIG_BLOCK_MAGIC_HELPER(PKG, BASE_NAME, FULL_NAME) +class FULL_NAME; +typedef boost::shared_ptr<FULL_NAME> FULL_NAME ## _sptr; +%template(FULL_NAME ## _sptr) boost::shared_ptr<FULL_NAME>; +%ignore FULL_NAME; +%rename(FULL_NAME) PKG ## _make_ ## BASE_NAME; +/* FIXME May want to add something here to get a friendlier printed representation */ %enddef +#endif +#endif diff --git a/gnuradio-core/src/lib/swig/guile/std_complex.i b/gnuradio-core/src/lib/swig/guile/std_complex.i new file mode 100644 index 000000000..2a5c72aa2 --- /dev/null +++ b/gnuradio-core/src/lib/swig/guile/std_complex.i @@ -0,0 +1,37 @@ +%{ +#include <complex> +%} + +// To the target language, complex number conversion +%typemap(out) complex, complex<double>, std::complex<double> { + $result = scm_make_rectangular( gh_double2scm ($1.real ()), + gh_double2scm ($1.imag ()) ); +} + +// To the target language, complex number conversion +%typemap(out) complex, complex<float>, std::complex<float> { + $result = scm_make_rectangular( gh_double2scm ($1.real ()), + gh_double2scm ($1.imag ()) ); +} + +// From the target language, complex number conversion +%typemap(in) complex, complex<double>, std::complex<double> { + $1 = std::complex<double>( gh_scm2double (scm_real_part ($input)), + gh_scm2double (scm_imag_part ($input)) ); +} + +// From the target language, complex number conversion +%typemap(in) complex, complex<float>, std::complex<float> { + $1 = std::complex<float>( gh_scm2double (scm_real_part ($input)), + gh_scm2double (scm_imag_part ($input)) ); +} + +%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>); +%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>); + +%typecheck(SWIG_TYPECHECK_COMPLEX) + std::complex<float>, std::complex<double>, + const std::complex<float> &, const std::complex<double> & +{ + $1 = scm_is_complex($input) ? 1 : 0; +} diff --git a/gnuradio-core/src/lib/swig/guile/std_vector.i b/gnuradio-core/src/lib/swig/guile/std_vector.i new file mode 100644 index 000000000..ef1f20667 --- /dev/null +++ b/gnuradio-core/src/lib/swig/guile/std_vector.i @@ -0,0 +1,437 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * SWIG typemaps for std::vector + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// Guile as much as possible, namely, to allow the user to pass and +// be returned Guile vectors or lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a Guile sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a Guile vector of T:s +// is returned which is most easily used in other Guile functions +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +#include <complex> +%} + +%{ + inline std::complex<float> SWIG_scm2cmplxfloat(SCM x){ + return std::complex<float>(scm_c_real_part(x), scm_c_imag_part(x)); + } + + inline std::complex<double> SWIG_scm2cmplxdouble(SCM x){ + return std::complex<double>(scm_c_real_part(x), scm_c_imag_part(x)); + } + + inline SCM SWIG_cmplxfloat2scm(std::complex<float> x){ + return scm_c_make_rectangular(x.real(), x.imag()); + } + + inline SCM SWIG_cmplxdouble2scm(std::complex<double> x){ + return scm_c_make_rectangular(x.real(), x.imag()); + } +%} + +// exported class + +namespace std { + + template<class T> class vector { + %typemap(in) vector<T> { + if (gh_vector_p($input)) { + unsigned long size = gh_vector_length($input); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(i)); + (($1_type &)$1)[i] = + *((T*) SWIG_MustGetPtr(o,$descriptor(T *),$argnum, 0)); + } + } else if (gh_null_p($input)) { + $1 = std::vector<T >(); + } else if (gh_pair_p($input)) { + SCM head, tail; + $1 = std::vector<T >(); + tail = $input; + while (!gh_null_p(tail)) { + head = gh_car(tail); + tail = gh_cdr(tail); + $1.push_back(*((T*)SWIG_MustGetPtr(head, + $descriptor(T *), + $argnum, 0))); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const vector<T>& (std::vector<T> temp), + const vector<T>* (std::vector<T> temp) { + if (gh_vector_p($input)) { + unsigned long size = gh_vector_length($input); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(i)); + temp[i] = *((T*) SWIG_MustGetPtr(o, + $descriptor(T *), + $argnum, 0)); + } + } else if (gh_null_p($input)) { + temp = std::vector<T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::vector<T >(); + $1 = &temp; + SCM head, tail; + tail = $input; + while (!gh_null_p(tail)) { + head = gh_car(tail); + tail = gh_cdr(tail); + temp.push_back(*((T*) SWIG_MustGetPtr(head, + $descriptor(T *), + $argnum, 0))); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) vector<T> { + $result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED); + for (unsigned int i=0; i<$1.size(); i++) { + T* x = new T((($1_type &)$1)[i]); + gh_vector_set_x($result,gh_long2scm(i), + SWIG_NewPointerObj(x, $descriptor(T *), 1)); + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + /* native sequence? */ + if (gh_vector_p($input)) { + unsigned int size = gh_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + T* x; + if (SWIG_ConvertPtr(o,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + if (SWIG_ConvertPtr(head,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + /* native sequence? */ + if (gh_vector_p($input)) { + unsigned int size = gh_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + if (SWIG_ConvertPtr(o,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + if (SWIG_ConvertPtr(head,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T>&); + %rename(length) size; + unsigned int size() const; + %rename("empty?") empty; + bool empty() const; + %rename("clear!") clear; + void clear(); + %rename("set!") set; + %rename("pop!") pop; + %rename("push!") push_back; + void push_back(const T& x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T& ref(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const T& x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + + // specializations for built-ins + %define specialize_stl_vector(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<> class vector<T > { + %typemap(in) vector<T > { + if (gh_vector_p($input)) { + unsigned long size = gh_vector_length($input); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(i)); + if (CHECK(o)) + (($1_type &)$1)[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else if (gh_null_p($input)) { + $1 = std::vector<T >(); + } else if (gh_pair_p($input)) { + SCM v = gh_list_to_vector($input); + unsigned long size = gh_vector_length(v); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref(v,gh_ulong2scm(i)); + if (CHECK(o)) + (($1_type &)$1)[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const vector<T >& (std::vector<T > temp), + const vector<T >* (std::vector<T > temp) { + if (gh_vector_p($input)) { + unsigned long size = gh_vector_length($input); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(i)); + if (CHECK(o)) + temp[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else if (gh_null_p($input)) { + temp = std::vector<T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + SCM v = gh_list_to_vector($input); + unsigned long size = gh_vector_length(v); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref(v,gh_ulong2scm(i)); + if (CHECK(o)) + temp[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) vector<T > { + $result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED); + for (unsigned int i=0; i<$1.size(); i++) { + SCM x = CONVERT_TO((($1_type &)$1)[i]); + gh_vector_set_x($result,gh_long2scm(i),x); + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T > { + /* native sequence? */ + if (gh_vector_p($input)) { + unsigned int size = gh_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + $1 = CHECK(o) ? 1 : 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + $1 = CHECK(head) ? 1 : 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + $1 = (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor, 0) != -1) ? 1 : 0; + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T >&, + const vector<T >* { + /* native sequence? */ + if (gh_vector_p($input)) { + unsigned int size = gh_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + $1 = CHECK(o) ? 1 : 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + $1 = CHECK(head) ? 1 : 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + $1 = (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor, 0) != -1) ? 1 : 0; + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T >&); + %rename(length) size; + unsigned int size() const; + %rename("empty?") empty; + bool empty() const; + %rename("clear!") clear; + void clear(); + %rename("set!") set; + %rename("pop!") pop; + %rename("push!") push_back; + void push_back(T x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T ref(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + %enddef + + specialize_stl_vector(bool,gh_boolean_p,gh_scm2bool,SWIG_bool2scm); + specialize_stl_vector(char,gh_number_p,gh_scm2long,gh_long2scm); + specialize_stl_vector(int,gh_number_p,gh_scm2long,gh_long2scm); + specialize_stl_vector(long,gh_number_p,gh_scm2long,gh_long2scm); + specialize_stl_vector(short,gh_number_p,gh_scm2long,gh_long2scm); + specialize_stl_vector(unsigned char,gh_number_p,gh_scm2ulong,gh_ulong2scm); + specialize_stl_vector(unsigned int,gh_number_p,gh_scm2ulong,gh_ulong2scm); + specialize_stl_vector(unsigned long,gh_number_p,gh_scm2ulong,gh_ulong2scm); + specialize_stl_vector(unsigned short,gh_number_p,gh_scm2ulong,gh_ulong2scm); + specialize_stl_vector(float,gh_number_p,gh_scm2double,gh_double2scm); + specialize_stl_vector(double,gh_number_p,gh_scm2double,gh_double2scm); + specialize_stl_vector(std::string,gh_string_p,SWIG_scm2string,SWIG_string2scm); + specialize_stl_vector(std::complex<float>, scm_is_complex, + SWIG_scm2cmplxfloat, SWIG_cmplxfloat2scm); + specialize_stl_vector(std::complex<double>, scm_is_complex, + SWIG_scm2cmplxdouble,SWIG_cmplxdouble2scm); + +} + diff --git a/gnuradio-core/src/python/Makefile.am b/gnuradio-core/src/python/Makefile.am index e50af8944..a90aaba5c 100644 --- a/gnuradio-core/src/python/Makefile.am +++ b/gnuradio-core/src/python/Makefile.am @@ -21,9 +21,10 @@ include $(top_srcdir)/Makefile.common +if PYTHON SUBDIRS = gnuradio bin noinst_PYTHON = \ build_utils.py \ build_utils_codes.py - +endif diff --git a/gnuradio-core/src/python/bin/Makefile.am b/gnuradio-core/src/python/bin/Makefile.am index 0afd32767..6f9f162f1 100644 --- a/gnuradio-core/src/python/bin/Makefile.am +++ b/gnuradio-core/src/python/bin/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2005,2009 Free Software Foundation, Inc. +# Copyright 2005,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,7 @@ include $(top_srcdir)/Makefile.common -EXTRA_DIST = microtune.py +EXTRA_DIST += microtune.py noinst_SCRIPTS = \ microtune.py diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am index 341f58812..b8da9cf48 100644 --- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am @@ -21,12 +21,11 @@ include $(top_srcdir)/Makefile.common -EXTRA_DIST = \ +EXTRA_DIST += \ run_tests.in \ test_16bit_1chunk.wav -TESTS = \ - run_tests +TESTS = run_tests grgrpythondir = $(grpythondir)/gr @@ -39,7 +38,6 @@ grgrpython_PYTHON = \ gr_threading_24.py \ hier_block2.py \ prefs.py \ - scheduler.py \ top_block.py \ pubsub.py diff --git a/gnuradio-core/src/python/gnuradio/gr/__init__.py b/gnuradio-core/src/python/gnuradio/gr/__init__.py index 6f939c470..73ca8e08f 100644 --- a/gnuradio-core/src/python/gnuradio/gr/__init__.py +++ b/gnuradio-core/src/python/gnuradio/gr/__init__.py @@ -1,5 +1,5 @@ # -# Copyright 2003,2004,2006,2008,2009 Free Software Foundation, Inc. +# Copyright 2003,2004,2006,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -40,7 +40,7 @@ if _RTLD_GLOBAL != 0: _dlopenflags = sys.getdlopenflags() sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL) -from gnuradio_swig_python import * +from gnuradio_core import * from exceptions import * from hier_block2 import * from top_block import * diff --git a/gnuradio-core/src/python/gnuradio/gr/hier_block2.py b/gnuradio-core/src/python/gnuradio/gr/hier_block2.py index b43c5feda..debb65d91 100644 --- a/gnuradio-core/src/python/gnuradio/gr/hier_block2.py +++ b/gnuradio-core/src/python/gnuradio/gr/hier_block2.py @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio_swig_python import hier_block2_swig +from gnuradio_core import hier_block2_swig # # This hack forces a 'has-a' relationship to look like an 'is-a' one. @@ -66,7 +66,7 @@ class hier_block2(object): raise ValueError, ("connect requires at least one endpoint; %d provided." % (len (points),)) else: if len(points) == 1: - self._hb.connect(points[0].basic_block()) + self._hb.primitive_connect(points[0].to_basic_block()) else: for i in range (1, len (points)): self._connect(points[i-1], points[i]) @@ -74,11 +74,11 @@ class hier_block2(object): def _connect(self, src, dst): (src_block, src_port) = self._coerce_endpoint(src) (dst_block, dst_port) = self._coerce_endpoint(dst) - self._hb.connect(src_block.basic_block(), src_port, - dst_block.basic_block(), dst_port) + self._hb.primitive_connect(src_block.to_basic_block(), src_port, + dst_block.to_basic_block(), dst_port) def _coerce_endpoint(self, endp): - if hasattr(endp, 'basic_block'): + if hasattr(endp, 'to_basic_block'): return (endp, 0) else: if hasattr(endp, "__getitem__") and len(endp) == 2: @@ -97,10 +97,10 @@ class hier_block2(object): """ if len (points) < 1: - raise ValueError, ("disconnect requires at least two endpoints; %d provided." % (len (points),)) + raise ValueError, ("disconnect requires at least one endpoint; %d provided." % (len (points),)) else: if len (points) == 1: - self._hb.disconnect(points[0].basic_block()) + self._hb.primitive_disconnect(points[0].to_basic_block()) else: for i in range (1, len (points)): self._disconnect(points[i-1], points[i]) @@ -108,6 +108,6 @@ class hier_block2(object): def _disconnect(self, src, dst): (src_block, src_port) = self._coerce_endpoint(src) (dst_block, dst_port) = self._coerce_endpoint(dst) - self._hb.disconnect(src_block.basic_block(), src_port, - dst_block.basic_block(), dst_port) + self._hb.primitive_disconnect(src_block.to_basic_block(), src_port, + dst_block.to_basic_block(), dst_port) diff --git a/gnuradio-core/src/python/gnuradio/gr/prefs.py b/gnuradio-core/src/python/gnuradio/gr/prefs.py index 9b31b772b..40347a2f4 100644 --- a/gnuradio-core/src/python/gnuradio/gr/prefs.py +++ b/gnuradio-core/src/python/gnuradio/gr/prefs.py @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -import gnuradio_swig_python as gsp +import gnuradio_core as gsp _prefs_base = gsp.gr_prefs diff --git a/gnuradio-core/src/python/gnuradio/gr/scheduler.py b/gnuradio-core/src/python/gnuradio/gr/scheduler.py deleted file mode 100644 index 4694d48b2..000000000 --- a/gnuradio-core/src/python/gnuradio/gr/scheduler.py +++ /dev/null @@ -1,70 +0,0 @@ -# -# Copyright 2004 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio.gr.exceptions import * -from gnuradio_swig_python import single_threaded_scheduler, sts_pyrun -import gr_threading as _threading -#import threading as _threading - -class scheduler_thread(_threading.Thread): - def __init__(self, sts): - _threading.Thread.__init__(self) - self.sts = sts - def run(self): - # Invoke the single threaded scheduler's run method - # - # Note that we're in a new thread, and that sts_pyrun - # releases the global interpreter lock. This has the - # effect of evaluating the graph in parallel to the - # main line control code. - sts_pyrun(self.sts) - self.sts = None - -class scheduler(object): - def __init__(self, fg): - graphs = fg.partition_graph(fg.blocks) - # print "@@@ # graphs = %d" % (len(graphs)) - - self.state = [] - - for g in graphs: - list_of_blocks = [x.block() for x in g] - sts = single_threaded_scheduler(list_of_blocks) - thread = scheduler_thread(sts) - thread.setDaemon(1) - self.state.append((sts, thread)) - - def start(self): - for (sts, thread) in self.state: - thread.start() - - def stop(self): - for (sts, thread) in self.state: - sts.stop() - self.wait() - - def wait(self): - for (sts, thread) in self.state: - timeout = 0.100 - while True: - thread.join(timeout) - if not thread.isAlive(): - break diff --git a/gnuradio-core/src/python/gnuradio/gr/top_block.py b/gnuradio-core/src/python/gnuradio/gr/top_block.py index 71e401424..1e36d3b48 100644 --- a/gnuradio-core/src/python/gnuradio/gr/top_block.py +++ b/gnuradio-core/src/python/gnuradio/gr/top_block.py @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio_swig_python import top_block_swig, \ +from gnuradio_core import top_block_swig, \ top_block_wait_unlocked, top_block_run_unlocked #import gnuradio.gr.gr_threading as _threading @@ -118,7 +118,7 @@ class top_block(object): raise ValueError, ("connect requires at least one endpoint; %d provided." % (len (points),)) else: if len(points) == 1: - self._tb.connect(points[0].basic_block()) + self._tb.primitive_connect(points[0].to_basic_block()) else: for i in range (1, len (points)): self._connect(points[i-1], points[i]) @@ -126,11 +126,11 @@ class top_block(object): def _connect(self, src, dst): (src_block, src_port) = self._coerce_endpoint(src) (dst_block, dst_port) = self._coerce_endpoint(dst) - self._tb.connect(src_block.basic_block(), src_port, - dst_block.basic_block(), dst_port) + self._tb.primitive_connect(src_block.to_basic_block(), src_port, + dst_block.to_basic_block(), dst_port) def _coerce_endpoint(self, endp): - if hasattr(endp, 'basic_block'): + if hasattr(endp, 'to_basic_block'): return (endp, 0) else: if hasattr(endp, "__getitem__") and len(endp) == 2: @@ -139,14 +139,14 @@ class top_block(object): raise ValueError("unable to coerce endpoint") def disconnect(self, *points): - '''connect requires one or more arguments that can be coerced to endpoints. + '''disconnect requires one or more arguments that can be coerced to endpoints. If more than two arguments are provided, they are disconnected successively. ''' if len (points) < 1: - raise ValueError, ("disconnect requires at least two endpoints; %d provided." % (len (points),)) + raise ValueError, ("disconnect requires at least one endpoint; %d provided." % (len (points),)) else: if len(points) == 1: - self._tb.disconnect(points[0].basic_block()) + self._tb.primitive_disconnect(points[0].to_basic_block()) else: for i in range (1, len (points)): self._disconnect(points[i-1], points[i]) @@ -154,6 +154,6 @@ class top_block(object): def _disconnect(self, src, dst): (src_block, src_port) = self._coerce_endpoint(src) (dst_block, dst_port) = self._coerce_endpoint(dst) - self._tb.disconnect(src_block.basic_block(), src_port, - dst_block.basic_block(), dst_port) + self._tb.primitive_disconnect(src_block.to_basic_block(), src_port, + dst_block.to_basic_block(), dst_port) diff --git a/gnuradio-core/src/tests/Makefile.am b/gnuradio-core/src/tests/Makefile.am index 2bf7cb4e5..c75bb8c2a 100644 --- a/gnuradio-core/src/tests/Makefile.am +++ b/gnuradio-core/src/tests/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2008 Free Software Foundation, Inc. +# Copyright 2001,2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -31,7 +31,7 @@ TESTS = test_all # test_atsc #Test program to test setting up buffers using gr_test which can be run manually -EXTRA_DIST = \ +EXTRA_DIST += \ test_buffers.py \ benchmark_dotprod diff --git a/gnuradio-core/src/utils/Makefile.am b/gnuradio-core/src/utils/Makefile.am index 07960a072..acf439140 100644 --- a/gnuradio-core/src/utils/Makefile.am +++ b/gnuradio-core/src/utils/Makefile.am @@ -21,7 +21,7 @@ include $(top_srcdir)/Makefile.common -EXTRA_DIST = \ +EXTRA_DIST += \ cic_comp_taps.m \ db_width.m \ filter_tools.m \ @@ -42,4 +42,15 @@ EXTRA_DIST = \ read_cshort_binary.m \ single_pole_iir.m \ write_float_binary.m \ - write_short_binary.m + write_short_binary.m \ + is_complex.m \ + split_vect.m \ + rainbow.m \ + lp_to_bp.m \ + cool.m \ + read_xambi.m \ + runsum.m \ + plot_cic_decimator_response.m + +# partition-cascaded-decimating-filters.scm +# permute.scm |