ArrayBase.hx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 hl.types;
  23. @:keep
  24. class ArrayAccess {
  25. public function getDyn(pos:Int):Dynamic {
  26. throw new haxe.exceptions.NotImplementedException();
  27. return 0;
  28. }
  29. public function setDyn(pos:Int, v:Dynamic) {
  30. throw new haxe.exceptions.NotImplementedException();
  31. }
  32. public function blit(pos:Int, src:ArrayAccess, srcpos:Int, len:Int):Void {
  33. throw new haxe.exceptions.NotImplementedException();
  34. }
  35. }
  36. @:keep
  37. class ArrayBase extends ArrayAccess {
  38. public var length(default, null):Int;
  39. public function pushDyn(v:Dynamic):Int {
  40. throw new haxe.exceptions.NotImplementedException();
  41. return 0;
  42. }
  43. public function popDyn():Null<Dynamic> {
  44. throw new haxe.exceptions.NotImplementedException();
  45. return null;
  46. }
  47. public function shiftDyn():Null<Dynamic> {
  48. throw new haxe.exceptions.NotImplementedException();
  49. return null;
  50. }
  51. public function unshiftDyn(v:Dynamic):Void {
  52. throw new haxe.exceptions.NotImplementedException();
  53. }
  54. public function insertDyn(pos:Int, v:Dynamic):Void {
  55. throw new haxe.exceptions.NotImplementedException();
  56. }
  57. public function containsDyn(v:Dynamic):Bool {
  58. throw new haxe.exceptions.NotImplementedException();
  59. return false;
  60. }
  61. public function removeDyn(v:Dynamic):Bool {
  62. throw new haxe.exceptions.NotImplementedException();
  63. return false;
  64. }
  65. public function sortDyn(f:Dynamic->Dynamic->Int):Void {
  66. throw new haxe.exceptions.NotImplementedException();
  67. }
  68. public function slice(pos:Int, ?end:Int):ArrayBase {
  69. throw new haxe.exceptions.NotImplementedException();
  70. return null;
  71. }
  72. public function splice(pos:Int, len:Int):ArrayBase {
  73. throw new haxe.exceptions.NotImplementedException();
  74. return null;
  75. }
  76. public function join(sep:String):String {
  77. throw new haxe.exceptions.NotImplementedException();
  78. return null;
  79. }
  80. public function reverse() {
  81. throw new haxe.exceptions.NotImplementedException();
  82. }
  83. public function resize(len:Int) {
  84. throw new haxe.exceptions.NotImplementedException();
  85. }
  86. public function toString():String {
  87. throw new haxe.exceptions.NotImplementedException();
  88. return null;
  89. }
  90. function __cast(t:Type):Dynamic {
  91. if (t == Type.get((null : ArrayDyn)))
  92. return ArrayDyn.alloc(this, false);
  93. return null;
  94. }
  95. function isArrayObj() {
  96. return false;
  97. }
  98. public static function allocI32(bytes:BytesAccess<Int>, length:Int) @:privateAccess {
  99. var a:ArrayBytes.ArrayI32 = untyped $new(ArrayBytes.ArrayI32);
  100. a.length = length;
  101. a.bytes = bytes;
  102. a.size = length;
  103. return a;
  104. }
  105. public static function allocUI16(bytes:BytesAccess<UI16>, length:Int) @:privateAccess {
  106. var a:ArrayBytes.ArrayUI16 = untyped $new(ArrayBytes.ArrayUI16);
  107. a.length = length;
  108. a.bytes = bytes;
  109. a.size = length;
  110. return a;
  111. }
  112. public static function allocF32(bytes:BytesAccess<F32>, length:Int) @:privateAccess {
  113. var a:ArrayBytes.ArrayF32 = untyped $new(ArrayBytes.ArrayF32);
  114. a.length = length;
  115. a.bytes = bytes;
  116. a.size = length;
  117. return a;
  118. }
  119. public static function allocF64(bytes:BytesAccess<Float>, length:Int) @:privateAccess {
  120. var a:ArrayBytes.ArrayF64 = untyped $new(ArrayBytes.ArrayF64);
  121. a.length = length;
  122. a.bytes = bytes;
  123. a.size = length;
  124. return a;
  125. }
  126. }