@@ 1,4 1,5 @@
use ast;
+use ast::{ptype};
use fmt;
use io;
use strio;
@@ 21,9 22,11 @@ const c_iface_method_src: str =
`export fn $iface_$method(
ep: helios::cap,$mparams
) $result = {
- helios::call(ep,
+ const (tag, a1) = helios::call(ep,
$iface_label::$methodid,$params
- )!;
+ );
+ assert(rt::label(tag) == 0); // TODO: Error handling
+ return a1: $result;
};
`;
let ct_iface_method: tmpl::template = [];
@@ 83,11 86,15 @@ fn c_meth(
fmt::fprintf(¶ms, "\n\t\t{}: u64,", param.name)!;
};
+ let result = strio::dynamic();
+ defer io::close(&result)!;
+ ipc_type(&result, &meth.result)!;
+
tmpl::execute(&ct_iface_method, out,
("iface", iface.name),
("method", meth.name),
("methodid", name),
- ("result", "void"), // TODO
+ ("result", strio::string(&result)),
("mparams", strio::string(&mparams)),
("params", strio::string(¶ms)),
)?;
@@ 8,6 8,7 @@ use tmpl = strings::template;
// Generates code for a server to implement the given interface.
export fn server(out: io::handle, doc: *ast::document) (void | io::error) = {
fmt::fprintln(out, "// This file was generated by ipcgen; do not modify by hand")!;
+ fmt::fprintln(out, "use errors;")!;
fmt::fprintln(out, "use helios;")!;
fmt::fprintln(out, "use rt;")!;
fmt::fprintln(out)!;