mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-13 05:20:45 +00:00
768e812e45
* On windows it's strongly desired to be able to compile straight out of a clean checkout or source download. This means anyone can download the source and investigate something quickly, without having to worry about the hassle of figuring out how the project downloads 3rd party dependencies, fetching them, getting them registered in the right place. * This can't be put in a submodule as git submodules don't get downloaded by default so people new to git will get confusing compilation messages, and someone downloading the source from github directly without cloning via git won't get submodules included. * It does add some extra size to a fresh download/checkout which is unfortunate, but absolutely worth the cost. Shallow checkouts still aren't unfeasibly large, and it's only a one-off cost at clone time.
87 lines
2.2 KiB
Plaintext
87 lines
2.2 KiB
Plaintext
/*
|
|
Defines the As/From converters for double/float complex, you need to
|
|
provide complex Type, the Name you want to use in the converters,
|
|
the complex Constructor method, and the Real and Imag complex
|
|
accessor methods.
|
|
|
|
See the std_complex.i and ccomplex.i for concrete examples.
|
|
*/
|
|
|
|
/* the common from converter */
|
|
%define %swig_fromcplx_conv(Type, Real, Imag)
|
|
%fragment(SWIG_From_frag(Type),"header")
|
|
{
|
|
SWIGINTERNINLINE PyObject*
|
|
SWIG_From(Type)(%ifcplusplus(const Type&, Type) c)
|
|
{
|
|
return PyComplex_FromDoubles(Real(c), Imag(c));
|
|
}
|
|
}
|
|
%enddef
|
|
|
|
/* the double case */
|
|
%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
|
|
%fragment(SWIG_AsVal_frag(Type),"header",
|
|
fragment=SWIG_AsVal_frag(double))
|
|
{
|
|
SWIGINTERN int
|
|
SWIG_AsVal(Type) (PyObject *o, Type* val)
|
|
{
|
|
if (PyComplex_Check(o)) {
|
|
if (val) *val = Constructor(PyComplex_RealAsDouble(o), PyComplex_ImagAsDouble(o));
|
|
return SWIG_OK;
|
|
} else {
|
|
double d;
|
|
int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d));
|
|
if (SWIG_IsOK(res)) {
|
|
if (val) *val = Constructor(d, 0.0);
|
|
return res;
|
|
}
|
|
}
|
|
return SWIG_TypeError;
|
|
}
|
|
}
|
|
%swig_fromcplx_conv(Type, Real, Imag);
|
|
%enddef
|
|
|
|
/* the float case */
|
|
%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
|
|
%fragment(SWIG_AsVal_frag(Type),"header",
|
|
fragment=SWIG_AsVal_frag(float)) {
|
|
SWIGINTERN int
|
|
SWIG_AsVal(Type)(PyObject *o, Type *val)
|
|
{
|
|
if (PyComplex_Check(o)) {
|
|
double re = PyComplex_RealAsDouble(o);
|
|
double im = PyComplex_ImagAsDouble(o);
|
|
if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
|
|
if (val) *val = Constructor(%numeric_cast(re, float),
|
|
%numeric_cast(im, float));
|
|
return SWIG_OK;
|
|
} else {
|
|
return SWIG_OverflowError;
|
|
}
|
|
} else {
|
|
float re;
|
|
int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
|
|
if (SWIG_IsOK(res)) {
|
|
if (val) *val = Constructor(re, 0.0);
|
|
return res;
|
|
}
|
|
}
|
|
return SWIG_TypeError;
|
|
}
|
|
}
|
|
|
|
%swig_fromcplx_conv(Type, Real, Imag);
|
|
%enddef
|
|
|
|
#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
|
|
%swig_cplxflt_conv(Type, Constructor, Real, Imag)
|
|
|
|
|
|
#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
|
|
%swig_cplxdbl_conv(Type, Constructor, Real, Imag)
|
|
|
|
|