Class-ify ui_out_table
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 1 Dec 2016 21:20:02 +0000 (16:20 -0500)
committerSimon Marchi <simon.marchi@ericsson.com>
Thu, 1 Dec 2016 21:20:35 +0000 (16:20 -0500)
commit36d18bc526b055be896d8dc319cb3ade42238534
treeeb2dea0c1b2051112d8cc8a8c3dd5b1bd6d2174f
parent77a179e77b38161e461f5e37512f0b3fc3582181
Class-ify ui_out_table

This patch makes a class out of the ui_out_table structure, the
structure responsible for managing the generation of an UI table.

To simplify the ui_out_table object, I changed it so that it can only be
used for generating a single object.  Instead of clearing the header
list when starting a new table, we an ui_out_table when starting a
table and delete it when we're done.  Therefore, the checks:

  if (uiout->table->flag)
  if (!uiout->table->flag)

are respectively replaced with

  if (uiout->table != nullptr)
  if (uiout->table == nullptr)

Note: I removed the check at the beginning of ui_out_begin, because
there is an equivalent check at the beginning of verify_field.

New in v2:

  - use "enum class" for ui_out_table::state and update references.

gdb/ChangeLog:

* ui-out.c (enum ui_out_table_state): Move to class
ui_out_table as ui_out_table::state.
(struct ui_out_table): Change to ...
(class ui_out_table): ... this.
<flag>: Remove.
<entry_level>: Rename to ...
<m_entry_level>: ... this.
<columns>: Rename to ...
<m_nr_cols>: ... this.
<id>: Rename to ...
<m_id>: ... this.
<headers>: Rename to ...
<m_headers>: ... this.
<headers_iterator>: Rename to ...
<m_headers_iterator>: ... this.
<start_body, append_header, start_row, get_next_header,
query_field, current_state, entry_level>: New methods.
(struct ui_out) <table>: Change type to unique_ptr to
ui_out_table.
(append_header_to_list, get_next_header, clear_header_list,
clear_table): Remove.
(ui_out_table_begin): Instantiate ui_out_table object.  Update
table check.
(ui_out_table_body): Update table check, replace code with call
to ui_out_table::start_body.
(ui_out_table_end): Update table check, replace manual cleanup
with assignment of uiout->table unique_ptr to nullptr.
(ui_out_table_header): Update table check, replace call to
append_header_to_list with call to append_header method.
(ui_out_begin): Remove one table state check, update another.
Replace code with call to start_row method.
(verify_field): Update table checks.
(ui_out_query_field): Update table check, replace code with call
to query_field method.
(ui_out_new): Remove table initialization code.
gdb/ChangeLog
gdb/ui-out.c
This page took 0.026803 seconds and 4 git commands to generate.