This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 20/22] Class-ify ui_out_table
On 11/24/2016 07:10 PM, Simon Marchi wrote:
> 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.
>
> gdb/ChangeLog:
>
> * ui-out.c (enum ui_out_table_state): Move to class
> ui_out_table.
> (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.
LGTM.
Thanks,
Pedro Alves