CArray.hx 1012 B

123456789101112131415161718192021222324252627282930313233343536
  1. package hl;
  2. #if (hl_ver >= version("1.13.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. public var length(get,never) : Int;
  9. inline function get_length() return getLen(cast this);
  10. @:arrayAccess inline function get( index : Int ) : T return getIndex(cast this, index);
  11. public static function alloc<T>( cl : Class<T>, size : Int ) : CArray<T> {
  12. return cast alloc_carray( (cast cl:BaseType).__type__ , size );
  13. }
  14. @:hlNative("?std","carray_get")
  15. static function getIndex( arr : CArray<Dynamic>, index : Int ) : Dynamic {
  16. return null;
  17. }
  18. @:hlNative("?std","carray_length")
  19. static function getLen( arr : CArray<Dynamic> ) : Int {
  20. return 0;
  21. }
  22. @:hlNative("?std","alloc_carray")
  23. static function alloc_carray( t : hl.Type, size : Int ) : CArray<Dynamic> {
  24. return null;
  25. }
  26. }
  27. #end