Changed main callback return values to an enumeration

Fixes https://github.com/libsdl-org/SDL/issues/10515
This commit is contained in:
Sam Lantinga
2024-08-16 09:54:35 -07:00
parent 83adcb9d38
commit 438a214420
24 changed files with 180 additions and 207 deletions

View File

@@ -17,7 +17,7 @@ static SDL_AudioStream *stream = NULL;
static int total_samples_generated = 0;
/* This function runs once at startup. */
int SDL_AppInit(void **appstate, int argc, char *argv[])
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
SDL_AudioSpec spec;
@@ -51,7 +51,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
}
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
int SDL_AppEvent(void *appstate, const SDL_Event *event)
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT) {
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
@@ -60,7 +60,7 @@ int SDL_AppEvent(void *appstate, const SDL_Event *event)
}
/* This function runs once per frame, and is the heart of the program. */
int SDL_AppIterate(void *appstate)
SDL_AppResult SDL_AppIterate(void *appstate)
{
/* see if we need to feed the audio stream more data yet.
We're being lazy here, but if there's less than half a second queued, generate more.

View File

@@ -49,7 +49,7 @@ static void SDLCALL FeedTheAudioStreamMore(void *userdata, SDL_AudioStream *astr
}
/* This function runs once at startup. */
int SDL_AppInit(void **appstate, int argc, char *argv[])
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
SDL_AudioSpec spec;
@@ -83,7 +83,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
}
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
int SDL_AppEvent(void *appstate, const SDL_Event *event)
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT) {
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
@@ -92,7 +92,7 @@ int SDL_AppEvent(void *appstate, const SDL_Event *event)
}
/* This function runs once per frame, and is the heart of the program. */
int SDL_AppIterate(void *appstate)
SDL_AppResult SDL_AppIterate(void *appstate)
{
/* we're not doing anything with the renderer, so just blank it out. */
SDL_RenderClear(renderer);

View File

@@ -26,7 +26,7 @@ static Uint8 *wav_data = NULL;
static Uint32 wav_data_len = 0;
/* This function runs once at startup. */
int SDL_AppInit(void **appstate, int argc, char *argv[])
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
SDL_AudioSpec spec;
char *wav_path = NULL;
@@ -65,7 +65,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
}
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
int SDL_AppEvent(void *appstate, const SDL_Event *event)
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT) {
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
@@ -74,7 +74,7 @@ int SDL_AppEvent(void *appstate, const SDL_Event *event)
}
/* This function runs once per frame, and is the heart of the program. */
int SDL_AppIterate(void *appstate)
SDL_AppResult SDL_AppIterate(void *appstate)
{
/* see if we need to feed the audio stream more data yet.
We're being lazy here, but if there's less than the entire wav file left to play,

View File

@@ -76,7 +76,7 @@ static void set_rect_xy_(SDL_FRect *r, short x, short y)
r->y = (float)(y * SNAKE_BLOCK_SIZE_IN_PIXELS);
}
int SDL_AppIterate(void *appstate)
SDL_AppResult SDL_AppIterate(void *appstate)
{
AppState *as;
SnakeContext *ctx;
@@ -109,7 +109,7 @@ int SDL_AppIterate(void *appstate)
return SDL_APP_CONTINUE;
}
int SDL_AppInit(void **appstate, int argc, char *argv[])
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
(void)argc;
(void)argv;
@@ -134,7 +134,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
return SDL_APP_CONTINUE;
}
int SDL_AppEvent(void *appstate, const SDL_Event *event)
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
{
SnakeContext *ctx = &((AppState *)appstate)->snake_ctx;
switch (event->type) {

View File

@@ -21,7 +21,7 @@ static float previous_touch_x = -1.0f;
static float previous_touch_y = -1.0f;
/* This function runs once at startup. */
int SDL_AppInit(void **appstate, int argc, char *argv[])
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
@@ -52,7 +52,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
}
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
int SDL_AppEvent(void *appstate, const SDL_Event *event)
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT) {
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
@@ -84,7 +84,7 @@ int SDL_AppEvent(void *appstate, const SDL_Event *event)
}
/* This function runs once per frame, and is the heart of the program. */
int SDL_AppIterate(void *appstate)
SDL_AppResult SDL_AppIterate(void *appstate)
{
/* make sure we're drawing to the window and not the render target */
SDL_SetRenderTarget(renderer, NULL);

View File

@@ -23,7 +23,7 @@ static int fade_direction = 1;
/* This function runs once at startup. */
int SDL_AppInit(void **appstate, int argc, char *argv[])
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
@@ -39,7 +39,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
}
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
int SDL_AppEvent(void *appstate, const SDL_Event *event)
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT) {
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
@@ -48,7 +48,7 @@ int SDL_AppEvent(void *appstate, const SDL_Event *event)
}
/* This function runs once per frame, and is the heart of the program. */
int SDL_AppIterate(void *appstate)
SDL_AppResult SDL_AppIterate(void *appstate)
{
/* since we're always fading red, we leave green and blue at zero.
alpha doesn't mean much here, so leave it at full (255, no transparency). */

View File

@@ -15,7 +15,7 @@ static SDL_Renderer *renderer = NULL;
static SDL_FPoint points[500];
/* This function runs once at startup. */
int SDL_AppInit(void **appstate, int argc, char *argv[])
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
int i;
@@ -39,7 +39,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
}
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
int SDL_AppEvent(void *appstate, const SDL_Event *event)
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT) {
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
@@ -48,7 +48,7 @@ int SDL_AppEvent(void *appstate, const SDL_Event *event)
}
/* This function runs once per frame, and is the heart of the program. */
int SDL_AppIterate(void *appstate)
SDL_AppResult SDL_AppIterate(void *appstate)
{
SDL_FRect rect;

View File

@@ -14,7 +14,7 @@ static SDL_Renderer *renderer = NULL;
/* This function runs once at startup. */
int SDL_AppInit(void **appstate, int argc, char *argv[])
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
@@ -29,7 +29,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
}
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
int SDL_AppEvent(void *appstate, const SDL_Event *event)
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT) {
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
@@ -38,7 +38,7 @@ int SDL_AppEvent(void *appstate, const SDL_Event *event)
}
/* This function runs once per frame, and is the heart of the program. */
int SDL_AppIterate(void *appstate)
SDL_AppResult SDL_AppIterate(void *appstate)
{
return SDL_APP_CONTINUE; /* carry on with the program! */
}