[05/15] Private data members in tui_data_window

Message ID 20190821022535.9762-6-tom@tromey.com
State New
Headers show
Series
  • More TUI Refactorings
Related show

Commit Message

Tom Tromey Aug. 21, 2019, 2:25 a.m.
This changes tui_data_window so that the data members are private.
This required the addition of a simple accessor method in one case.

gdb/ChangeLog
2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (struct tui_data_window) <regs_content,
	regs_column_count, current_group>: Move later.  Now private.
	<get_current_group>: New method.
	* tui/tui-regs.c (tui_reg_command): Update.
	* tui/tui-layout.c (tui_set_layout): Update.
---
 gdb/ChangeLog        |  8 ++++++++
 gdb/tui/tui-layout.c |  2 +-
 gdb/tui/tui-regs.c   |  2 +-
 gdb/tui/tui-regs.h   | 15 ++++++++++-----
 4 files changed, 20 insertions(+), 7 deletions(-)

-- 
2.17.2

Comments

Pedro Alves Aug. 26, 2019, 2:06 p.m. | #1
On 8/21/19 3:25 AM, Tom Tromey wrote:
> This changes tui_data_window so that the data members are private.

> This required the addition of a simple accessor method in one case.


OOC, do you have plans at some point later in the series to rename
local variables to m_xxx ?

(I understand not doing this now, and am not suggesting it.)

Thanks,
Pedro Alves
Tom Tromey Aug. 30, 2019, 7:06 p.m. | #2
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:


Pedro> On 8/21/19 3:25 AM, Tom Tromey wrote:
>> This changes tui_data_window so that the data members are private.

>> This required the addition of a simple accessor method in one case.


Pedro> OOC, do you have plans at some point later in the series to rename
Pedro> local variables to m_xxx ?

Pedro> (I understand not doing this now, and am not suggesting it.)

I didn't but it's no trouble.

Tom

Patch

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 01d50e437e5..387a4f51aff 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -189,7 +189,7 @@  tui_set_layout (enum tui_layout_type layout_type)
       tui_update_source_windows_with_addr (gdbarch, addr);
       if (new_layout == SRC_DATA_COMMAND
 	  || new_layout == DISASSEM_DATA_COMMAND)
-	TUI_DATA_WIN->show_registers (TUI_DATA_WIN->current_group);
+	TUI_DATA_WIN->show_registers (TUI_DATA_WIN->get_current_group ());
     }
 }
 
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 4a09a590446..98096e2cdc4 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -622,7 +622,7 @@  tui_reg_command (const char *args, int from_tty)
       if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible ())
 	tui_reg_layout ();
 
-      struct reggroup *current_group = TUI_DATA_WIN->current_group;
+      struct reggroup *current_group = TUI_DATA_WIN->get_current_group ();
       if (strncmp (args, "next", len) == 0)
 	match = tui_reg_next (current_group, gdbarch);
       else if (strncmp (args, "prev", len) == 0)
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index fa76cae0b18..2606c39f5a1 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -63,15 +63,15 @@  struct tui_data_window : public tui_win_info
     return DATA_NAME;
   }
 
-  /* Windows that are used to display registers.  */
-  std::vector<tui_data_item_window> regs_content;
-  int regs_column_count = 0;
-  struct reggroup *current_group = nullptr;
-
   void check_register_values (struct frame_info *frame);
 
   void show_registers (struct reggroup *group);
 
+  struct reggroup *get_current_group () const
+  {
+    return current_group;
+  }
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
@@ -126,6 +126,11 @@  private:
   void delete_data_content_windows ();
 
   void erase_data_content (const char *prompt);
+
+  /* Windows that are used to display registers.  */
+  std::vector<tui_data_item_window> regs_content;
+  int regs_column_count = 0;
+  struct reggroup *current_group = nullptr;
 };
 
 #endif /* TUI_TUI_REGS_H */