wasm.memutils.pas 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. {
  2. This file is part of the Free Component Library
  3. Webassembly memory utils.
  4. Copyright (c) 2025 by Michael Van Canneyt [email protected]
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit wasm.memutils;
  12. {$mode ObjFPC}{$H+}
  13. interface
  14. Type
  15. TWasmGrowMemoryEvent = procedure(aPages : longint) of object;
  16. var
  17. MemGrowNotifyCallBack : TWasmGrowMemoryCallBack;
  18. MemGrowNotifyEvent : TWasmGrowMemoryEvent;
  19. implementation
  20. procedure __wasm_memory_grow_notification(aPages : Longint); external 'wasmmem' name 'wasm_memory_grow_notification' ;
  21. procedure MemNotify(aPages : longint);
  22. begin
  23. __wasm_memory_grow_notification(aPages);
  24. if assigned(MemGrowNotifyCallBack) then
  25. MemGrowNotifyCallBack(aPages);
  26. if assigned(MemGrowNotifyEvent) then
  27. MemGrowNotifyEvent(aPages);
  28. end;
  29. initialization
  30. WasmGrowMemoryCallback:=@MemNotify;
  31. end.