|
1 | 1 | #define NO_PYGAME_C_API
|
2 | 2 |
|
| 3 | +#define CONTROLLER_NOPYX |
| 4 | + |
3 | 5 | #define PYGAMEAPI_RECT_INTERNAL
|
4 | 6 | #define PYGAMEAPI_EVENT_INTERNAL
|
5 | 7 | #define PYGAMEAPI_JOYSTICK_INTERNAL
|
@@ -150,11 +152,13 @@ PyInit_mixer(void);
|
150 | 152 | PyMODINIT_FUNC
|
151 | 153 | PyInit_system(void);
|
152 | 154 |
|
| 155 | +#if defined(CONTROLLER_NOPYX) |
153 | 156 | PyMODINIT_FUNC
|
154 | 157 | PyInit_controller(void);
|
155 |
| - |
| 158 | +#else |
156 | 159 | PyMODINIT_FUNC
|
157 | 160 | PyInit_controller_old(void);
|
| 161 | +#endif |
158 | 162 |
|
159 | 163 | PyMODINIT_FUNC
|
160 | 164 | PyInit_transform(void);
|
@@ -216,48 +220,44 @@ load_submodule_mphase(const char *parent, PyObject *mdef, PyObject *spec,
|
216 | 220 | {
|
217 | 221 | char fqn[1024];
|
218 | 222 | snprintf(fqn, sizeof(fqn), "%s.%s", parent, alias);
|
219 |
| - |
220 | 223 | PyObject *modules = PyImport_GetModuleDict();
|
221 | 224 |
|
222 | 225 | Py_DECREF(PyObject_GetAttrString(spec, "name"));
|
223 |
| - |
224 | 226 | PyObject_SetAttrString(spec, "name", PyUnicode_FromString(alias));
|
225 |
| - |
226 | 227 | PyObject *pmod = PyDict_GetItemString(modules, parent);
|
227 |
| - |
228 | 228 | PyObject *mod = PyModule_FromDefAndSpec((PyModuleDef *)mdef, spec);
|
229 |
| - |
230 | 229 | PyDict_SetItemString(PyModule_GetDict(mod), "__package__",
|
231 | 230 | PyUnicode_FromString(parent));
|
232 |
| - |
233 | 231 | // TODO SET PACKAGE
|
234 |
| - |
235 | 232 | PyModule_ExecDef(mod, (PyModuleDef *)mdef);
|
236 | 233 |
|
237 |
| - if (!pmod) { |
238 |
| - snprintf(fqn, sizeof(fqn), "ERROR: %s.%s", parent, alias); |
239 |
| - puts(fqn); |
240 |
| - PyErr_Print(); |
241 |
| - PyErr_Clear(); |
242 |
| - } |
243 |
| - else { |
| 234 | + if (pmod) { |
244 | 235 | PyDict_SetItemString(modules, fqn, mod);
|
245 | 236 | PyDict_SetItemString(PyModule_GetDict(mod), "__name__",
|
246 | 237 | PyUnicode_FromString(fqn));
|
247 | 238 | PyModule_AddObjectRef(pmod, alias, mod);
|
248 | 239 | Py_XDECREF(mod);
|
249 | 240 | }
|
| 241 | + if (!pmod || PyErr_Occurred()) { |
| 242 | + snprintf(fqn, sizeof(fqn), "Error after init in : %s.%s\n", parent, |
| 243 | + alias); |
| 244 | + fputs(fqn, stderr); |
| 245 | + PyErr_Print(); |
| 246 | + PyErr_Clear(); |
| 247 | + } |
250 | 248 | }
|
251 | 249 |
|
252 | 250 | static PyObject *
|
253 | 251 | mod_pygame_import_cython(PyObject *self, PyObject *spec)
|
254 | 252 | {
|
255 | 253 | load_submodule_mphase("pygame._sdl2", PyInit_sdl2(), spec, "sdl2");
|
256 | 254 | load_submodule_mphase("pygame._sdl2", PyInit_mixer(), spec, "mixer");
|
| 255 | +#if defined(CONTROLLER_NOPYX) |
| 256 | + load_submodule("pygame._sdl2", PyInit_controller(), "controller"); |
| 257 | +#else |
257 | 258 | load_submodule_mphase("pygame._sdl2", PyInit_controller_old(), spec,
|
258 | 259 | "controller_old");
|
259 |
| - load_submodule_mphase("pygame._sdl2", PyInit_controller(), spec, |
260 |
| - "controller"); |
| 260 | +#endif |
261 | 261 | load_submodule_mphase("pygame._sdl2", PyInit_audio(), spec, "audio");
|
262 | 262 | load_submodule_mphase("pygame._sdl2", PyInit_video(), spec, "video");
|
263 | 263 |
|
|
0 commit comments