MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / print_enum

Function print_enum

utils/wasi-cpp-header/src/cpp_header.rs:135–172  ·  view source on GitHub ↗
(ret: &mut String, name: &Id, v: &Variant)

Source from the content-addressed store, hash-verified

133}
134
135fn print_enum(ret: &mut String, name: &Id, v: &Variant) {
136 ret.push_str(&format!(
137 "enum __wasi_{}_e_t : {} {{\n",
138 ident_name(name),
139 intrepr_name(v.tag_repr)
140 ));
141
142 for (index, case) in v.cases.iter().enumerate() {
143 if !case.docs.is_empty() {
144 ret.push_str(" /**\n");
145 for line in case.docs.lines() {
146 ret.push_str(&format!(" * {}\n", line));
147 }
148 ret.push_str(" */\n");
149 }
150 ret.push_str(&format!(
151 " __WASI_{}_{} = {},\n",
152 ident_name(&name).to_shouty_snake_case(),
153 ident_name(&case.name).to_shouty_snake_case(),
154 index
155 ));
156 ret.push_str("\n");
157 }
158 ret.push_str("};\n");
159
160 ret.push_str(&format!(
161 "static_assert(sizeof(__wasi_{}_e_t) == {}, \"witx calculated size\");\n",
162 ident_name(name),
163 v.tag_repr.mem_size()
164 ));
165 ret.push_str(&format!(
166 "static_assert(alignof(__wasi_{}_e_t) == {}, \"witx calculated align\");\n",
167 ident_name(name),
168 v.tag_repr.mem_align()
169 ));
170
171 ret.push_str("\n");
172}
173
174fn print_record(ret: &mut String, name: &Id, s: &RecordDatatype) {
175 if let Some(repr) = s.bitflags_repr() {

Callers 1

print_variantFunction · 0.85

Calls 1

enumerateMethod · 0.80

Tested by

no test coverage detected