Class-ify ui_out_hdr
[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 struct ui_out_level
94 {
95 /* Count each field; the first element is for non-list fields. */
96 int field_count;
97 /* The type of this level. */
98 enum ui_out_type type;
99 };
100
101
102 /* Tables are special. Maintain a separate structure that tracks
103 their state. At present an output can only contain a single table
104 but that restriction might eventually be lifted. */
105
106 struct ui_out_table
107 {
108 /* If on, a table is being generated. */
109 int flag;
110
111 /* If on, the body of a table is being generated. If off, the table
112 header is being generated. */
113 int body_flag;
114
115 /* The level at which each entry of the table is to be found. A row
116 (a tuple) is made up of entries. Consequently ENTRY_LEVEL is one
117 above that of the table. */
118 int entry_level;
119
120 /* Number of table columns (as specified in the table_begin call). */
121 int columns;
122
123 /* String identifying the table (as specified in the table_begin
124 call). */
125 std::string id;
126
127 /* Pointers to the column headers. */
128 std::vector<std::unique_ptr<ui_out_hdr>> headers;
129
130 /* Iterator over the headers vector, used when printing successive fields. */
131 std::vector<std::unique_ptr<ui_out_hdr>>::const_iterator headers_iterator;
132
133 };
134
135
136 /* The ui_out structure */
137
138 struct ui_out
139 {
140 int flags;
141 /* Specific implementation of ui-out. */
142 const struct ui_out_impl *impl;
143 void *data;
144
145 /* Current level. */
146 int level;
147
148 /* Vector to store and track the ui-out levels. */
149 std::vector<std::unique_ptr<ui_out_level>> levels;
150
151 /* A table, if any. At present only a single table is supported. */
152 struct ui_out_table table;
153 };
154
155 /* The current (inner most) level. */
156 static struct ui_out_level *
157 current_level (struct ui_out *uiout)
158 {
159 return uiout->levels[uiout->level].get ();
160 }
161
162 /* Create a new level, of TYPE. Return the new level's index. */
163 static int
164 push_level (struct ui_out *uiout,
165 enum ui_out_type type)
166 {
167 std::unique_ptr<ui_out_level> current (new ui_out_level ());
168
169 current->field_count = 0;
170 current->type = type;
171
172 uiout->level++;
173 uiout->levels.push_back (std::move (current));
174
175 return uiout->level;
176 }
177
178 /* Discard the current level, return the discarded level's index.
179 TYPE is the type of the level being discarded. */
180 static int
181 pop_level (struct ui_out *uiout,
182 enum ui_out_type type)
183 {
184 /* We had better not underflow the buffer. */
185 gdb_assert (uiout->level > 0);
186 gdb_assert (current_level (uiout)->type == type);
187
188 uiout->levels.pop_back ();
189 uiout->level--;
190
191 return uiout->level + 1;
192 }
193
194 /* These are the interfaces to implementation functions. */
195
196 static void uo_table_begin (struct ui_out *uiout, int nbrofcols,
197 int nr_rows, const char *tblid);
198 static void uo_table_body (struct ui_out *uiout);
199 static void uo_table_end (struct ui_out *uiout);
200 static void uo_table_header (struct ui_out *uiout, int width,
201 enum ui_align align,
202 const std::string &col_name,
203 const std::string &col_hdr);
204 static void uo_begin (struct ui_out *uiout,
205 enum ui_out_type type,
206 int level, const char *id);
207 static void uo_end (struct ui_out *uiout,
208 enum ui_out_type type,
209 int level);
210 static void uo_field_int (struct ui_out *uiout, int fldno, int width,
211 enum ui_align align, const char *fldname, int value);
212 static void uo_field_skip (struct ui_out *uiout, int fldno, int width,
213 enum ui_align align, const char *fldname);
214 static void uo_field_fmt (struct ui_out *uiout, int fldno, int width,
215 enum ui_align align, const char *fldname,
216 const char *format, va_list args)
217 ATTRIBUTE_PRINTF (6, 0);
218 static void uo_spaces (struct ui_out *uiout, int numspaces);
219 static void uo_text (struct ui_out *uiout, const char *string);
220 static void uo_message (struct ui_out *uiout,
221 const char *format, va_list args)
222 ATTRIBUTE_PRINTF (2, 0);
223 static void uo_wrap_hint (struct ui_out *uiout, const char *identstring);
224 static void uo_flush (struct ui_out *uiout);
225 static int uo_redirect (struct ui_out *uiout, struct ui_file *outstream);
226
227 /* Prototypes for local functions */
228
229 static void append_header_to_list (struct ui_out *uiout, int width,
230 enum ui_align alignment,
231 const std::string &col_name,
232 const std::string &col_hdr);
233 static int get_next_header (struct ui_out *uiout, int *colno, int *width,
234 enum ui_align *alignment, const char **col_hdr);
235 static void clear_header_list (struct ui_out *uiout);
236 static void clear_table (struct ui_out *uiout);
237 static void verify_field (struct ui_out *uiout, int *fldno, int *width,
238 enum ui_align *align);
239
240 /* exported functions (ui_out API) */
241
242 /* Mark beginning of a table. */
243
244 static void
245 ui_out_table_begin (struct ui_out *uiout, int nbrofcols,
246 int nr_rows, const std::string &tblid)
247 {
248 if (uiout->table.flag)
249 internal_error (__FILE__, __LINE__,
250 _("tables cannot be nested; table_begin found before \
251 previous table_end."));
252
253 uiout->table.flag = 1;
254 uiout->table.body_flag = 0;
255 uiout->table.entry_level = uiout->level + 1;
256 uiout->table.columns = nbrofcols;
257 uiout->table.id = tblid;
258
259 clear_header_list (uiout);
260
261 uo_table_begin (uiout, nbrofcols, nr_rows, uiout->table.id.c_str ());
262 }
263
264 void
265 ui_out_table_body (struct ui_out *uiout)
266 {
267 if (!uiout->table.flag)
268 internal_error (__FILE__, __LINE__,
269 _("table_body outside a table is not valid; it must be \
270 after a table_begin and before a table_end."));
271 if (uiout->table.body_flag)
272 internal_error (__FILE__, __LINE__,
273 _("extra table_body call not allowed; there must be \
274 only one table_body after a table_begin and before a table_end."));
275 if (uiout->table.headers.size () != uiout->table.columns)
276 internal_error (__FILE__, __LINE__,
277 _("number of headers differ from number of table \
278 columns."));
279
280 uiout->table.body_flag = 1;
281
282 uo_table_body (uiout);
283 }
284
285 static void
286 ui_out_table_end (struct ui_out *uiout)
287 {
288 if (!uiout->table.flag)
289 internal_error (__FILE__, __LINE__,
290 _("misplaced table_end or missing table_begin."));
291
292 uiout->table.entry_level = 0;
293 uiout->table.body_flag = 0;
294 uiout->table.flag = 0;
295
296 uo_table_end (uiout);
297 clear_table (uiout);
298 }
299
300 void
301 ui_out_table_header (struct ui_out *uiout, int width, enum ui_align alignment,
302 const std::string &col_name, const std::string &col_hdr)
303 {
304 if (!uiout->table.flag || uiout->table.body_flag)
305 internal_error (__FILE__, __LINE__,
306 _("table header must be specified after table_begin \
307 and before table_body."));
308
309 append_header_to_list (uiout, width, alignment, col_name, col_hdr);
310
311 uo_table_header (uiout, width, alignment, col_name, col_hdr);
312 }
313
314 static void
315 do_cleanup_table_end (void *data)
316 {
317 struct ui_out *ui_out = (struct ui_out *) data;
318
319 ui_out_table_end (ui_out);
320 }
321
322 struct cleanup *
323 make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out, int nr_cols,
324 int nr_rows, const char *tblid)
325 {
326 ui_out_table_begin (ui_out, nr_cols, nr_rows, tblid);
327 return make_cleanup (do_cleanup_table_end, ui_out);
328 }
329
330 void
331 ui_out_begin (struct ui_out *uiout,
332 enum ui_out_type type,
333 const char *id)
334 {
335 int new_level;
336
337 if (uiout->table.flag && !uiout->table.body_flag)
338 internal_error (__FILE__, __LINE__,
339 _("table header or table_body expected; lists must be \
340 specified after table_body."));
341
342 /* Be careful to verify the ``field'' before the new tuple/list is
343 pushed onto the stack. That way the containing list/table/row is
344 verified and not the newly created tuple/list. This verification
345 is needed (at least) for the case where a table row entry
346 contains either a tuple/list. For that case bookkeeping such as
347 updating the column count or advancing to the next heading still
348 needs to be performed. */
349 {
350 int fldno;
351 int width;
352 enum ui_align align;
353
354 verify_field (uiout, &fldno, &width, &align);
355 }
356
357 new_level = push_level (uiout, type);
358
359 /* If the push puts us at the same level as a table row entry, we've
360 got a new table row. Put the header pointer back to the start. */
361 if (uiout->table.body_flag
362 && uiout->table.entry_level == new_level)
363 uiout->table.headers_iterator = uiout->table.headers.begin ();
364
365 uo_begin (uiout, type, new_level, id);
366 }
367
368 void
369 ui_out_end (struct ui_out *uiout,
370 enum ui_out_type type)
371 {
372 int old_level = pop_level (uiout, type);
373
374 uo_end (uiout, type, old_level);
375 }
376
377 struct ui_out_end_cleanup_data
378 {
379 struct ui_out *uiout;
380 enum ui_out_type type;
381 };
382
383 static void
384 do_cleanup_end (void *data)
385 {
386 struct ui_out_end_cleanup_data *end_cleanup_data
387 = (struct ui_out_end_cleanup_data *) data;
388
389 ui_out_end (end_cleanup_data->uiout, end_cleanup_data->type);
390 xfree (end_cleanup_data);
391 }
392
393 static struct cleanup *
394 make_cleanup_ui_out_end (struct ui_out *uiout,
395 enum ui_out_type type)
396 {
397 struct ui_out_end_cleanup_data *end_cleanup_data;
398
399 end_cleanup_data = XNEW (struct ui_out_end_cleanup_data);
400 end_cleanup_data->uiout = uiout;
401 end_cleanup_data->type = type;
402 return make_cleanup (do_cleanup_end, end_cleanup_data);
403 }
404
405 struct cleanup *
406 make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout,
407 const char *id)
408 {
409 ui_out_begin (uiout, ui_out_type_tuple, id);
410 return make_cleanup_ui_out_end (uiout, ui_out_type_tuple);
411 }
412
413 struct cleanup *
414 make_cleanup_ui_out_list_begin_end (struct ui_out *uiout,
415 const char *id)
416 {
417 ui_out_begin (uiout, ui_out_type_list, id);
418 return make_cleanup_ui_out_end (uiout, ui_out_type_list);
419 }
420
421 void
422 ui_out_field_int (struct ui_out *uiout,
423 const char *fldname,
424 int value)
425 {
426 int fldno;
427 int width;
428 enum ui_align align;
429
430 verify_field (uiout, &fldno, &width, &align);
431
432 uo_field_int (uiout, fldno, width, align, fldname, value);
433 }
434
435 void
436 ui_out_field_fmt_int (struct ui_out *uiout,
437 int input_width,
438 enum ui_align input_align,
439 const char *fldname,
440 int value)
441 {
442 int fldno;
443 int width;
444 enum ui_align align;
445
446 verify_field (uiout, &fldno, &width, &align);
447
448 uo_field_int (uiout, fldno, input_width, input_align, fldname, value);
449 }
450
451 /* Documented in ui-out.h. */
452
453 void
454 ui_out_field_core_addr (struct ui_out *uiout,
455 const char *fldname,
456 struct gdbarch *gdbarch,
457 CORE_ADDR address)
458 {
459 ui_out_field_string (uiout, fldname,
460 print_core_address (gdbarch, address));
461 }
462
463 void
464 ui_out_field_stream (struct ui_out *uiout,
465 const char *fldname,
466 struct ui_file *stream)
467 {
468 std::string buffer = ui_file_as_string (stream);
469
470 if (!buffer.empty ())
471 ui_out_field_string (uiout, fldname, buffer.c_str ());
472 else
473 ui_out_field_skip (uiout, fldname);
474 ui_file_rewind (stream);
475 }
476
477 /* Used to omit a field. */
478
479 void
480 ui_out_field_skip (struct ui_out *uiout,
481 const char *fldname)
482 {
483 int fldno;
484 int width;
485 enum ui_align align;
486
487 verify_field (uiout, &fldno, &width, &align);
488
489 uo_field_skip (uiout, fldno, width, align, fldname);
490 }
491
492 void
493 ui_out_field_string (struct ui_out *uiout,
494 const char *fldname,
495 const char *string)
496 {
497 int fldno;
498 int width;
499 enum ui_align align;
500
501 verify_field (uiout, &fldno, &width, &align);
502
503 uo_field_string (uiout, fldno, width, align, fldname, string);
504 }
505
506 /* VARARGS */
507 void
508 ui_out_field_fmt (struct ui_out *uiout,
509 const char *fldname,
510 const char *format, ...)
511 {
512 va_list args;
513 int fldno;
514 int width;
515 enum ui_align align;
516
517 /* Will not align, but has to call anyway. */
518 verify_field (uiout, &fldno, &width, &align);
519
520 va_start (args, format);
521
522 uo_field_fmt (uiout, fldno, width, align, fldname, format, args);
523
524 va_end (args);
525 }
526
527 void
528 ui_out_spaces (struct ui_out *uiout, int numspaces)
529 {
530 uo_spaces (uiout, numspaces);
531 }
532
533 void
534 ui_out_text (struct ui_out *uiout,
535 const char *string)
536 {
537 uo_text (uiout, string);
538 }
539
540 void
541 ui_out_message (struct ui_out *uiout, const char *format, ...)
542 {
543 va_list args;
544
545 va_start (args, format);
546 uo_message (uiout, format, args);
547 va_end (args);
548 }
549
550 void
551 ui_out_wrap_hint (struct ui_out *uiout, const char *identstring)
552 {
553 uo_wrap_hint (uiout, identstring);
554 }
555
556 void
557 ui_out_flush (struct ui_out *uiout)
558 {
559 uo_flush (uiout);
560 }
561
562 int
563 ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream)
564 {
565 return uo_redirect (uiout, outstream);
566 }
567
568 /* Test the flags against the mask given. */
569 int
570 ui_out_test_flags (struct ui_out *uiout, int mask)
571 {
572 return (uiout->flags & mask);
573 }
574
575 int
576 ui_out_is_mi_like_p (struct ui_out *uiout)
577 {
578 return uiout->impl->is_mi_like_p;
579 }
580
581 /* Interface to the implementation functions. */
582
583 void
584 uo_table_begin (struct ui_out *uiout, int nbrofcols,
585 int nr_rows,
586 const char *tblid)
587 {
588 if (!uiout->impl->table_begin)
589 return;
590 uiout->impl->table_begin (uiout, nbrofcols, nr_rows, tblid);
591 }
592
593 void
594 uo_table_body (struct ui_out *uiout)
595 {
596 if (!uiout->impl->table_body)
597 return;
598 uiout->impl->table_body (uiout);
599 }
600
601 void
602 uo_table_end (struct ui_out *uiout)
603 {
604 if (!uiout->impl->table_end)
605 return;
606 uiout->impl->table_end (uiout);
607 }
608
609 void
610 uo_table_header (struct ui_out *uiout, int width, enum ui_align align,
611 const std::string &col_name, const std::string &col_hdr)
612 {
613 if (!uiout->impl->table_header)
614 return;
615 uiout->impl->table_header (uiout, width, align, col_name, col_hdr);
616 }
617
618 /* Clear the table associated with UIOUT. */
619
620 static void
621 clear_table (struct ui_out *uiout)
622 {
623 uiout->table.id.clear ();
624 clear_header_list (uiout);
625 }
626
627 void
628 uo_begin (struct ui_out *uiout,
629 enum ui_out_type type,
630 int level,
631 const char *id)
632 {
633 if (uiout->impl->begin == NULL)
634 return;
635 uiout->impl->begin (uiout, type, level, id);
636 }
637
638 void
639 uo_end (struct ui_out *uiout,
640 enum ui_out_type type,
641 int level)
642 {
643 if (uiout->impl->end == NULL)
644 return;
645 uiout->impl->end (uiout, type, level);
646 }
647
648 void
649 uo_field_int (struct ui_out *uiout, int fldno, int width, enum ui_align align,
650 const char *fldname,
651 int value)
652 {
653 if (!uiout->impl->field_int)
654 return;
655 uiout->impl->field_int (uiout, fldno, width, align, fldname, value);
656 }
657
658 void
659 uo_field_skip (struct ui_out *uiout, int fldno, int width, enum ui_align align,
660 const char *fldname)
661 {
662 if (!uiout->impl->field_skip)
663 return;
664 uiout->impl->field_skip (uiout, fldno, width, align, fldname);
665 }
666
667 void
668 uo_field_string (struct ui_out *uiout, int fldno, int width,
669 enum ui_align align,
670 const char *fldname,
671 const char *string)
672 {
673 if (!uiout->impl->field_string)
674 return;
675 uiout->impl->field_string (uiout, fldno, width, align, fldname, string);
676 }
677
678 void
679 uo_field_fmt (struct ui_out *uiout, int fldno, int width, enum ui_align align,
680 const char *fldname,
681 const char *format,
682 va_list args)
683 {
684 if (!uiout->impl->field_fmt)
685 return;
686 uiout->impl->field_fmt (uiout, fldno, width, align, fldname, format, args);
687 }
688
689 void
690 uo_spaces (struct ui_out *uiout, int numspaces)
691 {
692 if (!uiout->impl->spaces)
693 return;
694 uiout->impl->spaces (uiout, numspaces);
695 }
696
697 void
698 uo_text (struct ui_out *uiout,
699 const char *string)
700 {
701 if (!uiout->impl->text)
702 return;
703 uiout->impl->text (uiout, string);
704 }
705
706 void
707 uo_message (struct ui_out *uiout,
708 const char *format,
709 va_list args)
710 {
711 if (!uiout->impl->message)
712 return;
713 uiout->impl->message (uiout, format, args);
714 }
715
716 void
717 uo_wrap_hint (struct ui_out *uiout, const char *identstring)
718 {
719 if (!uiout->impl->wrap_hint)
720 return;
721 uiout->impl->wrap_hint (uiout, identstring);
722 }
723
724 void
725 uo_flush (struct ui_out *uiout)
726 {
727 if (!uiout->impl->flush)
728 return;
729 uiout->impl->flush (uiout);
730 }
731
732 int
733 uo_redirect (struct ui_out *uiout, struct ui_file *outstream)
734 {
735 if (!uiout->impl->redirect)
736 return -1;
737 return uiout->impl->redirect (uiout, outstream);
738 }
739
740 /* local functions */
741
742 /* List of column headers manipulation routines. */
743
744 static void
745 clear_header_list (struct ui_out *uiout)
746 {
747 uiout->table.headers.clear ();
748 uiout->table.headers_iterator = uiout->table.headers.end ();
749 }
750
751 static void
752 append_header_to_list (struct ui_out *uiout,
753 int width,
754 enum ui_align alignment,
755 const std::string &col_name,
756 const std::string &col_hdr)
757 {
758 std::unique_ptr<ui_out_hdr> temphdr(
759 new ui_out_hdr (uiout->table.headers.size () + 1, width,
760 alignment, col_name, col_hdr));
761
762 uiout->table.headers.push_back (std::move (temphdr));
763 }
764
765 /* Extract the format information for the NEXT header and advance
766 the header pointer. Return 0 if there was no next header. */
767
768 static int
769 get_next_header (struct ui_out *uiout,
770 int *colno,
771 int *width,
772 enum ui_align *alignment,
773 const char **col_hdr)
774 {
775 /* There may be no headers at all or we may have used all columns. */
776 if (uiout->table.headers_iterator == uiout->table.headers.end ())
777 return 0;
778
779 ui_out_hdr *hdr = uiout->table.headers_iterator->get ();
780
781 *colno = hdr->number ();
782 *width = hdr->min_width ();
783 *alignment = hdr->alignment ();
784 *col_hdr = hdr->header ().c_str ();
785
786 /* Advance the header pointer to the next entry. */
787 uiout->table.headers_iterator++;
788
789 return 1;
790 }
791
792
793 /* Verify that the field/tuple/list is correctly positioned. Return
794 the field number and corresponding alignment (if
795 available/applicable). */
796
797 static void
798 verify_field (struct ui_out *uiout, int *fldno, int *width,
799 enum ui_align *align)
800 {
801 struct ui_out_level *current = current_level (uiout);
802 const char *text;
803
804 if (uiout->table.flag)
805 {
806 if (!uiout->table.body_flag)
807 internal_error (__FILE__, __LINE__,
808 _("table_body missing; table fields must be \
809 specified after table_body and inside a list."));
810 /* NOTE: cagney/2001-12-08: There was a check here to ensure
811 that this code was only executed when uiout->level was
812 greater than zero. That no longer applies - this code is run
813 before each table row tuple is started and at that point the
814 level is zero. */
815 }
816
817 current->field_count += 1;
818
819 if (uiout->table.body_flag
820 && uiout->table.entry_level == uiout->level
821 && get_next_header (uiout, fldno, width, align, &text))
822 {
823 if (*fldno != current->field_count)
824 internal_error (__FILE__, __LINE__,
825 _("ui-out internal error in handling headers."));
826 }
827 else
828 {
829 *width = 0;
830 *align = ui_noalign;
831 *fldno = current->field_count;
832 }
833 }
834
835
836 /* Access to ui-out members data. */
837
838 void *
839 ui_out_data (struct ui_out *uiout)
840 {
841 return uiout->data;
842 }
843
844 /* Access table field parameters. */
845 int
846 ui_out_query_field (struct ui_out *uiout, int colno,
847 int *width, int *alignment, const char **col_name)
848 {
849 if (!uiout->table.flag)
850 return 0;
851
852 /* Column numbers are 1-based, so convert to 0-based index. */
853 int index = colno - 1;
854
855 if (index >= 0 && index < uiout->table.headers.size ())
856 {
857 ui_out_hdr *hdr = uiout->table.headers[index].get ();
858
859 gdb_assert (colno == hdr->number ());
860
861 *width = hdr->min_width ();
862 *alignment = hdr->alignment ();
863 *col_name = hdr->name ().c_str ();
864
865 return 1;
866 }
867 else
868 return 0;
869 }
870
871 /* Initialize private members at startup. */
872
873 struct ui_out *
874 ui_out_new (const struct ui_out_impl *impl, void *data,
875 int flags)
876 {
877 struct ui_out *uiout = new ui_out ();
878 std::unique_ptr<ui_out_level> current (new ui_out_level ());
879
880 uiout->data = data;
881 uiout->impl = impl;
882 uiout->flags = flags;
883 uiout->table.flag = 0;
884 uiout->table.body_flag = 0;
885 uiout->level = 0;
886
887 /* Create uiout->level 0, the default level. */
888 current->type = ui_out_type_tuple;
889 current->field_count = 0;
890 uiout->levels.push_back (std::move (current));
891
892 uiout->table.headers_iterator = uiout->table.headers.end ();
893
894 return uiout;
895 }
This page took 0.04684 seconds and 5 git commands to generate.