-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclasses_hscript.py
2399 lines (2118 loc) · 78.8 KB
/
classes_hscript.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from _hx_AnonObject import _hx_AnonObject
import globalClasses
import math as Math
import re as python_lib_Re
import math as python_lib_Math
import math as Math
from os import path as python_lib_os_Path
import inspect as python_lib_Inspect
import sys as python_lib_Sys
try:
import msvcrt as python_lib_Msvcrt
except:
pass
import os as python_lib_Os
import random as python_lib_Random
import re as python_lib_Re
import subprocess as python_lib_Subprocess
try:
import termios as python_lib_Termios
except:
pass
import time as python_lib_Time
import timeit as python_lib_Timeit
try:
import tty as python_lib_Tty
except:
pass
from datetime import datetime as python_lib_datetime_Datetime
from datetime import timedelta as python_lib_datetime_Timedelta
from datetime import timezone as python_lib_datetime_Timezone
from io import StringIO as python_lib_io_StringIO
import urllib.parse as python_lib_urllib_Parse
Math.NEGATIVE_INFINITY = float("-inf")
Math.POSITIVE_INFINITY = float("inf")
Math.NaN = float("nan")
Math.PI = python_lib_Math.pi
class Bool: pass
class Date:
_hx_class_name = "Date"
__slots__ = ("date", "dateUTC")
_hx_fields = ["date", "dateUTC"]
_hx_methods = ["getTime", "getHours", "getMinutes", "getSeconds", "getFullYear", "getMonth", "getDate", "getDay", "getUTCHours", "getUTCMinutes", "getUTCSeconds", "getUTCFullYear", "getUTCMonth", "getUTCDate", "getUTCDay", "getTimezoneOffset", "toString"]
_hx_statics = ["now", "fromTime", "makeLocal", "UTC", "fromString"]
def __init__(self,year,month,day,hour,_hx_min,sec):
self.dateUTC = None
if (year < python_lib_datetime_Datetime.min.year):
year = python_lib_datetime_Datetime.min.year
if (day == 0):
day = 1
self.date = Date.makeLocal(python_lib_datetime_Datetime(year,(month + 1),day,hour,_hx_min,sec,0))
self.dateUTC = self.date.astimezone(python_lib_datetime_Timezone.utc)
def getTime(self):
return (self.date.timestamp() * 1000)
def getHours(self):
return self.date.hour
def getMinutes(self):
return self.date.minute
def getSeconds(self):
return self.date.second
def getFullYear(self):
return self.date.year
def getMonth(self):
return (self.date.month - 1)
def getDate(self):
return self.date.day
def getDay(self):
return HxOverrides.mod(self.date.isoweekday(), 7)
def getUTCHours(self):
return self.dateUTC.hour
def getUTCMinutes(self):
return self.dateUTC.minute
def getUTCSeconds(self):
return self.dateUTC.second
def getUTCFullYear(self):
return self.dateUTC.year
def getUTCMonth(self):
return (self.dateUTC.month - 1)
def getUTCDate(self):
return self.dateUTC.day
def getUTCDay(self):
return HxOverrides.mod(self.dateUTC.isoweekday(), 7)
def getTimezoneOffset(self):
x = (self.date.utcoffset() / python_lib_datetime_Timedelta(0,60))
tmp = None
try:
tmp = int(x)
except BaseException as _g:
None
tmp = None
return -tmp
def toString(self):
return self.date.strftime("%Y-%m-%d %H:%M:%S")
@staticmethod
def now():
d = Date(2000,0,1,0,0,0)
d.date = Date.makeLocal(python_lib_datetime_Datetime.now())
d.dateUTC = d.date.astimezone(python_lib_datetime_Timezone.utc)
return d
@staticmethod
def fromTime(t):
d = Date(2000,0,1,0,0,0)
d.date = Date.makeLocal(python_lib_datetime_Datetime.fromtimestamp((t / 1000.0)))
d.dateUTC = d.date.astimezone(python_lib_datetime_Timezone.utc)
return d
@staticmethod
def makeLocal(date):
from python import python__KwArgs_KwArgs_Impl_
try:
return date.astimezone()
except BaseException as _g:
None
tzinfo = python_lib_datetime_Datetime.now(python_lib_datetime_Timezone.utc).astimezone().tzinfo
return date.replace(**python__KwArgs_KwArgs_Impl_.fromT(_hx_AnonObject({'tzinfo': tzinfo})))
@staticmethod
def UTC(year,month,day,hour,_hx_min,sec):
return (python_lib_datetime_Datetime(year,(month + 1),day,hour,_hx_min,sec,0,python_lib_datetime_Timezone.utc).timestamp() * 1000)
@staticmethod
def fromString(s):
from haxe import haxe_Exception
_g = len(s)
if (_g == 8):
k = s.split(":")
return Date.fromTime((((Std.parseInt((k[0] if 0 < len(k) else None)) * 3600000.) + ((Std.parseInt((k[1] if 1 < len(k) else None)) * 60000.))) + ((Std.parseInt((k[2] if 2 < len(k) else None)) * 1000.))))
elif (_g == 10):
k = s.split("-")
return Date(Std.parseInt((k[0] if 0 < len(k) else None)),(Std.parseInt((k[1] if 1 < len(k) else None)) - 1),Std.parseInt((k[2] if 2 < len(k) else None)),0,0,0)
elif (_g == 19):
k = s.split(" ")
_this = (k[0] if 0 < len(k) else None)
y = _this.split("-")
_this = (k[1] if 1 < len(k) else None)
t = _this.split(":")
return Date(Std.parseInt((y[0] if 0 < len(y) else None)),(Std.parseInt((y[1] if 1 < len(y) else None)) - 1),Std.parseInt((y[2] if 2 < len(y) else None)),Std.parseInt((t[0] if 0 < len(t) else None)),Std.parseInt((t[1] if 1 < len(t) else None)),Std.parseInt((t[2] if 2 < len(t) else None)))
else:
raise haxe_Exception.thrown(("Invalid date format : " + ("null" if s is None else s)))
@staticmethod
def _hx_empty_init(_hx_o):
_hx_o.date = None
_hx_o.dateUTC = None
Date._hx_class = Date
globalClasses._hx_classes["Date"] = Date
class Dynamic: pass
class EReg:
_hx_class_name = "EReg"
__slots__ = ("pattern", "matchObj", "_hx_global")
_hx_fields = ["pattern", "matchObj", "global"]
_hx_methods = ["match", "matched", "matchedLeft", "matchedRight", "matchedPos", "matchSub", "split", "replace", "map"]
_hx_statics = ["escape"]
def __init__(self,r,opt):
self.matchObj = None
self._hx_global = False
options = 0
_g = 0
_g1 = len(opt)
while (_g < _g1):
i = _g
_g = (_g + 1)
c = (-1 if ((i >= len(opt))) else ord(opt[i]))
if (c == 109):
options = (options | python_lib_Re.M)
if (c == 105):
options = (options | python_lib_Re.I)
if (c == 115):
options = (options | python_lib_Re.S)
if (c == 117):
options = (options | python_lib_Re.U)
if (c == 103):
self._hx_global = True
self.pattern = python_lib_Re.compile(r,options)
def match(self,s):
self.matchObj = python_lib_Re.search(self.pattern,s)
return (self.matchObj is not None)
def matched(self,n):
return self.matchObj.group(n)
def matchedLeft(self):
return HxString.substr(self.matchObj.string,0,self.matchObj.start())
def matchedRight(self):
return HxString.substr(self.matchObj.string,self.matchObj.end(),None)
def matchedPos(self):
return _hx_AnonObject({'pos': self.matchObj.start(), 'len': (self.matchObj.end() - self.matchObj.start())})
def matchSub(self,s,pos,_hx_len = None):
if (_hx_len is None):
_hx_len = -1
if (_hx_len != -1):
self.matchObj = self.pattern.search(s,pos,(pos + _hx_len))
else:
self.matchObj = self.pattern.search(s,pos)
return (self.matchObj is not None)
def split(self,s):
from python import python_HaxeIterator
if self._hx_global:
ret = []
lastEnd = 0
x = python_HaxeIterator(python_lib_Re.finditer(self.pattern,s))
while x.hasNext():
x1 = x.next()
x2 = HxString.substring(s,lastEnd,x1.start())
ret.append(x2)
lastEnd = x1.end()
x = HxString.substr(s,lastEnd,None)
ret.append(x)
return ret
else:
self.matchObj = python_lib_Re.search(self.pattern,s)
if (self.matchObj is None):
return [s]
else:
return [HxString.substring(s,0,self.matchObj.start()), HxString.substr(s,self.matchObj.end(),None)]
def replace(self,s,by):
from python import python_Boot
_this = by.split("$$")
by = "_hx_#repl#__".join([python_Boot.toString1(x1,'') for x1 in _this])
def _hx_local_0(x):
res = by
g = x.groups()
_g = 0
_g1 = len(g)
while (_g < _g1):
i = _g
_g = (_g + 1)
gs = g[i]
if (gs is None):
continue
delimiter = ("$" + HxOverrides.stringOrNull(str((i + 1))))
_this = (list(res) if ((delimiter == "")) else res.split(delimiter))
res = gs.join([python_Boot.toString1(x1,'') for x1 in _this])
_this = res.split("_hx_#repl#__")
res = "$".join([python_Boot.toString1(x1,'') for x1 in _this])
return res
replace = _hx_local_0
return python_lib_Re.sub(self.pattern,replace,s,(0 if (self._hx_global) else 1))
def map(self,s,f):
buf_b = python_lib_io_StringIO()
pos = 0
right = s
cur = self
while (pos < len(s)):
if (self.matchObj is None):
self.matchObj = python_lib_Re.search(self.pattern,s)
else:
self.matchObj = self.matchObj.re.search(s,pos)
if (self.matchObj is None):
break
pos1 = self.matchObj.end()
curPos_pos = cur.matchObj.start()
curPos_len = (cur.matchObj.end() - cur.matchObj.start())
buf_b.write(Std.string(HxString.substr(HxString.substr(cur.matchObj.string,0,cur.matchObj.start()),pos,None)))
buf_b.write(Std.string(f(cur)))
right = HxString.substr(cur.matchObj.string,cur.matchObj.end(),None)
if (not self._hx_global):
buf_b.write(Std.string(right))
return buf_b.getvalue()
if (curPos_len == 0):
buf_b.write(Std.string(("" if (((pos1 < 0) or ((pos1 >= len(s))))) else s[pos1])))
right = HxString.substr(right,1,None)
pos = (pos1 + 1)
else:
pos = pos1
buf_b.write(Std.string(right))
return buf_b.getvalue()
@staticmethod
def escape(s):
return python_lib_Re.escape(s)
@staticmethod
def _hx_empty_init(_hx_o):
_hx_o.pattern = None
_hx_o.matchObj = None
_hx_o._hx_global = None
EReg._hx_class = EReg
globalClasses._hx_classes["EReg"] = EReg
class Enum:
_hx_class_name = "Enum"
__slots__ = ("tag", "index", "params")
_hx_fields = ["tag", "index", "params"]
_hx_methods = ["__str__"]
def __init__(self,tag,index,params):
self.tag = tag
self.index = index
self.params = params
def __str__(self):
if (self.params is None):
return self.tag
else:
return self.tag + '(' + (', '.join(str(v) for v in self.params)) + ')'
@staticmethod
def _hx_empty_init(_hx_o):
_hx_o.tag = None
_hx_o.index = None
_hx_o.params = None
Enum._hx_class = Enum
globalClasses._hx_classes["Enum"] = Enum
class Float: pass
class HxOverrides:
_hx_class_name = "HxOverrides"
__slots__ = ()
_hx_statics = ["iterator", "keyValueIterator", "eq", "stringOrNull", "shift", "pop", "push", "join", "filter", "map", "toUpperCase", "toLowerCase", "split", "length", "rshift", "modf", "mod", "arrayGet", "arraySet", "mapKwArgs", "reverseMapKwArgs"]
@staticmethod
def iterator(x):
from haxe import haxe_iterators_ArrayIterator
if isinstance(x,list):
return haxe_iterators_ArrayIterator(x)
return x.iterator()
@staticmethod
def keyValueIterator(x):
from haxe import haxe_iterators_ArrayKeyValueIterator
if isinstance(x,list):
return haxe_iterators_ArrayKeyValueIterator(x)
return x.keyValueIterator()
@staticmethod
def eq(a,b):
if (isinstance(a,list) or isinstance(b,list)):
return a is b
return (a == b)
@staticmethod
def stringOrNull(s):
if (s is None):
return "null"
else:
return s
@staticmethod
def shift(x):
if isinstance(x,list):
_this = x
return (None if ((len(_this) == 0)) else _this.pop(0))
return x.shift()
@staticmethod
def pop(x):
if isinstance(x,list):
_this = x
return (None if ((len(_this) == 0)) else _this.pop())
return x.pop()
@staticmethod
def push(x,e):
if isinstance(x,list):
_this = x
_this.append(e)
return len(_this)
return x.push(e)
@staticmethod
def join(x,sep):
from python import python_Boot
if isinstance(x,list):
return sep.join([python_Boot.toString1(x1,'') for x1 in x])
return x.join(sep)
@staticmethod
def filter(x,f):
if isinstance(x,list):
return list(filter(f,x))
return x.filter(f)
@staticmethod
def map(x,f):
if isinstance(x,list):
return list(map(f,x))
return x.map(f)
@staticmethod
def toUpperCase(x):
if isinstance(x,str):
return x.upper()
return x.toUpperCase()
@staticmethod
def toLowerCase(x):
if isinstance(x,str):
return x.lower()
return x.toLowerCase()
@staticmethod
def split(x,delimiter):
if isinstance(x,str):
_this = x
if (delimiter == ""):
return list(_this)
else:
return _this.split(delimiter)
return x.split(delimiter)
@staticmethod
def length(x):
if isinstance(x,str):
return len(x)
elif isinstance(x,list):
return len(x)
return x.length
@staticmethod
def rshift(val,n):
return ((val % 0x100000000) >> n)
@staticmethod
def modf(a,b):
if (b == 0.0):
return float('nan')
elif (a < 0):
if (b < 0):
return -(-a % (-b))
else:
return -(-a % b)
elif (b < 0):
return a % (-b)
else:
return a % b
@staticmethod
def mod(a,b):
if (a < 0):
if (b < 0):
return -(-a % (-b))
else:
return -(-a % b)
elif (b < 0):
return a % (-b)
else:
return a % b
@staticmethod
def arrayGet(a,i):
if isinstance(a,list):
x = a
if ((i > -1) and ((i < len(x)))):
return x[i]
else:
return None
else:
return a[i]
@staticmethod
def arraySet(a,i,v):
if isinstance(a,list):
x = a
v1 = v
l = len(x)
while (l < i):
x.append(None)
l = (l + 1)
if (l == i):
x.append(v1)
else:
x[i] = v1
return v1
else:
a[i] = v
return v
@staticmethod
def mapKwArgs(a,v):
from python import python_HaxeIterator, python_Lib
a1 = _hx_AnonObject(python_Lib.anonToDict(a))
k = python_HaxeIterator(iter(v.keys()))
while k.hasNext():
k1 = k.next()
val = v.get(k1)
if a1._hx_hasattr(k1):
x = getattr(a1,k1)
setattr(a1,val,x)
delattr(a1,k1)
return a1
@staticmethod
def reverseMapKwArgs(a,v):
from python import python_HaxeIterator
a1 = a.copy()
k = python_HaxeIterator(iter(v.keys()))
while k.hasNext():
k1 = k.next()
val = v.get(k1)
if (val in a1):
x = a1.get(val,None)
a1[k1] = x
del a1[val]
return a1
HxOverrides._hx_class = HxOverrides
globalClasses._hx_classes["HxOverrides"] = HxOverrides
class HxString:
_hx_class_name = "HxString"
__slots__ = ()
_hx_statics = ["split", "charCodeAt", "charAt", "lastIndexOf", "toUpperCase", "toLowerCase", "indexOf", "indexOfImpl", "toString", "get_length", "fromCharCode", "substring", "substr"]
@staticmethod
def split(s,d):
if (d == ""):
return list(s)
else:
return s.split(d)
@staticmethod
def charCodeAt(s,index):
if ((((s is None) or ((len(s) == 0))) or ((index < 0))) or ((index >= len(s)))):
return None
else:
return ord(s[index])
@staticmethod
def charAt(s,index):
if ((index < 0) or ((index >= len(s)))):
return ""
else:
return s[index]
@staticmethod
def lastIndexOf(s,_hx_str,startIndex = None):
if (startIndex is None):
return s.rfind(_hx_str, 0, len(s))
elif (_hx_str == ""):
length = len(s)
if (startIndex < 0):
startIndex = (length + startIndex)
if (startIndex < 0):
startIndex = 0
if (startIndex > length):
return length
else:
return startIndex
else:
i = s.rfind(_hx_str, 0, (startIndex + 1))
startLeft = (max(0,((startIndex + 1) - len(_hx_str))) if ((i == -1)) else (i + 1))
check = s.find(_hx_str, startLeft, len(s))
if ((check > i) and ((check <= startIndex))):
return check
else:
return i
@staticmethod
def toUpperCase(s):
return s.upper()
@staticmethod
def toLowerCase(s):
return s.lower()
@staticmethod
def indexOf(s,_hx_str,startIndex = None):
if (startIndex is None):
return s.find(_hx_str)
else:
return HxString.indexOfImpl(s,_hx_str,startIndex)
@staticmethod
def indexOfImpl(s,_hx_str,startIndex):
if (_hx_str == ""):
length = len(s)
if (startIndex < 0):
startIndex = (length + startIndex)
if (startIndex < 0):
startIndex = 0
if (startIndex > length):
return length
else:
return startIndex
return s.find(_hx_str, startIndex)
@staticmethod
def toString(s):
return s
@staticmethod
def get_length(s):
return len(s)
@staticmethod
def fromCharCode(code):
return "".join(map(chr,[code]))
@staticmethod
def substring(s,startIndex,endIndex = None):
if (startIndex < 0):
startIndex = 0
if (endIndex is None):
return s[startIndex:]
else:
if (endIndex < 0):
endIndex = 0
if (endIndex < startIndex):
return s[endIndex:startIndex]
else:
return s[startIndex:endIndex]
@staticmethod
def substr(s,startIndex,_hx_len = None):
if (_hx_len is None):
return s[startIndex:]
else:
if (_hx_len == 0):
return ""
if (startIndex < 0):
startIndex = (len(s) + startIndex)
if (startIndex < 0):
startIndex = 0
return s[startIndex:(startIndex + _hx_len)]
HxString._hx_class = HxString
globalClasses._hx_classes["HxString"] = HxString
class IntIterator:
_hx_class_name = "IntIterator"
__slots__ = ("min", "max")
_hx_fields = ["min", "max"]
_hx_methods = ["hasNext", "next"]
def __init__(self,_hx_min,_hx_max):
self.min = _hx_min
self.max = _hx_max
def hasNext(self):
return (self.min < self.max)
def next(self):
def _hx_local_3():
def _hx_local_2():
_hx_local_0 = self
_hx_local_1 = _hx_local_0.min
_hx_local_0.min = (_hx_local_1 + 1)
return _hx_local_1
return _hx_local_2()
return _hx_local_3()
@staticmethod
def _hx_empty_init(_hx_o):
_hx_o.min = None
_hx_o.max = None
IntIterator._hx_class = IntIterator
globalClasses._hx_classes["IntIterator"] = IntIterator
class Int: pass
class Lambda:
_hx_class_name = "Lambda"
__slots__ = ()
_hx_statics = ["array", "list", "map", "mapi", "flatten", "flatMap", "has", "exists", "foreach", "iter", "filter", "fold", "count", "empty", "indexOf", "find", "concat"]
@staticmethod
def array(it):
a = list()
i = HxOverrides.iterator(it)
while i.hasNext():
i1 = i.next()
a.append(i1)
return a
@staticmethod
def list(it):
from haxe import haxe_ds_List
l = haxe_ds_List()
i = HxOverrides.iterator(it)
while i.hasNext():
i1 = i.next()
l.add(i1)
return l
@staticmethod
def map(it,f):
from haxe import haxe_ds_List
l = haxe_ds_List()
x = HxOverrides.iterator(it)
while x.hasNext():
x1 = x.next()
l.add(f(x1))
return l
@staticmethod
def mapi(it,f):
from haxe import haxe_ds_List
l = haxe_ds_List()
i = 0
x = HxOverrides.iterator(it)
while x.hasNext():
x1 = x.next()
tmp = i
i = (i + 1)
l.add(f(tmp,x1))
return l
@staticmethod
def flatten(it):
from haxe import haxe_ds_List
l = haxe_ds_List()
e = HxOverrides.iterator(it)
while e.hasNext():
e1 = e.next()
x = HxOverrides.iterator(e1)
while x.hasNext():
x1 = x.next()
l.add(x1)
return l
@staticmethod
def flatMap(it,f):
return Lambda.flatten(Lambda.map(it,f))
@staticmethod
def has(it,elt):
x = HxOverrides.iterator(it)
while x.hasNext():
x1 = x.next()
if HxOverrides.eq(x1,elt):
return True
return False
@staticmethod
def exists(it,f):
x = HxOverrides.iterator(it)
while x.hasNext():
x1 = x.next()
if f(x1):
return True
return False
@staticmethod
def foreach(it,f):
x = HxOverrides.iterator(it)
while x.hasNext():
x1 = x.next()
if (not f(x1)):
return False
return True
@staticmethod
def iter(it,f):
x = HxOverrides.iterator(it)
while x.hasNext():
x1 = x.next()
f(x1)
@staticmethod
def filter(it,f):
from haxe import haxe_ds_List
l = haxe_ds_List()
x = HxOverrides.iterator(it)
while x.hasNext():
x1 = x.next()
if f(x1):
l.add(x1)
return l
@staticmethod
def fold(it,f,first):
x = HxOverrides.iterator(it)
while x.hasNext():
x1 = x.next()
first = f(x1,first)
return first
@staticmethod
def count(it,pred = None):
n = 0
if (pred is None):
_ = HxOverrides.iterator(it)
while _.hasNext():
_1 = _.next()
n = (n + 1)
else:
x = HxOverrides.iterator(it)
while x.hasNext():
x1 = x.next()
if pred(x1):
n = (n + 1)
return n
@staticmethod
def empty(it):
return (not HxOverrides.iterator(it).hasNext())
@staticmethod
def indexOf(it,v):
i = 0
v2 = HxOverrides.iterator(it)
while v2.hasNext():
v21 = v2.next()
if HxOverrides.eq(v,v21):
return i
i = (i + 1)
return -1
@staticmethod
def find(it,f):
v = HxOverrides.iterator(it)
while v.hasNext():
v1 = v.next()
if f(v1):
return v1
return None
@staticmethod
def concat(a,b):
from haxe import haxe_ds_List
l = haxe_ds_List()
x = HxOverrides.iterator(a)
while x.hasNext():
x1 = x.next()
l.add(x1)
x = HxOverrides.iterator(b)
while x.hasNext():
x1 = x.next()
l.add(x1)
return l
Lambda._hx_class = Lambda
globalClasses._hx_classes["Lambda"] = Lambda
class Reflect:
_hx_class_name = "Reflect"
__slots__ = ()
_hx_statics = ["hasField", "field", "setField", "getProperty", "setProperty", "callMethod", "fields", "isFunction", "compare", "isClosure", "compareMethods", "isObject", "isEnumValue", "deleteField", "copy", "makeVarArgs"]
@staticmethod
def hasField(o,field):
from python import python_Boot
return python_Boot.hasField(o,field)
@staticmethod
def field(o,field):
from python import python_Boot
return python_Boot.field(o,field)
@staticmethod
def setField(o,field,value):
from python import python_Boot
setattr(o,(("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field)),value)
@staticmethod
def getProperty(o,field):
from python import python_Boot
if (o is None):
return None
if (field in python_Boot.keywords):
field = ("_hx_" + field)
elif ((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95))):
field = ("_hx_" + field)
if isinstance(o,_hx_AnonObject):
return Reflect.field(o,field)
tmp = Reflect.field(o,("get_" + ("null" if field is None else field)))
if ((tmp is not None) and callable(tmp)):
return tmp()
else:
return Reflect.field(o,field)
@staticmethod
def setProperty(o,field,value):
from python import python_Boot
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if isinstance(o,_hx_AnonObject):
setattr(o,field1,value)
elif hasattr(o,("set_" + ("null" if field1 is None else field1))):
getattr(o,("set_" + ("null" if field1 is None else field1)))(value)
else:
setattr(o,field1,value)
@staticmethod
def callMethod(o,func,args):
if callable(func):
return func(*args)
else:
return None
@staticmethod
def fields(o):
from python import python_Boot
return python_Boot.fields(o)
@staticmethod
def isFunction(f):
if (not ((python_lib_Inspect.isfunction(f) or python_lib_Inspect.ismethod(f)))):
from python import python_Boot
return python_Boot.hasField(f,"func_code")
else:
return True
@staticmethod
def compare(a,b):
if ((a is None) and ((b is None))):
return 0
if (a is None):
return 1
elif (b is None):
return -1
elif HxOverrides.eq(a,b):
return 0
elif (a > b):
return 1
else:
return -1
@staticmethod
def isClosure(v):
from python import python_internal_MethodClosure
return isinstance(v,python_internal_MethodClosure)
@staticmethod
def compareMethods(f1,f2):
from python import python_internal_MethodClosure
if HxOverrides.eq(f1,f2):
return True
if (isinstance(f1,python_internal_MethodClosure) and isinstance(f2,python_internal_MethodClosure)):
m1 = f1
m2 = f2
if HxOverrides.eq(m1.obj,m2.obj):
return (m1.func == m2.func)
else:
return False
if ((not Reflect.isFunction(f1)) or (not Reflect.isFunction(f2))):
return False
return False
@staticmethod
def isObject(v):
_g = Type.typeof(v)
tmp = _g.index
if (tmp == 4):
return True
elif (tmp == 6):
_g1 = _g.params[0]
return True
else:
return False
@staticmethod
def isEnumValue(v):
if not HxOverrides.eq(v,Enum):
return isinstance(v,Enum)
else:
return False
@staticmethod
def deleteField(o,field):
from python import python_Boot
if (field in python_Boot.keywords):
field = ("_hx_" + field)
elif ((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95))):
field = ("_hx_" + field)
if (not python_Boot.hasField(o,field)):