2
0

StdTypes.hx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (C)2005-2013 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. // standard haXe types
  23. /**
  24. The standard Void type. Only [null] values can be of the type [Void].
  25. **/
  26. @:coreType abstract Void { }
  27. /**
  28. The standard Float type, this is a double-precision IEEE 64bit float.
  29. **/
  30. @:coreType @:notNull @:runtimeValue abstract Float { }
  31. /**
  32. The standard Int type. Its precision depends on the platform.
  33. **/
  34. @:coreType @:notNull @:runtimeValue abstract Int to Float { }
  35. #if (flash9 || flash9doc || cs)
  36. /**
  37. The unsigned Int type is only defined for Flash9. It's currently
  38. handled the same as a normal Int.
  39. **/
  40. @:coreType @:notNull @:runtimeValue abstract UInt to Int from Int { }
  41. #end
  42. #if (java || cs)
  43. @:coreType @:notNull @:runtimeValue abstract Single to Float from Float {}
  44. #end
  45. /**
  46. [Null] can be useful in two cases. In order to document some methods
  47. that accepts or can return a [null] value, or for the Flash9 compiler and AS3
  48. generator to distinguish between base values that can be null and others that
  49. can't.
  50. **/
  51. typedef Null<T> = T
  52. /**
  53. The standard Boolean type is represented as an enum with two choices.
  54. **/
  55. @:coreType @:notNull @:runtimeValue abstract Bool {
  56. }
  57. /**
  58. Dynamic is an internal compiler type which has special behavior.
  59. See the haXe language reference for more informations.
  60. **/
  61. @:coreType @:runtimeValue abstract Dynamic<T> {
  62. }
  63. /**
  64. An Iterator is a structure that permits iteration over elements of type T.
  65. Any class with matching hasNext and next fields is considered an Iterator
  66. and can then be used e.g. in for-loops. This makes it easy to implement
  67. custom iterators.
  68. **/
  69. typedef Iterator<T> = {
  70. /**
  71. Returns false if the iteration is complete, true otherwise.
  72. Usually iteration is considered to be complete if all elements of the
  73. underlying data structure were handled through calls to next(). However,
  74. in custom iterators any logic may be used to determine the completion
  75. state.
  76. **/
  77. function hasNext() : Bool;
  78. /**
  79. Returns the current item of the Iterator and advances to the next one.
  80. This method is not required to check hasNext() first. A call to this
  81. method while hasNext() is false yields unspecified behavior.
  82. **/
  83. function next() : T;
  84. }
  85. /**
  86. An Iterable is a data structure which has an iterator() method.
  87. See [Lambda] for generic functions on iterable structures.
  88. **/
  89. typedef Iterable<T> = {
  90. function iterator() : Iterator<T>;
  91. }
  92. /**
  93. ArrayAccess is used to indicate a class that can be accessed using brackets.
  94. The type parameter represent the type of the elements stored.
  95. **/
  96. extern interface ArrayAccess<T> { }