OILS / prebuilt / asdl / runtime.mycpp.h View on Github | oilshell.org

166 lines, 112 significant
1// prebuilt/asdl/runtime.mycpp.h: GENERATED by mycpp
2
3#ifndef ASDL_RUNTIME_MYCPP_H
4#define ASDL_RUNTIME_MYCPP_H
5
6#include "_gen/asdl/hnode.asdl.h"
7#include "_gen/display/pretty.asdl.h"
8#include "cpp/data_lang.h"
9#include "mycpp/runtime.h"
10
11#include "_gen/display/pretty.asdl.h"
12
13using pretty_asdl::doc; // ad hoc
14
15namespace runtime { // forward declare
16
17 class TraversalState;
18
19} // forward declare namespace runtime
20
21namespace format { // forward declare
22
23 class ColorOutput;
24 class TextOutput;
25 class HtmlOutput;
26 class AnsiOutput;
27 class _PrettyPrinter;
28
29} // forward declare namespace format
30
31namespace runtime { // declare
32
33using hnode_asdl::hnode;
34extern int NO_SPID;
35hnode::Record* NewRecord(BigStr* node_type);
36hnode::Leaf* NewLeaf(BigStr* s, hnode_asdl::color_t e_color);
37class TraversalState {
38 public:
39 TraversalState();
40 Dict<int, bool>* seen;
41 Dict<int, int>* ref_count;
42
43 static constexpr ObjHeader obj_header() {
44 return ObjHeader::ClassScanned(2, sizeof(TraversalState));
45 }
46
47 DISALLOW_COPY_AND_ASSIGN(TraversalState)
48};
49
50extern BigStr* TRUE_STR;
51extern BigStr* FALSE_STR;
52
53} // declare namespace runtime
54
55namespace format { // declare
56
57using hnode_asdl::hnode;
58format::ColorOutput* DetectConsoleOutput(mylib::Writer* f);
59class ColorOutput {
60 public:
61 ColorOutput(mylib::Writer* f);
62 virtual format::ColorOutput* NewTempBuffer();
63 virtual void FileHeader();
64 virtual void FileFooter();
65 virtual void PushColor(hnode_asdl::color_t e_color);
66 virtual void PopColor();
67 virtual void write(BigStr* s);
68 void WriteRaw(Tuple2<BigStr*, int>* raw);
69 int NumChars();
70 Tuple2<BigStr*, int> GetRaw();
71 mylib::Writer* f;
72 int num_chars;
73
74 static constexpr uint32_t field_mask() {
75 return maskbit(offsetof(ColorOutput, f));
76 }
77
78 static constexpr ObjHeader obj_header() {
79 return ObjHeader::ClassFixed(field_mask(), sizeof(ColorOutput));
80 }
81
82 DISALLOW_COPY_AND_ASSIGN(ColorOutput)
83};
84
85class TextOutput : public ::format::ColorOutput {
86 public:
87 TextOutput(mylib::Writer* f);
88 virtual format::TextOutput* NewTempBuffer();
89 virtual void PushColor(hnode_asdl::color_t e_color);
90 virtual void PopColor();
91
92 static constexpr uint32_t field_mask() {
93 return ::format::ColorOutput::field_mask();
94 }
95
96 static constexpr ObjHeader obj_header() {
97 return ObjHeader::ClassFixed(field_mask(), sizeof(TextOutput));
98 }
99
100 DISALLOW_COPY_AND_ASSIGN(TextOutput)
101};
102
103class HtmlOutput : public ::format::ColorOutput {
104 public:
105 HtmlOutput(mylib::Writer* f);
106 virtual format::HtmlOutput* NewTempBuffer();
107 virtual void FileHeader();
108 virtual void FileFooter();
109 virtual void PushColor(hnode_asdl::color_t e_color);
110 virtual void PopColor();
111 virtual void write(BigStr* s);
112
113 static constexpr uint32_t field_mask() {
114 return ::format::ColorOutput::field_mask();
115 }
116
117 static constexpr ObjHeader obj_header() {
118 return ObjHeader::ClassFixed(field_mask(), sizeof(HtmlOutput));
119 }
120
121 DISALLOW_COPY_AND_ASSIGN(HtmlOutput)
122};
123
124class AnsiOutput : public ::format::ColorOutput {
125 public:
126 AnsiOutput(mylib::Writer* f);
127 virtual format::AnsiOutput* NewTempBuffer();
128 virtual void PushColor(hnode_asdl::color_t e_color);
129 virtual void PopColor();
130
131 static constexpr uint32_t field_mask() {
132 return ::format::ColorOutput::field_mask();
133 }
134
135 static constexpr ObjHeader obj_header() {
136 return ObjHeader::ClassFixed(field_mask(), sizeof(AnsiOutput));
137 }
138
139 DISALLOW_COPY_AND_ASSIGN(AnsiOutput)
140};
141
142extern int INDENT;
143class _PrettyPrinter {
144 public:
145 _PrettyPrinter(int max_col);
146 bool _PrintWrappedArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent);
147 bool _PrintWholeArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent);
148 void _PrintRecord(hnode::Record* node, format::ColorOutput* f, int indent);
149 void PrintNode(hnode_asdl::hnode_t* node, format::ColorOutput* f, int indent);
150 int max_col;
151
152 static constexpr ObjHeader obj_header() {
153 return ObjHeader::ClassScanned(0, sizeof(_PrettyPrinter));
154 }
155
156 DISALLOW_COPY_AND_ASSIGN(_PrettyPrinter)
157};
158
159bool _TrySingleLineObj(hnode::Record* node, format::ColorOutput* f, int max_chars);
160bool _TrySingleLine(hnode_asdl::hnode_t* node, format::ColorOutput* f, int max_chars);
161void PrintTree(hnode_asdl::hnode_t* node, format::ColorOutput* f);
162void PrintTree2(hnode_asdl::hnode_t* node, format::ColorOutput* f);
163
164} // declare namespace format
165
166#endif // ASDL_RUNTIME_MYCPP_H