2022-10-10 12:50:21 +00:00
|
|
|
import { SyscallContext, SysCallMapping } from "../system.ts";
|
2022-03-25 11:03:06 +00:00
|
|
|
|
2022-04-05 15:02:17 +00:00
|
|
|
export function proxySyscalls(
|
2022-03-25 11:03:06 +00:00
|
|
|
names: string[],
|
2022-03-31 12:28:07 +00:00
|
|
|
transportCall: (
|
|
|
|
ctx: SyscallContext,
|
|
|
|
name: string,
|
|
|
|
...args: any[]
|
2022-10-10 12:50:21 +00:00
|
|
|
) => Promise<any>,
|
2022-03-25 11:03:06 +00:00
|
|
|
): SysCallMapping {
|
2022-10-10 12:50:21 +00:00
|
|
|
const syscalls: SysCallMapping = {};
|
2022-03-25 11:03:06 +00:00
|
|
|
|
2022-10-10 12:50:21 +00:00
|
|
|
for (const name of names) {
|
2022-03-25 11:03:06 +00:00
|
|
|
syscalls[name] = (ctx, ...args: any[]) => {
|
2022-03-31 12:28:07 +00:00
|
|
|
return transportCall(ctx, name, ...args);
|
2022-03-25 11:03:06 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return syscalls;
|
|
|
|
}
|