[38/61] Remove the win_type parameter from tui_gen_win_info::reset

Message ID 20190704170311.15982-39-tom@tromey.com
State New
Headers show
Series
  • More TUI refactorings
Related show

Commit Message

Tom Tromey July 4, 2019, 5:02 p.m.
tui_gen_win_info::reset has a window type parameter that is only used
for an assertion.  This made sense as a defensive measure when window
creation was more dynamic -- it ensured that one did not make
mistakes.  However, there's no need for it any more, so this removes
it.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-source.c (tui_source_window_base::reset): Remove
	win_type parameter.
	* tui/tui-layout.c (make_command_window, make_source_window)
	(make_disasm_window, make_data_window)
	(show_source_disasm_command, show_data, tui_gen_win_info::reset)
	(reset_locator, show_source_or_disasm_and_command): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <reset>: Remove
	win_type parameter.
	(struct tui_source_window_base) <reset>: Likewise.
---
 gdb/ChangeLog        | 12 ++++++++++++
 gdb/tui/tui-data.h   | 11 ++++-------
 gdb/tui/tui-layout.c | 42 +++++++++++++++---------------------------
 gdb/tui/tui-source.c |  7 +++----
 4 files changed, 34 insertions(+), 38 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 39c7f0c9d2f..3c34bd31961 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -58,11 +58,9 @@  public:
     return "";
   }
 
