diff options
author | Rob Savoye | 2010-11-21 21:49:17 -0700 |
---|---|---|
committer | Rob Savoye | 2010-11-21 21:49:17 -0700 |
commit | 534d95dcadcd4351337ba3fd97a2c94405bc6124 (patch) | |
tree | 5384896921f7050ed4004f6543e55f617fad6ee0 | |
parent | 9cf988ad17529416f841870b01d0f548e1a0b9a0 (diff) | |
parent | e4eb47f0dd55485693e70ec2f45f79912fa899c4 (diff) | |
download | gnuradio-534d95dcadcd4351337ba3fd97a2c94405bc6124.tar.gz gnuradio-534d95dcadcd4351337ba3fd97a2c94405bc6124.tar.bz2 gnuradio-534d95dcadcd4351337ba3fd97a2c94405bc6124.zip |
merge from upstream
24 files changed, 341 insertions, 155 deletions
diff --git a/Guile-TODO b/Guile-TODO index 93d96fa17..7cbf5ac60 100644 --- a/Guile-TODO +++ b/Guile-TODO @@ -1,7 +1,5 @@ In no particular order: -2) SIGINT handling in gr_top_block::wait - 3) Ensure that all 4 combinations of --{enable,disable}-python --{enable,disable}-guile work correctly. @@ -18,7 +16,8 @@ In no particular order: 6) Fix printed representation of blocks in gr_block.i -9) Any other FIXME style warnings +9) Any other FIXME style warnings. + (Last one is in usrp2.i) 10) Finish gnuradio-core test cases @@ -35,9 +34,6 @@ In no particular order: 13) Change guile libnames to libguile-gnuradio-<module-name> -14) Add support to setup_guile_test_env.in for - "withlibs", OS/X (DYLD_LIBRARY_PATH), windows (PATH) - 15) Rewrite gr-run-waveform as C/C++ code that embeds guile. See if we can't statically link libguile into this. Will need to figure out which packages provide libguile.a. @@ -46,7 +42,6 @@ In no particular order: how much faster it is. Load time currently is currently kind of doggy. - I'm sure I'm forgetting some things... @@ -72,6 +67,8 @@ These are done: 1) [DONE] Ensure that libraries containing swig generated code are regenerated when any relevant .i file is touched. +2) [DONE] SIGINT handling in gr_top_block::wait + 4) [DONE] Fix GR_SWIG_BLOCK_MAGIC so that in the guile case we don't map all the constructors into the same name. E.g. audio_alsa_sink -> sink. (Causes problem when multiple gr-* modules are used.) @@ -84,5 +81,7 @@ These are done: 8) [DONE] Fix gr_message_{sink,source} so that they work under guile. (Not sure if I disabled one or both of these...) -17) [DONE] Get std::vector< std::complex<float> > working +14) [DONE] Add support to setup_guile_test_env.in for + "withlibs", OS/X (DYLD_LIBRARY_PATH), windows (PATH) +17) [DONE] Get std::vector< std::complex<float> > working diff --git a/Makefile.common b/Makefile.common index 7ea573ebb..182b29ffa 100644 --- a/Makefile.common +++ b/Makefile.common @@ -40,7 +40,6 @@ swigincludedir = $(grincludedir)/swig guiledir = $(prefix)/share/guile/site grguiledir = $(guiledir)/gnuradio -if PYTHON # Install the gnuradio stuff in the appropriate subdirectory # This usually ends up at: # ${prefix}/lib/python${python_version}/site-packages/gnuradio @@ -54,7 +53,6 @@ grpyexecdir = $(pyexecdir)/gnuradio usrppythondir = $(pythondir)/usrpm usrppyexecdir = $(pyexecdir)/usrpm -endif # gcell includes gcellincludedir = $(includedir)/gcell @@ -125,7 +123,6 @@ MOSTLYCLEANFILES = $(BUILT_SOURCES) $(STAMPS) *.pyc *.pyo *~ *.tmp *.loT ## SWIG suffixes for automake to know about SUFFIXES = .i .scm .py -if GUILE # Compile a .i to what guile needs. We use -o to set the output file name, # or even with -outdir guile in SWIG_GUILE_ARGS, swig keeps putting a # gnuradio_core_*_wrap.cxx in the source directory. @@ -140,7 +137,6 @@ gnuradio/%.scm : %.i $(SED) -i -e 's/<--dummy-[0-9]\+-->/<top>/g' gnuradio/$*.scm $(SED) -i -e 's/^(export /(export-safely /' gnuradio/$*.scm $(RM) guile/$*.Std -endif # Compile a .i file to what python needs .i.py: @@ -152,7 +148,7 @@ endif $(SED) -e 's|python/\(.*\)\.cc:|\1.py:|' python/$*.Std > python/$*.d $(RM) python/$*.Std -# Don't distribute the files defined in the variable 'no_dist_files' +# or the directories listed in no_dist_dirs (set in Makefile.swig) dist-hook: @for dir in $(no_dist_dirs); do \ echo $(RM) -fr $(distdir)/$$dir; \ diff --git a/Makefile.swig b/Makefile.swig index 03b7c92a3..c6b36ddef 100644 --- a/Makefile.swig +++ b/Makefile.swig @@ -1,6 +1,6 @@ # -*- Makefile -*- # -# Copyright 2009 Free Software Foundation, Inc. +# Copyright 2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -25,6 +25,9 @@ ## in Makefile.am's which require SWIG wrapping / compilation. ## For just installing .i files, this Makefile is not required. +CLEANFILES = python/*.cc python/*.h python/*.lo python/*.o +CLEANFILES += guile/*.cc gnuradio/*.scm guile/*.lo guile/*.o + ## swig flags ## -w511 turns off keyword argument warning ## "-outdir $(builddir)" writes all generated output files to @@ -32,9 +35,6 @@ ## In some older autotools, $(builddir) is not defined, so ## just use '.' instead. -CLEANFILES = python/*.cc python/*.h python/*.lo python/*.o -CLEANFILES += guile/*.cc gnuradio/*.scm guile/*.lo guile/*.o - SWIG_PYTHON_FLAGS = \ -fvirtual \ -python \ @@ -144,3 +144,6 @@ if GUILE GUILE_GEN = $(foreach HFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,gnuradio/%.scm,$(HFILE))) swig_built_sources += $(GUILE_GEN) endif + +no_dist_dirs = python gnuradio guile +no_dist_files = $(swig_built_sources) diff --git a/config/grc_build.m4 b/config/grc_build.m4 index 77b59db6b..121c4feb6 100644 --- a/config/grc_build.m4 +++ b/config/grc_build.m4 @@ -259,6 +259,7 @@ AC_DEFUN([_GRC_BUILD_CONDITIONAL],[ GRC_ADD_TO_LIST($3, PYDIRPATH, ":") GRC_ADD_TO_LIST($3, SWIGDIRPATH, ":") GRC_ADD_TO_LIST($3, LIBDIRPATH, ":") + GRC_ADD_TO_LIST($3, GUILE_LOAD_PATH, ":") AC_MSG_RESULT([Component $1 will be included from a pre-installed library and includes.]) $3[_with]=yes else diff --git a/config/grc_gnuradio_core.m4 b/config/grc_gnuradio_core.m4 index 8cbba49ef..ff3df8c60 100644 --- a/config/grc_gnuradio_core.m4 +++ b/config/grc_gnuradio_core.m4 @@ -26,6 +26,8 @@ AC_DEFUN([GRC_GNURADIO_CORE],[ gnuradio_core_I="$gnuradio_core_SWIGDIRPATH/gnuradio.i" gnuradio_core_SWIG_INCLUDES="-I$gnuradio_core_SWIGDIRPATH" gnuradio_core_PYDIRPATH=$pythondir + gnuradio_core_GUILE_LOAD_PATH="`pkg-config --variable=guile_load_path gnuradio-core`" + gnuradio_core_LIBDIRPATH="`pkg-config --variable=libdir gnuradio-core`" ]) dnl Don't do gnuradio-core if gruel skipped diff --git a/configure.ac b/configure.ac index fe32ccf5e..00527d383 100644 --- a/configure.ac +++ b/configure.ac @@ -411,6 +411,7 @@ AC_SUBST(with_SWIG_INCLUDES) AC_SUBST(with_PYDIRPATH) AC_SUBST(with_SWIGDIRPATH) AC_SUBST(with_LIBDIRPATH) +AC_SUBST(with_GUILE_LOAD_PATH) # Local files tweaked by AC AC_CONFIG_FILES([\ diff --git a/gnuradio-core/gnuradio-core.pc.in b/gnuradio-core/gnuradio-core.pc.in index 5d743a4e9..40c26a129 100644 --- a/gnuradio-core/gnuradio-core.pc.in +++ b/gnuradio-core/gnuradio-core.pc.in @@ -2,6 +2,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@/gnuradio +guile_load_path=@prefix@/share/guile/site Name: gnuradio-core Description: GNU Software Radio toolkit diff --git a/gnuradio-core/src/guile/gnuradio/runtime-shim.scm b/gnuradio-core/src/guile/gnuradio/runtime-shim.scm index c08d3947c..bba702670 100644 --- a/gnuradio-core/src/guile/gnuradio/runtime-shim.scm +++ b/gnuradio-core/src/guile/gnuradio/runtime-shim.scm @@ -19,6 +19,7 @@ (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)) @@ -86,4 +87,43 @@ (loop (1+ n)))))))))) -(export-safely <gr-endpoint> gr:ep gr:connect gr:disconnect) + + +(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/run_guile_tests.in b/gnuradio-core/src/guile/run_guile_tests.in index 3aca7bdb0..61968065e 100644 --- a/gnuradio-core/src/guile/run_guile_tests.in +++ b/gnuradio-core/src/guile/run_guile_tests.in @@ -2,14 +2,16 @@ . @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 -# We're in gnuradio-core, we don't need these -# add_local_paths \ -# "" \ -# "" \ -# "" +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_ctors.test b/gnuradio-core/src/guile/tests/00_runtime_ctors.test index 0c131f5bd..966d8c909 100644 --- a/gnuradio-core/src/guile/tests/00_runtime_ctors.test +++ b/gnuradio-core/src/guile/tests/00_runtime_ctors.test @@ -32,4 +32,23 @@ ;;; 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/general_ctors.test b/gnuradio-core/src/guile/tests/general_ctors.test index d09766a95..ff5ee74fa 100644 --- a/gnuradio-core/src/guile/tests/general_ctors.test +++ b/gnuradio-core/src/guile/tests/general_ctors.test @@ -259,18 +259,18 @@ ;;; ./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 FIXME: "No matching method for generic function `ofdm_frame_sink'" -;; (pass-if (true? (gr:ofdm-frame-sink #(1+3i 23+5i) #('a' 'b') (gr:msg-queue) 1 0.25 0))) +;;; ./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" -;; (pass-if (true? (gr:ofdm-insert-preamble 1 #(#(1+3i 23+5i))))) - -;;; ./general/gr_ofdm_mapper_bcv.h FIXME: Wrong type argument in position ~A: -;; gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, -;; unsigned int msgq_limit, -;; unsigned int bits_per_symbol, -;; unsigned int fft_length); -;; (pass-if (true? (gr:ofdm-mapper-bcv #(1+3i 23+5i) 1 1 1))) +;;; 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))) diff --git a/gnuradio-core/src/guile/tests/gengen_ctors.test b/gnuradio-core/src/guile/tests/gengen_ctors.test index 43996c001..6e1213c63 100644 --- a/gnuradio-core/src/guile/tests/gengen_ctors.test +++ b/gnuradio-core/src/guile/tests/gengen_ctors.test @@ -198,16 +198,16 @@ (pass-if (true? (gr:multiply-ss 1))) ;;; ./gengen/gr_mute_cc.h FIXME: not found -;; (pass-if (true? (gr:mute-cc false))) +(pass-if (true? (gr:mute-cc #f))) ;;; ./gengen/gr_mute_ff.h FIXME: not found -;;(pass-if (true? (gr:mute-ff false))) +(pass-if (true? (gr:mute-ff #f))) ;;; ./gengen/gr_mute_ii.h FIXME: not found -;; (pass-if (true? (gr:mute-ii false))) +(pass-if (true? (gr:mute-ii #f))) ;;; ./gengen/gr_mute_ss.h FIXME: not found -;; (pass-if (true? (gr:mute-ss false))) +(pass-if (true? (gr:mute-ss #f))) ;;; ./gengen/gr_noise_source_c.h (pass-if (true? (gr:noise-source-c 1 0 3021))) @@ -318,19 +318,19 @@ (pass-if (true? (gr:vector-sink-s 1))) ;;; ./gengen/gr_vector_source_b.h -;; (pass-if (true? (gr:vector-source-b #(1 2) false 1))) +;; (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) false 1))) +;; (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) false 1))) +;; (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) false 1))) +;; (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) false 1))) +;; (pass-if (true? (gr:vector-source-s #(1 2) #f 1))) ;;; ./gengen/gr_xor_bb.h (pass-if (true? (gr:xor-bb))) diff --git a/gnuradio-core/src/guile/tests/io_ctors.test b/gnuradio-core/src/guile/tests/io_ctors.test index 99c84ae37..1c5c9a771 100644 --- a/gnuradio-core/src/guile/tests/io_ctors.test +++ b/gnuradio-core/src/guile/tests/io_ctors.test @@ -37,20 +37,21 @@ ;;; ;;; ./io/gr_file_descriptor_sink.h -(pass-if (true? (gr:file-descriptor-sink 1 1))) +(pass-if (true? (gr:file-descriptor-sink 1 (dup 1)))) -;;; ./io/gr_file_descriptor_source.h FIXME: not found -;; (pass-if (true? (gr:file-descriptor-source 1 1 #f))) +;;; ./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 FIXME: not found -;; (pass-if (true? (gr:file-source 1 "foo" #f))) +;;; ./io/gr_file_source.h +(pass-if (true? (gr:file-source 1 "foo" #f))) +(rm-foo) -;;; ./io/gr_histo_sink_f.h FIXME: not found +;;; ./io/gr_histo_sink_f.h ;; gr_make_histo_sink_f (gr_msg_queue_sptr msgq); -;; (pass-if (true? (gr:histo-sink-f 1))) +(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))) @@ -59,25 +60,23 @@ (pass-if (true? (gr:message-source 1 1))) (pass-if (true? (gr:message-source 1 (gr:msg-queue)))) -;;; ./io/gr_oscope_sink_f.h FIXME: not found -;; _oscope_sink_x (const std::string name, gr_io_signature_sptr input_sig, -;; double sample_rate); -;; (pass-if (true? (gr:oscope-sink-f "foo" 1 1))) +;;; ./io/gr_oscope_sink_f.h +(pass-if (true? (gr:oscope-sink-f 1000 (gr:msg-queue)))) -;;; ./io/gr_oscope_sink_x.h FIXME: not found -;; gr_oscope_sink_x (const std::string name, gr_io_signature_sptr input_sig, -;; double sampling_rate); -;; (pass-if (true? (gr:oscope_sink_x "foo" 1 1))) +;;; ./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_sink.h FIXME: not found -;; (pass-if (true? (gr:udp-sink 1 "foo" 1472 #t))) +;;; ./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_udp_source.h FIXME: not found -;; (pass-if (true? (gr:message-source 0 "foo" 0 1472 #t #t))) - -;;; ./io/gr_wavfile_sink.h FIXME: not found -;; (pass-if (true? (gr:message-source "foo" 1 1 1))) - -;;; ./io/gr_wavfile_source.h FIXME: not found -;; (pass-if (true? (gr:message-source "foo" #f))) +;;; ./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/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_feval.i b/gnuradio-core/src/lib/general/gr_feval.i index 843ca3f2a..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; @@ -65,8 +68,8 @@ // catch (Swig::DirectorException &e) { std::cerr << e.getMessage(); SWIG_fail; } //} -#ifdef SWIGPYTHON %{ + // class that ensures we acquire and release the Python GIL class ensure_py_gil_state { @@ -77,19 +80,6 @@ public: }; %} -#endif - -#ifdef SWIGGUILE -#if 0 -// FIXME: this is a bogus stub, just here so things build -class ensure_py_gil_state { -public: - ensure_py_gil_state() { } - ~ensure_py_gil_state() { } -}; -#endif -#warning "class ensure_py_gil_state needs to be implemented!" -#endif /* * These are the real C++ base classes, however we don't want these exposed. @@ -158,9 +148,7 @@ class gr_py_feval_dd : public gr_feval_dd public: double calleval(double x) { -#ifdef PYTHON ensure_py_gil_state _lock; -#endif return eval(x); } }; @@ -170,9 +158,7 @@ class gr_py_feval_cc : public gr_feval_cc public: gr_complex calleval(gr_complex x) { -#ifdef PYTHON ensure_py_gil_state _lock; -#endif return eval(x); } }; @@ -182,9 +168,7 @@ class gr_py_feval_ll : public gr_feval_ll public: long calleval(long x) { -#ifdef PYTHON ensure_py_gil_state _lock; -#endif return eval(x); } }; @@ -194,9 +178,7 @@ class gr_py_feval : public gr_feval public: void calleval() { -#ifdef PYTHON ensure_py_gil_state _lock; -#endif eval(); } }; @@ -218,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_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/runtime/gr_msg_queue.i b/gnuradio-core/src/lib/runtime/gr_msg_queue.i index 5b8fea49f..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 * @@ -104,8 +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 +#endif // SWIGPYTHON +/* + * Similar trickery as above, only this time for Guile + */ #ifdef SWIGGUILE -#warning "gr_msg_queue.i: gr_msg_queue_sptr needs to be implemented!" -#endif + +%{ + 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_top_block.i b/gnuradio-core/src/lib/runtime/gr_top_block.i index f18d8890b..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,8 +42,8 @@ public: void start() throw (std::runtime_error); void stop(); - void wait(); - void run() throw (std::runtime_error); + //void wait(); + //void run() throw (std::runtime_error); void lock(); void unlock() throw (std::runtime_error); void dump(); @@ -71,6 +71,33 @@ void top_block_wait_unlocked(gr_top_block_sptr r) throw (std::runtime_error) #endif -#ifdef SWIG_GUILE -#warning "gr_top_block.i: top_block_run_unlocked needs to be implemented!" +#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/swig/Makefile.am b/gnuradio-core/src/lib/swig/Makefile.am index 95edf5181..a97bb6ea0 100644 --- a/gnuradio-core/src/lib/swig/Makefile.am +++ b/gnuradio-core/src/lib/swig/Makefile.am @@ -24,11 +24,6 @@ include $(top_srcdir)/Makefile.swig BUILT_SOURCES = $(grinclude_HEADERS) $(swig_built_sources) -CLEANFILES = python/*.cc python/*.h -if GUILE -CLEANFILES += guile/*.cc gnuradio/*.scm -endif - # ---------------------------------------------------------------- # We've split the previously monstrous gnuradio_core into 6 # smaller pieces. This reduces compile time coupling and creates @@ -62,7 +57,6 @@ AM_CPPFLAGS = -I$(srcdir) $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ EXTRA_DIST = gen-swig-bug-fix -if PYTHON # special install for this top-level Python script which includes all # of the split Python libraries. ourpythondir = $(grpythondir)/gr @@ -95,20 +89,5 @@ 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) -# 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. -PYTHON_GEN = $(foreach HFILE,$(TOP_SWIG_IFILES), $(subst .i,.py,$(HFILE))) -swig_built_sources += $(PYTHON_GEN) -endif # end of if python -if GUILE SWIG_GUILE_FLAGS += -DIN_GNURADIO_CORE -GUILE_GEN = $(foreach HFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,gnuradio/%.scm,$(HFILE))) -swig_built_sources += $(GUILE_GEN) -endif # end of if guile - -# Do not distribute the output of SWIG -no_dist_files = $(swig_built_sources) - diff --git a/gr-uhd/lib/uhd_mimo_sink.h b/gr-uhd/lib/uhd_mimo_sink.h index 28a530b60..29e9298a9 100644 --- a/gr-uhd/lib/uhd_mimo_sink.h +++ b/gr-uhd/lib/uhd_mimo_sink.h @@ -37,7 +37,7 @@ boost::shared_ptr<uhd_mimo_sink> uhd_make_mimo_sink( /*********************************************************************** * DEPRECATED **********************************************************************/ -class UHD_DEPRECATED uhd_mimo_sink : public gr_sync_block{ +class /*UHD_DEPRECATED*/ uhd_mimo_sink : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_mimo_source.h b/gr-uhd/lib/uhd_mimo_source.h index dc2927598..36735ae7e 100644 --- a/gr-uhd/lib/uhd_mimo_source.h +++ b/gr-uhd/lib/uhd_mimo_source.h @@ -37,7 +37,7 @@ boost::shared_ptr<uhd_mimo_source> uhd_make_mimo_source( /*********************************************************************** * DEPRECATED **********************************************************************/ -class UHD_DEPRECATED uhd_mimo_source : public gr_sync_block{ +class /*UHD_DEPRECATED*/ uhd_mimo_source : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index b239e3f21..930487049 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -36,7 +36,7 @@ boost::shared_ptr<uhd_simple_sink> uhd_make_simple_sink( /*********************************************************************** * DEPRECATED **********************************************************************/ -class UHD_DEPRECATED uhd_simple_sink : public gr_sync_block{ +class /*UHD_DEPRECATED*/ uhd_simple_sink : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index c524a024a..d9f8d252a 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -36,7 +36,7 @@ boost::shared_ptr<uhd_simple_source> uhd_make_simple_source( /*********************************************************************** * DEPRECATED **********************************************************************/ -class UHD_DEPRECATED uhd_simple_source : public gr_sync_block{ +class /*UHD_DEPRECATED*/ uhd_simple_source : public gr_sync_block{ public: /*! diff --git a/setup_guile_test_env.in b/setup_guile_test_env.in index ee7e9ea46..f143685c0 100644 --- a/setup_guile_test_env.in +++ b/setup_guile_test_env.in @@ -1,16 +1,26 @@ -#!/bin/sh +# +# 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 is sourced by run_guile_tests to establish the environment # variables required to run the tests in the build tree. -abs_top_srcdir=@abs_top_srcdir@ -abs_top_builddir=@abs_top_builddir@ - - -# FIXME add in OS/X DYLD_LIBRARY_PATH -# FIXME add in cywin*/win*/mingw* PATH -# FIXME add in withdirs - +# add_local_paths is the only "public" function in this file # 1st argument is absolute path to hand coded guile source directory # 2nd argument is absolute path to component C++ shared library build directory @@ -22,12 +32,23 @@ function add_local_paths(){ echo "$0: requires 3 args" 1>&2 exit 1 fi - [ -n "$1" ] && prepend GUILE_LOAD_PATH "$1" - [ -n "$2" ] && prepend LTDL_LIBRARY_PATH "$2/.libs" - [ -n "$3" -a "$2" != "$3" ] && prepend LTDL_LIBRARY_PATH "$3/.libs" - [ -n "$3" ] && prepend GUILE_LOAD_PATH "$3" + + # Add local dirs to the front + prepend_to_guile_load_path "$1" + prepend_to_libpath "$2/.libs" + [ "$2" != "$3" ] && prepend_to_libpath "$3/.libs" + prepend_to_guile_load_path "$3" + + # Add withdirs to the end + append_to_guile_load_path "@with_GUILE_LOAD_PATH@" + append_to_libpath "@with_LIBDIRPATH@" } +# ------------------------------------------------------------------------ + +abs_top_srcdir=@abs_top_srcdir@ +abs_top_builddir=@abs_top_builddir@ + # usage: prepend <path-varname> <dir> function prepend(){ if [ $# -ne 2 ] @@ -37,9 +58,6 @@ function prepend(){ fi local path="$1" dir="$2" contents="" eval "contents=\$$path" - #echo "path = $path" - #echo "dir = $dir" - #echo "contents = $contents" if [ "$dir" != "" ] then if [ "$contents" = "" ] @@ -49,32 +67,85 @@ function prepend(){ eval "$path=\"$dir:$contents\"" fi fi - #echo end-of-prepend: $path=${!path} } +# usage: append <path-varname> <dir> +function append(){ + if [ $# -ne 2 ] + then + echo "$0: append needs 2 args" 1>&2 + exit 1 + fi + local path="$1" dir="$2" contents="" + eval "contents=\$$path" + if [ "$dir" != "" ] + then + if [ "$contents" = "" ] + then + eval "$path=\"$dir\"" + else + eval "$path=\"$contents:$dir\"" + fi + fi + #echo end-of-append: $path=${!path} +} + +function prepend_to_guile_load_path(){ + prepend GUILE_LOAD_PATH "$1" + export GUILE_LOAD_PATH +} + +function append_to_guile_load_path(){ + append GUILE_LOAD_PATH "$1" + export GUILE_LOAD_PATH +} + +function prepend_to_libpath(){ + prepend LTDL_LIBRARY_PATH "$1" + export LTDL_LIBRARY_PATH + case "@host_os@" in + darwin*) + prepend DYLD_LIBRARY_PATH "$1" + export DYLD_LIBRARY_PATH + ;; + cygwin*|win*|mingw*) + prepend PATH "$1" + export PATH + ;; + esac +} + +function append_to_libpath(){ + append LTDL_LIBRARY_PATH "$1" + export LTDL_LIBRARY_PATH + case "@host_os@" in + darwin*) + append DYLD_LIBRARY_PATH "$1" + export DYLD_LIBRARY_PATH + ;; + cygwin*|win*|mingw*) + append PATH "$1" + export PATH + ;; + esac +} + # ------------------------------------------------------------------------ # Everybody gets gruel and gnuradio-core for free. # FIXME Eventually this should be gruel and gnuradio-runtime. # ------------------------------------------------------------------------ # Where to search for not yet installed C++ shared libraries -prepend mylibdir $abs_top_builddir/gruel/src/lib/.libs -prepend mylibdir $abs_top_builddir/gnuradio-core/src/lib/.libs +prepend_to_libpath $abs_top_builddir/gruel/src/lib/.libs +prepend_to_libpath $abs_top_builddir/gnuradio-core/src/lib/.libs # Where to search for not yet installed swig generated guile libs -prepend mylibdir $abs_top_builddir/gnuradio-core/src/lib/swig/.libs +prepend_to_libpath $abs_top_builddir/gnuradio-core/src/lib/swig/.libs # Where to seach for guile code. -prepend guile_load_path $abs_top_srcdir/gnuradio-core/src/guile -prepend guile_load_path $abs_top_builddir/gnuradio-core/src/lib/swig - -#echo "mylibdir = $mylibdir" -#echo "guile_load_path = $guile_load_path" +prepend_to_guile_load_path $abs_top_srcdir/gnuradio-core/src/guile +prepend_to_guile_load_path $abs_top_builddir/gnuradio-core/src/lib/swig -prepend LTDL_LIBRARY_PATH "$mylibdir" -prepend GUILE_LOAD_PATH "$guile_load_path" -export LTDL_LIBRARY_PATH -export GUILE_LOAD_PATH export GUILE_WARN_DEPRECATED=no |