diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-05-23 10:34:58 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-05-23 10:34:58 -0400 |
commit | 12a469825e5d8196a290d3fd90ac67e327cc305a (patch) | |
tree | f487ffd575417d88e88448a629527e4dd06ab70c | |
parent | 8d73b019c43b747e0b6ae1a8a8ae8a8342202a33 (diff) |
build: fixed up feval/py_feval use and destructors.
-rw-r--r-- | gnuradio-runtime/include/gnuradio/py_feval.h | 9 | ||||
-rw-r--r-- | gnuradio-runtime/swig/feval.i | 149 | ||||
-rw-r--r-- | gnuradio-runtime/swig/gnuradio.i | 1 | ||||
-rw-r--r-- | gr-blocks/swig/blocks_swig2.i | 11 |
4 files changed, 10 insertions, 160 deletions
diff --git a/gnuradio-runtime/include/gnuradio/py_feval.h b/gnuradio-runtime/include/gnuradio/py_feval.h index ea5b144898..cef168c8f0 100644 --- a/gnuradio-runtime/include/gnuradio/py_feval.h +++ b/gnuradio-runtime/include/gnuradio/py_feval.h @@ -24,6 +24,7 @@ #define INCLUDED_GR_PY_FEVAL_H #include <pmt/pmt.h> +#include <gnuradio/feval.h> class ensure_py_gil_state { PyGILState_STATE d_gstate; @@ -53,7 +54,7 @@ namespace gr { ensure_py_gil_state _lock; return eval(x); } - virtual ~py_feval_cc(); + virtual ~py_feval_cc() {}; }; class GR_RUNTIME_API py_feval_ll : public feval_ll @@ -64,7 +65,7 @@ namespace gr { ensure_py_gil_state _lock; return eval(x); } - virtual ~py_feval_ll(); + virtual ~py_feval_ll() {}; }; class GR_RUNTIME_API py_feval : public feval @@ -75,7 +76,7 @@ namespace gr { ensure_py_gil_state _lock; eval(); } - virtual ~py_feval(); + virtual ~py_feval() {}; }; class GR_RUNTIME_API py_feval_p : public feval_p @@ -86,7 +87,7 @@ namespace gr { ensure_py_gil_state _lock; eval(x); } - virtual ~py_feval_p(); + virtual ~py_feval_p() {}; }; } /* namespace gr */ diff --git a/gnuradio-runtime/swig/feval.i b/gnuradio-runtime/swig/feval.i index f773346b1b..56b200e6f0 100644 --- a/gnuradio-runtime/swig/feval.i +++ b/gnuradio-runtime/swig/feval.i @@ -65,100 +65,18 @@ // catch (Swig::DirectorException &e) { std::cerr << e.getMessage(); SWIG_fail; } //} -%{ - -// class that ensures we acquire and release the Python GIL - -class ensure_py_gil_state { - PyGILState_STATE d_gstate; -public: - ensure_py_gil_state() { d_gstate = PyGILState_Ensure(); } - ~ensure_py_gil_state() { PyGILState_Release(d_gstate); } -}; - -%} - %ignore gr::feval_dd; %ignore gr::feval_cc; %ignore gr::feval_ll; %ignore gr::feval; %ignore gr::feval_p; -namespace gr { -/* - * These are the real C++ base classes, however we don't want these exposed. - */ - class gr::feval_dd - { - protected: - virtual double eval(double x); - - public: - feval_dd() {} - virtual ~feval_dd(); - - virtual double calleval(double x); - }; - //%rename(feval_dd) gr::feval_dd; - - class gr::feval_cc - { - protected: - virtual gr_complex eval(gr_complex x); - - public: - feval_cc() {} - virtual ~feval_cc(); - - virtual gr_complex calleval(gr_complex x); - }; - //%rename(feval_cc) gr::feval_cc; - - class gr::feval_ll - { - protected: - virtual long eval(long x); - - public: - feval_ll() {} - virtual ~feval_ll(); - - virtual long calleval(long x); - }; - //%rename(feval_ll) gr::feval_ll; - - class gr::feval - { - protected: - virtual void eval(); - - public: - feval() {} - virtual ~feval(); - - virtual void calleval(); - }; - //%rename(feval) gr::feval; - - class gr::feval_p - { - protected: - virtual void eval(pmt::pmt_t x); - - public: - feval_p() {} - virtual ~feval_p(); - - virtual void calleval(pmt::pmt_t x); - }; - //%rename(feval_p) gr::feval_p; -} +%include <gnuradio/feval.h> /* * These are the ones to derive from in Python. They have the magic shim * that ensures that we're holding the Python GIL when we enter Python land... */ - namespace gr { %rename(feval_dd) py_feval_dd; %rename(feval_cc) py_feval_cc; @@ -167,77 +85,14 @@ namespace gr { %rename(feval_p) py_feval_p; } -%inline %{ -#include <pmt/pmt.h> - - namespace gr { - - class py_feval_dd : public gr::feval_dd - { - public: - double calleval(double x) - { - ensure_py_gil_state _lock; - return eval(x); - } - }; - - class py_feval_cc : public gr::feval_cc - { - public: - gr_complex calleval(gr_complex x) - { - ensure_py_gil_state _lock; - return eval(x); - } - }; - - class py_feval_ll : public gr::feval_ll - { - public: - long calleval(long x) - { - ensure_py_gil_state _lock; - return eval(x); - } - }; - - class py_feval : public gr::feval - { - public: - void calleval() - { - ensure_py_gil_state _lock; - eval(); - } - }; - - class py_feval_p : public gr::feval_p - { - public: - void calleval(pmt::pmt_t x) - { - ensure_py_gil_state _lock; - eval(x); - } - }; - } -%} +%include <gnuradio/py_feval.h> namespace gr { // examples / test cases - %rename(feval_dd_example) gr::feval_dd_example; - double gr::feval_dd_example(gr::feval_dd *f, double x); - %rename(feval_cc_example) gr::feval_cc_example; - gr_complex gr::feval_cc_example(gr::feval_cc *f, gr_complex x); - %rename(feval_ll_example) gr::feval_ll_example; - 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-runtime/swig/gnuradio.i b/gnuradio-runtime/swig/gnuradio.i index 3a68624b98..39b8677759 100644 --- a/gnuradio-runtime/swig/gnuradio.i +++ b/gnuradio-runtime/swig/gnuradio.i @@ -65,5 +65,6 @@ #include <gnuradio/tagged_stream_block.h> #include <gnuradio/block_gateway.h> #include <gnuradio/feval.h> +#include <gnuradio/py_feval.h> %} diff --git a/gr-blocks/swig/blocks_swig2.i b/gr-blocks/swig/blocks_swig2.i index 7b5fa07ff9..f22af806e6 100644 --- a/gr-blocks/swig/blocks_swig2.i +++ b/gr-blocks/swig/blocks_swig2.i @@ -23,20 +23,13 @@ #define BLOCKS_API #define GR_RUNTIME_API -//%include "runtime_swig.i" %include "gnuradio.i" -%{ -#include "gnuradio/feval.h" -#include "gnuradio/py_feval.h" -%} - -//%include "feval.i" -%import "gnuradio/feval.h" - //load generated python docstrings %include "blocks_swig2_doc.i" +%include "feval.i" + %{ #include "gnuradio/blocks/add_ff.h" #include "gnuradio/blocks/add_ss.h" |