summaryrefslogtreecommitdiff
path: root/gdb/cli-out.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2010-04-18 00:11:54 +0000
committerPedro Alves <pedro@codesourcery.com>2010-04-18 00:11:54 +0000
commit9cf7bd5857f0fe4d75c732b6fcf7178588bc6404 (patch)
tree676125f866bf52c0747ea673f3f130bf314c655c /gdb/cli-out.c
parent928300f07f84b4c3b68f4caa961b8e01da9a210d (diff)
downloadgdb-9cf7bd5857f0fe4d75c732b6fcf7178588bc6404.tar.gz
PR tui/9217
* tui/tui-out.c: Include cli-out.h. (tui_table_begin, tui_table_body, tui_table_end, tui_table_header) (tui_begin, tui_end, tui_field_int, tui_field_skip) (tui_field_string, tui_field_fmt, tui_spaces, tui_text) (tui_message, tui_wrap_hint, tui_flush): Delete forward declarations. (struct ui_out_data): Rename to... (struct tui_ui_out_data): ... this. Remove `stream' and `suppress_output' fields, and inherit cli_ui_out_data. (tui_out_data): New typedef. (tui_ui_out_impl): Don't initialize fields staticaly. (tui_table_begin, tui_table_body, tui_table_end, tui_table_header) (tui_begin, tui_end): Delete. (tui_field_int): Adjust to delegate most work to the base type. (tui_field_skip): Delete. (tui_field_string, tui_field_fmt): Adjust comment. Adjust to delegate most work to the base type. (tui_spaces): Delete. (tui_text): Adjust to delegate most work to the base type. (tui_message): Delete. (tui_wrap_hint): Delete. (tui_flush): Delete. (out_field_fmt): Delete. (field_separator): Delete. (tui_out_new): Adjust to initialize the base type. (_initialize_tui_out): Initialize tui_ui_out_impl. * cli-out.c (struct ui_out_data): Moved out to cli-out.h, renamed cli_ui_out_data. (cli_out_data): Adjust. (cli_ui_out_impl): Make extern. (cli_table_header, cli_field_int, cli_field_skip): Use uo_field_string instead of cli_field_string. (cli_redirect): Adjust to use cli_out_data. (cli_out_data_ctor): New. (cli_out_new): Use it. * cli-out.h (struct ui_file): Remove forward declaration. (struct cli_ui_out_data): New, moved from cli-out.c, and renamed. (cli_ui_out_impl): Declare. (cli_out_data_ctor): Declare. * ui-out.c (struct ui_out) <data>: Change type to void pointer. (uo_field_string): No longer static. (ui_out_data): Change return type to void pointer. (ui_out_new): Change `data' parameter type to void pointer. * ui-out.h (struct ui_out_data): Don't forward declare. (ui_out_data): Change return type to void pointer. (ui_out_new): Change `data' parameter type to void pointer. (uo_field_string): Declare.
Diffstat (limited to 'gdb/cli-out.c')
-rw-r--r--gdb/cli-out.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 7b32f7ce840..e99edb08412 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -27,13 +27,7 @@
#include "gdb_string.h"
#include "gdb_assert.h"
-struct ui_out_data
- {
- struct ui_file *stream;
- struct ui_file *original_stream;
- int suppress_output;
- };
-typedef struct ui_out_data cli_out_data;
+typedef struct cli_ui_out_data cli_out_data;
/* These are the CLI output functions */
@@ -72,7 +66,7 @@ static int cli_redirect (struct ui_out *uiout, struct ui_file *outstream);
/* FIXME: This can be initialized dynamically after default is set to
handle initial output in main.c */
-static struct ui_out_impl cli_ui_out_impl =
+struct ui_out_impl cli_ui_out_impl =
{
cli_table_begin,
cli_table_body,
@@ -103,10 +97,6 @@ static void out_field_fmt (struct ui_out *uiout, int fldno,
const char *fldname,
const char *format,...) ATTR_FORMAT (printf, 4, 5);
-/* local variables */
-
-/* (none yet) */
-
/* Mark beginning of a table */
void
@@ -154,7 +144,10 @@ cli_table_header (struct ui_out *uiout, int width, enum ui_align alignment,
cli_out_data *data = ui_out_data (uiout);
if (data->suppress_output)
return;
- cli_field_string (uiout, 0, width, alignment, 0, colhdr);
+
+ /* Always go through the function pointer (virtual function call).
+ We may have been extended. */
+ uo_field_string (uiout, 0, width, alignment, 0, colhdr);
}
/* Mark beginning of a list */
@@ -195,7 +188,10 @@ cli_field_int (struct ui_out *uiout, int fldno, int width,
if (data->suppress_output)
return;
sprintf (buffer, "%d", value);
- cli_field_string (uiout, fldno, width, alignment, fldname, buffer);
+
+ /* Always go through the function pointer (virtual function call).
+ We may have been extended. */
+ uo_field_string (uiout, fldno, width, alignment, fldname, buffer);
}
/* used to ommit a field */
@@ -208,7 +204,10 @@ cli_field_skip (struct ui_out *uiout, int fldno, int width,
cli_out_data *data = ui_out_data (uiout);
if (data->suppress_output)
return;
- cli_field_string (uiout, fldno, width, alignment, fldname, "");
+
+ /* Always go through the function pointer (virtual function call).
+ We may have been extended. */
+ uo_field_string (uiout, fldno, width, alignment, fldname, "");
}
/* other specific cli_field_* end up here so alignment and field
@@ -330,7 +329,7 @@ cli_flush (struct ui_out *uiout)
int
cli_redirect (struct ui_out *uiout, struct ui_file *outstream)
{
- struct ui_out_data *data = ui_out_data (uiout);
+ cli_out_data *data = ui_out_data (uiout);
if (outstream != NULL)
{
data->original_stream = data->stream;
@@ -374,7 +373,17 @@ field_separator (void)
fputc_filtered (' ', data->stream);
}
-/* Initalize private members at startup. */
+/* Constructor for a `cli_out_data' object. */
+
+void
+cli_out_data_ctor (cli_out_data *self, struct ui_file *stream)
+{
+ self->stream = stream;
+ self->original_stream = NULL;
+ self->suppress_output = 0;
+}
+
+/* Initialize private members at startup. */
struct ui_out *
cli_out_new (struct ui_file *stream)
@@ -382,9 +391,7 @@ cli_out_new (struct ui_file *stream)
int flags = ui_source_list;
cli_out_data *data = XMALLOC (cli_out_data);
- data->stream = stream;
- data->original_stream = NULL;
- data->suppress_output = 0;
+ cli_out_data_ctor (data, stream);
return ui_out_new (&cli_ui_out_impl, data, flags);
}