M gen/client.ha => gen/client.ha +1 -32
@@ 14,7 14,7 @@ export fn client(out: io::handle, doc: *ast::document) (void | io::error) = {
for (let i = 0z; i < len(doc.enums); i += 1) {
const em = &doc.enums[i];
- c_enum(out, doc, em)?;
+ enum_type(out, doc, em)?;
};
for (let i = 0z; i < len(doc.interfaces); i += 1) {
@@ 165,34 165,3 @@ fn c_meth(
)?;
fmt::fprintln(out)?;
};
-
-const c_enum_head_src: str = `export type $name = enum uint {`;
-let ct_enum_head: tmpl::template = [];
-
-@init fn c_enum() void = {
- ct_enum_head = tmpl::compile(c_enum_head_src)!;
-};
-
-fn c_enum(
- out: io::handle,
- doc: *ast::document,
- em: *ast::enum_,
-) (void | io::error) = {
- tmpl::execute(&ct_enum_head, out, ("name", em.name))?;
-
- for (let i = 0z; i < len(em.membs); i += 1) {
- const memb = &em.membs[i];
- fmt::fprintf(out, "\n\t{}", memb.name)?;
-
- match (memb.val) {
- case void =>
- yield;
- case let val: uint =>
- fmt::fprintf(out, " = {}", val)?;
- };
-
- fmt::fprintf(out, ",")?;
- };
-
- fmt::fprintfln(out, "\n}};\n")?;
-};
M gen/server.ha => gen/server.ha +1 -9
@@ 16,7 16,7 @@ export fn server(out: io::handle, doc: *ast::document) (void | io::error) = {
for (let i = 0z; i < len(doc.enums); i += 1) {
const em = &doc.enums[i];
- s_enum(out, doc, em)?;
+ enum_type(out, doc, em)?;
};
for (let i = 0z; i < len(doc.interfaces); i += 1) {
@@ 325,11 325,3 @@ fn s_method_dispatch(
("params_out", params_out),
)?;
};
-
-fn s_enum(
- out: io::handle,
- doc: *ast::document,
- em: *ast::enum_,
-) (void | io::error) = {
- abort(); // TODO
-};
M gen/shared.ha => gen/shared.ha +31 -0
@@ 70,3 70,34 @@ fn ipc_type(
abort(); // TODO
};
};
+
+const enum_head_src: str = `export type $name = enum uint {`;
+let t_enum_head: tmpl::template = [];
+
+@init fn enum_type() void = {
+ t_enum_head = tmpl::compile(enum_head_src)!;
+};
+
+fn enum_type(
+ out: io::handle,
+ doc: *ast::document,
+ em: *ast::enum_,
+) (void | io::error) = {
+ tmpl::execute(&t_enum_head, out, ("name", em.name))?;
+
+ for (let i = 0z; i < len(em.membs); i += 1) {
+ const memb = &em.membs[i];
+ fmt::fprintf(out, "\n\t{}", memb.name)?;
+
+ match (memb.val) {
+ case void =>
+ yield;
+ case let val: uint =>
+ fmt::fprintf(out, " = {}", val)?;
+ };
+
+ fmt::fprintf(out, ",")?;
+ };
+
+ fmt::fprintfln(out, "\n}};\n")?;
+};