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: [PATCH] tui-out: don't "inherit" redirect from CLI


On Mon, 2010-08-30 at 12:29 +0100, Pedro Alves wrote:
> That was the main reason that tui_ui_out_impl was made to inherit
> cli_ui_out_impl in the first place.
> See <http://sourceware.org/ml/gdb-patches/2010-04/msg00540.html>.

Missed that one, obviously. (My excuse could be that the commit message
doesn't seem to mention that reason.)

> [...] tui_ui_out_data "inherits" cli_ui_out_data.
> See:
> 
> struct tui_ui_out_data
>   {
>     struct cli_ui_out_data base;
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
>     int line;
>     int start_of_line;
>   };
> typedef struct tui_ui_out_data tui_out_data;
> 
> "base" is the first field of tui_ui_out_data, so you can
> pass a pointer to a tui_ui_out_data to a function that expects
> a cli_ui_out_data pointer.  This is legal, and a common idiom on C,
> as means to implementing "is-a" inheritance.

Thanks for taking the time to explain this to me. Maybe next time I'll
recognize the idiom.


Paul


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