diff options
Diffstat (limited to 'gruel/src/swig')
-rw-r--r-- | gruel/src/swig/.gitignore | 4 | ||||
-rw-r--r-- | gruel/src/swig/CMakeLists.txt | 4 | ||||
-rw-r--r-- | gruel/src/swig/Makefile.am | 66 | ||||
-rw-r--r-- | gruel/src/swig/Makefile.swig.gen | 145 | ||||
-rw-r--r-- | gruel/src/swig/gruel_common.i | 66 | ||||
-rw-r--r-- | gruel/src/swig/pmt_swig.i | 17 |
6 files changed, 70 insertions, 232 deletions
diff --git a/gruel/src/swig/.gitignore b/gruel/src/swig/.gitignore deleted file mode 100644 index f99fdb19b..000000000 --- a/gruel/src/swig/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/Makefile -/Makefile.in -/python -/pmt_swig.py diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt index 7d69ee549..f9d1758ec 100644 --- a/gruel/src/swig/CMakeLists.txt +++ b/gruel/src/swig/CMakeLists.txt @@ -38,8 +38,8 @@ GR_SWIG_INSTALL( ) install( - FILES gr_intrusive_ptr.i pmt_swig.i + FILES gr_intrusive_ptr.i pmt_swig.i gruel_common.i ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + DESTINATION ${GR_INCLUDE_DIR}/gruel/swig COMPONENT "gruel_swig" ) diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am deleted file mode 100644 index 9953d5566..000000000 --- a/gruel/src/swig/Makefile.am +++ /dev/null @@ -1,66 +0,0 @@ -# -# Copyright 2011 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. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - -TESTS = - -AM_CPPFLAGS = \ - -I$(top_srcdir)/gruel/src/lib \ - $(STD_DEFINES_AND_INCLUDES) \ - $(PYTHON_CPPFLAGS) \ - $(WITH_INCLUDES) - -############################## -# SWIG interface and library -TOP_SWIG_IFILES = \ - pmt_swig_doc.i \ - pmt_swig.i - -TOP_SWIG_DOC_IFILES = \ - pmt_swig_doc.i - -BUILT_SOURCES += \ - $(TOP_SWIG_DOC_IFILES) - -EXTRA_DIST += \ - $(TOP_SWIG_DOC_IFILES) - -$(TOP_SWIG_DOC_IFILES): - `echo "" > $@` - -# Install so that they end up available as: -# import gruel.pmt -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gruel/pmt -pmt_swig_pythondir_category = \ - gruel/pmt - -# additional libraries for linking with the SWIG-generated library -pmt_swig_la_swig_libadd = \ - $(abs_top_builddir)/gruel/src/lib/pmt/libpmt.la - -# additional SWIG files to be installed -pmt_swig_swiginclude_headers = \ - gr_intrusive_ptr.i \ - $(TOP_SWIG_DOC_IFILES) - diff --git a/gruel/src/swig/Makefile.swig.gen b/gruel/src/swig/Makefile.swig.gen deleted file mode 100644 index 0abba0299..000000000 --- a/gruel/src/swig/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 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. -# - -# Makefile.swig.gen for pmt_swig.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/pmt_swig -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/pmt_swig -## -## 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. - -pmt_swig_pythondir_category ?= gnuradio/pmt_swig -pmt_swig_pylibdir_category ?= $(pmt_swig_pythondir_category) -pmt_swig_pythondir = $(pythondir)/$(pmt_swig_pythondir_category) -pmt_swig_pylibdir = $(pyexecdir)/$(pmt_swig_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. -pmt_swig_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/pmt_swig -# FIXME: determince whether these should be installed with gnuradio. -pmt_swig_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -pmt_swig_swigincludedir = $(gruelswigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -pmt_swig_swiginclude_HEADERS = \ - pmt_swig.i \ - $(pmt_swig_swiginclude_headers) - -if PYTHON -pmt_swig_pylib_LTLIBRARIES = \ - _pmt_swig.la - -_pmt_swig_la_SOURCES = \ - python/pmt_swig.cc \ - $(pmt_swig_la_swig_sources) - -pmt_swig_python_PYTHON = \ - pmt_swig.py \ - $(pmt_swig_python) - -_pmt_swig_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(pmt_swig_la_swig_libadd) - -_pmt_swig_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(pmt_swig_la_swig_ldflags) - -_pmt_swig_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(pmt_swig_la_swig_cxxflags) - -python/pmt_swig.cc: pmt_swig.py -pmt_swig.py: pmt_swig.i - -# Include the python dependencies for this file --include python/pmt_swig.d - -endif # end of if python - -if GUILE - -pmt_swig_scmlib_LTLIBRARIES = \ - libguile-gnuradio-pmt_swig.la -libguile_gnuradio_pmt_swig_la_SOURCES = \ - guile/pmt_swig.cc \ - $(pmt_swig_la_swig_sources) -nobase_pmt_swig_scm_DATA = \ - gnuradio/pmt_swig.scm \ - gnuradio/pmt_swig-primitive.scm -libguile_gnuradio_pmt_swig_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(pmt_swig_la_swig_libadd) -libguile_gnuradio_pmt_swig_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(pmt_swig_la_swig_ldflags) -libguile_gnuradio_pmt_swig_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(pmt_swig_la_swig_cxxflags) - -guile/pmt_swig.cc: gnuradio/pmt_swig.scm -gnuradio/pmt_swig.scm: pmt_swig.i -gnuradio/pmt_swig-primitive.scm: gnuradio/pmt_swig.scm - -# Include the guile dependencies for this file --include guile/pmt_swig.d - -endif # end of GUILE - - diff --git a/gruel/src/swig/gruel_common.i b/gruel/src/swig/gruel_common.i new file mode 100644 index 000000000..e4261cbfa --- /dev/null +++ b/gruel/src/swig/gruel_common.i @@ -0,0 +1,66 @@ +/* + * Copyright 2011 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 GRUEL_COMMON_I +#define GRUEL_COMMON_I + +//////////////////////////////////////////////////////////////////////// +// Language independent exception handler +//////////////////////////////////////////////////////////////////////// +%include exception.i + +%exception { + try { + $action + } + catch(std::exception &e) { + SWIG_exception(SWIG_RuntimeError, e.what()); + } + catch(...) { + SWIG_exception(SWIG_RuntimeError, "Unknown exception"); + } + +} + +//////////////////////////////////////////////////////////////////////// +// Wrapper for python calls that may block +//////////////////////////////////////////////////////////////////////// + +/*! + * Use GR_PYTHON_BLOCKING_CODE when calling code that blocks. + * + * The try/catch is to save us from boost::thread::interrupt: + * If a thread from the scheduler (or any other boost thread) + * is blocking the routine and throws an interrupt exception. + */ +%{ + +#define GR_PYTHON_BLOCKING_CODE(code) { \ + PyThreadState *_save; \ + _save = PyEval_SaveThread(); \ + try{code} \ + catch(...){PyEval_RestoreThread(_save); throw;} \ + PyEval_RestoreThread(_save); \ +} + +%} + +#endif /*GRUEL_COMMON_I*/ diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i index 0c937edfc..954501863 100644 --- a/gruel/src/swig/pmt_swig.i +++ b/gruel/src/swig/pmt_swig.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -34,26 +34,13 @@ #include <gruel/pmt.h> %} +%include "gruel_common.i" //load generated python docstrings %include "pmt_swig_doc.i" //////////////////////////////////////////////////////////////////////// // Language independent exception handler //////////////////////////////////////////////////////////////////////// -%include exception.i - -%exception { - try { - $action - } - catch(std::exception &e) { - SWIG_exception(SWIG_RuntimeError, e.what()); - } - catch(...) { - SWIG_exception(SWIG_RuntimeError, "Unknown exception"); - } - -} // Template intrusive_ptr for Swig to avoid dereferencing issues namespace pmt{ |