This commit is contained in:
Dirk Baeumer
2024-04-22 21:09:26 +02:00
parent 807ecbaa34
commit 1d2734ad76
2 changed files with 16 additions and 2 deletions

View File

@ -113,7 +113,7 @@ export namespace example {
constructor(handleTag: Symbol, handle: $wcm.ResourceHandle);
constructor(...args: any[]) {
super(...args, om);
rm.registerProxy(this);
// rm.registerProxy(this);
}
};
}

View File

@ -26,8 +26,22 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
// The context for the WASM module
const wasmContext: WasmContext.Default = new WasmContext.Default();
const imports: any = {
'foo': () => 20,
'[export]vscode:example/types' : {
'[resource-drop]engine': (...args: any[]) => {
console.log(args);
},
'[resource-new]engine': (...args: any[]) => {
console.log(args);
return args[0];
}
}
};
// Instantiate the module and create the necessary imports from the service implementation
const instance = await WebAssembly.instantiate(module, calculator._.imports.create({ foo: () => 20 }, wasmContext));
// const imports = calculator._.imports.create({ foo: () => 20 }, wasmContext);
const instance = await WebAssembly.instantiate(module, imports);
// Bind the WASM memory to the context
wasmContext.initialize(new Memory.Default(instance.exports));