~sircmpwn/ipcgen

a4ca97d01e9e7c147b0bda046ab5efab1d1e923b — Drew DeVault a month ago 06f89c8
gen server: emit caps_in
2 files changed, 23 insertions(+), 3 deletions(-)

M gen/client.ha
M gen/server.ha
M gen/client.ha => gen/client.ha +1 -0
@@ 78,6 78,7 @@ fn c_meth(

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

M gen/server.ha => gen/server.ha +22 -3
@@ 81,7 81,7 @@ fn s_iface(
};

const s_method_fntype_src: str =
	`export type fn_$iface_$method = fn(object: *$object$params) $result;`;
	`export type fn_$iface_$method = fn(object: *$object${caps_in}$params) $result;`;
let st_method_fntype: tmpl::template = [];

@init fn s_method_fntype() void = {


@@ 93,9 93,17 @@ fn s_method_fntype(
	iface: *ast::interface,
	meth: *ast::method,
) (void | io::error) = {
	assert(len(meth.caps_in) == 0); // TODO
	assert(len(meth.caps_out) == 0); // TODO

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

	for (let i = 0z; i < len(meth.caps_in); i += 1) {
		const cap = &meth.caps_in[i];
		assert(!cap.variadic); // TODO
		fmt::fprintf(&caps_in, ", {}: helios::cap", cap.name)!;
	};

	let params = strio::dynamic();
	defer io::close(&params)!;
	if (len(meth.params) != 0) {


@@ 119,6 127,7 @@ fn s_method_fntype(
		("method", meth.name),
		("iface", iface.name),
		("object", iface.name),
		("caps_in", strio::string(&caps_in)),
		("params", strio::string(&params)),
		("result", strio::string(&result)),
	)?;


@@ 162,7 171,7 @@ const s_iface_dispatch_footer_src: str = `	case =>
// the user stored the reply capability for later
const s_iface_dispatch_method_src: str = `	case $iface_label::$methodid =>
		${rval_store}object._iface.$method(
			object,$params
			object,${caps_in}$params
		);
		match (helios::reply(0${rval_param})) {
		case void =>


@@ 208,6 217,15 @@ fn s_method_dispatch(
	const method_id = gen_name_upper(&id);
	defer free(method_id);

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

	for (let i = 0z; i < len(meth.caps_in); i += 1) {
		assert(!meth.caps_in[i].variadic); // TODO
		fmt::fprint(&caps_in, "\n\t\t\t")!;
		fmt::fprintf(&caps_in, "rt::ipcbuf.caps[{}],", i)!;
	};

	let params = strio::dynamic();
	defer io::close(&params)!;
	for (let i = 0z; i < len(meth.params); i += 1) {


@@ 237,6 255,7 @@ fn s_method_dispatch(
		("iface", iface.name),
		("method", meth.name),
		("methodid", method_id),
		("caps_in", strio::string(&caps_in)),
		("params", strio::string(&params)),
		("rval_store", strio::string(&rval_store)),
		("rval_param", strio::string(&rval_param)),