CArray.hx 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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 ) : 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. #if (hl_ver >= version("1.16.0"))
  18. public inline function blit( cl : Class<T>, pos : Int, src : CArray<T>, srcPos : Int, srcLen : Int ) : Void {
  19. carray_blit( cast this, (cast cl:BaseType).__type__, pos, src, srcPos, srcLen );
  20. }
  21. @:hlNative("?std","carray_blit")
  22. static function carray_blit( dst: CArray<Dynamic>, t : hl.Type, pos : Int, src : CArray<Dynamic>, srcPos : Int, srcLen : Int ) : Void {
  23. }
  24. #end
  25. }
  26. #end