diff options
author | Vince Harron <vharron@google.com> | 2015-06-02 18:58:48 -0700 |
---|---|---|
committer | Vince Harron <vharron@google.com> | 2015-06-02 18:58:48 -0700 |
commit | b46a6ee1ee38582dd3af57ebe1b6d5e4158c34e0 (patch) | |
tree | b342a62eea47f607a7c0846c731bf151c1503359 /share/swig/2.0.11/ocaml/std_complex.i | |
parent | 6c85ed3bdac5c6dd65ad8cef83fc4fc7ef99a6c9 (diff) | |
download | linux-x86-b46a6ee1ee38582dd3af57ebe1b6d5e4158c34e0.tar.gz |
Adding binaries for 2.0.11HEADstudio-master-dev_before_27917934studio-master-dev_before_26911779studio-3.1.2studio-2.3studio-2.0-rc1studio-2.0studio-1.5studio-1.4gradle_3.1.2gradle_2.3.0gradle_2.0.0studio-master-releasestudio-1.4-releasestudio-1.4-devstudio-1.3-releasestudio-1.3-devmastermain
Diffstat (limited to 'share/swig/2.0.11/ocaml/std_complex.i')
-rw-r--r-- | share/swig/2.0.11/ocaml/std_complex.i | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/share/swig/2.0.11/ocaml/std_complex.i b/share/swig/2.0.11/ocaml/std_complex.i new file mode 100644 index 0000000..5192261 --- /dev/null +++ b/share/swig/2.0.11/ocaml/std_complex.i @@ -0,0 +1,65 @@ +// -*- C++ -*- +#ifndef SWIG_STD_COMPLEX_I_ +#define SWIG_STD_COMPLEX_I_ + +#ifdef SWIG + +%{ +#include <complex> +%} + +namespace std +{ + template <class T> class complex; + + %define specialize_std_complex(T) + + %typemap(in) complex<T> { + if (PyComplex_Check($input)) { + $1 = std::complex<T>(PyComplex_RealAsDouble($input), + PyComplex_ImagAsDouble($input)); + } else if (PyFloat_Check($input)) { + $1 = std::complex<T>(PyFloat_AsDouble($input), 0); + } else if (PyInt_Check($input)) { + $1 = std::complex<T>(PyInt_AsLong($input), 0); + } + else { + PyErr_SetString(PyExc_TypeError,"Expected a complex"); + SWIG_fail; + } + } + + %typemap(in) const complex<T>& (std::complex<T> temp) { + if (PyComplex_Check($input)) { + temp = std::complex<T>(PyComplex_RealAsDouble($input), + PyComplex_ImagAsDouble($input)); + $1 = &temp; + } else if (PyFloat_Check($input)) { + temp = std::complex<T>(PyFloat_AsDouble($input), 0); + $1 = &temp; + } else if (PyInt_Check($input)) { + temp = std::complex<T>(PyInt_AsLong($input), 0); + $1 = &temp; + } else { + PyErr_SetString(PyExc_TypeError,"Expected a complex"); + SWIG_fail; + } + } + + %typemap(out) complex<T> { + $result = PyComplex_FromDoubles($1.real(), $1.imag()); + } + + %typemap(out) const complex<T> & { + $result = PyComplex_FromDoubles($1->real(), $1->imag()); + } + + %enddef + + specialize_std_complex(double); + specialize_std_complex(float); +} + +#endif // SWIG + +#endif //SWIG_STD_COMPLEX_I_ |