Browse Source

* Allow to access webassembly memory as Uint8Array

Michael Van Canneyt 1 year ago
parent
commit
13742a5375
1 changed files with 9 additions and 3 deletions
  1. 9 3
      packages/job/src/job_browser.pp

+ 9 - 3
packages/job/src/job_browser.pp

@@ -268,9 +268,15 @@ end;
 
 function TJSObjectBridge.FindGlobalObject(const aName: string): TJOBObjectID;
 begin
-  if not FGlobalNames.hasOwnProperty(aName) then
-    exit(0);
-  Result:=NativeInt(FGlobalNames[aName]);
+  // this one is special, it needs to be re-registered every time
+  if aName='InstanceMemory' then
+    Exit(RegisterLocalObject(TJSUint8Array.New(getModuleMemoryDataView.buffer)));
+  else
+    begin
+    if not FGlobalNames.hasOwnProperty(aName) then
+      exit(0);
+    Result:=NativeInt(FGlobalNames[aName]);
+    end;
 end;
 
 function TJSObjectBridge.RegisterLocalObject(Obj: TJSObject): TJOBObjectID;