From 1d2734ad76e8dce74f57bb7830b4d57b52bfe623 Mon Sep 17 00:00:00 2001 From: Dirk Baeumer Date: Mon, 22 Apr 2024 21:09:26 +0200 Subject: [PATCH] WIP --- wasm-component-model-resource/src/example.ts | 2 +- wasm-component-model-resource/src/extension.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/wasm-component-model-resource/src/example.ts b/wasm-component-model-resource/src/example.ts index 473b3050..51826695 100644 --- a/wasm-component-model-resource/src/example.ts +++ b/wasm-component-model-resource/src/example.ts @@ -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); } }; } diff --git a/wasm-component-model-resource/src/extension.ts b/wasm-component-model-resource/src/extension.ts index be2a697c..2917b6a8 100644 --- a/wasm-component-model-resource/src/extension.ts +++ b/wasm-component-model-resource/src/extension.ts @@ -26,8 +26,22 @@ export async function activate(context: vscode.ExtensionContext): Promise // 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));