In my effort to make a Swift version of SDL, I’m wondering if there’s a way to specify automatic module/library-level initialization and deinitialization? SDL has two APIs,
SDL_Init() needs to be called before anything else can be used, and
SDL_Quit() should be called upon program termination.
This isn’t particularly Swifty, so I’m wondering if there’s any mechanism for implicitly calling something when a module is loaded and unloaded.
Alternatively, I’ll be wrapping all of the “classes” in SDL in Swift types, and those could reference a singleton that handles the SDL init/deinit, but it’s a lot of boilerplate my code will have to include. Is there a facility in Swift that would make this easier?