~sircmpwn/ipcgen

2cdc53095a052b4f5ce3fdc6e410f2dd17eea54d — Drew DeVault 1 year, 12 days ago 265f237
client: implement return values
2 files changed, 11 insertions(+), 3 deletions(-)

M gen/client.ha
M gen/server.ha
M gen/client.ha => gen/client.ha +10 -3
@@ 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(&params, "\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(&params)),
	)?;

M gen/server.ha => gen/server.ha +1 -0
@@ 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)!;