Skip to content

Commit

Permalink
Clean up multi-include magic.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 10, 2019
1 parent 6a0f00c commit d2097aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 1 addition & 9 deletions src/SDL12_compat.c
Expand Up @@ -57,19 +57,15 @@
#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
SDL20_SYM(rc,fn,params,args,ret)
#include "SDL20_syms.h"
#undef SDL20_SYM_PASSTHROUGH
#undef SDL20_SYM

/* this doesn't get handled in SDL20_syms.h because it uses varargs. */
typedef int (SDLCALL *SDL20_SetError_t)(const char *fmt, ...);
static SDL20_SetError_t SDL20_SetError = NULL;

/* Things that _should_ be binary compatible pass right through... */
#define SDL20_SYM(rc,fn,params,args,ret)
#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
DECLSPEC rc SDLCALL SDL_##fn params { ret SDL20_##fn args; }
#include "SDL20_syms.h"
#undef SDL20_SYM_PASSTHROUGH
#undef SDL20_SYM


/* these are macros (etc) in the SDL headers, so make our own. */
Expand Down Expand Up @@ -446,8 +442,6 @@ UnloadSDL20(void)
#define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = NULL;
#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL20_SYM(rc,fn,params,args,ret)
#include "SDL20_syms.h"
#undef SDL20_SYM_PASSTHROUGH
#undef SDL20_SYM
SDL20_SetError = NULL;
CloseSDL20Library();
}
Expand All @@ -462,8 +456,6 @@ LoadSDL20(void)
#define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = (SDL20_##fn##_t) LoadSDL20Symbol("SDL_" #fn, &okay);
#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL20_SYM(rc,fn,params,args,ret)
#include "SDL20_syms.h"
#undef SDL20_SYM_PASSTHROUGH
#undef SDL20_SYM
SDL20_SetError = (SDL20_SetError_t) LoadSDL20Symbol("SDL_SetError", &okay);
if (!okay)
UnloadSDL20();
Expand Down
11 changes: 11 additions & 0 deletions src/SDL20_syms.h
Expand Up @@ -21,6 +21,14 @@

/* don't #pragma once this file, it gets #included multiple times! */

#ifndef SDL20_SYM
#define SDL20_SYM(rc,fn,params,args,ret)
#endif

#ifndef SDL20_SYM_PASSTHROUGH
#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret)
#endif

SDL20_SYM(int,Init,(Uint32 a),(a),return)
SDL20_SYM(int,InitSubSystem,(Uint32 a),(a),return)
SDL20_SYM(Uint32,WasInit,(Uint32 a),(a),return)
Expand Down Expand Up @@ -224,5 +232,8 @@ SDL20_SYM_PASSTHROUGH(char *,iconv_string,(const char *a, const char *b, const c
SDL20_SYM(int,setenv,(const char *a, const char *b, int c),(a,b,c),return)
SDL20_SYM(int,atoi,(const char *a),(a),return)

#undef SDL20_SYM
#undef SDL20_SYM_PASSTHROUGH

/* vi: set ts=4 sw=4 expandtab: */

0 comments on commit d2097aa

Please sign in to comment.