2
0

Memory.hx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package js.lib.webassembly;
  23. /**
  24. A new WebAssembly `Memory` object which is a resizable ArrayBuffer that holds the raw bytes of memory
  25. accessed by a WebAssembly WebAssembly `Instance`.
  26. A memory created by JavaScript or in WebAssembly code will be accessible and mutable from
  27. both JavaScript and WebAssembly.
  28. Documentation [Memory](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
  29. **/
  30. @:native("WebAssembly.Memory")
  31. extern class Memory {
  32. /**
  33. An accessor property that returns the buffer contained in the memory.
  34. **/
  35. final buffer:js.lib.ArrayBuffer;
  36. @:pure function new(memoryDescriptor:MemoryDescriptor):Void;
  37. /**
  38. Increases the size of the memory instance by a specified number of WebAssembly pages
  39. (each one is 64KB in size).
  40. **/
  41. function grow(number:Int):Int;
  42. }
  43. typedef MemoryDescriptor = {
  44. /**
  45. The initial size of the WebAssembly Memory, in units of WebAssembly pages.
  46. **/
  47. var initial:Int;
  48. /**
  49. The maximum size the WebAssembly Memory is allowed to grow to, in units of WebAssembly pages.
  50. When present, the `maximum` parameter acts as a hint to the engine to reserve memory up front.
  51. However, the engine may ignore or clamp this reservation request.
  52. In general, most WebAssembly modules shouldn't need to set a `maximum`.
  53. */
  54. var ?maximum:Int;
  55. }