Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: swig/Lib/python/pycomplex.swg

Issue 553095: Checkin swig binaries for win, linux and Mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « swig/Lib/python/pyclasses.swg ('k') | swig/Lib/python/pycontainer.swg » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 Defines the As/From converters for double/float complex, you need to
3 provide complex Type, the Name you want to use in the converters,
4 the complex Constructor method, and the Real and Imag complex
5 accessor methods.
6
7 See the std_complex.i and ccomplex.i for concret examples.
8 */
9
10 /* the common from converter */
11 %define %swig_fromcplx_conv(Type, Real, Imag)
12 %fragment(SWIG_From_frag(Type),"header")
13 {
14 SWIGINTERNINLINE PyObject*
15 SWIG_From(Type)(%ifcplusplus(const Type&, Type) c)
16 {
17 return PyComplex_FromDoubles(Real(c), Imag(c));
18 }
19 }
20 %enddef
21
22 /* the double case */
23 %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
24 %fragment(SWIG_AsVal_frag(Type),"header",
25 fragment=SWIG_AsVal_frag(double))
26 {
27 SWIGINTERN int
28 SWIG_AsVal(Type) (PyObject *o, Type* val)
29 {
30 if (PyComplex_Check(o)) {
31 if (val) *val = Constructor(PyComplex_RealAsDouble(o), PyComplex_ImagAsDoubl e(o));
32 return SWIG_OK;
33 } else {
34 double d;
35 int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d));
36 if (SWIG_IsOK(res)) {
37 if (val) *val = Constructor(d, 0.0);
38 return res;
39 }
40 }
41 return SWIG_TypeError;
42 }
43 }
44 %swig_fromcplx_conv(Type, Real, Imag);
45 %enddef
46
47 /* the float case */
48 %define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
49 %fragment(SWIG_AsVal_frag(Type),"header",
50 fragment=SWIG_AsVal_frag(float)) {
51 SWIGINTERN int
52 SWIG_AsVal(Type)(PyObject *o, Type *val)
53 {
54 if (PyComplex_Check(o)) {
55 double re = PyComplex_RealAsDouble(o);
56 double im = PyComplex_ImagAsDouble(o);
57 if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
58 if (val) *val = Constructor(%numeric_cast(re, float),
59 %numeric_cast(im, float));
60 return SWIG_OK;
61 } else {
62 return SWIG_OverflowError;
63 }
64 } else {
65 float re;
66 int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
67 if (SWIG_IsOK(res)) {
68 if (val) *val = Constructor(re, 0.0);
69 return res;
70 }
71 }
72 return SWIG_TypeError;
73 }
74 }
75
76 %swig_fromcplx_conv(Type, Real, Imag);
77 %enddef
78
79 #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
80 %swig_cplxflt_conv(Type, Constructor, Real, Imag)
81
82
83 #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
84 %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
85
86
OLDNEW
« no previous file with comments | « swig/Lib/python/pyclasses.swg ('k') | swig/Lib/python/pycontainer.swg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698