-  /* Reset this window.  WIN_TYPE must match the existing type of this
-     window (it is only passed for self-test purposes).  The other
-     parameters are used to set the window's size and position.  */
-  virtual void reset (enum tui_win_type win_type,
-		      int height, int width,
+  /* Reset this window.  The parameters are used to set the window's
+     size and position.  */
+  virtual void reset (int height, int width,
 		      int origin_x, int origin_y);
 
   /* Window handle.  */
@@ -393,8 +391,7 @@  public:
 
   virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
 
-  void reset (enum tui_win_type win_type,
-	      int height, int width,
+  void reset (int height, int width,
 	      int origin_x, int origin_y) override;
 
   /* Does the locator belong to this window?  */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index ab849a9813d..79c7996d19b 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -518,7 +518,7 @@  static struct tui_win_info *
 make_command_window (int height, int origin_y)
 {
   struct tui_win_info *result = new tui_cmd_window ();
-  result->reset (CMD_WIN, height, tui_term_width (), 0, origin_y);
+  result->reset (height, tui_term_width (), 0, origin_y);
   tui_make_window (result, DONT_BOX_WINDOW);
   return result;
 }
@@ -530,7 +530,7 @@  static struct tui_win_info *
 make_source_window (int height, int origin_y)
 {
   tui_win_info *result = new tui_source_window ();
-  result->reset (SRC_WIN, height, tui_term_width (), 0, origin_y);
+  result->reset (height, tui_term_width (), 0, origin_y);
   result->make_visible (true);
   return result;
 }
@@ -542,7 +542,7 @@  static struct tui_win_info *
 make_disasm_window (int height, int origin_y)
 {
   tui_win_info *result = new tui_disasm_window ();
-  result->reset (SRC_WIN, height, tui_term_width (), 0, origin_y);
+  result->reset (height, tui_term_width (), 0, origin_y);
   result->make_visible (true);
   return result;
 }
@@ -552,7 +552,7 @@  static tui_win_info *
 make_data_window (int height, int origin_y)
 {
   tui_win_info *result = new tui_data_window ();
-  result->reset (DATA_WIN, height, tui_term_width (), 0, origin_y);
+  result->reset (height, tui_term_width (), 0, origin_y);
   result->make_visible (true);
   return result;
 }
@@ -595,8 +595,7 @@  show_source_disasm_command (void)
 	tui_win_list[SRC_WIN] = make_source_window (src_height, 0);
       else
 	{
-	  TUI_SRC_WIN->reset (TUI_SRC_WIN->type,
-			      src_height,
+	  TUI_SRC_WIN->reset (src_height,
 			      tui_term_width (),
 			      0,
 			      0);
@@ -620,14 +619,12 @@  show_source_disasm_command (void)
 	}
       else
 	{
-	  locator->reset (LOCATOR_WIN,
-			  2 /* 1 */ ,
+	  locator->reset (2 /* 1 */ ,
 			  tui_term_width (),
 			  0,
 			  (src_height + asm_height) - 1);
 	  TUI_DISASM_WIN->m_has_locator = true;
-	  TUI_DISASM_WIN->reset (TUI_DISASM_WIN->type,
-				 asm_height,
+	  TUI_DISASM_WIN->reset (asm_height,
 				 tui_term_width (),
 				 0,
 				 src_height - 1);
@@ -644,8 +641,7 @@  show_source_disasm_command (void)
 	  = make_command_window (cmd_height, tui_term_height () - cmd_height);
       else
 	{
-	  TUI_CMD_WIN->reset (TUI_CMD_WIN->type,
-			      TUI_CMD_WIN->height,
+	  TUI_CMD_WIN->reset (TUI_CMD_WIN->height,
 			      TUI_CMD_WIN->width,
 			      0,
 			      TUI_CMD_WIN->origin.y);
@@ -702,14 +698,12 @@  show_data (enum tui_layout_type new_layout)
   else
     {
       base = (tui_source_window_base *) tui_win_list[win_type];
-      tui_win_list[win_type]->reset (tui_win_list[win_type]->type,
-				     src_height,
+      tui_win_list[win_type]->reset (src_height,
 				     tui_term_width (),
 				     0,
 				     data_height - 1);
       tui_make_visible (tui_win_list[win_type]);
-      locator->reset (LOCATOR_WIN,
-		      2 /* 1 */ ,
+      locator->reset (2 /* 1 */ ,
 		      tui_term_width (),
 		      0,
 		      total_height - 1);
@@ -723,14 +717,11 @@  show_data (enum tui_layout_type new_layout)
 }
 
 void
-tui_gen_win_info::reset (enum tui_win_type win_type,
-			 int height_, int width_,
+tui_gen_win_info::reset (int height_, int width_,
 			 int origin_x_, int origin_y_)
 {
   int h = height_;
 
-  gdb_assert (type == win_type);
-
   width = width_;
   height = h;
   if (h > 1)
@@ -750,7 +741,7 @@  reset_locator (tui_gen_win_info *win_info,
 	       int height, int width, 
 	       int origin_x, int origin_y)
 {
-  win_info->reset (LOCATOR_WIN, height, width, origin_x, origin_y);
+  win_info->reset (height, width, origin_x, origin_y);
   tui_make_window (win_info, DONT_BOX_WINDOW);
 }
 
@@ -794,14 +785,12 @@  show_source_or_disasm_and_command (enum tui_layout_type layout_type)
       else
 	{
 	  base = (tui_source_window_base *) *win_info_ptr;
-	  locator->reset (LOCATOR_WIN,
-			  2 /* 1 */ ,
+	  locator->reset (2 /* 1 */ ,
 			  tui_term_width (),
 			  0,
 			  src_height - 1);
 	  base->m_has_locator = true;
-	  (*win_info_ptr)->reset ((*win_info_ptr)->type,
-				  src_height - 1,
+	  (*win_info_ptr)->reset (src_height - 1,
 				  tui_term_width (),
 				  0,
 				  0);
@@ -820,8 +809,7 @@  show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	}
       else
 	{
-	  TUI_CMD_WIN->reset (TUI_CMD_WIN->type,
-			      TUI_CMD_WIN->height,
+	  TUI_CMD_WIN->reset (TUI_CMD_WIN->height,
 			      TUI_CMD_WIN->width,
 			      TUI_CMD_WIN->origin.x,
 			      TUI_CMD_WIN->origin.y);
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 873612fecce..e171101e7fb 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -293,11 +293,10 @@  tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
 }
 
 void
-tui_source_window_base::reset (enum tui_win_type win_type,
-			       int height, int width,
+tui_source_window_base::reset (int height, int width,
 			       int origin_x, int origin_y)
 {
-  tui_gen_win_info::reset (win_type, height, width - 3,
+  tui_gen_win_info::reset (height, width - 3,
 			   origin_x + 3, origin_y);
-  execution_info->reset (EXEC_INFO_WIN, height, 3, origin_x, origin_y);
+  execution_info->reset (height, 3, origin_x, origin_y);
 }