From bef721e278d9ba3178e679eda38ac86ef2dc0d5d Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 2 Dec 2016 17:12:37 -0500 Subject: [PATCH] Introduce enum_flag type for ui_out flags This patch changes the ui_out flags to be an enum flag. gdb/ChangeLog: * ui-out.h: Include "common/enum-flags.h". (enum ui_flags): Rename to ... (enum ui_out_flag): ... this. (ui_out_flags): Define enum flag type. (ui_out_test_flags): Change type of parameter to ui_out_flags. (ui_out_new): Likewise. * ui-out.c (ui_out_test_flags): Likewise. (ui_out_new): Likewise. * cli-out.c (cli_out_new): Update variable type. * mi/mi-out.c (mi_out_new): Likewise. * tui/tui-out.c (tui_out_new): Likewise. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/cli-out.c | 2 +- gdb/mi/mi-out.c | 2 +- gdb/tui/tui-out.c | 2 +- gdb/ui-out.c | 4 ++-- gdb/ui-out.h | 15 ++++++++------- 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 777abc7c30a..4a64fca8d2d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +2016-12-02 Simon Marchi + + * ui-out.h: Include "common/enum-flags.h". + (enum ui_flags): Rename to ... + (enum ui_out_flag): ... this. + (ui_out_flags): Define enum flag type. + (ui_out_test_flags): Change type of parameter to ui_out_flags. + (ui_out_new): Likewise. + * ui-out.c (ui_out_test_flags): Likewise. + (ui_out_new): Likewise. + * cli-out.c (cli_out_new): Update variable type. + * mi/mi-out.c (mi_out_new): Likewise. + * tui/tui-out.c (tui_out_new): Likewise. + 2016-12-02 Pedro Alves * NEWS: Mention that user commands now accept an unlimited number diff --git a/gdb/cli-out.c b/gdb/cli-out.c index ac19e38c3d3..f5b5072e557 100644 --- a/gdb/cli-out.c +++ b/gdb/cli-out.c @@ -388,7 +388,7 @@ cli_out_data_ctor (cli_out_data *self, struct ui_file *stream) struct ui_out * cli_out_new (struct ui_file *stream) { - int flags = ui_source_list; + ui_out_flags flags = ui_source_list; cli_out_data *data = new cli_out_data (); cli_out_data_ctor (data, stream); diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index 6e69d7cb348..19fcf87fbf3 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -393,7 +393,7 @@ mi_out_data_dtor (struct ui_out *ui_out) struct ui_out * mi_out_new (int mi_version) { - int flags = 0; + ui_out_flags flags = 0; mi_out_data *data = new mi_out_data (); struct ui_file *stream = mem_fileopen (); diff --git a/gdb/tui/tui-out.c b/gdb/tui/tui-out.c index 48565623436..a5f0541037a 100644 --- a/gdb/tui/tui-out.c +++ b/gdb/tui/tui-out.c @@ -145,7 +145,7 @@ tui_text (struct ui_out *uiout, const char *string) struct ui_out * tui_out_new (struct ui_file *stream) { - int flags = 0; + ui_out_flags flags = 0; tui_out_data *data = new tui_out_data (); diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 8f745dadac0..774be2cb715 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -702,7 +702,7 @@ ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream) /* Test the flags against the mask given. */ int -ui_out_test_flags (struct ui_out *uiout, int mask) +ui_out_test_flags (struct ui_out *uiout, ui_out_flags mask) { return (uiout->flags & mask); } @@ -923,7 +923,7 @@ ui_out_query_field (struct ui_out *uiout, int colno, struct ui_out * ui_out_new (const struct ui_out_impl *impl, void *data, - int flags) + ui_out_flags flags) { struct ui_out *uiout = new ui_out (); diff --git a/gdb/ui-out.h b/gdb/ui-out.h index 06c05e2f3af..cdf567148fd 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -23,6 +23,8 @@ #ifndef UI_OUT_H #define UI_OUT_H 1 +#include "common/enum-flags.h" + /* The ui_out structure */ struct ui_out; @@ -45,12 +47,12 @@ enum ui_align }; /* flags enum */ -enum ui_flags +enum ui_out_flag { - ui_from_tty = 1, - ui_source_list = 2 + ui_source_list = (1 << 0), }; +DEF_ENUM_FLAGS_TYPE (ui_out_flag, ui_out_flags); /* Prototypes for ui-out API. */ @@ -127,7 +129,7 @@ extern void ui_out_wrap_hint (struct ui_out *uiout, const char *identstring); extern void ui_out_flush (struct ui_out *uiout); -extern int ui_out_test_flags (struct ui_out *uiout, int mask); +extern int ui_out_test_flags (struct ui_out *uiout, ui_out_flags mask); extern int ui_out_query_field (struct ui_out *uiout, int colno, int *width, int *alignment, @@ -222,9 +224,8 @@ extern void uo_field_string (struct ui_out *uiout, int fldno, int width, /* Create a ui_out object */ -extern struct ui_out *ui_out_new (const struct ui_out_impl *impl, - void *data, - int flags); +extern struct ui_out *ui_out_new (const struct ui_out_impl *impl, void *data, + ui_out_flags flags); /* Redirect the ouptut of a ui_out object temporarily. */ -- 2.30.2