Skip to content

Commit 850c786

Browse files
committed
Detect missing functions.
1 parent e812280 commit 850c786

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sdl3/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,16 @@ def SDL_GET_CURRENT_BINARY() -> typing.Any:
188188

189189
def SDL_FUNC(name: str, retType: typing.Any, *args: typing.List[typing.Any]) -> None:
190190
"""Define an SDL3 function."""
191-
func = getattr(binary := SDL_GET_CURRENT_BINARY(), name)
192-
func.__binary__, func.restype, func.argtypes = binary, retType, args
193-
if not __doc_generator__: setattr(__module__, name, func)
194-
__module__.modules[SDL_GET_BINARY_NAME(binary)][name] = func
191+
192+
if not hasattr(binary := SDL_GET_CURRENT_BINARY(), name):
193+
if int(os.environ.get("SDL_IGNORE_MISSING_FUNCTIONS", "0")) > 0: return
194+
print("\33[35m", f"function '{name}' not found in binary: '{SDL_GET_BINARY_NAME(binary)}'.", "\33[0m", sep = "", flush = True)
195+
196+
else:
197+
func = getattr(binary, name)
198+
func.__binary__, func.restype, func.argtypes = binary, retType, args
199+
if not __doc_generator__: setattr(__module__, name, func)
200+
__module__.modules[SDL_GET_BINARY_NAME(binary)][name] = func
195201

196202
async def SDL_GET_LATEST_RELEASES() -> typing.Dict[str, str]:
197203
"""Get latest releases of SDL3 modules from their official github repositories."""

0 commit comments

Comments
 (0)