8f745dadac025deba7c9fc0b7b8bd1ef8fcef617
[deliverable/binutils-gdb.git] / gdb / ui-out.c
1 /* Output generating routines for GDB.
2
3 Copyright (C) 1999-2016 Free Software Foundation, Inc.
4
5 Contributed by Cygnus Solutions.
6 Written by Fernando Nasser for Cygnus.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22
23 #include "defs.h"
24 #include "expression.h" /* For language.h */
25 #include "language.h"
26 #include "ui-out.h"
27
28 #include <vector>
29 #include <memory>
30 #include <string>
31
32 /* A header of a ui_out_table. */
33
34 class ui_out_hdr
35 {
36 public:
37
38 explicit ui_out_hdr (int number, int min_width, ui_align alignment,
39 const std::string &name, const std::string &header)
40 : m_number (number),
41 m_min_width (min_width),
42 m_alignment (alignment),
43 m_name (name),
44 m_header (header)
45 {
46 }
47
48 int number () const
49 {
50 return m_number;
51 }
52
53 int min_width () const
54 {
55 return m_min_width;
56 }
57
58 ui_align alignment () const
59 {
60 return m_alignment;
61 }
62
63 const std::string &header () const
64 {
65 return m_header;
66 }
67
68 const std::string &name () const
69 {
70 return m_name;
71 }
72
73 private:
74
75 /* The number of the table column this header represents, 1-based. */
76 int m_number;
77
78 /* Minimal column width in characters. May or may not be applicable,
79 depending on the actual implementation of ui_out. */
80 int m_min_width;
81
82 /* Alignment of the content in the column. May or may not be applicable,
83 depending on the actual implementation of ui_out. */
84 ui_align m_alignment;
85
86 /* Internal column name, used to internally refer to the column. */
87 std::string m_name;
88
89 /* Printed header text of the column. */
90 std::string m_header;
91 };
92
93 /* A level of nesting (either a list or a tuple) in a ui_out output. */
94
95 class ui_out_level
96 {
97 public:
98
99 explicit ui_out_level (ui_out_type type)
100 : m_type (type),
101 m_field_count (0)
102 {
103 }
104
105 ui_out_type type () const
106 {
107 return m_type;
108 }
109
110 int field_count () const
111 {
112 return m_field_count;
113 }
114
115 void inc_field_count ()
116 {
117 m_field_count++;
118 }
119
120 private:
121
122 /* The type of this level. */
123 ui_out_type m_type;
124
125 /* Count each field; the first element is for non-list fields. */
126 int m_field_count;
127 };
128
129 /* Tables are special. Maintain a separate structure that tracks
130 their state. At present an output can only contain a single table
131 but that restriction might eventually be lifted. */
132
133 class ui_out_table
134 {
135 public:
136
137 /* States (steps) of a table generation. */
138
139 enum class state
140 {
141 /* We are generating the table headers. */
142 HEADERS,
143
144 /* We are generating the table body. */
145 BODY,
146 };
147
148 explicit ui_out_table (int entry_level, int nr_cols, const std::string &id)
149 : m_state (state::HEADERS),
150 m_entry_level (entry_level),
151 m_nr_cols (nr_cols),
152 m_id (id)
153 {
154 }
155
156 /* Start building the body of the table. */
157
158 void start_body ();
159
160 /* Add a new header to the table. */
161
162 void append_header (int width, ui_align alignment,
163 const std::string &col_name, const std::string &col_hdr);
164
165 void start_row ();
166
167 /* Extract the format information for the next header and advance
168 the header iterator. Return false if there was no next header. */
169
170 bool get_next_header (int *colno, int *width, ui_align *alignment,
171 const char **col_hdr);
172
173 bool query_field (int colno, int *width, int *alignment,
174 const char **col_name) const;
175
176 state current_state () const;
177
178 int entry_level () const;
179
180 private:
181
182 state m_state;
183
184 /* The level at which each entry of the table is to be found. A row
185 (a tuple) is made up of entries. Consequently ENTRY_LEVEL is one
186 above that of the table. */
187 int m_entry_level;
188
189 /* Number of table columns (as specified in the table_begin call). */
190 int m_nr_cols;
191
192 /* String identifying the table (as specified in the table_begin
193 call). */
194 std::string m_id;
195
196 /* Pointers to the column headers. */
197 std::vector<std::unique_ptr<ui_out_hdr>> m_headers;
198
199 /* Iterator over the headers vector, used when printing successive fields. */
200 std::vector<std::unique_ptr<ui_out_hdr>>::const_iterator m_headers_iterator;
201 };
202
203 /* See ui-out.h. */
204
205 void ui_out_table::start_body ()
206 {
207 if (m_state != state::HEADERS)
208 internal_error (__FILE__, __LINE__,
209 _("extra table_body call not allowed; there must be only "
210 "one table_body after a table_begin and before a "
211 "table_end."));
212
213 /* Check if the number of defined headers matches the number of expected
214 columns. */
215 if (m_headers.size () != m_nr_cols)
216 internal_error (__FILE__, __LINE__,
217 _("number of headers differ from number of table "
218 "columns."));
219
220 m_state = state::BODY;
221 m_headers_iterator = m_headers.begin ();
222 }
223
224 /* See ui-out.h. */
225
226 void ui_out_table::append_header (int width, ui_align alignment,
227 const std::string &col_name,
228 const std::string &col_hdr)
229 {
230 if (m_state != state::HEADERS)
231 internal_error (__FILE__, __LINE__,
232 _("table header must be specified after table_begin and "
233 "before table_body."));
234
235 std::unique_ptr<ui_out_hdr> header (new ui_out_hdr (m_headers.size () + 1,
236 width, alignment,
237 col_name, col_hdr));
238
239 m_headers.push_back (std::move (header));
240 }
241
242 /* See ui-out.h. */
243
244 void ui_out_table::start_row ()
245 {
246 m_headers_iterator = m_headers.begin ();
247 }
248
249 /* See ui-out.h. */
250
251 bool ui_out_table::get_next_header (int *colno, int *width, ui_align *alignment,
252 const char **col_hdr)
253 {
254 /* There may be no headers at all or we may have used all columns. */
255 if (m_headers_iterator == m_headers.end ())
256 return false;
257
258 ui_out_hdr *hdr = m_headers_iterator->get ();
259
260 *colno = hdr->number ();
261 *width = hdr->min_width ();
262 *alignment = hdr->alignment ();
263 *col_hdr = hdr->header ().c_str ();
264
265 /* Advance the header pointer to the next entry. */
266 m_headers_iterator++;
267
268 return true;
269 }
270
271 /* See ui-out.h. */
272
273 bool ui_out_table::query_field (int colno, int *width, int *alignment,
274 const char **col_name) const
275 {
276 /* Column numbers are 1-based, so convert to 0-based index. */
277 int index = colno - 1;
278
279 if (index >= 0 && index < m_headers.size ())
280 {
281 ui_out_hdr *hdr = m_headers[index].get ();
282
283 gdb_assert (colno == hdr->number ());
284
285 *width = hdr->min_width ();
286 *alignment = hdr->alignment ();
287 *col_name = hdr->name ().c_str ();
288
289 return true;
290 }
291 else
292 return false;
293 }
294
295 /* See ui-out.h. */
296
297 ui_out_table::state ui_out_table::current_state () const
298 {
299 return m_state;
300 }
301
302 /* See ui-out.h. */
303
304 int ui_out_table::entry_level () const
305 {
306 return m_entry_level;
307 }
308
309 /* The ui_out structure */
310
311 struct ui_out
312 {
313 int flags;
314 /* Specific implementation of ui-out. */
315 const struct ui_out_impl *impl;
316 void *data;
317
318 /* Vector to store and track the ui-out levels. */
319 std::vector<std::unique_ptr<ui_out_level>> levels;
320
321 int level () const
322 {
323 return this->levels.size ();
324 }
325
326 /* A table, if any. At present only a single table is supported. */
327 std::unique_ptr<ui_out_table> table;
328 };
329
330 /* The current (inner most) level. */
331 static ui_out_level *
332 current_level (struct ui_out *uiout)
333 {
334 return uiout->levels.back ().get ();
335 }
336
337 /* Create a new level, of TYPE. */
338 static void
339 push_level (struct ui_out *uiout,
340 enum ui_out_type type)
341 {
342 std::unique_ptr<ui_out_level> level (new ui_out_level (type));
343
344 uiout->levels.push_back (std::move (level));
345 }
346
347 /* Discard the current level. TYPE is the type of the level being
348 discarded. */
349 static void
350 pop_level (struct ui_out *uiout,
351 enum ui_out_type type)
352 {
353 /* We had better not underflow the buffer. */
354 gdb_assert (uiout->level () > 0);
355 gdb_assert (current_level (uiout)->type () == type);
356
357 uiout->levels.pop_back ();
358 }
359
360 /* These are the interfaces to implementation functions. */
361
362 static void uo_table_begin (struct ui_out *uiout, int nbrofcols,
363 int nr_rows, const char *tblid);
364 static void uo_table_body (struct ui_out *uiout);
365 static void uo_table_end (struct ui_out *uiout);
366 static void uo_table_header (struct ui_out *uiout, int width,
367 enum ui_align align,
368 const std::string &col_name,
369 const std::string &col_hdr);
370 static void uo_begin (struct ui_out *uiout,
371 enum ui_out_type type,
372 const char *id);
373 static void uo_end (struct ui_out *uiout,
374 enum ui_out_type type);
375 static void uo_field_int (struct ui_out *uiout, int fldno, int width,
376 enum ui_align align, const char *fldname, int value);
377 static void uo_field_skip (struct ui_out *uiout, int fldno, int width,
378 enum ui_align align, const char *fldname);
379 static void uo_field_fmt (struct ui_out *uiout, int fldno, int width,
380 enum ui_align align, const char *fldname,
381 const char *format, va_list args)
382 ATTRIBUTE_PRINTF (6, 0);
383 static void uo_spaces (struct ui_out *uiout, int numspaces);
384 static void uo_text (struct ui_out *uiout, const char *string);
385 static void uo_message (struct ui_out *uiout,
386 const char *format, va_list args)
387 ATTRIBUTE_PRINTF (2, 0);
388 static void uo_wrap_hint (struct ui_out *uiout, const char *identstring);
389 static void uo_flush (struct ui_out *uiout);
390 static int uo_redirect (struct ui_out *uiout, struct ui_file *outstream);
391
392 /* Prototypes for local functions */
393
394 static void verify_field (struct ui_out *uiout, int *fldno, int *width,
395 enum ui_align *align);
396
397 /* exported functions (ui_out API) */
398
399 /* Mark beginning of a table. */
400
401 static void
402 ui_out_table_begin (struct ui_out *uiout, int nr_cols,
403 int nr_rows, const std::string &tblid)
404 {
405 if (uiout->table != nullptr)
406 internal_error (__FILE__, __LINE__,
407 _("tables cannot be nested; table_begin found before \
408 previous table_end."));
409
410 uiout->table.reset (
411 new ui_out_table (uiout->level () + 1, nr_cols, tblid));
412
413 uo_table_begin (uiout, nr_cols, nr_rows, tblid.c_str ());
414 }
415
416 void
417 ui_out_table_body (struct ui_out *uiout)
418 {
419 if (uiout->table == nullptr)
420 internal_error (__FILE__, __LINE__,
421 _("table_body outside a table is not valid; it must be \
422 after a table_begin and before a table_end."));
423
424 uiout->table->start_body ();
425
426 uo_table_body (uiout);
427 }
428
429 static void
430 ui_out_table_end (struct ui_out *uiout)
431 {
432 if (uiout->table == nullptr)
433 internal_error (__FILE__, __LINE__,
434 _("misplaced table_end or missing table_begin."));
435
436 uo_table_end (uiout);
437
438 uiout->table = nullptr;
439 }
440
441 void
442 ui_out_table_header (struct ui_out *uiout, int width, enum ui_align alignment,
443 const std::string &col_name, const std::string &col_hdr)
444 {
445 if (uiout->table == nullptr)
446 internal_error (__FILE__, __LINE__,
447 _("table_header outside a table is not valid; it must be "
448 "after a table_begin and before a table_body."));
449
450 uiout->table->append_header (width, alignment, col_name, col_hdr);
451
452 uo_table_header (uiout, width, alignment, col_name, col_hdr);
453 }
454
455 static void
456 do_cleanup_table_end (void *data)
457 {
458 struct ui_out *ui_out = (struct ui_out *) data;
459
460 ui_out_table_end (ui_out);
461 }
462
463 struct cleanup *
464 make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out, int nr_cols,
465 int nr_rows, const char *tblid)
466 {
467 ui_out_table_begin (ui_out, nr_cols, nr_rows, tblid);
468 return make_cleanup (do_cleanup_table_end, ui_out);
469 }
470
471 void
472 ui_out_begin (struct ui_out *uiout,
473 enum ui_out_type type,
474 const char *id)
475 {
476 /* Be careful to verify the ``field'' before the new tuple/list is
477 pushed onto the stack. That way the containing list/table/row is
478 verified and not the newly created tuple/list. This verification
479 is needed (at least) for the case where a table row entry
480 contains either a tuple/list. For that case bookkeeping such as
481 updating the column count or advancing to the next heading still
482 needs to be performed. */
483 {
484 int fldno;
485 int width;
486 enum ui_align align;
487
488 verify_field (uiout, &fldno, &width, &align);
489 }
490
491 push_level (uiout, type);
492
493 /* If the push puts us at the same level as a table row entry, we've
494 got a new table row. Put the header pointer back to the start. */
495 if (uiout->table != nullptr
496 && uiout->table->current_state () == ui_out_table::state::BODY
497 && uiout->table->entry_level () == uiout->level ())
498 uiout->table->start_row ();
499
500 uo_begin (uiout, type, id);
501 }
502
503 void
504 ui_out_end (struct ui_out *uiout,
505 enum ui_out_type type)
506 {
507 pop_level (uiout, type);
508
509 uo_end (uiout, type);
510 }
511
512 struct ui_out_end_cleanup_data
513 {
514 struct ui_out *uiout;
515 enum ui_out_type type;
516 };
517
518 static void
519 do_cleanup_end (void *data)
520 {
521 struct ui_out_end_cleanup_data *end_cleanup_data
522 = (struct ui_out_end_cleanup_data *) data;
523
524 ui_out_end (end_cleanup_data->uiout, end_cleanup_data->type);
525 xfree (end_cleanup_data);
526 }
527
528 static struct cleanup *
529 make_cleanup_ui_out_end (struct ui_out *uiout,
530 enum ui_out_type type)
531 {
532 struct ui_out_end_cleanup_data *end_cleanup_data;
533
534 end_cleanup_data = XNEW (struct ui_out_end_cleanup_data);
535 end_cleanup_data->uiout = uiout;
536 end_cleanup_data->type = type;
537 return make_cleanup (do_cleanup_end, end_cleanup_data);
538 }
539
540 struct cleanup *
541 make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout,
542 const char *id)
543 {
544 ui_out_begin (uiout, ui_out_type_tuple, id);
545 return make_cleanup_ui_out_end (uiout, ui_out_type_tuple);
546 }
547
548 struct cleanup *
549 make_cleanup_ui_out_list_begin_end (struct ui_out *uiout,
550 const char *id)
551 {
552 ui_out_begin (uiout, ui_out_type_list, id);
553 return make_cleanup_ui_out_end (uiout, ui_out_type_list);
554 }
555
556 void
557 ui_out_field_int (struct ui_out *uiout,
558 const char *fldname,
559 int value)
560 {
561 int fldno;
562 int width;
563 enum ui_align align;
564
565 verify_field (uiout, &fldno, &width, &align);
566
567 uo_field_int (uiout, fldno, width, align, fldname, value);
568 }
569
570 void
571 ui_out_field_fmt_int (struct ui_out *uiout,
572 int input_width,
573 enum ui_align input_align,
574 const char *fldname,
575 int value)
576 {
577 int fldno;
578 int width;
579 enum ui_align align;
580
581 verify_field (uiout, &fldno, &width, &align);
582
583 uo_field_int (uiout, fldno, input_width, input_align, fldname, value);
584 }
585
586 /* Documented in ui-out.h. */
587
588 void
589 ui_out_field_core_addr (struct ui_out *uiout,
590 const char *fldname,
591 struct gdbarch *gdbarch,
592 CORE_ADDR address)
593 {
594 ui_out_field_string (uiout, fldname,
595 print_core_address (gdbarch, address));
596 }
597
598 void
599 ui_out_field_stream (struct ui_out *uiout,
600 const char *fldname,
601 struct ui_file *stream)
602 {
603 std::string buffer = ui_file_as_string (stream);
604
605 if (!buffer.empty ())
606 ui_out_field_string (uiout, fldname, buffer.c_str ());
607 else
608 ui_out_field_skip (uiout, fldname);
609 ui_file_rewind (stream);
610 }
611
612 /* Used to omit a field. */
613
614 void
615 ui_out_field_skip (struct ui_out *uiout,
616 const char *fldname)
617 {
618 int fldno;
619 int width;
620 enum ui_align align;
621
622 verify_field (uiout, &fldno, &width, &align);
623
624 uo_field_skip (uiout, fldno, width, align, fldname);
625 }
626
627 void
628 ui_out_field_string (struct ui_out *uiout,
629 const char *fldname,
630 const char *string)
631 {
632 int fldno;
633 int width;
634 enum ui_align align;
635
636 verify_field (uiout, &fldno, &width, &align);
637
638 uo_field_string (uiout, fldno, width, align, fldname, string);
639 }
640
641 /* VARARGS */
642 void
643 ui_out_field_fmt (struct ui_out *uiout,
644 const char *fldname,
645 const char *format, ...)
646 {
647 va_list args;
648 int fldno;
649 int width;
650 enum ui_align align;
651
652 /* Will not align, but has to call anyway. */
653 verify_field (uiout, &fldno, &width, &align);
654
655 va_start (args, format);
656
657 uo_field_fmt (uiout, fldno, width, align, fldname, format, args);
658
659 va_end (args);
660 }
661
662 void
663 ui_out_spaces (struct ui_out *uiout, int numspaces)
664 {
665 uo_spaces (uiout, numspaces);
666 }
667
668 void
669 ui_out_text (struct ui_out *uiout,
670 const char *string)
671 {
672 uo_text (uiout, string);
673 }
674
675 void
676 ui_out_message (struct ui_out *uiout, const char *format, ...)
677 {
678 va_list args;
679
680 va_start (args, format);
681 uo_message (uiout, format, args);
682 va_end (args);
683 }
684
685 void
686 ui_out_wrap_hint (struct ui_out *uiout, const char *identstring)
687 {
688 uo_wrap_hint (uiout, identstring);
689 }
690
691 void
692 ui_out_flush (struct ui_out *uiout)
693 {
694 uo_flush (uiout);
695 }
696
697 int
698 ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream)
699 {
700 return uo_redirect (uiout, outstream);
701 }
702
703 /* Test the flags against the mask given. */
704 int
705 ui_out_test_flags (struct ui_out *uiout, int mask)
706 {
707 return (uiout->flags & mask);
708 }
709
710 int
711 ui_out_is_mi_like_p (struct ui_out *uiout)
712 {
713 return uiout->impl->is_mi_like_p;
714 }
715
716 /* Interface to the implementation functions. */
717
718 void
719 uo_table_begin (struct ui_out *uiout, int nbrofcols,
720 int nr_rows,
721 const char *tblid)
722 {
723 if (!uiout->impl->table_begin)
724 return;
725 uiout->impl->table_begin (uiout, nbrofcols, nr_rows, tblid);
726 }
727
728 void
729 uo_table_body (struct ui_out *uiout)
730 {
731 if (!uiout->impl->table_body)
732 return;
733 uiout->impl->table_body (uiout);
734 }
735
736 void
737 uo_table_end (struct ui_out *uiout)
738 {
739 if (!uiout->impl->table_end)
740 return;
741 uiout->impl->table_end (uiout);
742 }
743
744 void
745 uo_table_header (struct ui_out *uiout, int width, enum ui_align align,
746 const std::string &col_name, const std::string &col_hdr)
747 {
748 if (!uiout->impl->table_header)
749 return;
750 uiout->impl->table_header (uiout, width, align, col_name, col_hdr);
751 }
752
753 void
754 uo_begin (struct ui_out *uiout,
755 enum ui_out_type type,
756 const char *id)
757 {
758 if (uiout->impl->begin == NULL)
759 return;
760 uiout->impl->begin (uiout, type, id);
761 }
762
763 void
764 uo_end (struct ui_out *uiout,
765 enum ui_out_type type)
766 {
767 if (uiout->impl->end == NULL)
768 return;
769 uiout->impl->end (uiout, type);
770 }
771
772 void
773 uo_field_int (struct ui_out *uiout, int fldno, int width, enum ui_align align,
774 const char *fldname,
775 int value)
776 {
777 if (!uiout->impl->field_int)
778 return;
779 uiout->impl->field_int (uiout, fldno, width, align, fldname, value);
780 }
781
782 void
783 uo_field_skip (struct ui_out *uiout, int fldno, int width, enum ui_align align,
784 const char *fldname)
785 {
786 if (!uiout->impl->field_skip)
787 return;
788 uiout->impl->field_skip (uiout, fldno, width, align, fldname);
789 }
790
791 void
792 uo_field_string (struct ui_out *uiout, int fldno, int width,
793 enum ui_align align,
794 const char *fldname,
795 const char *string)
796 {
797 if (!uiout->impl->field_string)
798 return;
799 uiout->impl->field_string (uiout, fldno, width, align, fldname, string);
800 }
801
802 void
803 uo_field_fmt (struct ui_out *uiout, int fldno, int width, enum ui_align align,
804 const char *fldname,
805 const char *format,
806 va_list args)
807 {
808 if (!uiout->impl->field_fmt)
809 return;
810 uiout->impl->field_fmt (uiout, fldno, width, align, fldname, format, args);
811 }
812
813 void
814 uo_spaces (struct ui_out *uiout, int numspaces)
815 {
816 if (!uiout->impl->spaces)
817 return;
818 uiout->impl->spaces (uiout, numspaces);
819 }
820
821 void
822 uo_text (struct ui_out *uiout,
823 const char *string)
824 {
825 if (!uiout->impl->text)
826 return;
827 uiout->impl->text (uiout, string);
828 }
829
830 void
831 uo_message (struct ui_out *uiout,
832 const char *format,
833 va_list args)
834 {
835 if (!uiout->impl->message)
836 return;
837 uiout->impl->message (uiout, format, args);
838 }
839
840 void
841 uo_wrap_hint (struct ui_out *uiout, const char *identstring)
842 {
843 if (!uiout->impl->wrap_hint)
844 return;
845 uiout->impl->wrap_hint (uiout, identstring);
846 }
847
848 void
849 uo_flush (struct ui_out *uiout)
850 {
851 if (!uiout->impl->flush)
852 return;
853 uiout->impl->flush (uiout);
854 }
855
856 int
857 uo_redirect (struct ui_out *uiout, struct ui_file *outstream)
858 {
859 if (!uiout->impl->redirect)
860 return -1;
861 return uiout->impl->redirect (uiout, outstream);
862 }
863
864 /* Verify that the field/tuple/list is correctly positioned. Return
865 the field number and corresponding alignment (if
866 available/applicable). */
867
868 static void
869 verify_field (struct ui_out *uiout, int *fldno, int *width,
870 enum ui_align *align)
871 {
872 ui_out_level *current = current_level (uiout);
873 const char *text;
874
875 if (uiout->table != nullptr
876 && uiout->table->current_state () != ui_out_table::state::BODY)
877 {
878 internal_error (__FILE__, __LINE__,
879 _("table_body missing; table fields must be \
880 specified after table_body and inside a list."));
881 }
882
883 current->inc_field_count ();
884
885 if (uiout->table != nullptr
886 && uiout->table->current_state () == ui_out_table::state::BODY
887 && uiout->table->entry_level () == uiout->level ()
888 && uiout->table->get_next_header (fldno, width, align, &text))
889 {
890 if (*fldno != current->field_count ())
891 internal_error (__FILE__, __LINE__,
892 _("ui-out internal error in handling headers."));
893 }
894 else
895 {
896 *width = 0;
897 *align = ui_noalign;
898 *fldno = current->field_count ();
899 }
900 }
901
902
903 /* Access to ui-out members data. */
904
905 void *
906 ui_out_data (struct ui_out *uiout)
907 {
908 return uiout->data;
909 }
910
911 /* Access table field parameters. */
912 int
913 ui_out_query_field (struct ui_out *uiout, int colno,
914 int *width, int *alignment, const char **col_name)
915 {
916 if (uiout->table == nullptr)
917 return 0;
918
919 return uiout->table->query_field (colno, width, alignment, col_name);
920 }
921
922 /* Initialize private members at startup. */
923
924 struct ui_out *
925 ui_out_new (const struct ui_out_impl *impl, void *data,
926 int flags)
927 {
928 struct ui_out *uiout = new ui_out ();
929
930 uiout->data = data;
931 uiout->impl = impl;
932 uiout->flags = flags;
933
934 /* Create the ui-out level #1, the default level. */
935 push_level (uiout, ui_out_type_tuple);
936
937 return uiout;
938 }
This page took 0.059808 seconds and 4 git commands to generate.