@@ -49,6 +49,11 @@ import_pygame_surface(void)
4949{
5050}
5151
52+ void
53+ import_pygame_window (void )
54+ {
55+ }
56+
5257void
5358import_pygame_geometry (void )
5459{
@@ -59,6 +64,16 @@ import_pygame_color(void)
5964{
6065}
6166
67+ void
68+ import_pygame_font (void )
69+ {
70+ }
71+
72+ void
73+ import_pygame_freetype (void )
74+ {
75+ }
76+
6277void
6378import_pygame_bufferproxy (void )
6479{
@@ -79,8 +94,22 @@ import_pygame_joystick(void)
7994{
8095}
8196
97+ #undef import_pygame_imageext
98+ #undef import_pygame_render
99+ #undef import_pygame_pixelarray
100+
82101void
83- import_pygame_window (void )
102+ import_pygame_imageext (void )
103+ {
104+ }
105+
106+ void
107+ import_pygame_render (void )
108+ {
109+ }
110+
111+ void
112+ import_pygame_pixelarray (void )
84113{
85114}
86115
@@ -198,24 +227,30 @@ void
198227load_submodule (const char * parent , PyObject * mod , const char * alias )
199228{
200229 char fqn [1024 ];
201- snprintf (fqn , sizeof (fqn ), "%s.%s" , parent , alias );
202-
203- PyObject * modules = PyImport_GetModuleDict ();
204-
205- PyObject * pmod = PyDict_GetItemString (modules , parent );
206-
207230 if (!mod ) {
208- snprintf (fqn , sizeof (fqn ), "ERROR: %s.%s" , parent , alias );
231+ snprintf (fqn , sizeof (fqn ), "ERROR: PyInit_%s failed for %s.%s" , alias ,
232+ parent , alias );
209233 puts (fqn );
210234 PyErr_Print ();
211235 PyErr_Clear ();
212236 }
213237 else {
214- PyDict_SetItemString (modules , fqn , mod );
215- PyDict_SetItemString (PyModule_GetDict (mod ), "__name__" ,
216- PyUnicode_FromString (fqn ));
217- PyModule_AddObjectRef (pmod , alias , mod );
218- Py_XDECREF (mod );
238+ snprintf (fqn , sizeof (fqn ), "%s.%s" , parent , alias );
239+ PyObject * modules = PyImport_GetModuleDict ();
240+
241+ PyObject * pmod = PyDict_GetItemString (modules , parent );
242+ if (!pmod ) {
243+ snprintf (fqn , sizeof (fqn ), "ERROR: Parent %s not found for %s.%s" ,
244+ parent , parent , alias );
245+ puts (fqn );
246+ }
247+ else {
248+ PyDict_SetItemString (modules , fqn , mod );
249+ PyDict_SetItemString (PyModule_GetDict (mod ), "__name__" ,
250+ PyUnicode_FromString (fqn ));
251+ PyModule_AddObjectRef (pmod , alias , mod );
252+ Py_XDECREF (mod );
253+ }
219254 }
220255}
221256
@@ -225,6 +260,7 @@ load_submodule_mphase(const char *parent, PyObject *mdef, PyObject *spec,
225260{
226261 char fqn [1024 ];
227262 snprintf (fqn , sizeof (fqn ), "%s.%s" , parent , alias );
263+
228264 PyObject * modules = PyImport_GetModuleDict ();
229265
230266 Py_DECREF (PyObject_GetAttrString (spec , "name" ));
@@ -256,6 +292,7 @@ static PyObject *
256292mod_pygame_import_cython (PyObject * self , PyObject * spec )
257293{
258294 load_submodule_mphase ("pygame._sdl2" , PyInit_sdl2 (), spec , "sdl2" );
295+
259296 load_submodule_mphase ("pygame._sdl2" , PyInit_mixer (), spec , "mixer" );
260297#if defined(CONTROLLER_NOPYX )
261298 load_submodule ("pygame._sdl2" , PyInit_controller (), "controller" );
@@ -288,47 +325,72 @@ PyInit_pygame_static()
288325 SDL_SetHint ("SDL_EMSCRIPTEN_KEYBOARD_ELEMENT" , "1" );
289326
290327 load_submodule ("pygame" , PyInit_base (), "base" );
328+
329+ //
291330 load_submodule ("pygame" , PyInit_constants (), "constants" );
292- load_submodule ("pygame" , PyInit_surflock (), "surflock" );
293- load_submodule ("pygame" , PyInit_rwobject (), "rwobject" );
331+ //
294332 load_submodule ("pygame" , PyInit_pg_math (), "math" );
295- load_submodule ("pygame" , PyInit_display (), "display" );
296- load_submodule ("pygame" , PyInit_surface (), "surface" );
297- load_submodule ("pygame" , PyInit_system (), "system" );
298- load_submodule ("pygame" , PyInit_key (), "key" );
299333
334+ // base, pygame.colordict
335+ load_submodule ("pygame" , PyInit_color (), "color" );
336+
337+ // base
300338 load_submodule ("pygame" , PyInit_rect (), "rect" );
339+
340+ // base, rect
301341 load_submodule ("pygame" , PyInit_geometry (), "geometry" );
302- load_submodule ("pygame" , PyInit_gfxdraw (), "gfxdraw" );
303- load_submodule ("pygame" , PyInit_pg_time (), "time" );
304- load_submodule ("pygame" , PyInit__freetype (), "_freetype" );
305342
306- load_submodule ("pygame" , PyInit_imageext (), "imageext" );
343+ load_submodule ("pygame" , PyInit_bufferproxy (), "bufferproxy" );
344+ load_submodule ("pygame" , PyInit_surflock (), "surflock" );
345+
346+ // base, color, rect, bufferproxy, surflock
347+ load_submodule ("pygame" , PyInit_surface (), "surface" );
348+
349+ load_submodule ("pygame" , PyInit_rwobject (), "rwobject" );
307350
351+ // base, color, rect, bufferproxy, surflock, surface, rwobject
352+ load_submodule ("pygame" , PyInit_imageext (), "imageext" );
353+ // base, color, rect, bufferproxy, surflock, surface, rwobject
308354 load_submodule ("pygame" , PyInit_image (), "image" );
355+
356+ load_submodule ("pygame" , PyInit__freetype (), "_freetype" );
309357 load_submodule ("pygame" , PyInit_font (), "font" );
310358 load_submodule ("pygame" , PyInit_pixelcopy (), "pixelcopy" );
311359 load_submodule ("pygame" , PyInit_newbuffer (), "newbuffer" );
312360
313- load_submodule ("pygame" , PyInit_color (), "color" );
314- load_submodule ("pygame" , PyInit_bufferproxy (), "bufferproxy" );
361+ // base
362+ load_submodule ("pygame" , PyInit_joystick (), "joystick" );
363+ // base, joystick
364+ load_submodule ("pygame" , PyInit_event (), "event" );
365+
366+ // base, rect, event
367+ load_submodule ("pygame" , PyInit_key (), "key" );
368+ // base, event
369+ load_submodule ("pygame" , PyInit_pg_time (), "time" );
315370
316371 load_submodule ("pygame" , PyInit_transform (), "transform" );
317372 load_submodule ("pygame" , PyInit_draw (), "draw" );
318373
319374 load_submodule ("pygame" , PyInit_mask (), "mask" );
320375 load_submodule ("pygame" , PyInit_mouse (), "mouse" );
321- load_submodule ("pygame" , PyInit_event (), "event" );
322- load_submodule ("pygame" , PyInit_joystick (), "joystick" );
323376
324377 load_submodule ("pygame" , PyInit_pg_mixer (), "mixer" );
325378 load_submodule ("pygame.mixer" , PyInit_mixer_music (), "music" );
326379
380+ // base, color, rect, bufferproxy, surflock, surface
327381 load_submodule ("pygame" , PyInit_window (), "window" );
382+
383+ // base, color, rect, surflock, surface, window
384+ load_submodule ("pygame" , PyInit_display (), "display" );
328385 load_submodule ("pygame" , PyInit__render (), "_render" );
329386
330387 load_submodule ("pygame" , PyInit_pixelarray (), "pixelarray" );
331388
389+ // base, color, rect, bufferproxy, surflock, surface
390+ load_submodule ("pygame" , PyInit_gfxdraw (), "gfxdraw" );
391+
392+ load_submodule ("pygame" , PyInit_system (), "system" );
393+
332394 return PyModule_Create (& mod_pygame_static );
333395}
334396
0 commit comments