/* * Copyright (C)2005-2019 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package python; import python.internal.UBuiltins; import python.Syntax; @:native("tuple") extern class Tuple implements ArrayAccess { @:overload(function():Void {}) function new(a:Array):Void; var length(get, never):Int; inline function get_length():Int { return UBuiltins.len(this); } inline function toArray():Array { return UBuiltins.list(this); } } @:native("tuple") extern class Tuple1 extends Tuple { static inline function make(a:A):Tuple1 return Syntax.tuple(a); var _1(get, null):A; inline function get__1():A return this[0]; } @:native("tuple") extern class Tuple2 extends Tuple { static inline function make(a:A, b:B):Tuple2 return Syntax.tuple(a, b); var _1(get, null):A; inline function get__1():A return this[0]; var _2(get, null):B; inline function get__2():B return this[1]; } @:native("tuple") extern class Tuple3 extends Tuple { static inline function make(a:A, b:B, c:C):Tuple3 return Syntax.tuple(a, b, c); var _1(get, null):A; inline function get__1():A return this[0]; var _2(get, null):B; inline function get__2():B return this[1]; var _3(get, null):C; inline function get__3():C return this[2]; } @:native("tuple") extern class Tuple4 extends Tuple { static inline function make(a:A, b:B, c:C, d:D):Tuple4 return Syntax.tuple(a, b, c, d); var _1(get, null):A; inline function get__1():A return this[0]; var _2(get, null):B; inline function get__2():B return this[1]; var _3(get, null):C; inline function get__3():C return this[2]; var _4(get, null):D; inline function get__4():D return this[3]; } @:native("tuple") extern class Tuple5 extends Tuple { static inline function make(a:A, b:B, c:C, d:D, e:E):Tuple5 return Syntax.tuple(a, b, c, d, e); var _1(get, null):A; inline function get__1():A return this[0]; var _2(get, null):B; inline function get__2():B return this[1]; var _3(get, null):C; inline function get__3():C return this[2]; var _4(get, null):D; inline function get__4():D return this[3]; var _5(get, null):E; inline function get__5():E return this[4]; }