Skip to content

Commit b145799

Browse files
committed
wasm 3.13 build
1 parent 29e821d commit b145799

File tree

3 files changed

+179
-50
lines changed

3 files changed

+179
-50
lines changed

src_c/static.c

Lines changed: 95 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#undef WITH_THREAD
2525
#endif
2626

27-
#if defined(BUILD_STATIC)
27+
#if 1 // defined(BUILD_STATIC)
2828
#undef import_pygame_base
2929
#undef import_pygame_rect
3030
#undef import_pygame_surface
@@ -33,56 +33,84 @@
3333
#undef import_pygame_bufferproxy
3434
#undef import_pygame_rwobject
3535
#undef import_pygame_event
36+
#undef import_pygame_imageext
37+
#undef import_pygame_image
38+
#undef import_pygame_font
3639

3740
void
3841
import_pygame_base(void)
3942
{
43+
puts("import_pygame_base");
4044
}
4145

4246
void
4347
import_pygame_rect(void)
4448
{
49+
puts("import_pygame_rect");
4550
}
4651

4752
void
4853
import_pygame_surface(void)
4954
{
55+
puts("import_pygame_surface");
56+
}
57+
58+
59+
void
60+
import_pygame_window(void)
61+
{
62+
puts("import_pygame_window");
5063
}
5164

5265
void
5366
import_pygame_geometry(void)
5467
{
68+
puts("import_pygame_geometry");
5569
}
5670

5771
void
5872
import_pygame_color(void)
5973
{
74+
puts("import_pygame_color");
75+
}
76+
77+
void
78+
import_pygame_font(void)
79+
{
80+
puts("import_pygame_font");
6081
}
6182

83+
void
84+
import_pygame_freetype(void)
85+
{
86+
puts("import_pygame_freetype");
87+
}
88+
89+
6290
void
6391
import_pygame_bufferproxy(void)
6492
{
93+
puts("import_pygame_bufferproxy");
6594
}
6695

6796
void
6897
import_pygame_rwobject(void)
6998
{
99+
puts("import_pygame_rwobject");
70100
}
71101

72102
void
73103
import_pygame_event(void)
74104
{
105+
puts("import_pygame_event");
75106
}
76107

77108
void
78109
import_pygame_joystick(void)
79110
{
111+
puts("import_pygame_joystick");
80112
}
81113

82-
void
83-
import_pygame_window(void)
84-
{
85-
}
86114

87115
PyMODINIT_FUNC
88116
PyInit_base(void);
@@ -198,24 +226,28 @@ void
198226
load_submodule(const char *parent, PyObject *mod, const char *alias)
199227
{
200228
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-
207229
if (!mod) {
208-
snprintf(fqn, sizeof(fqn), "ERROR: %s.%s", parent, alias);
230+
snprintf(fqn, sizeof(fqn), "ERROR: PyInit_%s failed for %s.%s", alias, parent, alias);
209231
puts(fqn);
210232
PyErr_Print();
211233
PyErr_Clear();
212234
}
213235
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);
236+
snprintf(fqn, sizeof(fqn), "%s.%s", parent, alias);
237+
puts(fqn);
238+
PyObject *modules = PyImport_GetModuleDict();
239+
240+
PyObject *pmod = PyDict_GetItemString(modules, parent);
241+
if (!pmod) {
242+
snprintf(fqn, sizeof(fqn), "ERROR: Parent %s not found for %s.%s", parent, parent, alias);
243+
puts(fqn);
244+
} else {
245+
PyDict_SetItemString(modules, fqn, mod);
246+
PyDict_SetItemString(PyModule_GetDict(mod), "__name__",
247+
PyUnicode_FromString(fqn));
248+
PyModule_AddObjectRef(pmod, alias, mod);
249+
Py_XDECREF(mod);
250+
}
219251
}
220252
}
221253

