From 06f89c8c653c1f2bf3ff8223ff738f6937170857 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2023 14:35:11 +0100 Subject: [PATCH] gen client: emit caps_in --- gen/client.ha | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/gen/client.ha b/gen/client.ha index a52e8e5..5ef385a 100644 --- a/gen/client.ha +++ b/gen/client.ha @@ -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(¶ms)), )?; -- 2.38.4