This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA v2 07/17] Remove make_cleanup_restore_current_ui


On 10/13/2016 10:10 PM, Tom Tromey wrote:

> --- a/gdb/top.h
> +++ b/gdb/top.h
> @@ -155,27 +155,48 @@ extern struct ui *current_ui;
>  /* The list of all UIs.  */
>  extern struct ui *ui_list;
>  
> -/* State for SWITCH_THRU_ALL_UIS.  Declared here because it is meant
> -   to be created on the stack, but should be treated as opaque.  */
> -struct switch_thru_all_uis
> +/* State for SWITCH_THRU_ALL_UIS.  */
> +class switch_thru_all_uis
>  {
> -  struct ui *iter;
> -  struct cleanup *old_chain;
> +public:
> +
> +  switch_thru_all_uis () : m_iter (ui_list), m_save_ui (&current_ui)
> +  {
> +    current_ui = ui_list;
> +  }
> +
> +  // If done iterating, return true; otherwise return false.
> +  bool done () const
> +  {
> +    return m_iter == NULL;
> +  }
> +
> +  // Move to the next UI, setting current_ui if iteration is not yet
> +  // complete.
> +  void next ()
> +  {
> +    m_iter = m_iter->next;
> +    if (m_iter != NULL)
> +      current_ui = m_iter;
> +  }
> +
> + private:
> +
> +  // No need for these.  They are intentionally not defined anywhere.
> +  switch_thru_all_uis &operator= (const switch_thru_all_uis &);
> +  switch_thru_all_uis (const switch_thru_all_uis &);
> +
> +  // Used to iterate through the UIs.
> +  struct ui *m_iter;
> +
> +  // Save and restore current_ui.
> +  scoped_restore_tmpl<struct ui *> m_save_ui;
>  };

// vs /**/ comments.

OK with that change.  Thanks much!

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]