summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/swig
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib/swig')
-rw-r--r--gnuradio-core/src/lib/swig/Makefile.am111
-rw-r--r--gnuradio-core/src/lib/swig/atsc.i136
-rwxr-xr-xgnuradio-core/src/lib/swig/gen-swig-bug-fix111
-rw-r--r--gnuradio-core/src/lib/swig/gnuradio.i84
-rw-r--r--gnuradio-core/src/lib/swig/shared_ptr.i43
5 files changed, 485 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/swig/Makefile.am b/gnuradio-core/src/lib/swig/Makefile.am
new file mode 100644
index 000000000..77bd03083
--- /dev/null
+++ b/gnuradio-core/src/lib/swig/Makefile.am
@@ -0,0 +1,111 @@
+#
+# Copyright 2001,2003,2004,2005 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+# Install this stuff in the gr subdirectory of the python pkg dir.
+# This usually ends up at:
+# ${prefix}/lib/python${python_version}/site-packages/gnuradio/gr
+
+grgrpythondir = $(grpythondir)/gr
+grgrlibdir = $(grpyexecdir)/gr
+
+
+INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) -I$(srcdir)
+
+
+EXTRA_DIST = gen-swig-bug-fix
+
+
+LOCAL_IFILES = \
+ gnuradio.i \
+ shared_ptr.i
+
+ALL_IFILES = \
+ $(LOCAL_IFILES)
+
+
+BUILT_SOURCES = \
+ gnuradio_swig_python.cc \
+ gnuradio_swig_python.py \
+ gnuradio_swig_python.h \
+ gnuradio_swig_bug_workaround.h
+
+grgrpython_PYTHON = \
+ gnuradio_swig_python.py
+
+
+SWIGPYTHONARGS = $(SWIGPYTHONFLAGS) $(INCLUDES)
+
+
+# ----------------------------------------------------------------
+# _gnuradio_swig_python contains all the glue that implements
+# the gnuradio.gr python package
+
+grgrlib_LTLIBRARIES = \
+ _gnuradio_swig_python.la
+
+_gnuradio_swig_python_la_SOURCES = \
+ gnuradio_swig_python.cc
+
+
+_gnuradio_swig_python_la_LIBADD = \
+ $(top_builddir)/gnuradio-core/src/lib/libgnuradio-core.la \
+ $(PYTHON_LDFLAGS) \
+ -lstdc++
+
+_gnuradio_swig_python_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
+
+
+# KLUDGE: Force runtime include of gnuradio_swig_python.d dependency file.
+# This is not guaranteed to be portable, but will probably work.
+# If it works, we have accurate dependencies for our swig stuff, which is good.
+@am__include@ @am__quote@./gnuradio_swig_python.d@am__quote@
+
+gnuradio_swig_python.cc gnuradio_swig_python.py gnuradio_swig_python.h : gnuradio.i
+ if $(SWIG) $(SWIGPYTHONARGS) -MMD -MF gnuradio_swig_python.Td -module gnuradio_swig_python -o gnuradio_swig_python.cc $< ;\
+ then if test $(host_os) = mingw32; \
+ then sed 's,\\\\,/,g' <gnuradio_swig_python.Td >gnuradio_swig_python.d; rm -f gnuradio_swig_python.Td; \
+ else mv -f gnuradio_swig_python.Td gnuradio_swig_python.d; fi \
+ else rm -f gnuradio_swig_python.Td; exit 1; fi
+
+gnuradio_swig_bug_workaround.h : gnuradio_swig_python.cc $(srcdir)/gen-swig-bug-fix
+ $(srcdir)/gen-swig-bug-fix $< $@
+
+
+# ----------------------------------------------------------------
+
+# Don't distribute output of swig
+dist-hook:
+ @for file in $(BUILT_SOURCES); do echo $(RM) $(distdir)/$$file; done
+ @for file in $(BUILT_SOURCES); do $(RM) $(distdir)/$$file; done
+
+
+grinclude_HEADERS = \
+ gnuradio_swig_bug_workaround.h
+
+swiginclude_HEADERS = \
+ $(LOCAL_IFILES)
+
+MOSTLYCLEANFILES = \
+ $(BUILT_SOURCES) *~ *.pyc
+
+DISTCLEANFILES = gnuradio_swig_python.d
diff --git a/gnuradio-core/src/lib/swig/atsc.i b/gnuradio-core/src/lib/swig/atsc.i
new file mode 100644
index 000000000..4e8bf48f2
--- /dev/null
+++ b/gnuradio-core/src/lib/swig/atsc.i
@@ -0,0 +1,136 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2003 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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+%{
+#include <atsc_types.h>
+#include <atsc_consts.h>
+#include <GrAtscRandomizer.h>
+#include <GrAtscRSEncoder.h>
+#include <GrAtscInterleaver.h>
+#include <GrAtscTrellisEncoder.h>
+#include <GrAtscFieldSyncMux.h>
+#include <GrAtscSymbolMapper.h>
+#include <GrAtscConvert2xTo20.h>
+#include <GrWeaverModHead.h>
+#include <GrWeaverModTail.h>
+
+%}
+
+// from atsc_types.h
+class plinfo;
+class atsc_mpeg_packet;
+class atsc_mpeg_packet_no_sync;
+class atsc_mpeg_packet_rs_encoded;
+class atsc_data_segment;
+class atsc_soft_data_segment;
+
+%include <atsc_consts.h>
+
+
+// leave out the VrHistoryProc and pretend we're directly derived from VrSigProc
+
+// %template(VrHistoryProc_1) VrHistoryProc<atsc_mpeg_packet,atsc_mpeg_packet_no_sync>;
+
+class GrAtscRandomizer : public VrSigProc
+// class GrAtscRandomizer : public VrHistoryProc<atsc_mpeg_packet, atsc_mpeg_packet_no_sync>
+{
+public:
+ GrAtscRandomizer ();
+ ~GrAtscRandomizer ();
+};
+
+class GrAtscRSEncoder : public VrSigProc
+{
+public:
+ GrAtscRSEncoder ();
+ ~GrAtscRSEncoder ();
+};
+
+class GrAtscInterleaver : public VrSigProc
+{
+public:
+ GrAtscInterleaver ();
+ ~GrAtscInterleaver ();
+};
+
+class GrAtscTrellisEncoder : public VrSigProc
+{
+public:
+ GrAtscTrellisEncoder ();
+ ~GrAtscTrellisEncoder ();
+};
+
+class GrAtscFieldSyncMux : public VrSigProc
+{
+public:
+ GrAtscFieldSyncMux ();
+ ~GrAtscFieldSyncMux ();
+};
+
+template<class oType>
+class GrAtscSymbolMapper : public VrSigProc
+{
+public:
+ GrAtscSymbolMapper ();
+ ~GrAtscSymbolMapper ();
+};
+
+%template(GrAtscSymbolMapperF) GrAtscSymbolMapper<float>;
+
+template<class iType, class oType>
+class GrWeaverModHead : public VrSigProc
+{
+public:
+ GrWeaverModHead (int interp_factor);
+ ~GrWeaverModHead ();
+};
+
+%template(GrWeaverModHeadFF) GrWeaverModHead<float,float>;
+
+template<class iType, class oType>
+class GrWeaverModTail : public VrSigProc {
+public:
+ GrWeaverModTail (float freq, float gain);
+ ~GrWeaverModTail ();
+
+ //! frequency is in Hz
+ void set_freq (float frequency);
+ void set_gain (float g);
+};
+
+%template(GrWeaverModTailFS) GrWeaverModTail<float,short>;
+
+class GrAtscConvert2xTo20 : public VrSigProc
+{
+public:
+ GrAtscConvert2xTo20 ();
+ ~GrAtscConvert2xTo20 ();
+};
+
+
+#if 0 // FIXME
+%template(VrSource_mpeg_packet) VrSource<atsc_mpeg_packet>;
+%template(VrFileSource_mpeg_packet) VrFileSource<atsc_mpeg_packet>;
+
+%template(VrSink_mpeg_packet) VrSink<atsc_mpeg_packet>;
+%template(VrFileSink_mpeg_packet) VrFileSink<atsc_mpeg_packet>;
+#endif
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..36332cc59
--- /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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, 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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, 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..b8c58538c
--- /dev/null
+++ b/gnuradio-core/src/lib/swig/gnuradio.i
@@ -0,0 +1,84 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2003,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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+////////////////////////////////////////////////////////////////////////
+// gnuradio.i
+// SWIG interface definition
+////////////////////////////////////////////////////////////////////////
+
+
+#ifndef SWIGIMPORTED
+// we set the module name on the command line (not any more)
+%module(directors="1") gnuradio_swig_python
+#endif
+
+////////////////////////////////////////////////////////////////////////
+// Headers
+
+
+%{
+#include <gr_types.h>
+#include <stddef.h> // size_t
+%}
+
+%feature("autodoc","1");
+
+%include <shared_ptr.i>
+%include <stl.i>
+%include <std_complex.i>
+
+
+typedef std::complex<float> gr_complex;
+typedef std::complex<double> gr_complexd;
+
+
+// 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() vector<std::complex<float> >;
+};
+
+////////////////////////////////////////////////////////////////////////
+
+%constant int sizeof_char = sizeof(char);
+%constant int sizeof_short = sizeof(short);
+%constant int sizeof_int = sizeof(int);
+%constant int sizeof_float = sizeof(float);
+%constant int sizeof_double = sizeof(double);
+%constant int sizeof_gr_complex = sizeof(gr_complex);
+
+////////////////////////////////////////////////////////////////////////
+
+%include <runtime.i>
+%include <general.i>
+%include <filter.i>
+%include <io.i>
+
+// %include <atsc.i>
+
+////////////////////////////////////////////////////////////////////////
diff --git a/gnuradio-core/src/lib/swig/shared_ptr.i b/gnuradio-core/src/lib/swig/shared_ptr.i
new file mode 100644
index 000000000..9663033ae
--- /dev/null
+++ b/gnuradio-core/src/lib/swig/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