diff options
Diffstat (limited to 'gnuradio-core/src/lib/swig')
-rw-r--r-- | gnuradio-core/src/lib/swig/CMakeLists.txt | 88 | ||||
-rwxr-xr-x | gnuradio-core/src/lib/swig/gen-swig-bug-fix | 111 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gnuradio.i | 91 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gnuradio_core.py | 28 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gnuradio_core_filter.i | 32 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gnuradio_core_general.i | 54 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gnuradio_core_gengen.i | 32 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gnuradio_core_hier.i | 32 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gnuradio_core_io.i | 32 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gnuradio_core_runtime.i | 34 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h | 45 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gr_shared_ptr.i | 43 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/gr_swig_block_magic.i | 50 |
13 files changed, 672 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt new file mode 100644 index 000000000..d8a64cc0f --- /dev/null +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -0,0 +1,88 @@ +# Copyright 2010-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(GrPython) +include(GrSwig) + +set(GR_SWIG_INCLUDE_DIRS + ${CMAKE_CURRENT_BINARY_DIR} + ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} +) +set(GR_SWIG_LIBRARIES gnuradio-core) + +link_directories(${Boost_LIBRARY_DIRS}) + +######################################################################## +# Build and install the swig targets +######################################################################## +# ---------------------------------------------------------------- +# We've split the previously monstrous gnuradio_corethon 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! +# ---------------------------------------------------------------- + +set(GR_SWIG_TARGET_DEPS general_generated gengen_generated filter_generated pmt_swig) + +foreach(what runtime general gengen filter io hier) + SET(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${what}_swig_doc.i) + SET(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../${what} ${CMAKE_CURRENT_BINARY_DIR}/../${what}) + GR_SWIG_MAKE(gnuradio_core_${what} gnuradio_core_${what}.i) + GR_SWIG_INSTALL( + TARGETS gnuradio_core_${what} + DESTINATION ${GR_PYTHON_DIR}/gnuradio/gr + COMPONENT "core_python" + ) + install( + FILES + gnuradio_core_${what}.i + ${CMAKE_CURRENT_BINARY_DIR}/${what}_swig_doc.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" + ) + list(APPEND core_swig_deps ${SWIG_MODULE_gnuradio_core_${what}_REAL_NAME}) +endforeach(what) + +add_custom_target(core_swig DEPENDS ${core_swig_deps}) + +######################################################################## +# Install various files +######################################################################## +install(FILES + gnuradio.i + gr_swig_block_magic.i + gr_shared_ptr.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" +) + +GR_PYTHON_INSTALL( + FILES gnuradio_core.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/gr + COMPONENT "core_python" +) + +install( + FILES ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio_swig_bug_workaround.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_swig" +) diff --git a/gnuradio-core/src/lib/swig/gen-swig-bug-fix b/gnuradio-core/src/lib/swig/gen-swig-bug-fix new file mode 100755 index 000000000..5e9f82e7d --- /dev/null +++ b/gnuradio-core/src/lib/swig/gen-swig-bug-fix @@ -0,0 +1,111 @@ +#!/usr/bin/env python +# +# 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. +# + +import sys +import re + +def write_header (f): + f.write ('''/* -*- 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" + */ + +''') + +def write_trailer (f): + f.write (''' +#endif /* INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H */ +''') + +def doit (input, output): + re_RULES_BEGIN = re.compile ('RULES \(BEGIN\)') + re_RULES_END = re.compile ('RULES \(END\)') + re_RETURN = re.compile ('^\s*return') + re_NOT_ID = re.compile ('[^a-zA-Z0-9_]') + words = {} + + write_header (output) + for line in input: + if re_RULES_BEGIN.search (line): + break + + for line in input: + if re_RULES_END.search (line): + break + if not re_RETURN.match (line): + continue + line = re_NOT_ID.sub (' ', line) + line = re.sub (' +', ' ', line) + for w in line.split (' '): + words[w] = 1 + + for w in ('', 'return', 'void', 'x'): + del words[w] + + wl = words.keys() + wl.sort () + for w in wl: + output.write ('class ' + w + ';\n') + + write_trailer (output) + + +def main (): + if len (sys.argv) != 3: + sys.stderr.write ("usage: %s gnuradio_swig_python.cc gnuradio_swig_bug_workaround.h\n" + % (sys.argv[0],)) + sys.exit (1) + input_filename = sys.argv[1] + output_filename = sys.argv[2] + input = open (input_filename, "r") + output = open (output_filename, "w") + doit (input, output) + +if __name__ == '__main__': + main () + diff --git a/gnuradio-core/src/lib/swig/gnuradio.i b/gnuradio-core/src/lib/swig/gnuradio.i new file mode 100644 index 000000000..bf23bbbb2 --- /dev/null +++ b/gnuradio-core/src/lib/swig/gnuradio.i @@ -0,0 +1,91 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2004,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. + */ + +%pythoncode %{ +import gras +%} + +// Disable warning about base class types +#pragma SWIG nowarn=401 + +//////////////////////////////////////////////////////////////////////// +// gnuradio.i +// SWIG interface definition +//////////////////////////////////////////////////////////////////////// + +%include <gruel_common.i> + +//////////////////////////////////////////////////////////////////////// +// Headers + +%{ +#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix +#include <gr_types.h> +#include <stddef.h> // size_t +#include <complex> +%} + +%feature("autodoc","1"); + +// local file +%include <gr_shared_ptr.i> +%include <gr_types.h> +%include <std_complex.i> +%include <std_vector.i> +%include <stl.i> +%include <std_except.i> + +typedef std::complex<float> gr_complex; +typedef std::complex<double> gr_complexd; +typedef unsigned long long uint64_t; +typedef long long int64_t; + + +// instantiate the required template specializations + +namespace std { + %template() vector<unsigned char>; + %template() vector<char>; + %template() vector<short>; + %template() vector<int>; + %template() vector<float>; + %template() vector<double>; + // %template() std::complex<float>; + + %template() vector< std::complex<float> >; + %template() vector< std::vector< unsigned char > >; + %template() vector< std::vector< char > >; + %template() vector< std::vector< short > >; + %template() vector< std::vector< int > >; + %template() vector< std::vector< float > >; + %template() vector< std::vector< double > >; + %template() vector< std::vector< std::complex<float> > >; +}; + +//////////////////////////////////////////////////////////////////////// + +#ifndef SW_RUNTIME +// import runtime.i for all but sw_runtime, since it needs to %include +%import <runtime.i> +#endif + +//////////////////////////////////////////////////////////////////////// diff --git a/gnuradio-core/src/lib/swig/gnuradio_core.py b/gnuradio-core/src/lib/swig/gnuradio_core.py new file mode 100644 index 000000000..23de74077 --- /dev/null +++ b/gnuradio-core/src/lib/swig/gnuradio_core.py @@ -0,0 +1,28 @@ +# +# 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. +# + +# This file implements the old gnuradio_core namespace + +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_core_filter.i b/gnuradio-core/src/lib/swig/gnuradio_core_filter.i new file mode 100644 index 000000000..e9a44e54b --- /dev/null +++ b/gnuradio-core/src/lib/swig/gnuradio_core_filter.i @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +%include "filter_swig_doc.i" + +#ifndef SWIGIMPORTED +%module(directors="1") gnuradio_core_filter +#endif + + //%feature("autodoc", "1"); // generate python docstrings + +%include "gnuradio.i" // the common stuff + +%include "filter.i" diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_general.i b/gnuradio-core/src/lib/swig/gnuradio_core_general.i new file mode 100644 index 000000000..33f97815e --- /dev/null +++ b/gnuradio-core/src/lib/swig/gnuradio_core_general.i @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +%include "general_swig_doc.i" + +#define GR_CORE_API + +#ifndef SWIGIMPORTED +%module(directors="1") gnuradio_core_general +#endif + + //%feature("autodoc", "1"); // generate python docstrings + +%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); + } + +%} diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i b/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i new file mode 100644 index 000000000..b90a5bab3 --- /dev/null +++ b/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +%include "gengen_swig_doc.i" + +#ifndef SWIGIMPORTED +%module(directors="1") gnuradio_core_gengen +#endif + + //%feature("autodoc", "1"); // generate python docstrings + +%include "gnuradio.i" // the common stuff + +%include "gengen.i" diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_hier.i b/gnuradio-core/src/lib/swig/gnuradio_core_hier.i new file mode 100644 index 000000000..141d9b163 --- /dev/null +++ b/gnuradio-core/src/lib/swig/gnuradio_core_hier.i @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +%include "hier_swig_doc.i" + +#ifndef SWIGIMPORTED +%module(directors="1") gnuradio_hier_hier +#endif + + //%feature("autodoc", "1"); // generate python docstrings + +%include "gnuradio.i" // the common stuff + +%include "hier.i" diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_io.i b/gnuradio-core/src/lib/swig/gnuradio_core_io.i new file mode 100644 index 000000000..522b12b34 --- /dev/null +++ b/gnuradio-core/src/lib/swig/gnuradio_core_io.i @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +%include "io_swig_doc.i" + +#ifndef SWIGIMPORTED +%module(directors="1") gnuradio_core_io +#endif + + //%feature("autodoc", "1"); // generate python docstrings + +%include "gnuradio.i" // the common stuff + +%include "io.i" diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_runtime.i b/gnuradio-core/src/lib/swig/gnuradio_core_runtime.i new file mode 100644 index 000000000..fb311d226 --- /dev/null +++ b/gnuradio-core/src/lib/swig/gnuradio_core_runtime.i @@ -0,0 +1,34 @@ +/* -*- c++ -*- */ +/* + * 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, + * Boston, MA 02110-1301, USA. + */ + +%include "runtime_swig_doc.i" + +#ifndef SWIGIMPORTED +%module(directors="1") gnuradio_core_runtime +#endif + + //%feature("autodoc", "1"); // generate python docstrings + +#define SW_RUNTIME +%include "gnuradio.i" // the common stuff + +%include "runtime.i" 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..1994f0660 --- /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_shared_ptr.i b/gnuradio-core/src/lib/swig/gr_shared_ptr.i new file mode 100644 index 000000000..323d33ad7 --- /dev/null +++ b/gnuradio-core/src/lib/swig/gr_shared_ptr.i @@ -0,0 +1,43 @@ +// +// shared_ptr +// +// An enhanced relative of scoped_ptr with reference counted copy semantics. +// The object pointed to is deleted when the last shared_ptr pointing to it +// is destroyed or reset. +// + +// +// This is highly hacked up version of boost::shared_ptr +// We just need enough to get SWIG to "do the right thing" and +// generate "Smart Pointer" code. +// + +namespace boost { + +template<class T> class shared_ptr +{ +public: + + shared_ptr() + { + } + + shared_ptr (T * p) + { + } + + + T * operator-> () // never throws + { + return px; + } + + +private: + + T * px; // contained pointer + int pn; + +}; // shared_ptr + +};
\ No newline at end of file diff --git a/gnuradio-core/src/lib/swig/gr_swig_block_magic.i b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i new file mode 100644 index 000000000..4016ae772 --- /dev/null +++ b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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. + */ + +%define GR_SWIG_BLOCK_MAGIC(PKG, BASE_NAME) +_GR_SWIG_BLOCK_MAGIC_HELPER(PKG, BASE_NAME, PKG ## _ ## BASE_NAME) +%enddef + +%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 %{ +FULL_NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id ()) +%} +%enddef +#endif + +%define GR_SWIG_BLOCK_MAGIC2(PKG, BASE_NAME) +%template(BASE_NAME ## _sptr) boost::shared_ptr<gr:: ## PKG ## :: ## BASE_NAME>; +%pythoncode %{ +BASE_NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id()) +BASE_NAME = BASE_NAME.make; +%} +%enddef |