Add the macros %typemap_asfromcheck() %typemap_asfrom() that can be used to defined all the different typemaps for types where the As/From/Check methods are provided. All the basic type (int, char,...) typemaps are implemented using them. The std::string and std::complex<T> are reimplemented using the new %typemap_asfrom/check macros too. This helps to complete all the previously missing typemaps (consttab, varin, varout,..) and also ilustrates how to define the As/From/Check methods to use with the %typemap_asfrom/check macros. As a byproduct, the C complex typemap was added, and the file complex.i can be used to load the complex support for either C or C++. The original C++ std_complex.i is still there, and the corresponding C ccomplex.i too, if they need to be included explicitly. Also, the As/From methods are declared via %fragment, so, they can be reused as needed, and only appear in the wrapped code if they corresponding typemap is invoked, making the typemaps and the entire code shorter and simpler. Marcelo. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5691 626c5289-ae23-0410-ae9c-e8d60b6d4f22
41 lines
854 B
OpenEdge ABL
41 lines
854 B
OpenEdge ABL
#ifndef __python_ccomplex_i__
|
|
#define __python_ccomplex_i__
|
|
|
|
/*
|
|
* C complex wrap
|
|
* ISO C99: 7.3 Complex arithmetic <complex.h>
|
|
*/
|
|
|
|
%{
|
|
#include <complex.h>
|
|
%}
|
|
|
|
|
|
/*
|
|
the %{}% around these typedefs must be removed once
|
|
swig parser supports 'float complex'...
|
|
*/
|
|
%{
|
|
typedef float complex float_complex;
|
|
typedef double complex double_complex;
|
|
%}
|
|
|
|
|
|
%include "complex_common.i"
|
|
|
|
#define CCOMPLEX(r, i) ((r) + I*(i))
|
|
%swig_cplxflt_conv(float_complex, CCplxFlt, CCOMPLEX, creal, cimag)
|
|
%swig_cplxdbl_conv(double_complex, CCplxDbl, CCOMPLEX, creal, cimag)
|
|
|
|
/* declaring the typemaps */
|
|
%typemap_asfrom(float_complex, CPLXFLT,
|
|
SWIG_PyObj_AsCCplxFlt, SWIG_PyObj_FromCCplxFlt);
|
|
|
|
%typemap_asfrom(double_complex, CPLXDBL,
|
|
SWIG_PyObj_AsCCplxDbl, SWIG_PyObj_FromCCplxDbl);
|
|
|
|
%apply double_complex { complex };
|
|
|
|
|
|
|
|
#endif //__python_ccomplex_i__
|