CArray.hx 769 B

123456789101112131415161718192021222324
  1. package hl;
  2. #if (hl_ver >= version("1.14.0"))
  3. /**
  4. CArray is a compact array where all objects are memory aligned and stored as a single GC block.
  5. You must hold a reference to the CArray while any of the objects it contains is still referenced somewhere.
  6. **/
  7. abstract CArray<T>(Abstract<"hl_carray">) {
  8. @:arrayAccess inline function get( index : Int ) : T return untyped this[index];
  9. public inline function unsafeSet( index : Int, v : T ) return untyped this[index] = v;
  10. public static inline function alloc<T>( cl : Class<T>, size : Int ) : CArray<T> {
  11. return cast alloc_carray( (cast cl:BaseType).__type__ , size );
  12. }
  13. @:hlNative("?std","alloc_carray")
  14. static function alloc_carray( t : hl.Type, size : Int ) : CArray<Dynamic> {
  15. return null;
  16. }
  17. }
  18. #end