2331
|
1 |
--- pygame-1.9.1release/src/pgcompat.h-orig 2010-02-03 07:53:46.178657442 -0600
|
|
2 |
+++ pygame-1.9.1release/src/pgcompat.h 2010-02-03 07:53:57.263344034 -0600
|
|
3 |
@@ -1,118 +1,118 @@
|
|
4 |
-/* Python 2.x/3.x compitibility tools
|
|
5 |
- */
|
|
6 |
-
|
|
7 |
-#if !defined(PGCOMPAT_H)
|
|
8 |
-#define PGCOMPAT_H
|
|
9 |
-
|
|
10 |
-#if PY_MAJOR_VERSION >= 3
|
|
11 |
-
|
|
12 |
-#define PY3 1
|
|
13 |
-
|
|
14 |
-/* Define some aliases for the removed PyInt_* functions */
|
|
15 |
-#define PyInt_Check(op) PyLong_Check(op)
|
|
16 |
-#define PyInt_FromString PyLong_FromString
|
|
17 |
-#define PyInt_FromUnicode PyLong_FromUnicode
|
|
18 |
-#define PyInt_FromLong PyLong_FromLong
|
|
19 |
-#define PyInt_FromSize_t PyLong_FromSize_t
|
|
20 |
-#define PyInt_FromSsize_t PyLong_FromSsize_t
|
|
21 |
-#define PyInt_AsLong PyLong_AsLong
|
|
22 |
-#define PyInt_AsSsize_t PyLong_AsSsize_t
|
|
23 |
-#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
|
|
24 |
-#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
|
|
25 |
-#define PyInt_AS_LONG PyLong_AS_LONG
|
|
26 |
-#define PyNumber_Int PyNumber_Long
|
|
27 |
-
|
|
28 |
-/* Weakrefs flags changed in 3.x */
|
|
29 |
-#define Py_TPFLAGS_HAVE_WEAKREFS 0
|
|
30 |
-
|
|
31 |
-/* Module init function returns new module instance. */
|
|
32 |
-#define MODINIT_RETURN(x) return x
|
|
33 |
-#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name (void)
|
|
34 |
-#define DECREF_MOD(mod) Py_DECREF (mod)
|
|
35 |
-
|
|
36 |
-/* Type header differs. */
|
|
37 |
-#define TYPE_HEAD(x,y) PyVarObject_HEAD_INIT(x,y)
|
|
38 |
-
|
|
39 |
-/* Text interface. Use unicode strings. */
|
|
40 |
-#define Text_Type PyUnicode_Type
|
|
41 |
-#define Text_Check PyUnicode_Check
|
|
42 |
-#define Text_FromUTF8 PyUnicode_FromString
|
|
43 |
-#define Text_FromUTF8AndSize PyUnicode_FromStringAndSize
|
|
44 |
-#define Text_FromFormat PyUnicode_FromFormat
|
|
45 |
-#define Text_GetSize PyUnicode_GetSize
|
|
46 |
-#define Text_GET_SIZE PyUnicode_GET_SIZE
|
|
47 |
-
|
|
48 |
-/* Binary interface. Use bytes. */
|
|
49 |
-#define Bytes_Type PyBytes_Type
|
|
50 |
-#define Bytes_Check PyBytes_Check
|
|
51 |
-#define Bytes_Size PyBytes_Size
|
|
52 |
-#define Bytes_AsString PyBytes_AsString
|
|
53 |
-#define Bytes_AsStringAndSize PyBytes_AsStringAndSize
|
|
54 |
-#define Bytes_FromStringAndSize PyBytes_FromStringAndSize
|
|
55 |
-#define Bytes_AS_STRING PyBytes_AS_STRING
|
|
56 |
-#define Bytes_GET_SIZE PyBytes_GET_SIZE
|
|
57 |
-
|
|
58 |
-#define IsTextObj(x) (PyUnicode_Check(x) || PyBytes_Check(x))
|
|
59 |
-
|
|
60 |
-/* Renamed builtins */
|
|
61 |
-#define BUILTINS_MODULE "builtins"
|
|
62 |
-#define BUILTINS_UNICODE "str"
|
|
63 |
-#define BUILTINS_UNICHR "chr"
|
|
64 |
-
|
|
65 |
-#else /* PY_VERSION_HEX >= 0x03000000 */
|
|
66 |
-
|
|
67 |
-#define PY3 0
|
|
68 |
-
|
|
69 |
-/* Module init function returns nothing. */
|
|
70 |
-#define MODINIT_RETURN(x) return
|
|
71 |
-#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC init##mod_name (void)
|
|
72 |
-#define DECREF_MOD(mod)
|
|
73 |
-
|
|
74 |
-/* Type header differs. */
|
|
75 |
-#define TYPE_HEAD(x,y) \
|
|
76 |
- PyObject_HEAD_INIT(x) \
|
|
77 |
- 0,
|
|
78 |
-
|
|
79 |
-/* Text interface. Use ascii strings. */
|
|
80 |
-#define Text_Type PyString_Type
|
|
81 |
-#define Text_Check PyString_Check
|
|
82 |
-#define Text_FromUTF8 PyString_FromString
|
|
83 |
-#define Text_FromUTF8AndSize PyString_FromStringAndSize
|
|
84 |
-#define Text_FromFormat PyString_FromFormat
|
|
85 |
-#define Text_GetSize PyString_GetSize
|
|
86 |
-#define Text_GET_SIZE PyString_GET_SIZE
|
|
87 |
-
|
|
88 |
-/* Binary interface. Use ascii strings. */
|
|
89 |
-#define Bytes_Type PyString_Type
|
|
90 |
-#define Bytes_Check PyString_Check
|
|
91 |
-#define Bytes_Size PyString_Size
|
|
92 |
-#define Bytes_AsString PyString_AsString
|
|
93 |
-#define Bytes_AsStringAndSize PyString_AsStringAndSize
|
|
94 |
-#define Bytes_FromStringAndSize PyString_FromStringAndSize
|
|
95 |
-#define Bytes_AS_STRING PyString_AS_STRING
|
|
96 |
-#define Bytes_GET_SIZE PyString_GET_SIZE
|
|
97 |
-
|
|
98 |
-/* Renamed builtins */
|
|
99 |
-#define BUILTINS_MODULE "__builtin__"
|
|
100 |
-#define BUILTINS_UNICODE "unicode"
|
|
101 |
-#define BUILTINS_UNICHR "unichr"
|
|
102 |
-
|
|
103 |
-#endif /* PY_VERSION_HEX >= 0x03000000 */
|
|
104 |
-
|
|
105 |
-#define MODINIT_ERROR MODINIT_RETURN (NULL)
|
|
106 |
-
|
|
107 |
-/* Module state. These macros are used to define per-module macros.
|
|
108 |
- * v - global state variable (Python 2.x)
|
|
109 |
- * s - global state structure (Python 3.x)
|
|
110 |
- */
|
|
111 |
-#define PY2_GETSTATE(v) (&(v))
|
|
112 |
-#define PY3_GETSTATE(s, m) ((struct s *) PyModule_GetState (m))
|
|
113 |
-
|
|
114 |
-/* Pep 3123: Making PyObject_HEAD conform to standard C */
|
|
115 |
-#if !defined(Py_TYPE)
|
|
116 |
-#define Py_TYPE(o) (((PyObject*)(o))->ob_type)
|
|
117 |
-#define Py_REFCNT(o) (((PyObject*)(o))->ob_refcnt)
|
|
118 |
-#define Py_SIZE(o) (((PyVarObject*)(o))->ob_size)
|
|
119 |
-#endif
|
|
120 |
-
|
|
121 |
-#endif /* !defined(PGCOMPAT_H) */
|
|
122 |
+/* Python 2.x/3.x compitibility tools
|
|
123 |
+ */
|
|
124 |
+
|
|
125 |
+#if !defined(PGCOMPAT_H)
|
|
126 |
+#define PGCOMPAT_H
|
|
127 |
+
|
|
128 |
+#if PY_MAJOR_VERSION >= 3
|
|
129 |
+
|
|
130 |
+#define PY3 1
|
|
131 |
+
|
|
132 |
+/* Define some aliases for the removed PyInt_* functions */
|
|
133 |
+#define PyInt_Check(op) PyLong_Check(op)
|
|
134 |
+#define PyInt_FromString PyLong_FromString
|
|
135 |
+#define PyInt_FromUnicode PyLong_FromUnicode
|
|
136 |
+#define PyInt_FromLong PyLong_FromLong
|
|
137 |
+#define PyInt_FromSize_t PyLong_FromSize_t
|
|
138 |
+#define PyInt_FromSsize_t PyLong_FromSsize_t
|
|
139 |
+#define PyInt_AsLong PyLong_AsLong
|
|
140 |
+#define PyInt_AsSsize_t PyLong_AsSsize_t
|
|
141 |
+#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
|
|
142 |
+#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
|
|
143 |
+#define PyInt_AS_LONG PyLong_AS_LONG
|
|
144 |
+#define PyNumber_Int PyNumber_Long
|
|
145 |
+
|
|
146 |
+/* Weakrefs flags changed in 3.x */
|
|
147 |
+#define Py_TPFLAGS_HAVE_WEAKREFS 0
|
|
148 |
+
|
|
149 |
+/* Module init function returns new module instance. */
|
|
150 |
+#define MODINIT_RETURN(x) return x
|
|
151 |
+#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name (void)
|
|
152 |
+#define DECREF_MOD(mod) Py_DECREF (mod)
|
|
153 |
+
|
|
154 |
+/* Type header differs. */
|
|
155 |
+#define TYPE_HEAD(x,y) PyVarObject_HEAD_INIT(x,y)
|
|
156 |
+
|
|
157 |
+/* Text interface. Use unicode strings. */
|
|
158 |
+#define Text_Type PyUnicode_Type
|
|
159 |
+#define Text_Check PyUnicode_Check
|
|
160 |
+#define Text_FromUTF8 PyUnicode_FromString
|
|
161 |
+#define Text_FromUTF8AndSize PyUnicode_FromStringAndSize
|
|
162 |
+#define Text_FromFormat PyUnicode_FromFormat
|
|
163 |
+#define Text_GetSize PyUnicode_GetSize
|
|
164 |
+#define Text_GET_SIZE PyUnicode_GET_SIZE
|
|
165 |
+
|
|
166 |
+/* Binary interface. Use bytes. */
|
|
167 |
+#define Bytes_Type PyBytes_Type
|
|
168 |
+#define Bytes_Check PyBytes_Check
|
|
169 |
+#define Bytes_Size PyBytes_Size
|
|
170 |
+#define Bytes_AsString PyBytes_AsString
|
|
171 |
+#define Bytes_AsStringAndSize PyBytes_AsStringAndSize
|
|
172 |
+#define Bytes_FromStringAndSize PyBytes_FromStringAndSize
|
|
173 |
+#define Bytes_AS_STRING PyBytes_AS_STRING
|
|
174 |
+#define Bytes_GET_SIZE PyBytes_GET_SIZE
|
|
175 |
+
|
|
176 |
+#define IsTextObj(x) (PyUnicode_Check(x) || PyBytes_Check(x))
|
|
177 |
+
|
|
178 |
+/* Renamed builtins */
|
|
179 |
+#define BUILTINS_MODULE "builtins"
|
|
180 |
+#define BUILTINS_UNICODE "str"
|
|
181 |
+#define BUILTINS_UNICHR "chr"
|
|
182 |
+
|
|
183 |
+#else /* PY_VERSION_HEX >= 0x03000000 */
|
|
184 |
+
|
|
185 |
+#define PY3 0
|
|
186 |
+
|
|
187 |
+/* Module init function returns nothing. */
|
|
188 |
+#define MODINIT_RETURN(x) return
|
|
189 |
+#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC init##mod_name (void)
|
|
190 |
+#define DECREF_MOD(mod)
|
|
191 |
+
|
|
192 |
+/* Type header differs. */
|
|
193 |
+#define TYPE_HEAD(x,y) \
|
|
194 |
+ PyObject_HEAD_INIT(x) \
|
|
195 |
+ 0,
|
|
196 |
+
|
|
197 |
+/* Text interface. Use ascii strings. */
|
|
198 |
+#define Text_Type PyString_Type
|
|
199 |
+#define Text_Check PyString_Check
|
|
200 |
+#define Text_FromUTF8 PyString_FromString
|
|
201 |
+#define Text_FromUTF8AndSize PyString_FromStringAndSize
|
|
202 |
+#define Text_FromFormat PyString_FromFormat
|
|
203 |
+#define Text_GetSize PyString_GetSize
|
|
204 |
+#define Text_GET_SIZE PyString_GET_SIZE
|
|
205 |
+
|
|
206 |
+/* Binary interface. Use ascii strings. */
|
|
207 |
+#define Bytes_Type PyString_Type
|
|
208 |
+#define Bytes_Check PyString_Check
|
|
209 |
+#define Bytes_Size PyString_Size
|
|
210 |
+#define Bytes_AsString PyString_AsString
|
|
211 |
+#define Bytes_AsStringAndSize PyString_AsStringAndSize
|
|
212 |
+#define Bytes_FromStringAndSize PyString_FromStringAndSize
|
|
213 |
+#define Bytes_AS_STRING PyString_AS_STRING
|
|
214 |
+#define Bytes_GET_SIZE PyString_GET_SIZE
|
|
215 |
+
|
|
216 |
+/* Renamed builtins */
|
|
217 |
+#define BUILTINS_MODULE "__builtin__"
|
|
218 |
+#define BUILTINS_UNICODE "unicode"
|
|
219 |
+#define BUILTINS_UNICHR "unichr"
|
|
220 |
+
|
|
221 |
+#endif /* PY_VERSION_HEX >= 0x03000000 */
|
|
222 |
+
|
|
223 |
+#define MODINIT_ERROR MODINIT_RETURN (NULL)
|
|
224 |
+
|
|
225 |
+/* Module state. These macros are used to define per-module macros.
|
|
226 |
+ * v - global state variable (Python 2.x)
|
|
227 |
+ * s - global state structure (Python 3.x)
|
|
228 |
+ */
|
|
229 |
+#define PY2_GETSTATE(v) (&(v))
|
|
230 |
+#define PY3_GETSTATE(s, m) ((struct s *) PyModule_GetState (m))
|
|
231 |
+
|
|
232 |
+/* Pep 3123: Making PyObject_HEAD conform to standard C */
|
|
233 |
+#if !defined(Py_TYPE)
|
|
234 |
+#define Py_TYPE(o) (((PyObject*)(o))->ob_type)
|
|
235 |
+#define Py_REFCNT(o) (((PyObject*)(o))->ob_refcnt)
|
|
236 |
+#define Py_SIZE(o) (((PyVarObject*)(o))->ob_size)
|
|
237 |
+#endif
|
|
238 |
+
|
|
239 |
+#endif /* !defined(PGCOMPAT_H) */
|