.gitignore added
[dotfiles/.git] / .local / include / python3.9 / pygame / include / pgcompat.h
1 /* Python 2.x/3.x and SDL compatibility tools
2  */
3
4 #if !defined(PGCOMPAT_H)
5 #define PGCOMPAT_H
6
7 #include <Python.h>
8
9 /* Cobjects vanish in Python 3.2; so we will code as though we use capsules */
10 #if defined(Py_CAPSULE_H)
11 #define PG_HAVE_CAPSULE 1
12 #else
13 #define PG_HAVE_CAPSULE 0
14 #endif
15 #if defined(Py_COBJECT_H)
16 #define PG_HAVE_COBJECT 1
17 #else
18 #define PG_HAVE_COBJECT 0
19 #endif
20 #if !PG_HAVE_CAPSULE
21 #define PyCapsule_New(ptr, n, dfn) PyCObject_FromVoidPtr(ptr, dfn)
22 #define PyCapsule_GetPointer(obj, n) PyCObject_AsVoidPtr(obj)
23 #define PyCapsule_CheckExact(obj) PyCObject_Check(obj)
24 #endif
25
26 /* Pygame uses Py_buffer (PEP 3118) to exchange array information internally;
27  * define here as needed.
28  */
29 #if !defined(PyBUF_SIMPLE)
30 typedef struct bufferinfo {
31         void *buf;
32         PyObject *obj;
33         Py_ssize_t len;
34         Py_ssize_t itemsize;
35         int readonly;
36         int ndim;
37         char *format;
38         Py_ssize_t *shape;
39         Py_ssize_t *strides;
40         Py_ssize_t *suboffsets;
41         void *internal;
42 } Py_buffer;
43
44 /* Flags for getting buffers */
45 #define PyBUF_SIMPLE 0
46 #define PyBUF_WRITABLE 0x0001
47 /*  we used to include an E, backwards compatible alias  */
48 #define PyBUF_WRITEABLE PyBUF_WRITABLE
49 #define PyBUF_FORMAT 0x0004
50 #define PyBUF_ND 0x0008
51 #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
52 #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
53 #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
54 #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
55 #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
56
57 #define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
58 #define PyBUF_CONTIG_RO (PyBUF_ND)
59
60 #define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
61 #define PyBUF_STRIDED_RO (PyBUF_STRIDES)
62
63 #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
64 #define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
65
66 #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
67 #define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
68
69 #define PyBUF_READ 0x100
70 #define PyBUF_WRITE 0x200
71 #define PyBUF_SHADOW 0x400
72
73 typedef int(*getbufferproc)(PyObject *, Py_buffer *, int);
74 typedef void(*releasebufferproc)(Py_buffer *);
75 #endif /* ~defined(PyBUF_SIMPLE) */
76
77 /* define common types where SDL is not included */
78 #ifndef SDL_VERSION_ATLEAST
79 #ifdef _MSC_VER
80 typedef unsigned __int8 uint8_t;
81 typedef unsigned __int32 uint32_t;
82 #else
83 #include <stdint.h>
84 #endif
85 typedef uint32_t Uint32;
86 typedef uint8_t Uint8;
87 #endif /* no SDL */
88
89
90 #if defined(SDL_VERSION_ATLEAST)
91
92 #ifndef SDL_WINDOW_VULKAN
93 #define SDL_WINDOW_VULKAN 0
94 #endif
95
96 #ifndef SDL_WINDOW_ALWAYS_ON_TOP
97 #define SDL_WINDOW_ALWAYS_ON_TOP 0
98 #endif
99
100 #ifndef SDL_WINDOW_SKIP_TASKBAR
101 #define SDL_WINDOW_SKIP_TASKBAR 0
102 #endif
103
104 #ifndef SDL_WINDOW_UTILITY
105 #define SDL_WINDOW_UTILITY 0
106 #endif
107
108 #ifndef SDL_WINDOW_TOOLTIP
109 #define SDL_WINDOW_TOOLTIP 0
110 #endif
111
112 #ifndef SDL_WINDOW_POPUP_MENU
113 #define SDL_WINDOW_POPUP_MENU 0
114 #endif
115
116
117 #ifndef SDL_WINDOW_INPUT_GRABBED
118 #define SDL_WINDOW_INPUT_GRABBED 0
119 #endif
120
121 #ifndef SDL_WINDOW_INPUT_FOCUS
122 #define SDL_WINDOW_INPUT_FOCUS 0
123 #endif
124
125 #ifndef SDL_WINDOW_MOUSE_FOCUS
126 #define SDL_WINDOW_MOUSE_FOCUS 0
127 #endif
128
129 #ifndef SDL_WINDOW_FOREIGN
130 #define SDL_WINDOW_FOREIGN 0
131 #endif
132
133 #ifndef SDL_WINDOW_ALLOW_HIGHDPI
134 #define SDL_WINDOW_ALLOW_HIGHDPI 0
135 #endif
136
137 #ifndef SDL_WINDOW_MOUSE_CAPTURE
138 #define SDL_WINDOW_MOUSE_CAPTURE 0
139 #endif
140
141 #ifndef SDL_WINDOW_ALWAYS_ON_TOP
142 #define SDL_WINDOW_ALWAYS_ON_TOP 0
143 #endif
144
145 #ifndef SDL_WINDOW_SKIP_TASKBAR
146 #define SDL_WINDOW_SKIP_TASKBAR 0
147 #endif
148
149 #ifndef SDL_WINDOW_UTILITY
150 #define SDL_WINDOW_UTILITY 0
151 #endif
152
153 #ifndef SDL_WINDOW_TOOLTIP
154 #define SDL_WINDOW_TOOLTIP 0
155 #endif
156
157 #ifndef SDL_WINDOW_POPUP_MENU
158 #define SDL_WINDOW_POPUP_MENU 0
159 #endif
160
161 #if SDL_VERSION_ATLEAST(2, 0, 4)
162 /* To control the use of:
163  * SDL_AUDIODEVICEADDED
164  * SDL_AUDIODEVICEREMOVED
165  *
166  * Ref: https://wiki.libsdl.org/SDL_EventType
167  * Ref: https://wiki.libsdl.org/SDL_AudioDeviceEvent
168  */
169 #define SDL2_AUDIODEVICE_SUPPORTED
170 #endif
171
172 #ifndef SDL_MOUSEWHEEL_FLIPPED
173 #define NO_SDL_MOUSEWHEEL_FLIPPED
174 #endif
175
176
177 #endif /* defined(SDL_VERSION_ATLEAST) */
178
179
180 #endif /* ~defined(PGCOMPAT_H) */