Table.hx 574 B

1234567891011121314151617181920212223
  1. package lua;
  2. /**
  3. Abstract implementation of a standard Lua table. Automatically converts to the
  4. 1-based indexing that Lua uses as default for int-keyed tables.
  5. **/
  6. abstract Table<A,B>({}) {
  7. inline public function new() this = {};
  8. @:arrayAccess inline function getIntV(k:Int) : B{
  9. return untyped this[k+1];
  10. }
  11. @:arrayAccess inline function setIntV(k:Int, v:B){
  12. untyped this[k+1] = v;
  13. return v;
  14. }
  15. @:arrayAccess inline function getV(k:A) : B{
  16. return untyped this[k];
  17. }
  18. @:arrayAccess inline function setV(k:A, v:B){
  19. untyped this[k] = v;
  20. return v;
  21. }
  22. }