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

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