[AD] Implement AL_*_DEPRECATED macros |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
As suggested by Laurence some time ago, this patch implements three new
internal macros:
AL_FUNC_DEPRECATED(type, name, args)
AL_PRINTFUNC_DEPRECATED(type, name, args, a, b)
AL_INLINE_DEPRECATED(type, name, args, code)
that allow the compiler to flag the usage of deprecated API functions from
alcompat.h if it supports the feature, and enables them for GCC version 3.1
or later.
Tested with GCC 2.95.3, 3.0.4, 3.1.1, 3.2.3 and 3.3pre. Note that the library
doesn't compile anymore with the latter three, I'll fix that shortly.
Applied on mainline.
--
Eric Botcazou
Index: include/allegro/alcompat.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/alcompat.h,v
retrieving revision 1.12
diff -u -r1.12 alcompat.h
--- include/allegro/alcompat.h 23 Jan 2003 13:16:14 -0000 1.12
+++ include/allegro/alcompat.h 13 May 2003 19:42:07 -0000
@@ -124,7 +124,7 @@
#define JOY_HAT_RIGHT 3
#define JOY_HAT_UP 4
-AL_FUNC(int, initialise_joystick, (void));
+AL_FUNC_DEPRECATED(int, initialise_joystick, (void));
/* in case you want to spell 'palette' as 'pallete' */
@@ -148,64 +148,64 @@
#define OLD_FILESEL_WIDTH -1
#define OLD_FILESEL_HEIGHT -1
-AL_INLINE(int, file_select, (AL_CONST char *message, char *path, AL_CONST char *ext),
+AL_INLINE_DEPRECATED(int, file_select, (AL_CONST char *message, char *path, AL_CONST char *ext),
{
return file_select_ex(message, path, ext, 1024, OLD_FILESEL_WIDTH, OLD_FILESEL_HEIGHT);
})
/* the old (and broken!) file enumeration function */
-AL_FUNC(int, for_each_file, (AL_CONST char *name, int attrib, AL_METHOD(void, callback, (AL_CONST char *filename, int attrib, int param)), int param));
+AL_FUNC_DEPRECATED(int, for_each_file, (AL_CONST char *name, int attrib, AL_METHOD(void, callback, (AL_CONST char *filename, int attrib, int param)), int param));
/* the old state-based textout functions */
AL_VAR(int, _textmode);
-AL_FUNC(int, text_mode, (int mode));
+AL_FUNC_DEPRECATED(int, text_mode, (int mode));
-AL_INLINE(void, textout, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x, int y, int color),
+AL_INLINE_DEPRECATED(void, textout, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x, int y, int color),
{
textout_ex(bmp, f, str, x, y, color, _textmode);
})
-AL_INLINE(void, textout_centre, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x, int y, int color),
+AL_INLINE_DEPRECATED(void, textout_centre, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x, int y, int color),
{
textout_centre_ex(bmp, f, str, x, y, color, _textmode);
})
-AL_INLINE(void, textout_right, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x, int y, int color),
+AL_INLINE_DEPRECATED(void, textout_right, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x, int y, int color),
{
textout_right_ex(bmp, f, str, x, y, color, _textmode);
})
-AL_INLINE(void, textout_justify, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x1, int x2, int y, int diff, int color),
+AL_INLINE_DEPRECATED(void, textout_justify, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x1, int x2, int y, int diff, int color),
{
textout_justify_ex(bmp, f, str, x1, x2, y, diff, color, _textmode);
})
-AL_PRINTFUNC(void, textprintf, (struct BITMAP *bmp, AL_CONST FONT *f, int x, int y, int color, AL_CONST char *format, ...), 6, 7);
-AL_PRINTFUNC(void, textprintf_centre, (struct BITMAP *bmp, AL_CONST FONT *f, int x, int y, int color, AL_CONST char *format, ...), 6, 7);
-AL_PRINTFUNC(void, textprintf_right, (struct BITMAP *bmp, AL_CONST FONT *f, int x, int y, int color, AL_CONST char *format, ...), 6, 7);
-AL_PRINTFUNC(void, textprintf_justify, (struct BITMAP *bmp, AL_CONST FONT *f, int x1, int x2, int y, int diff, int color, AL_CONST char *format, ...), 8, 9);
+AL_PRINTFUNC_DEPRECATED(void, textprintf, (struct BITMAP *bmp, AL_CONST FONT *f, int x, int y, int color, AL_CONST char *format, ...), 6, 7);
+AL_PRINTFUNC_DEPRECATED(void, textprintf_centre, (struct BITMAP *bmp, AL_CONST FONT *f, int x, int y, int color, AL_CONST char *format, ...), 6, 7);
+AL_PRINTFUNC_DEPRECATED(void, textprintf_right, (struct BITMAP *bmp, AL_CONST FONT *f, int x, int y, int color, AL_CONST char *format, ...), 6, 7);
+AL_PRINTFUNC_DEPRECATED(void, textprintf_justify, (struct BITMAP *bmp, AL_CONST FONT *f, int x1, int x2, int y, int diff, int color, AL_CONST char *format, ...), 8, 9);
-AL_INLINE(void, draw_character, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color),
+AL_INLINE_DEPRECATED(void, draw_character, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color),
{
draw_character_ex(bmp, sprite, x, y, color, _textmode);
})
-AL_INLINE(int, gui_textout, (struct BITMAP *bmp, AL_CONST char *s, int x, int y, int color, int centre),
+AL_INLINE_DEPRECATED(int, gui_textout, (struct BITMAP *bmp, AL_CONST char *s, int x, int y, int color, int centre),
{
return gui_textout_ex(bmp, s, x, y, color, _textmode, centre);
})
/* the old close button functions */
-AL_INLINE(int, set_window_close_button, (int enable),
+AL_INLINE_DEPRECATED(int, set_window_close_button, (int enable),
{
(void)enable;
return 0;
})
-AL_INLINE(void, set_window_close_hook, (void (*proc)(void)),
+AL_INLINE_DEPRECATED(void, set_window_close_hook, (void (*proc)(void)),
{
set_close_button_callback(proc);
})
Index: include/allegro/internal/alconfig.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/internal/alconfig.h,v
retrieving revision 1.10
diff -u -r1.10 alconfig.h
--- include/allegro/internal/alconfig.h 26 Mar 2003 10:27:26 -0000 1.10
+++ include/allegro/internal/alconfig.h 13 May 2003 19:42:07 -0000
@@ -109,6 +109,13 @@
#define AL_CONST const
#endif
+ #ifndef AL_FUNC_DEPRECATED
+ #if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
+ #define AL_FUNC_DEPRECATED(type, name, args) AL_FUNC(__attribute__ ((deprecated)) type, name, args)
+ #define AL_PRINTFUNC_DEPRECATED(type, name, args, a, b) AL_PRINTFUNC(__attribute__ ((deprecated)) type, name, args, a, b)
+ #define AL_INLINE_DEPRECATED(type, name, args, code) AL_INLINE(__attribute__ ((deprecated)) type, name, args, code)
+ #endif
+ #endif
#endif
@@ -170,6 +177,12 @@
#ifndef AL_INLINE
#define AL_INLINE(type, name, args, code) type name args;
+#endif
+
+#ifndef AL_FUNC_DEPRECATED
+ #define AL_FUNC_DEPRECATED(type, name, args) AL_FUNC(type, name, args)
+ #define AL_PRINTFUNC_DEPRECATED(type, name, args, a, b) AL_PRINTFUNC(type, name, args, a, b)
+ #define AL_INLINE_DEPRECATED(type, name, args, code) AL_INLINE(type, name, args, code)
#endif
#ifndef END_OF_MAIN