]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/pyfragments.swg
more warning fixes about empty if statement in helper classes in release build
[wxWidgets.git] / wxPython / src / pyfragments.swg
1
2
3 //----------------------------------------------------------------------
4
5 // The standard t_output_helper has been changed to return a list rather than
6 // a tuple, we'll replace it with the old implementation here. In SWIG 1.3.27
7 // and earlier it is implemented as a $fragment, so it is only inserted into
8 // the modules that need it. For SWIG 1.3.28+ we just need to add a -D on the
9 // compile command line to turn on the tuple version of the AppendOuput
10 // function.
11 #if SWIG_VERSION < 0x010328
12 %fragment("t_output_helper","header")
13 %{
14 static PyObject* t_output_helper(PyObject* result, PyObject* obj)
15 {
16 PyObject* o2;
17 PyObject* o3;
18 if (!result) {
19 result = obj;
20 } else if (result == Py_None) {
21 Py_DECREF(result);
22 result = obj;
23 } else {
24 if (!PyTuple_Check(result)) {
25 o2 = result;
26 result = PyTuple_New(1);
27 PyTuple_SET_ITEM(result, 0, o2);
28 }
29 o3 = PyTuple_New(1);
30 PyTuple_SetItem(o3, 0, obj);
31 o2 = result;
32 result = PySequence_Concat(o2, o3);
33 Py_DECREF(o2);
34 Py_DECREF(o3);
35 }
36 return result;
37 }
38 %}
39
40 #endif
41
42
43
44
45 //----------------------------------------------------------------------
46 // These fragments are inserted in modules that need to convert PyObjects to
47 // integer values, my versions allow any numeric type to be used, as long as
48 // it can be converted to a PyInt. (Specifically, I allow floats where the
49 // default SWIG_AsVal_long would just raise an exception.
50 //
51
52 #if SWIG_VERSION < 0x010328
53
54 %fragment(SWIG_AsVal_frag(long), "header") {
55 SWIGINTERN int
56 SWIG_AsVal(long)(PyObject* obj, long* val)
57 {
58 if (PyNumber_Check(obj)) {
59 if (val) *val = PyInt_AsLong(obj);
60 return 1;
61 }
62 else {
63 SWIG_Python_TypeError("number", obj);
64 }
65 return 0;
66 }
67 }
68
69
70 %fragment(SWIG_AsVal_frag(unsigned long), "header",
71 fragment=SWIG_AsVal_frag(long)) {
72 SWIGINTERN int
73 SWIG_AsVal(unsigned long)(PyObject* obj, unsigned long* val)
74 {
75 long v = 0;
76 if (SWIG_AsVal_long(obj, &v) && v < 0) {
77 SWIG_Python_TypeError("unsigned number", obj);
78 }
79 else if (val)
80 *val = (unsigned long)v;
81 return 1;
82 }
83 }
84
85
86 %fragment(SWIG_AsVal_frag(double), "header") {
87 SWIGINTERN int
88 SWIG_AsVal(double)(PyObject *obj, double* val)
89 {
90 if (PyNumber_Check(obj)) {
91 if (val) *val = PyFloat_AsDouble(obj);
92 return 1;
93 }
94 else {
95 SWIG_Python_TypeError("number", obj);
96 }
97 return 0;
98 }
99 }
100
101
102 #else // SWIG_VERSION >= 1.3.28
103
104 %fragment(SWIG_AsVal_frag(long), "header") {
105 SWIGINTERN int
106 SWIG_AsVal(long)(PyObject* obj, long* val)
107 {
108 if (PyNumber_Check(obj)) {
109 if (val) *val = PyInt_AsLong(obj);
110 return SWIG_OK;
111 }
112 return SWIG_TypeError;
113 }
114 }
115
116
117 %fragment(SWIG_AsVal_frag(unsigned long), "header",
118 fragment=SWIG_AsVal_frag(long)) {
119 SWIGINTERN int
120 SWIG_AsVal(unsigned long)(PyObject* obj, unsigned long* val)
121 {
122 long v = 0;
123 if (SWIG_AsVal_long(obj, &v) && v < 0) {
124 return SWIG_TypeError;
125 }
126 else if (val)
127 *val = (unsigned long)v;
128 return SWIG_OK;
129 }
130 }
131
132
133 %fragment(SWIG_AsVal_frag(double), "header") {
134 SWIGINTERN int
135 SWIG_AsVal(double)(PyObject *obj, double* val)
136 {
137 if (PyNumber_Check(obj)) {
138 if (val) *val = PyFloat_AsDouble(obj);
139 return SWIG_OK;
140 }
141 return SWIG_TypeError;
142 }
143 }
144
145
146 #endif // SWIG_VERSION