OILS / _gen / display / pretty.asdl.h View on Github | oils.pub

266 lines, 168 significant
1// _gen/display/pretty.asdl.h is generated by asdl_main.py
2
3#ifndef PRETTY_ASDL
4#define PRETTY_ASDL
5
6#include <cstdint>
7
8#include "mycpp/runtime.h"
9#include "asdl/cpp_runtime.h"
10namespace pretty_asdl {
11
12// use struct instead of namespace so 'using' works consistently
13#define ASDL_NAMES struct
14
15class MeasuredDoc;
16class Measure;
17class doc_t;
18class DocFragment;
19
20ASDL_NAMES doc_e {
21 enum no_name {
22 Break = 1,
23 Text = 2,
24 Indent = 3,
25 Group = 64,
26 Flat = 5,
27 IfFlat = 6,
28 Concat = 66,
29 };
30};
31
32BigStr* doc_str(int tag, bool dot = true);
33
34class doc_t {
35 protected:
36 doc_t() {
37 }
38 public:
39 int tag() const {
40 return ObjHeader::FromObject(this)->type_tag;
41 }
42 constexpr int sum_type_id() {
43 return 0;
44 }
45 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
46 DISALLOW_COPY_AND_ASSIGN(doc_t)
47};
48
49class doc__Break : public doc_t {
50 public:
51 doc__Break(BigStr* string)
52 : string(string) {
53 }
54
55 static doc__Break* CreateNull(bool alloc_lists = false) {
56 return Alloc<doc__Break>(kEmptyString);
57 }
58
59 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
60
61 static constexpr ObjHeader obj_header() {
62 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Break), 1);
63 }
64
65 BigStr* string;
66
67 DISALLOW_COPY_AND_ASSIGN(doc__Break)
68};
69
70class doc__Text : public doc_t {
71 public:
72 doc__Text(BigStr* string)
73 : string(string) {
74 }
75
76 static doc__Text* CreateNull(bool alloc_lists = false) {
77 return Alloc<doc__Text>(kEmptyString);
78 }
79
80 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
81
82 static constexpr ObjHeader obj_header() {
83 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Text), 1);
84 }
85
86 BigStr* string;
87
88 DISALLOW_COPY_AND_ASSIGN(doc__Text)
89};
90
91class doc__Indent : public doc_t {
92 public:
93 doc__Indent(int indent, MeasuredDoc* mdoc)
94 : mdoc(mdoc),
95 indent(indent) {
96 }
97
98 static doc__Indent* CreateNull(bool alloc_lists = false) {
99 return Alloc<doc__Indent>(-1, nullptr);
100 }
101
102 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
103
104 static constexpr ObjHeader obj_header() {
105 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Indent), 1);
106 }
107
108 MeasuredDoc* mdoc;
109 int indent;
110
111 DISALLOW_COPY_AND_ASSIGN(doc__Indent)
112};
113
114class doc__Flat : public doc_t {
115 public:
116 doc__Flat(MeasuredDoc* mdoc)
117 : mdoc(mdoc) {
118 }
119
120 static doc__Flat* CreateNull(bool alloc_lists = false) {
121 return Alloc<doc__Flat>(nullptr);
122 }
123
124 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
125
126 static constexpr ObjHeader obj_header() {
127 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Flat), 1);
128 }
129
130 MeasuredDoc* mdoc;
131
132 DISALLOW_COPY_AND_ASSIGN(doc__Flat)
133};
134
135class doc__IfFlat : public doc_t {
136 public:
137 doc__IfFlat(MeasuredDoc* flat_mdoc, MeasuredDoc* nonflat_mdoc)
138 : flat_mdoc(flat_mdoc),
139 nonflat_mdoc(nonflat_mdoc) {
140 }
141
142 static doc__IfFlat* CreateNull(bool alloc_lists = false) {
143 return Alloc<doc__IfFlat>(nullptr, nullptr);
144 }
145
146 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
147
148 static constexpr ObjHeader obj_header() {
149 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::IfFlat), 2);
150 }
151
152 MeasuredDoc* flat_mdoc;
153 MeasuredDoc* nonflat_mdoc;
154
155 DISALLOW_COPY_AND_ASSIGN(doc__IfFlat)
156};
157
158ASDL_NAMES doc {
159 typedef doc__Break Break;
160 typedef doc__Text Text;
161 typedef doc__Indent Indent;
162 typedef doc__Flat Flat;
163 typedef doc__IfFlat IfFlat;
164};
165
166class MeasuredDoc : public doc_t {
167 public:
168 MeasuredDoc(doc_t* doc, Measure* measure)
169 : doc(doc),
170 measure(measure) {
171 }
172
173 static MeasuredDoc* CreateNull(bool alloc_lists = false) {
174 return Alloc<MeasuredDoc>(nullptr, nullptr);
175 }
176
177 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
178
179 static constexpr ObjHeader obj_header() {
180 return ObjHeader::AsdlClass(64, 2);
181 }
182
183 doc_t* doc;
184 Measure* measure;
185
186 DISALLOW_COPY_AND_ASSIGN(MeasuredDoc)
187};
188
189class Measure {
190 public:
191 Measure(int flat, int nonflat)
192 : flat(flat),
193 nonflat(nonflat) {
194 }
195
196 static Measure* CreateNull(bool alloc_lists = false) {
197 return Alloc<Measure>(-1, -1);
198 }
199
200 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
201
202 static constexpr ObjHeader obj_header() {
203 return ObjHeader::AsdlClass(65, 0);
204 }
205
206 int flat;
207 int nonflat;
208
209 DISALLOW_COPY_AND_ASSIGN(Measure)
210};
211
212class DocFragment {
213 public:
214 DocFragment(MeasuredDoc* mdoc, int indent, bool is_flat, Measure* measure)
215 : mdoc(mdoc),
216 measure(measure),
217 indent(indent),
218 is_flat(is_flat) {
219 }
220
221 static DocFragment* CreateNull(bool alloc_lists = false) {
222 return Alloc<DocFragment>(nullptr, -1, false, nullptr);
223 }
224
225 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
226
227 static constexpr ObjHeader obj_header() {
228 return ObjHeader::AsdlClass(67, 2);
229 }
230
231 MeasuredDoc* mdoc;
232 Measure* measure;
233 int indent;
234 bool is_flat;
235
236 DISALLOW_COPY_AND_ASSIGN(DocFragment)
237};
238
239class List_Measured : public doc_t, public List<MeasuredDoc*> {
240 public:
241 List_Measured() : List<MeasuredDoc*>() {
242 }
243 List_Measured(List<MeasuredDoc*>* plain_list) :
244 List<MeasuredDoc*>(plain_list) {
245 }
246 static List_Measured* New() {
247 return Alloc<List_Measured>();
248 }
249 static List_Measured* Take(List<MeasuredDoc*>* plain_list) {
250 auto* result = Alloc<List_Measured>(plain_list);
251 plain_list->SetTaken();
252 return result;
253 }
254 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
255
256 static constexpr ObjHeader obj_header() {
257 return ObjHeader::TaggedSubtype(66, field_mask());
258 }
259
260 DISALLOW_COPY_AND_ASSIGN(List_Measured)
261};
262
263
264} // namespace pretty_asdl
265
266#endif // PRETTY_ASDL