Refactor all the things

This commit is contained in:
Zef Hemel
2023-08-28 17:12:15 +02:00
parent 54d2deea15
commit 5ff1a8bae3
87 changed files with 930 additions and 896 deletions
+7 -11
View File
@@ -10,16 +10,6 @@ export function systemSyscalls(
): SysCallMapping {
const api: SysCallMapping = {
"system.invokeFunction": (
ctx,
_env: string,
name: string,
...args: any[]
) => {
// For backwards compatibility
// TODO: Remove at some point
return api["system.invoke"](ctx, name, ...args);
},
"system.invoke": (
ctx,
name: string,
...args: any[]
@@ -28,6 +18,12 @@ export function systemSyscalls(
throw Error("No plug associated with context");
}
if (name === "server" || name === "client") {
// Backwards compatibility mode (previously there was an 'env' argument)
name = args[0];
args = args.slice(1);
}
let plug: Plug<any> | undefined = ctx.plug;
if (name.indexOf(".") !== -1) {
// plug name in the name
@@ -44,7 +40,7 @@ export function systemSyscalls(
}
if (functionDef.env && system.env && functionDef.env !== system.env) {
// Proxy to another environment
return proxySyscall(editor.remoteSpacePrimitives, name, args);
return proxySyscall(ctx, editor.remoteSpacePrimitives, name, args);
}
return plug.invoke(name, args);
},