+2001-05-08 Andrew Cagney <ac131313@redhat.com>
+
+ * cli-out.c (cli_begin, cli_end): Replace cli_list_begin and
+ cli_list_end.
+ (cli_ui_out_impl): Update.
+
+ * ui-out.c (default_begin, default_end): Replace
+ default_list_begin and default_list_end.
+ (default_ui_out_impl): Update.
+ (uo_begin, uo_end): Replace ou_list_begin and uo_list_end.
+ (ui_out_begin, ui_out_end): Replace ui_out_list_begin and
+ ui_out_list_end.
+ (ui_out_list_begin, ui_out_list_end): New. Compatibility
+ functions.
+ (struct ui_out_level): Add field type.
+ (push_level, pop_level): Update. Add type parameter.
+
+ * ui-out.h (enum ui_out_type): Declare.
+ (ui_out_begin, ui_out_end): Declare.
+ (ui_out_begin_ftype, ui_out_end_ftype): Replace list_begin_ftype
+ and list_end_ftype.
+ (struct ui_out_impl): Update.
+
2001-05-07 Andrew Cagney <ac131313@redhat.com>
* ui-out.h (list_begin_ftype, list_end_ftype): Rename argument
static void cli_table_end (struct ui_out *uiout);
static void cli_table_header (struct ui_out *uiout, int width,
enum ui_align alig, char *colhdr);
-static void cli_list_begin (struct ui_out *uiout, int list_flag, char *lstid);
-static void cli_list_end (struct ui_out *uiout, int list_flag);
+static void cli_begin (struct ui_out *uiout, enum ui_out_type type,
+ int level, const char *lstid);
+static void cli_end (struct ui_out *uiout, enum ui_out_type type, int level);
static void cli_field_int (struct ui_out *uiout, int fldno, int width,
enum ui_align alig, char *fldname, int value);
static void cli_field_skip (struct ui_out *uiout, int fldno, int width,
cli_table_body,
cli_table_end,
cli_table_header,
- cli_list_begin,
- cli_list_end,
+ cli_begin,
+ cli_end,
cli_field_int,
cli_field_skip,
cli_field_string,
/* Mark beginning of a list */
void
-cli_list_begin (struct ui_out *uiout, int list_flag, char *lstid)
+cli_begin (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level,
+ const char *id)
{
}
/* Mark end of a list */
void
-cli_list_end (struct ui_out *uiout, int list_flag)
+cli_end (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level)
{
}
+2001-05-08 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-out.c (mi_begin, mi_end): Replace mi_list_begin and
+ mi_list_end.
+ (mi_ui_out_impl): Update.
+
2001-03-28 Andrew Cagney <ac131313@redhat.com>
* mi-main.c (mi_cmd_data_read_memory): Use xcalloc.
static void mi_table_end (struct ui_out *uiout);
static void mi_table_header (struct ui_out *uiout, int width,
enum ui_align alig, char *colhdr);
-static void mi_list_begin (struct ui_out *uiout, int list_flag, char *lstid);
-static void mi_list_end (struct ui_out *uiout, int list_flag);
+static void mi_begin (struct ui_out *uiout, enum ui_out_type type,
+ int level, const char *id);
+static void mi_end (struct ui_out *uiout, enum ui_out_type type, int level);
static void mi_field_int (struct ui_out *uiout, int fldno, int width,
enum ui_align alig, char *fldname, int value);
static void mi_field_skip (struct ui_out *uiout, int fldno, int width,
mi_table_body,
mi_table_end,
mi_table_header,
- mi_list_begin,
- mi_list_end,
+ mi_begin,
+ mi_end,
mi_field_int,
mi_field_skip,
mi_field_string,
/* Mark beginning of a list */
void
-mi_list_begin (struct ui_out *uiout, int list_flag, char *lstid)
+mi_begin (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level,
+ const char *lstid)
{
struct ui_out_data *data = ui_out_data (uiout);
field_separator (uiout);
/* Mark end of a list */
void
-mi_list_end (struct ui_out *uiout, int list_flag)
+mi_end (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level)
{
struct ui_out_data *data = ui_out_data (uiout);
list_close (uiout);
{
/* Count each field; the first element is for non-list fields */
int field_count;
+ /* The type of this level. */
+ enum ui_out_type type;
};
/* The ui_out structure */
/* Create a new level, of TYPE. Return the new level's index. */
static int
push_level (struct ui_out *uiout,
+ enum ui_out_type type,
const char *id)
{
struct ui_out_level *current;
/* We had better not overflow the buffer. */
uiout->level++;
- gdb_assert (uiout->level > 0 && uiout->level < MAX_UI_OUT_LEVELS);
+ gdb_assert (uiout->level >= 0 && uiout->level < MAX_UI_OUT_LEVELS);
current = current_level (uiout);
current->field_count = 0;
+ current->type = type;
return uiout->level;
}
/* Discard the current level, return the discarded level's index.
TYPE is the type of the level being discarded. */
static int
-pop_level (struct ui_out *uiout)
+pop_level (struct ui_out *uiout,
+ enum ui_out_type type)
{
/* We had better not underflow the buffer. */
gdb_assert (uiout->level > 0 && uiout->level < MAX_UI_OUT_LEVELS);
+ gdb_assert (current_level (uiout)->type == type);
uiout->level--;
return uiout->level + 1;
}
static void default_table_end (struct ui_out *uiout);
static void default_table_header (struct ui_out *uiout, int width,
enum ui_align alig, char *colhdr);
-static void default_list_begin (struct ui_out *uiout, int level,
- char *lstid);
-static void default_list_end (struct ui_out *uiout, int level);
+static void default_begin (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level, const char *id);
+static void default_end (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level);
static void default_field_int (struct ui_out *uiout, int fldno, int width,
enum ui_align alig, char *fldname, int value);
static void default_field_skip (struct ui_out *uiout, int fldno, int width,
default_table_body,
default_table_end,
default_table_header,
- default_list_begin,
- default_list_end,
+ default_begin,
+ default_end,
default_field_int,
default_field_skip,
default_field_string,
static void uo_table_end (struct ui_out *uiout);
static void uo_table_header (struct ui_out *uiout, int width,
enum ui_align align, char *colhdr);
-static void uo_list_begin (struct ui_out *uiout, int level, char *lstid);
-static void uo_list_end (struct ui_out *uiout, int level);
+static void uo_begin (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level, const char *id);
+static void uo_end (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level);
static void uo_field_int (struct ui_out *uiout, int fldno, int width,
enum ui_align align, char *fldname, int value);
static void uo_field_skip (struct ui_out *uiout, int fldno, int width,
}
void
-ui_out_list_begin (struct ui_out *uiout, char *lstid)
+ui_out_begin (struct ui_out *uiout,
+ enum ui_out_type type,
+ const char *id)
{
int new_level;
if (uiout->table_flag && !uiout->body_flag)
internal_error (__FILE__, __LINE__,
"table header or table_body expected; lists must be \
specified after table_body.");
- new_level = push_level (uiout, lstid);
+ new_level = push_level (uiout, type, id);
if (uiout->table_flag && (new_level == 1))
uiout->headercurr = uiout->headerfirst;
- uo_list_begin (uiout, new_level, lstid);
+ uo_begin (uiout, type, new_level, id);
+}
+
+void
+ui_out_list_begin (struct ui_out *uiout,
+ char *id)
+{
+ ui_out_begin (uiout, ui_out_type_list, id);
+}
+
+void
+ui_out_end (struct ui_out *uiout,
+ enum ui_out_type type)
+{
+ int old_level = pop_level (uiout, type);
+ uo_end (uiout, type, old_level);
}
void
ui_out_list_end (struct ui_out *uiout)
{
- int old_level = pop_level (uiout);
- uo_list_end (uiout, old_level);
+ ui_out_end (uiout, ui_out_type_list);
}
static void
}
static void
-default_list_begin (struct ui_out *uiout, int level, char *lstid)
+default_begin (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level,
+ const char *id)
{
}
static void
-default_list_end (struct ui_out *uiout, int level)
+default_end (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level)
{
}
}
void
-uo_list_begin (struct ui_out *uiout, int level, char *lstid)
+uo_begin (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level,
+ const char *id)
{
- if (!uiout->impl->list_begin)
+ if (uiout->impl->begin == NULL)
return;
- uiout->impl->list_begin (uiout, level, lstid);
+ uiout->impl->begin (uiout, type, level, id);
}
void
-uo_list_end (struct ui_out *uiout, int level)
+uo_end (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level)
{
- if (!uiout->impl->list_end)
+ if (uiout->impl->end == NULL)
return;
- uiout->impl->list_end (uiout, level);
+ uiout->impl->end (uiout, type, level);
}
void
/* Prototypes for ui-out API. */
+/* A result is a recursive data structure consisting of lists and
+ tupples. */
+
+enum ui_out_type
+ {
+ ui_out_type_tupple,
+ ui_out_type_list
+ };
+
+extern void ui_out_begin (struct ui_out *uiout,
+ enum ui_out_type level_type,
+ const char *id);
+
+extern void ui_out_end (struct ui_out *uiout, enum ui_out_type type);
+
+/* A table can be considered a special tupple/list combination with
+ the implied structure: ``table = { hdr = { header, ... } , body = [ {
+ field, ... }, ... ] }'' */
+
extern void ui_out_table_begin (struct ui_out *uiout, int nbrofcols,
char *tblid);
extern void ui_out_table_end (struct ui_out *uiout);
+/* Compatibility wrappers, new code should use ui_out_begin() and
+ ui_out_end(). */
+
extern void ui_out_list_begin (struct ui_out *uiout, char *lstid);
extern void ui_out_list_end (struct ui_out *uiout);
enum ui_align align, char *colhdr);
/* Note: level 0 is the top-level so LEVEL is always greater than
zero. */
-typedef void (list_begin_ftype) (struct ui_out * uiout,
- int level, char *lstid);
-typedef void (list_end_ftype) (struct ui_out * uiout, int level);
+typedef void (ui_out_begin_ftype) (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level, const char *id);
+typedef void (ui_out_end_ftype) (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level);
typedef void (field_int_ftype) (struct ui_out * uiout, int fldno, int width,
enum ui_align align, char *fldname, int value);
typedef void (field_skip_ftype) (struct ui_out * uiout, int fldno, int width,
table_body_ftype *table_body;
table_end_ftype *table_end;
table_header_ftype *table_header;
- list_begin_ftype *list_begin;
- list_end_ftype *list_end;
+ ui_out_begin_ftype *begin;
+ ui_out_end_ftype *end;
field_int_ftype *field_int;
field_skip_ftype *field_skip;
field_string_ftype *field_string;