Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [pushed] Introduce enum_flag type for ui_out flags
Date: Fri, 02 Dec 2016 22:22:00 -0000	[thread overview]
Message-ID: <20161202222224.4760-1-simon.marchi@ericsson.com> (raw)
In-Reply-To: <82c0febd-7237-15c8-b952-8ef978b1cd8e@redhat.com>

From: Simon Marchi <simon.marchi@polymtl.ca>

Here is the version I pushed.  I wanted to get rid of this patch while I rework
the last two big patches (which will become a single patch), so I cherry-picked
it and adapted it to the pre-class code.  It's obviously a bit different than
the version that was approved, but I think it's straightforward enough.

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 777abc7c30..4a64fca8d2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,17 @@
+2016-12-02  Simon Marchi  <simon.marchi@polymtl.ca>
+
+	* 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  <palves@redhat.com>
 
 	* NEWS: Mention that user commands now accept an unlimited number
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index ac19e38c3d..f5b5072e55 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 6e69d7cb34..19fcf87fbf 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 4856562343..a5f0541037 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 8f745dadac..774be2cb71 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 06c05e2f3a..cdf567148f 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.11.0


  parent reply	other threads:[~2016-12-02 22:22 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24 15:24 [PATCH 00/22] Convert ui-out subsystem to C++ Simon Marchi
2016-11-24 15:24 ` [PATCH 03/22] Remove ui_out_destroy Simon Marchi
2016-11-24 15:24 ` [PATCH 01/22] Remove unused functions and declarations Simon Marchi
2016-11-24 15:24 ` [PATCH 08/22] Use new/delete instead of malloc/free-based functions Simon Marchi
2016-11-24 15:24 ` [PATCH 02/22] Rename ui_out_data to mi_ui_out_data Simon Marchi
2016-11-24 15:24 ` [PATCH 07/22] Remove stale comments Simon Marchi
2016-11-24 18:38   ` Pedro Alves
2016-11-26 15:29     ` Simon Marchi
2016-11-24 15:24 ` [PATCH 09/22] Use std::vector for ui_out::levels Simon Marchi
2016-11-24 15:24 ` [PATCH 06/22] Remove verbosity from ui_out_message and friends Simon Marchi
2016-11-24 15:27 ` [PATCH 10/22] Use std::vector for mi_ui_out_data::streams Simon Marchi
2016-11-24 18:38   ` Pedro Alves
2016-11-26 15:48     ` Simon Marchi
2016-11-24 15:28 ` [PATCH 16/22] Class-ify ui_out_level Simon Marchi
2016-11-24 18:41   ` Pedro Alves
2016-11-26 16:22     ` Simon Marchi
2016-11-30 12:07       ` Pedro Alves
2016-11-30 12:41         ` Antoine Tremblay
2016-11-30 13:27           ` Pedro Alves
2016-11-30 13:47             ` Antoine Tremblay
2016-11-30 14:17               ` Pedro Alves
2016-11-30 14:21                 ` Antoine Tremblay
2016-11-30 20:40         ` Simon Marchi
2016-11-24 15:28 ` [PATCH 18/22] ui_out_table: Replace boolean flag with enum Simon Marchi
2016-11-24 18:42   ` Pedro Alves
2016-11-26 16:47     ` Simon Marchi
2016-11-30 12:10       ` Pedro Alves
2016-11-24 15:28 ` [PATCH 11/22] Use std::vector for cli_ui_out_data::streams Simon Marchi
2016-11-24 18:41   ` Pedro Alves
2016-11-26 15:51     ` Simon Marchi
2016-11-24 15:28 ` [PATCH 14/22] Use std::string for ui_out_hdr's text fields Simon Marchi
2016-11-24 15:28 ` [PATCH 17/22] Simplify ui-out level code Simon Marchi
2016-11-24 18:42   ` Pedro Alves
2016-11-26 16:39     ` Simon Marchi
2016-11-30 12:08       ` Pedro Alves
2016-11-24 15:28 ` [PATCH 13/22] Replace hand-made linked list of ui_out_hdr by vector and iterator Simon Marchi
2016-11-24 18:41   ` Pedro Alves
2016-11-26 16:13     ` Simon Marchi
2016-12-01 20:22       ` Simon Marchi
2016-12-01 20:23         ` Pedro Alves
2016-11-24 15:28 ` [PATCH 12/22] Use std::string in ui_out_table Simon Marchi
2016-11-24 15:28 ` [PATCH 15/22] Class-ify ui_out_hdr Simon Marchi
2016-11-24 15:32 ` [PATCH 22/22] Introduce enum_flag type for ui_out flags Simon Marchi
2016-11-30 13:34   ` Pedro Alves
2016-11-30 21:32     ` Simon Marchi
2016-12-02 22:22     ` Simon Marchi [this message]
2016-11-24 15:36 ` [PATCH 05/22] Constify wrap_here/wrap_hint code path Simon Marchi
2016-11-24 15:36 ` [PATCH 04/22] Fix return value of uo_redirect Simon Marchi
2016-11-24 16:08 ` [PATCH 00/22] Convert ui-out subsystem to C++ Simon Marchi
2016-11-24 18:46   ` Pedro Alves
2016-11-24 19:15     ` Simon Marchi
2016-11-24 20:33       ` Simon Marchi
2016-11-24 18:47   ` Pedro Alves
2016-11-27  3:14     ` Simon Marchi
2016-12-01  2:51     ` Simon Marchi
2016-12-01 21:24       ` Simon Marchi
2016-11-24 19:11 ` [PATCH 20/22] Class-ify ui_out_table Simon Marchi
2016-11-30 12:29   ` Pedro Alves
2016-11-24 19:19 ` [PATCH 21/22] Class-ify ui_out Simon Marchi
2016-11-30 12:46   ` Pedro Alves
2016-11-30 21:47     ` Simon Marchi
2016-11-26 15:20 ` [PATCH 19/22] Class-ify ui_out_impl simon.marchi
2016-11-30 13:09   ` Pedro Alves
2016-11-30 22:38     ` Simon Marchi
2016-11-30 22:58       ` Pedro Alves
2016-12-01 19:04         ` Simon Marchi
2016-12-01 19:30           ` Pedro Alves
     [not found] ` <20161124153228.25177-20-simon.marchi@polymtl.ca>
2016-11-26 17:18   ` [PATCH 20/22] Class-ify ui_out_table Simon Marchi
2016-11-30 12:30     ` Pedro Alves
2016-11-30 21:48       ` [PATCH v2] " Simon Marchi
2016-11-30 23:01         ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161202222224.4760-1-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox