Cleaned up the const_cast mess a little.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 16 Apr 2013 01:38:08 -0400
changeset 70761666f7a7494e
parent 7075 f4a3c5a68119
child 7077 f8e3dcefed59
Cleaned up the const_cast mess a little.
include/SDL_stdinc.h
     1.1 --- a/include/SDL_stdinc.h	Wed Apr 17 11:45:50 2013 -0400
     1.2 +++ b/include/SDL_stdinc.h	Tue Apr 16 01:38:08 2013 -0400
     1.3 @@ -93,9 +93,11 @@
     1.4  #ifdef __cplusplus
     1.5  #define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
     1.6  #define SDL_static_cast(type, expression) static_cast<type>(expression)
     1.7 +#define SDL_const_cast(type, expression) const_cast<type>(expression)
     1.8  #else
     1.9  #define SDL_reinterpret_cast(type, expression) ((type)(expression))
    1.10  #define SDL_static_cast(type, expression) ((type)(expression))
    1.11 +#define SDL_const_cast(type, expression) ((type)(expression))
    1.12  #endif
    1.13  /*@}*//*Cast operators*/
    1.14  
    1.15 @@ -502,49 +504,25 @@
    1.16  
    1.17  extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
    1.18  #ifdef HAVE_STRCHR
    1.19 -SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) {
    1.20 -#ifdef __cplusplus
    1.21 -return const_cast<char*>(strchr(str, c));
    1.22 -#else
    1.23 -return (char*)strchr(str, c);
    1.24 -#endif
    1.25 -}
    1.26 +SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,strchr(str, c)); }
    1.27  #define SDL_strchr SDL_strchr_inline
    1.28  #elif defined(HAVE_INDEX)  /* !!! FIXME: is there anywhere that has this but not strchr? */
    1.29 -SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); }
    1.30 +SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,index(str, c)); }
    1.31  #define SDL_strchr SDL_strchr_inline
    1.32  #endif
    1.33  
    1.34  extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
    1.35  #ifdef HAVE_STRRCHR
    1.36 -SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
    1.37 -#ifdef __cplusplus
    1.38 -return const_cast<char*>(strrchr(str, c));
    1.39 -#else
    1.40 -return (char*)strrchr(str, c);
    1.41 -#endif
    1.42 -}
    1.43 +SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,strrchr(str, c)); }
    1.44  #define SDL_strrchr SDL_strrchr_inline
    1.45  #elif defined(HAVE_RINDEX)  /* !!! FIXME: is there anywhere that has this but not strrchr? */
    1.46 -SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
    1.47 -#ifdef __cplusplus
    1.48 -return const_cast<char*>(rindex(str, c));
    1.49 -#else
    1.50 -return (char*)rindex(str, c);
    1.51 -#endif
    1.52 -}
    1.53 +SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,rindex(str, c)); }
    1.54  #define SDL_strrchr SDL_strrchr_inline
    1.55  #endif
    1.56  
    1.57  extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
    1.58  #ifdef HAVE_STRSTR
    1.59 -SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) {
    1.60 -#ifdef __cplusplus
    1.61 -return const_cast<char*>(strstr(haystack, needle));
    1.62 -#else
    1.63 -return (char*)strstr(haystack, needle);
    1.64 -#endif
    1.65 -}
    1.66 +SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return SDL_const_cast(char*,strstr(haystack, needle)); }
    1.67  #define SDL_strstr SDL_strstr_inline
    1.68  #endif
    1.69