~sircmpwn/ipcgen

06f89c8c653c1f2bf3ff8223ff738f6937170857 — Drew DeVault a month ago 9af9b9a
gen client: emit caps_in
1 files changed, 19 insertions(+), 4 deletions(-)

M gen/client.ha
M gen/client.ha => gen/client.ha +19 -4
@@ 20,9 20,9 @@ export fn client(out: io::handle, doc: *ast::document) (void | io::error) = {

const c_iface_method_src: str =
	`export fn $iface_$method(
	ep: helios::cap,$mparams
	ep: helios::cap,$cparams$mparams
) $result = {
	const (tag, a1) = helios::call(ep,
	${caps_in_setup}const (tag, a1) = helios::call(ep,
		$iface_label::$methodid,$params
	);
	assert(rt::label(tag) == 0); // TODO: Error handling


@@ 64,13 64,26 @@ fn c_meth(
	iface: *ast::interface,
	meth: *ast::method,
) (void | io::error) = {
	assert(len(meth.caps_in) == 0);  // TODO
	assert(len(meth.caps_out) == 0); // TODO
	assert(len(meth.caps_out) == 0);  // TODO

	const id: ast::ident = [meth.name];
	const name = gen_name_upper(&id);
	defer free(name);

	let cparams = strio::dynamic();
	defer io::close(&cparams)!;

	let caps_in_setup = strio::dynamic();
	defer io::close(&caps_in_setup)!;

	for (let i = 0z; i < len(meth.caps_in); i += 1) {
		const cap = &meth.caps_in[i];
		fmt::fprintf(&cparams, "\n\t{}: helios::cap,", cap.name)!;
		fmt::fprintf(&caps_in_setup,
			"rt::ipcbuf.caps[{}] = {};\n\t",
			i, cap.name)!;
	};

	let mparams = strio::dynamic();
	defer io::close(&mparams)!;



@@ 98,6 111,8 @@ fn c_meth(
		("method", meth.name),
		("methodid", name),
		("result", strio::string(&result)),
		("cparams", strio::string(&cparams)),
		("caps_in_setup", strio::string(&caps_in_setup)),
		("mparams", strio::string(&mparams)),
		("params", strio::string(&params)),
	)?;