@@ -225,6 +257,7 @@ load_submodule_mphase(const char *parent, PyObject *mdef, PyObject *spec,
225257
{
226258
char fqn[1024];
227259
snprintf(fqn, sizeof(fqn), "%s.%s", parent, alias);
260+
puts(fqn);
228261
PyObject *modules = PyImport_GetModuleDict();
229262

230263
Py_DECREF(PyObject_GetAttrString(spec, "name"));
@@ -255,7 +288,10 @@ load_submodule_mphase(const char *parent, PyObject *mdef, PyObject *spec,
255288
static PyObject *
256289
mod_pygame_import_cython(PyObject *self, PyObject *spec)
257290
{
291+
#if 1 //PY_VERSION_HEX <= 0x030C0000
292+
258293
load_submodule_mphase("pygame._sdl2", PyInit_sdl2(), spec, "sdl2");
294+
259295
load_submodule_mphase("pygame._sdl2", PyInit_mixer(), spec, "mixer");
260296
#if defined(CONTROLLER_NOPYX)
261297
load_submodule("pygame._sdl2", PyInit_controller(), "controller");
@@ -265,7 +301,7 @@ mod_pygame_import_cython(PyObject *self, PyObject *spec)
265301
#endif
266302
load_submodule_mphase("pygame._sdl2", PyInit_audio(), spec, "audio");
267303
load_submodule_mphase("pygame._sdl2", PyInit_video(), spec, "video");
268-
304+
#endif
269305
Py_RETURN_NONE;
270306
}
271307

@@ -288,47 +324,74 @@ PyInit_pygame_static()
288324
SDL_SetHint("SDL_EMSCRIPTEN_KEYBOARD_ELEMENT", "1");
289325

290326
load_submodule("pygame", PyInit_base(), "base");
327+
328+
//
291329
load_submodule("pygame", PyInit_constants(), "constants");
292-
load_submodule("pygame", PyInit_surflock(), "surflock");
293-
load_submodule("pygame", PyInit_rwobject(), "rwobject");
330+
//
294331
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");
299332

333+
// base, pygame.colordict
334+
load_submodule("pygame", PyInit_color(), "color");
335+
336+
// base
300337
load_submodule("pygame", PyInit_rect(), "rect");
338+
339+
// base, rect
301340
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");
305341

306-
load_submodule("pygame", PyInit_imageext(), "imageext");
342+
load_submodule("pygame", PyInit_bufferproxy(), "bufferproxy");
343+
load_submodule("pygame", PyInit_surflock(), "surflock");
307344

345+
// base, color, rect, bufferproxy, surflock
346+
load_submodule("pygame", PyInit_surface(), "surface");
347+
348+
load_submodule("pygame", PyInit_rwobject(), "rwobject");
349+
350+
// base, color, rect, bufferproxy, surflock, surface, rwobject
351+
load_submodule("pygame", PyInit_imageext(), "imageext");
352+
// base, color, rect, bufferproxy, surflock, surface, rwobject
308353
load_submodule("pygame", PyInit_image(), "image");
354+
355+
load_submodule("pygame", PyInit__freetype(), "_freetype");
309356
load_submodule("pygame", PyInit_font(), "font");
310357
load_submodule("pygame", PyInit_pixelcopy(), "pixelcopy");
311358
load_submodule("pygame", PyInit_newbuffer(), "newbuffer");
312359

313-
load_submodule("pygame", PyInit_color(), "color");
314-
load_submodule("pygame", PyInit_bufferproxy(), "bufferproxy");
360+
// base
361+
load_submodule("pygame", PyInit_joystick(), "joystick");
362+
// base, joystick
363+
load_submodule("pygame", PyInit_event(), "event");
364+
365+
// base, rect, event
366+
load_submodule("pygame", PyInit_key(), "key");
367+
// base, event
368+
load_submodule("pygame", PyInit_pg_time(), "time");
369+
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");
376+
323377

324378
load_submodule("pygame", PyInit_pg_mixer(), "mixer");
325379
load_submodule("pygame.mixer", PyInit_mixer_music(), "music");
326380

381+
// base, color, rect, bufferproxy, surflock, surface
327382
load_submodule("pygame", PyInit_window(), "window");
383+
384+
// base, color, rect, surflock, surface, window
385+
load_submodule("pygame", PyInit_display(), "display");
328386
load_submodule("pygame", PyInit__render(), "_render");
329387

330388
load_submodule("pygame", PyInit_pixelarray(), "pixelarray");
331389

390+
// base, color, rect, bufferproxy, surflock, surface
391+
load_submodule("pygame", PyInit_gfxdraw(), "gfxdraw");
392+
393+
//load_submodule("pygame", PyInit_system(), "system");
394+
332395
return PyModule_Create(&mod_pygame_static);
333396
}
334397

src_c/surface.c

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4595,7 +4595,7 @@ pgSurface_Blit(pgSurfaceObject *dstobj, pgSurfaceObject *srcobj,
45954595
}
45964596

45974597
static PyMethodDef _surface_methods[] = {{NULL, NULL, 0, NULL}};
4598-
4598+
#if !defined(BUILD_STATIC)
45994599
int
46004600
exec_surface(PyObject *module)
46014601
{
@@ -4688,3 +4688,61 @@ MODINIT_DEFINE(surface)
46884688

46894689
return PyModuleDef_Init(&_module);
46904690
}
4691+
#else
4692+
MODINIT_DEFINE(surface)
4693+
{
4694+
PyObject *module;
4695+
4696+
static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT,
4697+
"surface",
4698+
DOC_SURFACE,
4699+
-1,
4700+
_surface_methods,
4701+
NULL,
4702+
NULL,
4703+
NULL,
4704+
NULL};
4705+
4706+
module = PyModule_Create(&_module);
4707+
if (module == NULL) {
4708+
return NULL;
4709+
}
4710+
4711+
_IMPORT_PYGAME_MODULE(surflock);
4712+
if (PyErr_Occurred()) {
4713+
return NULL;
4714+
}
4715+
4716+
/* type preparation */
4717+
if (PyType_Ready(&pgSurface_Type) < 0) {
4718+
return NULL;
4719+
}
4720+
4721+
PyObject *apiobj;
4722+
static void *c_api[PYGAMEAPI_SURFACE_NUMSLOTS];
4723+
4724+
if (PyModule_AddObjectRef(module, "SurfaceType", (PyObject *)&pgSurface_Type)) {
4725+
return NULL;
4726+
}
4727+
4728+
if (PyModule_AddObjectRef(module, "Surface", (PyObject *)&pgSurface_Type)) {
4729+
return NULL;
4730+
}
4731+
4732+
/* export the c api */
4733+
c_api[0] = &pgSurface_Type;
4734+
c_api[1] = pgSurface_New2;
4735+
c_api[2] = pgSurface_Blit;
4736+
c_api[3] = pgSurface_SetSurface;
4737+
apiobj = encapsulate_api(c_api, "surface");
4738+
if (PyModule_Add(module, PYGAMEAPI_LOCAL_ENTRY, apiobj) < 0) {
4739+
return NULL;
4740+
}
4741+
4742+
if (PyModule_AddObjectRef(module, "_dict", pgSurface_Type.tp_dict)) {
4743+
return NULL;
4744+
}
4745+
4746+
return module;
4747+
}
4748+
#endif

0 commit comments

Comments
 (0)