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

263 lines, 166 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 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
43 DISALLOW_COPY_AND_ASSIGN(doc_t)
44};
45
46class doc__Break : public doc_t {
47 public:
48 doc__Break(BigStr* string)
49 : string(string) {
50 }
51
52 static doc__Break* CreateNull(bool alloc_lists = false) {
53 return Alloc<doc__Break>(kEmptyString);
54 }
55
56 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
57
58 static constexpr ObjHeader obj_header() {
59 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Break), 1);
60 }
61
62 BigStr* string;
63
64 DISALLOW_COPY_AND_ASSIGN(doc__Break)
65};
66
67class doc__Text : public doc_t {
68 public:
69 doc__Text(BigStr* string)
70 : string(string) {
71 }
72
73 static doc__Text* CreateNull(bool alloc_lists = false) {
74 return Alloc<doc__Text>(kEmptyString);
75 }
76
77 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
78
79 static constexpr ObjHeader obj_header() {
80 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Text), 1);
81 }
82
83 BigStr* string;
84
85 DISALLOW_COPY_AND_ASSIGN(doc__Text)
86};
87
88class doc__Indent : public doc_t {
89 public:
90 doc__Indent(int indent, MeasuredDoc* mdoc)
91 : mdoc(mdoc),
92 indent(indent) {
93 }
94
95 static doc__Indent* CreateNull(bool alloc_lists = false) {
96 return Alloc<doc__Indent>(-1, nullptr);
97 }
98
99 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
100
101 static constexpr ObjHeader obj_header() {
102 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Indent), 1);
103 }
104
105 MeasuredDoc* mdoc;
106 int indent;
107
108 DISALLOW_COPY_AND_ASSIGN(doc__Indent)
109};
110
111class doc__Flat : public doc_t {
112 public:
113 doc__Flat(MeasuredDoc* mdoc)
114 : mdoc(mdoc) {
115 }
116
117 static doc__Flat* CreateNull(bool alloc_lists = false) {
118 return Alloc<doc__Flat>(nullptr);
119 }
120
121 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
122
123 static constexpr ObjHeader obj_header() {
124 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Flat), 1);
125 }
126
127 MeasuredDoc* mdoc;
128
129 DISALLOW_COPY_AND_ASSIGN(doc__Flat)
130};
131
132class doc__IfFlat : public doc_t {
133 public:
134 doc__IfFlat(MeasuredDoc* flat_mdoc, MeasuredDoc* nonflat_mdoc)
135 : flat_mdoc(flat_mdoc),
136 nonflat_mdoc(nonflat_mdoc) {
137 }
138
139 static doc__IfFlat* CreateNull(bool alloc_lists = false) {
140 return Alloc<doc__IfFlat>(nullptr, nullptr);
141 }
142
143 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
144
145 static constexpr ObjHeader obj_header() {
146 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::IfFlat), 2);
147 }
148
149 MeasuredDoc* flat_mdoc;
150 MeasuredDoc* nonflat_mdoc;
151
152 DISALLOW_COPY_AND_ASSIGN(doc__IfFlat)
153};
154
155ASDL_NAMES doc {
156 typedef doc__Break Break;
157 typedef doc__Text Text;
158 typedef doc__Indent Indent;
159 typedef doc__Flat Flat;
160 typedef doc__IfFlat IfFlat;
161};
162
163class MeasuredDoc : public doc_t {
164 public:
165 MeasuredDoc(doc_t* doc, Measure* measure)
166 : doc(doc),
167 measure(measure) {
168 }
169
170 static MeasuredDoc* CreateNull(bool alloc_lists = false) {
171 return Alloc<MeasuredDoc>(nullptr, nullptr);
172 }
173
174 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
175
176 static constexpr ObjHeader obj_header() {
177 return ObjHeader::AsdlClass(64, 2);
178 }
179
180 doc_t* doc;
181 Measure* measure;
182
183 DISALLOW_COPY_AND_ASSIGN(MeasuredDoc)
184};
185
186class Measure {
187 public:
188 Measure(int flat, int nonflat)
189 : flat(flat),
190 nonflat(nonflat) {
191 }
192
193 static Measure* CreateNull(bool alloc_lists = false) {
194 return Alloc<Measure>(-1, -1);
195 }
196
197 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
198
199 static constexpr ObjHeader obj_header() {
200 return ObjHeader::AsdlClass(65, 0);
201 }
202
203 int flat;
204 int nonflat;
205
206 DISALLOW_COPY_AND_ASSIGN(Measure)
207};
208
209class DocFragment {
210 public:
211 DocFragment(MeasuredDoc* mdoc, int indent, bool is_flat, Measure* measure)
212 : mdoc(mdoc),
213 measure(measure),
214 indent(indent),
215 is_flat(is_flat) {
216 }
217
218 static DocFragment* CreateNull(bool alloc_lists = false) {
219 return Alloc<DocFragment>(nullptr, -1, false, nullptr);
220 }
221
222 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
223
224 static constexpr ObjHeader obj_header() {
225 return ObjHeader::AsdlClass(67, 2);
226 }
227
228 MeasuredDoc* mdoc;
229 Measure* measure;
230 int indent;
231 bool is_flat;
232
233 DISALLOW_COPY_AND_ASSIGN(DocFragment)
234};
235
236class List_Measured : public doc_t, public List<MeasuredDoc*> {
237 public:
238 List_Measured() : List<MeasuredDoc*>() {
239 }
240 List_Measured(List<MeasuredDoc*>* plain_list) :
241 List<MeasuredDoc*>(plain_list) {
242 }
243 static List_Measured* New() {
244 return Alloc<List_Measured>();
245 }
246 static List_Measured* Take(List<MeasuredDoc*>* plain_list) {
247 auto* result = Alloc<List_Measured>(plain_list);
248 plain_list->SetTaken();
249 return result;
250 }
251 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
252
253 static constexpr ObjHeader obj_header() {
254 return ObjHeader::TaggedSubtype(66, field_mask());
255 }
256
257 DISALLOW_COPY_AND_ASSIGN(List_Measured)
258};
259
260
261} // namespace pretty_asdl
262
263#endif // PRETTY_ASDL