annotate src/pgcompat.h @ 3172:d1b367fc08bc tests-returncode

Use a return code of 1 when the tests fail.
author Thomas Kluyver <takowl@gmail.com>
date Wed, 09 Jan 2013 10:13:57 +0000
parents a3d81c12a7d8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
1 /* Python 2.x/3.x compitibility tools
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
2 */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
3
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
4 #if !defined(PGCOMPAT_H)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
5 #define PGCOMPAT_H
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
6
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
7 #if PY_MAJOR_VERSION >= 3
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
8
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
9 #define PY3 1
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
10
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
11 /* Define some aliases for the removed PyInt_* functions */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
12 #define PyInt_Check(op) PyLong_Check(op)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
13 #define PyInt_FromString PyLong_FromString
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
14 #define PyInt_FromUnicode PyLong_FromUnicode
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
15 #define PyInt_FromLong PyLong_FromLong
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
16 #define PyInt_FromSize_t PyLong_FromSize_t
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
17 #define PyInt_FromSsize_t PyLong_FromSsize_t
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
18 #define PyInt_AsLong PyLong_AsLong
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
19 #define PyInt_AsSsize_t PyLong_AsSsize_t
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
20 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
21 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
22 #define PyInt_AS_LONG PyLong_AS_LONG
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
23 #define PyNumber_Int PyNumber_Long
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
24
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
25 /* Weakrefs flags changed in 3.x */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
26 #define Py_TPFLAGS_HAVE_WEAKREFS 0
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
27
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
28 /* Module init function returns new module instance. */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
29 #define MODINIT_RETURN(x) return x
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
30 #define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name (void)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
31 #define DECREF_MOD(mod) Py_DECREF (mod)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
32
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
33 /* Type header differs. */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
34 #define TYPE_HEAD(x,y) PyVarObject_HEAD_INIT(x,y)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
35
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
36 /* Text interface. Use unicode strings. */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
37 #define Text_Type PyUnicode_Type
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
38 #define Text_Check PyUnicode_Check
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
39 #define Text_FromUTF8 PyUnicode_FromString
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
40 #define Text_FromUTF8AndSize PyUnicode_FromStringAndSize
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
41 #define Text_FromFormat PyUnicode_FromFormat
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
42 #define Text_GetSize PyUnicode_GetSize
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
43 #define Text_GET_SIZE PyUnicode_GET_SIZE
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
44
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
45 /* Binary interface. Use bytes. */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
46 #define Bytes_Type PyBytes_Type
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
47 #define Bytes_Check PyBytes_Check
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
48 #define Bytes_Size PyBytes_Size
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
49 #define Bytes_AsString PyBytes_AsString
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
50 #define Bytes_AsStringAndSize PyBytes_AsStringAndSize
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
51 #define Bytes_FromStringAndSize PyBytes_FromStringAndSize
2266
a3d81c12a7d8 freetype: add Font.path font file path attribute; add vertical argument to Font.__init__
Lenard Lindstrom <len-l@telus.net>
parents: 2139
diff changeset
52 #define Bytes_FromFormat PyBytes_FromFormat
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
53 #define Bytes_AS_STRING PyBytes_AS_STRING
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
54 #define Bytes_GET_SIZE PyBytes_GET_SIZE
2266
a3d81c12a7d8 freetype: add Font.path font file path attribute; add vertical argument to Font.__init__
Lenard Lindstrom <len-l@telus.net>
parents: 2139
diff changeset
55 #define Bytes_AsDecodeObject PyBytes_AsDecodedObject
a3d81c12a7d8 freetype: add Font.path font file path attribute; add vertical argument to Font.__init__
Lenard Lindstrom <len-l@telus.net>
parents: 2139
diff changeset
56
a3d81c12a7d8 freetype: add Font.path font file path attribute; add vertical argument to Font.__init__
Lenard Lindstrom <len-l@telus.net>
parents: 2139
diff changeset
57 #define Object_Unicode PyObject_Str
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
58
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
59 #define IsTextObj(x) (PyUnicode_Check(x) || PyBytes_Check(x))
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
60
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
61 /* Renamed builtins */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
62 #define BUILTINS_MODULE "builtins"
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
63 #define BUILTINS_UNICODE "str"
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
64 #define BUILTINS_UNICHR "chr"
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
65
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
66 /* Defaults for unicode file path encoding */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
67 #define UNICODE_DEF_FS_CODEC Py_FileSystemDefaultEncoding
2122
3129146c2555 small fixes to get Pygame to pass the unit tests on Windows for Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents: 2120
diff changeset
68 #if defined(MS_WIN32)
3129146c2555 small fixes to get Pygame to pass the unit tests on Windows for Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents: 2120
diff changeset
69 #define UNICODE_DEF_FS_ERROR "replace"
3129146c2555 small fixes to get Pygame to pass the unit tests on Windows for Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents: 2120
diff changeset
70 #else
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
71 #define UNICODE_DEF_FS_ERROR "surrogateescape"
2122
3129146c2555 small fixes to get Pygame to pass the unit tests on Windows for Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents: 2120
diff changeset
72 #endif
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
73
2136
9de026eb9cab Merge the surface_buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2131
diff changeset
74 #else /* #if PY_MAJOR_VERSION >= 3 */
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
75
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
76 #define PY3 0
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
77
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
78 /* Module init function returns nothing. */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
79 #define MODINIT_RETURN(x) return
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
80 #define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC init##mod_name (void)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
81 #define DECREF_MOD(mod)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
82
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
83 /* Type header differs. */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
84 #define TYPE_HEAD(x,y) \
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
85 PyObject_HEAD_INIT(x) \
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
86 0,
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
87
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
88 /* Text interface. Use ascii strings. */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
89 #define Text_Type PyString_Type
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
90 #define Text_Check PyString_Check
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
91 #define Text_FromUTF8 PyString_FromString
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
92 #define Text_FromUTF8AndSize PyString_FromStringAndSize
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
93 #define Text_FromFormat PyString_FromFormat
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
94 #define Text_GetSize PyString_GetSize
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
95 #define Text_GET_SIZE PyString_GET_SIZE
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
96
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
97 /* Binary interface. Use ascii strings. */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
98 #define Bytes_Type PyString_Type
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
99 #define Bytes_Check PyString_Check
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
100 #define Bytes_Size PyString_Size
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
101 #define Bytes_AsString PyString_AsString
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
102 #define Bytes_AsStringAndSize PyString_AsStringAndSize
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
103 #define Bytes_FromStringAndSize PyString_FromStringAndSize
2266
a3d81c12a7d8 freetype: add Font.path font file path attribute; add vertical argument to Font.__init__
Lenard Lindstrom <len-l@telus.net>
parents: 2139
diff changeset
104 #define Bytes_FromFormat PyString_FromFormat
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
105 #define Bytes_AS_STRING PyString_AS_STRING
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
106 #define Bytes_GET_SIZE PyString_GET_SIZE
2266
a3d81c12a7d8 freetype: add Font.path font file path attribute; add vertical argument to Font.__init__
Lenard Lindstrom <len-l@telus.net>
parents: 2139
diff changeset
107 #define Bytes_AsDecodedObject PyString_AsDecodedObject
a3d81c12a7d8 freetype: add Font.path font file path attribute; add vertical argument to Font.__init__
Lenard Lindstrom <len-l@telus.net>
parents: 2139
diff changeset
108
a3d81c12a7d8 freetype: add Font.path font file path attribute; add vertical argument to Font.__init__
Lenard Lindstrom <len-l@telus.net>
parents: 2139
diff changeset
109 #define Object_Unicode PyObject_Unicode
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
110
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
111 /* Renamed builtins */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
112 #define BUILTINS_MODULE "__builtin__"
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
113 #define BUILTINS_UNICODE "unicode"
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
114 #define BUILTINS_UNICHR "unichr"
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
115
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
116 /* Defaults for unicode file path encoding */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
117 #define UNICODE_DEF_FS_CODEC Py_FileSystemDefaultEncoding
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
118 #define UNICODE_DEF_FS_ERROR "strict"
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
119
2139
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
120 #endif /* #if PY_MAJOR_VERSION >= 3 */
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
121
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
122 #define PY2 (!PY3)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
123
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
124 #define MODINIT_ERROR MODINIT_RETURN (NULL)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
125
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
126 /* Module state. These macros are used to define per-module macros.
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
127 * v - global state variable (Python 2.x)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
128 * s - global state structure (Python 3.x)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
129 */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
130 #define PY2_GETSTATE(v) (&(v))
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
131 #define PY3_GETSTATE(s, m) ((struct s *) PyModule_GetState (m))
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
132
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
133 /* Pep 3123: Making PyObject_HEAD conform to standard C */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
134 #if !defined(Py_TYPE)
2105
297803165311 merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents: 2082
diff changeset
135 #define Py_TYPE(o) (((PyObject *)(o))->ob_type)
297803165311 merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents: 2082
diff changeset
136 #define Py_REFCNT(o) (((PyObject *)(o))->ob_refcnt)
297803165311 merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents: 2082
diff changeset
137 #define Py_SIZE(o) (((PyVarObject *)(o))->ob_size)
2076
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
138 #endif
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
139
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
140 /* Encode a unicode file path */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
141 #define Unicode_AsEncodedPath(u) \
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
142 PyUnicode_AsEncodedString ((u), UNICODE_DEF_FS_CODEC, UNICODE_DEF_FS_ERROR)
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
143
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
144 /* Relative paths introduced in Python 2.6 */
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
145 #if PY_VERSION_HEX >= 0x02060000
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
146 #define HAVE_RELATIVE_IMPORT 1
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
147 #else
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
148 #define HAVE_RELATIVE_IMPORT 0
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
149 #endif
e97ba36855ff add RWopsEncodeFilePath Pygame api function to rwobject
Lenard Lindstrom <len-l@telus.net>
parents: 2063
diff changeset
150
2082
4c2e5111637f use less cluttered way of adding relative module prefix '.' to module name
Lenard Lindstrom <len-l@telus.net>
parents: 2077
diff changeset
151 #if HAVE_RELATIVE_IMPORT
4c2e5111637f use less cluttered way of adding relative module prefix '.' to module name
Lenard Lindstrom <len-l@telus.net>
parents: 2077
diff changeset
152 #define RELATIVE_MODULE(m) ("." m)
4c2e5111637f use less cluttered way of adding relative module prefix '.' to module name
Lenard Lindstrom <len-l@telus.net>
parents: 2077
diff changeset
153 #else
4c2e5111637f use less cluttered way of adding relative module prefix '.' to module name
Lenard Lindstrom <len-l@telus.net>
parents: 2077
diff changeset
154 #define RELATIVE_MODULE(m) (m)
4c2e5111637f use less cluttered way of adding relative module prefix '.' to module name
Lenard Lindstrom <len-l@telus.net>
parents: 2077
diff changeset
155 #endif
4c2e5111637f use less cluttered way of adding relative module prefix '.' to module name
Lenard Lindstrom <len-l@telus.net>
parents: 2077
diff changeset
156
2131
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
157 /* Python 3 (PEP 3118) buffer protocol */
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
158 #if PY_VERSION_HEX >= 0x02060000
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
159 #define HAVE_NEW_BUFPROTO 1
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
160 #else
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
161 #define HAVE_NEW_BUFPROTO 0
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
162 #endif
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
163
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
164 #define HAVE_OLD_BUFPROTO PY2
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
165
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
166 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
167 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
168 #endif
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
169
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
170 #ifndef Py_TPFLAGS_HAVE_CLASS
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
171 #define Py_TPFLAGS_HAVE_CLASS 0
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
172 #endif
018779fb04f5 Merge the buffer branch back into trunk.
Lenard Lindstrom <len-l@telus.net>
parents: 2122
diff changeset
173
2139
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
174 #if PY_VERSION_HEX >= 0x03020000
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
175 #define Slice_GET_INDICES_EX(slice, length, start, stop, step, slicelength) \
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
176 PySlice_GetIndicesEx(slice, length, start, stop, step, slicelength)
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
177 #else
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
178 #define Slice_GET_INDICES_EX(slice, length, start, stop, step, slicelength) \
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
179 PySlice_GetIndicesEx((PySliceObject *)(slice), length, \
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
180 start, stop, step, slicelength)
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
181 #endif
f804bebb7287 Surface.get_view('2') now returns a view for 24 bit surfaces.
Lenard Lindstrom <len-l@telus.net>
parents: 2136
diff changeset
182
2120
42e2bde1a12c Use capsule objects in preference to cobject objects. This allows Pygame to build an run from Python 3.2, which has to cobjects.
Lenard Lindstrom <len-l@telus.net>
parents: 2105
diff changeset
183 #endif /* #if !defined(PGCOMPAT_H) */