Reducing pyrun.swg and splitting python.swg into different files
for clarity and for easier maintainance. pyrun.swg almost the same than 1.3.20, therefore there will be compatible again. code generated is reduced by the use and reuse of %fragments. as usual, all the test-suite is compiling and a much bigger "test project" too. with the new typemaps definition should be much eaiser and uniform add stl/std and user types. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5706 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7fef280ae0
commit
68024b15ce
17 changed files with 1465 additions and 1250 deletions
|
|
@ -1,27 +1,40 @@
|
|||
#ifndef __python_complex_common_i__
|
||||
#define __python_complex_common_i__
|
||||
|
||||
/*
|
||||
Defines the As/From conversors for double/float complex, you need to
|
||||
provide complex Type, the Name you want to use in the conversors,
|
||||
the complex Constructor method, and the Real and Imag complex
|
||||
accesor methods.
|
||||
|
||||
See the std_complex.i and ccomplex.i for concret examples.
|
||||
*/
|
||||
|
||||
/* the common from conversor */
|
||||
%define %swig_fromcplx_conv(Type, Name, Real, Imag)
|
||||
%fragment("SWIG_PyObj_From"#Name,"header")
|
||||
%fragment("SWIG_From"#Name,"header")
|
||||
%{
|
||||
SWIGSTATIC(PyObject*)
|
||||
SWIG_PyObj_From##Name(Type c)
|
||||
SWIG_From##Name(Type c)
|
||||
{
|
||||
return PyComplex_FromDoubles(Real(c), Imag(c));
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
|
||||
/* the double case */
|
||||
%define %swig_cplxdbl_conv(Type, Name, Constructor, Real, Imag)
|
||||
%fragment("SWIG_PyObj_As"#Name,"header",fragment="SWIG_PyObj_AsDouble")
|
||||
%fragment("SWIG_As"#Name,"header",
|
||||
fragment="SWIG_AsDouble")
|
||||
%{
|
||||
SWIGSTATIC(Type)
|
||||
SWIG_PyObj_As##Name(PyObject *o)
|
||||
SWIG_As##Name(PyObject *o)
|
||||
{
|
||||
Type c = PyComplex_Check(o) ?
|
||||
Constructor(PyComplex_RealAsDouble(o),
|
||||
PyComplex_ImagAsDouble(o)) :
|
||||
Constructor(SWIG_PyObj_AsDouble(o), 0);
|
||||
Constructor(SWIG_AsDouble(o), 0);
|
||||
if (PyErr_Occurred()){
|
||||
PyErr_Clear();
|
||||
PyErr_SetString(PyExc_TypeError, "a Type is expected");
|
||||
|
|
@ -32,24 +45,27 @@ SWIG_PyObj_As##Name(PyObject *o)
|
|||
%swig_fromcplx_conv(Type, Name, Real, Imag);
|
||||
%enddef
|
||||
|
||||
/* the float case */
|
||||
%define %swig_cplxflt_conv(Type, Name, Constructor, Real, Imag)
|
||||
%fragment("SWIG_PyObj_As"#Name,"header",fragment="SWIG_PyObj_AsDouble")
|
||||
%fragment("SWIG_As"#Name,"header",
|
||||
fragment="SWIG_CheckFloat",
|
||||
fragment="SWIG_AsDouble")
|
||||
%{
|
||||
SWIGSTATIC(Type)
|
||||
SWIG_PyObj_As##Name(PyObject *o)
|
||||
SWIG_As##Name(PyObject *o)
|
||||
{
|
||||
Type c = PyComplex_Check(o) ?
|
||||
Constructor(SWIG_PyObj_AsFloatConv(o, PyComplex_RealAsDouble),
|
||||
SWIG_PyObj_AsFloatConv(o, PyComplex_ImagAsDouble)) :
|
||||
Constructor(SWIG_PyObj_AsFloatConv(o, SWIG_PyObj_AsDouble),
|
||||
0);
|
||||
if (PyErr_Occurred()){
|
||||
Constructor(SWIG_CheckFloat(PyComplex_RealAsDouble(o)),
|
||||
SWIG_CheckFloat(PyComplex_RealAsDouble(o))) :
|
||||
Constructor(SWIG_CheckFloat(SWIG_AsDouble(o)),0);
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Clear();
|
||||
PyErr_SetString(PyExc_TypeError, "a Type is expected");
|
||||
}
|
||||
return c;
|
||||
}
|
||||
%}
|
||||
|
||||
%swig_fromcplx_conv(Type, Name, Real, Imag);
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue