ArrayBase.hx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (C)2005-2017 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 "Not implemented";
  27. return 0;
  28. }
  29. public function setDyn( pos : Int, v : Dynamic ) {
  30. throw "Not implemented";
  31. }
  32. public function blit( pos : Int, src : ArrayAccess, srcpos : Int, len : Int ) : Void {
  33. throw "Not implemented";
  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 "Not implemented";
  41. return 0;
  42. }
  43. public function popDyn() : Null<Dynamic> {
  44. throw "Not implemented";
  45. return null;
  46. }
  47. public function shiftDyn() : Null<Dynamic> {
  48. throw "Not implemented";
  49. return null;
  50. }
  51. public function unshiftDyn( v : Dynamic ) : Void {
  52. throw "Not implemented";
  53. }
  54. public function insertDyn( pos : Int, v : Dynamic ) : Void {
  55. throw "Not implemented";
  56. }
  57. public function removeDyn( v : Dynamic ) : Bool {
  58. throw "Not implemented";
  59. return false;
  60. }
  61. public function sortDyn( f : Dynamic -> Dynamic -> Int ) : Void {
  62. throw "Not implemented";
  63. }
  64. public function slice( pos : Int, ?end : Int ) : ArrayBase{
  65. throw "Not implemented";
  66. return null;
  67. }
  68. public function splice( pos : Int, len : Int ) : ArrayBase{
  69. throw "Not implemented";
  70. return null;
  71. }
  72. public function join( sep : String ) : String {
  73. throw "Not implemented";
  74. return null;
  75. }
  76. public function reverse() {
  77. throw "Not implemented";
  78. }
  79. public function toString() : String {
  80. throw "Not implemented";
  81. return null;
  82. }
  83. function __cast( t : Type ) : Dynamic {
  84. if( t == Type.get(new ArrayDyn()) )
  85. return ArrayDyn.alloc(this, false);
  86. return null;
  87. }
  88. function isArrayObj() {
  89. return false;
  90. }
  91. public static function allocI32( bytes : BytesAccess<Int>, length : Int ) @:privateAccess {
  92. var a : ArrayBytes.ArrayI32 = untyped $new(ArrayBytes.ArrayI32);
  93. a.length = length;
  94. a.bytes = bytes;
  95. a.size = length;
  96. return a;
  97. }
  98. public static function allocUI16( bytes : BytesAccess<UI16>, length : Int ) @:privateAccess {
  99. var a : ArrayBytes.ArrayUI16 = untyped $new(ArrayBytes.ArrayUI16);
  100. a.length = length;
  101. a.bytes = bytes;
  102. a.size = length;
  103. return a;
  104. }
  105. public static function allocF32( bytes : BytesAccess<F32>, length : Int ) @:privateAccess {
  106. var a : ArrayBytes.ArrayF32 = untyped $new(ArrayBytes.ArrayF32);
  107. a.length = length;
  108. a.bytes = bytes;
  109. a.size = length;
  110. return a;
  111. }
  112. public static function allocF64( bytes : BytesAccess<Float>, length : Int ) @:privateAccess {
  113. var a : ArrayBytes.ArrayF64 = untyped $new(ArrayBytes.ArrayF64);
  114. a.length = length;
  115. a.bytes = bytes;
  116. a.size = length;
  117. return a;
  118. }
  119. }