From d1d226abdede58231583369047861cd2216489e9 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Thu, 18 Nov 2010 18:00:58 -0800 Subject: Disable items that require swig directors when building guile bindings. --- .../src/lib/general/gr_bin_statistics_f.i | 7 ++++- gnuradio-core/src/lib/general/gr_feval.i | 30 +++++----------------- 2 files changed, 13 insertions(+), 24 deletions(-) (limited to 'gnuradio-core/src/lib') 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 -- cgit From 6237fafa53938db53a3e2a82b79e80b524dd05db Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Thu, 18 Nov 2010 22:22:23 -0800 Subject: gr_msg_queue now working correctly from within guile. --- gnuradio-core/src/lib/runtime/gr_msg_queue.i | 58 ++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 3 deletions(-) (limited to 'gnuradio-core/src/lib') diff --git a/gnuradio-core/src/lib/runtime/gr_msg_queue.i b/gnuradio-core/src/lib/runtime/gr_msg_queue.i index 5b8fea49f..932747688 100644 --- a/gnuradio-core/src/lib/runtime/gr_msg_queue.i +++ b/gnuradio-core/src/lib/runtime/gr_msg_queue.i @@ -104,8 +104,60 @@ 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; + }; + + void *insert_tail_shim(void *arg) + { + arg_holder *a = (arg_holder *)arg; + a->q->insert_tail(a->msg); + return 0; + } + + 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 -- cgit From 31b5e27fbf72eca257bc4dd548e127ce16eef9ec Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 19 Nov 2010 00:13:28 -0800 Subject: Enable a couple more tests --- gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib') 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 &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 -- cgit From 6551f537ed235bbb0ddfadb50744ea3b3fcbc2e6 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Sat, 20 Nov 2010 16:30:43 -0800 Subject: Add guile shim to gr_top_block::wait that exits guile mode before blocking. --- gnuradio-core/src/lib/runtime/gr_top_block.i | 37 ++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'gnuradio-core/src/lib') 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 -- cgit From 5c91f873301a6eca0895788b0b03862fc0060a19 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Sat, 20 Nov 2010 16:34:04 -0800 Subject: Minor tweaks: comments, static --- gnuradio-core/src/lib/runtime/gr_msg_queue.i | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'gnuradio-core/src/lib') diff --git a/gnuradio-core/src/lib/runtime/gr_msg_queue.i b/gnuradio-core/src/lib/runtime/gr_msg_queue.i index 932747688..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 * @@ -117,14 +117,16 @@ gr_msg_queue_sptr.handle = gr_py_msg_queue__insert_tail gr_message_sptr msg; }; - void *insert_tail_shim(void *arg) + static void * + insert_tail_shim(void *arg) { arg_holder *a = (arg_holder *)arg; a->q->insert_tail(a->msg); return 0; } - void *delete_head_shim(void *arg) + static void * + delete_head_shim(void *arg) { arg_holder *a = (arg_holder *)arg; a->msg = a->q->delete_head(); @@ -135,7 +137,8 @@ gr_msg_queue_sptr.handle = gr_py_msg_queue__insert_tail %inline %{ // handle and insert_tail are equivalent - static void handle(gr_msg_queue_sptr q, gr_message_sptr msg) + static void + handle(gr_msg_queue_sptr q, gr_message_sptr msg) { arg_holder a; a.q = q; @@ -143,7 +146,8 @@ gr_msg_queue_sptr.handle = gr_py_msg_queue__insert_tail scm_without_guile(insert_tail_shim, (void *) &a); } - static void insert_tail(gr_msg_queue_sptr q, gr_message_sptr msg) + static void + insert_tail(gr_msg_queue_sptr q, gr_message_sptr msg) { arg_holder a; a.q = q; @@ -151,7 +155,8 @@ gr_msg_queue_sptr.handle = gr_py_msg_queue__insert_tail scm_without_guile(insert_tail_shim, (void *) &a); } - static gr_message_sptr delete_head(gr_msg_queue_sptr q) + static gr_message_sptr + delete_head(gr_msg_queue_sptr q) { arg_holder a; a.q = q; -- cgit From e4eb47f0dd55485693e70ec2f45f79912fa899c4 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Sun, 21 Nov 2010 19:43:39 -0800 Subject: Clean up lib/swig/Makefile.am, Makefile.common and Makefile.swig Confirmed that it builds and make checks on all four combintations of --{enable,disable}-{python,guile}. Have not tested make dist, but expect that there may be some problems with it. I'm pretty sure that not all files that need to be removed from the distribution are removed, and make clean may still be leaving some files around. --- gnuradio-core/src/lib/swig/Makefile.am | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'gnuradio-core/src/lib') 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) - -- cgit