Type.hx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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;
  23. enum abstract TypeKind(Int) {
  24. public var HVoid = 0;
  25. public var HUI8 = 1;
  26. public var HUI16 = 2;
  27. public var HI32 = 3;
  28. public var HI64 = 4;
  29. public var HF32 = 5;
  30. public var HF64 = 6;
  31. public var HBool = 7;
  32. public var HBytes = 8;
  33. public var HDyn = 9;
  34. public var HFun = 10;
  35. public var HObj = 11;
  36. public var HArray = 12;
  37. public var HType = 13;
  38. public var HRef = 14;
  39. public var HVirtual = 15;
  40. public var HDynObj = 16;
  41. public var HAbstract = 17;
  42. public var HEnum = 18;
  43. public var HNull = 19;
  44. }
  45. @:coreType abstract Type {
  46. public var kind(get, never):TypeKind;
  47. extern inline function get_kind():TypeKind {
  48. return untyped $tkind(this);
  49. }
  50. @:hlNative("std", "type_name") function getNameBytes():Bytes {
  51. return null;
  52. }
  53. extern public static inline function getDynamic(v:Dynamic):Type {
  54. return untyped $tdyntype(v);
  55. }
  56. extern public static inline function get<T>(v:T):Type {
  57. return untyped $ttype(v);
  58. }
  59. extern public static inline function void():Type {
  60. return untyped $ttype((null:Void));
  61. }
  62. extern public inline function getTypeName():String {
  63. var s = getNameBytes();
  64. if (s == null)
  65. return null;
  66. return @:privateAccess String.fromUCS2(s);
  67. }
  68. @:hlNative("std", "type_safe_cast") public function safeCast(t:Type):Bool {
  69. return false;
  70. }
  71. @:hlNative("std", "type_instance_fields") public function getInstanceFields():NativeArray<Bytes> {
  72. return null;
  73. }
  74. @:hlNative("std", "type_get_global") public function getGlobal():Dynamic {
  75. return null;
  76. }
  77. @:hlNative("std", "type_set_global") public function setGlobal(v:Dynamic):Bool {
  78. return false;
  79. }
  80. @:hlNative("std", "type_args_count") public function getArgsCount():Int {
  81. return 0;
  82. }
  83. @:hlNative("std", "type_super") public function getSuper():Type {
  84. return null;
  85. }
  86. @:hlNative("std", "type_enum_fields") public function getEnumFields():NativeArray<Bytes> {
  87. return null;
  88. }
  89. @:hlNative("std", "type_enum_values") public function getEnumValues():NativeArray<Dynamic> {
  90. return null;
  91. }
  92. @:hlNative("std", "alloc_obj") public function allocObject():Dynamic {
  93. return null;
  94. }
  95. @:hlNative("std", "alloc_enum_dyn") public function allocEnum(index:Int, args:NativeArray<Dynamic>, nargs:Int):Dynamic {
  96. return null;
  97. }
  98. }