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