Forráskód Böngészése

* forgot to commit

Michaël Van Canneyt 3 hónapja
szülő
commit
9e9153b2d3
1 módosított fájl, 45 hozzáadás és 0 törlés
  1. 45 0
      packages/wasm-utils/src/wasm.memutils.pas

+ 45 - 0
packages/wasm-utils/src/wasm.memutils.pas

@@ -0,0 +1,45 @@
+{
+    This file is part of the Free Component Library
+
+    Webassembly memory utils.
+    Copyright (c) 2025 by Michael Van Canneyt [email protected]
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+unit wasm.memutils;
+
+{$mode ObjFPC}{$H+}
+
+interface
+
+Type
+  TWasmGrowMemoryEvent = procedure(aPages : longint) of object;
+
+var
+  MemGrowNotifyCallBack : TWasmGrowMemoryCallBack;
+  MemGrowNotifyEvent : TWasmGrowMemoryEvent;
+
+implementation
+
+procedure __wasm_memory_grow_notification(aPages : Longint); external 'wasmmem' name 'wasm_memory_grow_notification' ;
+
+procedure MemNotify(aPages : longint);
+
+begin
+  __wasm_memory_grow_notification(aPages);
+  if assigned(MemGrowNotifyCallBack) then
+    MemGrowNotifyCallBack(aPages);
+  if assigned(MemGrowNotifyEvent) then
+    MemGrowNotifyEvent(aPages);
+end;
+
+initialization
+  WasmGrowMemoryCallback:=@MemNotify;
+end.
+