summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/lib/swig/.gitignore77
-rw-r--r--gnuradio-core/src/lib/swig/Makefile.am4
-rw-r--r--gnuradio-core/src/lib/swig/gnuradio.i6
-rw-r--r--gnuradio-core/src/lib/swig/gnuradio_core_general.i20
-rw-r--r--gnuradio-core/src/lib/swig/guile/std_complex.i30
5 files changed, 89 insertions, 48 deletions
diff --git a/gnuradio-core/src/lib/swig/.gitignore b/gnuradio-core/src/lib/swig/.gitignore
index 0018a2a54..75d6ce5b7 100644
--- a/gnuradio-core/src/lib/swig/.gitignore
+++ b/gnuradio-core/src/lib/swig/.gitignore
@@ -10,51 +10,34 @@
/swigrun.py
/swigrun_wrap.c
/Makefile.swigdeps.new
-/gnuradio_core_runtime.d
-/gnuradio_core_general.d
-/gnuradio_core_gengen.d
-/gnuradio_core_filter.d
-/gnuradio_core_io.d
/gnuradio_swig_bug_workaround.h
-/gnuradio_core_runtime.cc
-/gnuradio_core_runtime.h
-/gnuradio_core_runtime.py
-/gnuradio_core_general.cc
-/gnuradio_core_general.h
-/gnuradio_core_general.py
-/gnuradio_core_gengen.cc
-/gnuradio_core_gengen.h
-/gnuradio_core_gengen.py
-/gnuradio_core_filter.cc
-/gnuradio_core_filter.h
-/gnuradio_core_filter.py
-/gnuradio_core_io.cc
-/gnuradio_core_io.h
-/gnuradio_core_io.py
-/gnuradio_core_hier.cc
-/gnuradio_core_hier.h
-/gnuradio_core_hier.py
-/gnuradio_core_filter_python.cc
-/gnuradio_core_filter_python.h
-/gnuradio_core_general_python.cc
-/gnuradio_core_general_python.h
-/gnuradio_core_gengen_python.cc
-/gnuradio_core_gengen_python.h
-/gnuradio_core_hier_python.cc
-/gnuradio_core_hier_python.h
-/gnuradio_core_io_python.cc
-/gnuradio_core_io_python.h
-/gnuradio_core_runtime_python.cc
-/gnuradio_core_runtime_python.h
-/gnuradio_core_filter.scm
-/gnuradio_core_filter_guile.cc
-/gnuradio_core_general.scm
-/gnuradio_core_general_guile.cc
-/gnuradio_core_gengen.scm
-/gnuradio_core_gengen_guile.cc
-/gnuradio_core_hier.scm
-/gnuradio_core_hier_guile.cc
-/gnuradio_core_io.scm
-/gnuradio_core_io_guile.cc
-/gnuradio_core_runtime.scm
-/gnuradio_core_runtime_guile.cc
+gnuradio_core_filter.cc
+gnuradio_core_filter.d
+gnuradio_core_filter.h
+gnuradio_core_filter.py
+gnuradio_core_filter.scm
+gnuradio_core_general.cc
+gnuradio_core_general.d
+gnuradio_core_general.h
+gnuradio_core_general.py
+gnuradio_core_general.scm
+gnuradio_core_gengen.cc
+gnuradio_core_gengen.d
+gnuradio_core_gengen.h
+gnuradio_core_gengen.py
+gnuradio_core_gengen.scm
+gnuradio_core_hier.cc
+gnuradio_core_hier.d
+gnuradio_core_hier.h
+gnuradio_core_hier.py
+gnuradio_core_hier.scm
+gnuradio_core_io.cc
+gnuradio_core_io.d
+gnuradio_core_io.h
+gnuradio_core_io.py
+gnuradio_core_io.scm
+gnuradio_core_runtime.cc
+gnuradio_core_runtime.d
+gnuradio_core_runtime.h
+gnuradio_core_runtime.py
+gnuradio_core_runtime.scm
diff --git a/gnuradio-core/src/lib/swig/Makefile.am b/gnuradio-core/src/lib/swig/Makefile.am
index fb8577f72..f30b877a1 100644
--- a/gnuradio-core/src/lib/swig/Makefile.am
+++ b/gnuradio-core/src/lib/swig/Makefile.am
@@ -50,6 +50,10 @@ swiginclude_HEADERS = \
gr_swig_block_magic.i \
gr_shared_ptr.i
+# SWIG headers that get installed in ${prefix}/include/gnuradio/swig/...
+nobase_swiginclude_HEADERS = \
+ guile/std_complex.i
+
if GUILE
# This is the top level guile file, which loads all the other scm files
diff --git a/gnuradio-core/src/lib/swig/gnuradio.i b/gnuradio-core/src/lib/swig/gnuradio.i
index ec0264107..a30655f45 100644
--- a/gnuradio-core/src/lib/swig/gnuradio.i
+++ b/gnuradio-core/src/lib/swig/gnuradio.i
@@ -42,8 +42,12 @@
// non-local SWIG files
%include <stl.i>
-%include <std_complex.i>
%include <std_except.i>
+#ifdef SWIGGUILE
+%include <guile/std_complex.i>
+#else
+%include <std_complex.i>
+#endif
typedef std::complex<float> gr_complex;
typedef std::complex<double> gr_complexd;
diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_general.i b/gnuradio-core/src/lib/swig/gnuradio_core_general.i
index a82f1f5b3..3edca69ef 100644
--- a/gnuradio-core/src/lib/swig/gnuradio_core_general.i
+++ b/gnuradio-core/src/lib/swig/gnuradio_core_general.i
@@ -29,6 +29,26 @@
%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);
+ }
+
+%}
+
#if SWIGGUILE
%scheme %{
(load-extension "libguile-gnuradio_core_general" "SWIG_init")
diff --git a/gnuradio-core/src/lib/swig/guile/std_complex.i b/gnuradio-core/src/lib/swig/guile/std_complex.i
new file mode 100644
index 000000000..cafcfeae3
--- /dev/null
+++ b/gnuradio-core/src/lib/swig/guile/std_complex.i
@@ -0,0 +1,30 @@
+%{
+#include <complex>
+%}
+
+// To the target language, complex number conversion
+%typemap(out) complex, complex<double>, std::complex<double> {
+ $result = scm_make_rectangular( gh_double2scm ($1.real ()),
+ gh_double2scm ($1.imag ()) );
+}
+
+// To the target language, complex number conversion
+%typemap(out) complex, complex<float>, std::complex<float> {
+ $result = scm_make_rectangular( gh_double2scm ($1.real ()),
+ gh_double2scm ($1.imag ()) );
+}
+
+// From the target language, complex number conversion
+%typemap(in) complex, complex<double>, std::complex<double> {
+ $1 = std::complex<double>( gh_scm2double (scm_real_part ($input)),
+ gh_scm2double (scm_imag_part ($input)) );
+}
+
+// From the target language, complex number conversion
+%typemap(in) complex, complex<float>, std::complex<float> {
+ $1 = std::complex<float>( gh_scm2double (scm_real_part ($input)),
+ gh_scm2double (scm_imag_part ($input)) );
+}
+
+%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>);
+%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>);