-
-
Notifications
You must be signed in to change notification settings - Fork 192
Base header #3486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Base header #3486
Conversation
You could also do in #include "base.c"
[...] But that'll make building tests messy... |
Absolutely not That begs for linker problems that would be a pain to solve, and ultimately, having a header with all the declarations is just cleaner IMO. Including a source file is just plain nasty |
…g externally for potential unit tests
…future unit test purposes
…into base-header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are problems that could be solved i thing by simply merging static and base ( ie when wasm loading pygame_base static could be set to pygame.base by pygame/__init__.py
// in case of wasm+dynamic loading it could be a trampoline in the globals | ||
// generated at runtime. | ||
// when building static make global accessible symbol directly. | ||
extern PyObject *pgExc_SDLError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pgExc_SDLError is not defined anymore but it must be a global in the first C module loaded (afaik pygame.base but pygame_static in wasm).
|
||
/* Custom exceptions */ | ||
static PyObject *pgExc_BufferError = NULL; | ||
PyObject *pgExc_BufferError = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as pgExc_SDLError, this must be in toplevel C module.
Co-authored-by: pmp-p <[email protected]>
src_c/base.c
Outdated
static PyObject *pgExc_BufferError = NULL; | ||
PyObject *pgExc_BufferError = NULL; | ||
|
||
PyObject *pgExc_SDLError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be global only in the wasm codepath? The same symbol gets reused in the base init function. Alternatively, removing the declaration there could also work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pgExc_SDLError is used everywhere, imho it should not be defined in base init but globally- wasm or not - since it goes out of scope while being exported in c-api pointers
Line 2412 in 7896a55
c_api[0] = pgExc_SDLError; |
last commit won't do it : wasm at runtime says that pgExc_SDLError needs to be globally exported for dynamic loading. |
Another precursor PR to #3477
The reason I want to remove so much static linkage is because you can't test functions that aren't visible to you (not even worth putting those declarations in the header, since anyone that includes the header would need to provide their own implementation to call them).