-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchonkytypes.py
executable file
·85 lines (78 loc) · 1.71 KB
/
chonkytypes.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
class String:
'''
Simple String type
'''
def __init__(self, value):
self.value = value
self.length = len(value)
class ID:
'''
Simple ID type
'''
def __init__(self, value):
self.value = value
self.length = len(value)
class Char:
'''
Simple Char type
'''
size = 1
abbr_name = 'char'
def __init__(self, value):
self.value = ord(value) if type(value) == str else value
self.length = value
self.size = Char.size
self.hex = False
class Int8:
'''
Simple Int8 type
'''
size = 1
abbr_name = 'int8'
def __init__(self, value):
self.value = int(value)
self.length = value
self.size = Int8.size
self.hex = False
class Int32:
'''
Simple Int32 type
'''
size = 4
abbr_name = 'int'
def __init__(self, value):
self.value = int(value, 16) if (type(value) == str and value[0:2] == "0x") else int(value)
self.length = value
self.size = Int32.size
self.hex = False
class Pointer:
'''
Simple pointer type
'''
size = 4
abbr_name = 'ptr'
def __init__(self, value):
ID.__init__(self, value)
class HexInt32:
'''
Simple Int32 type
'''
size = 4
abbr_name = 'hex'
def __init__(self, value):
self.value = value
self.length = len(value)
self.size = Int32.size
self.hex = True
class List:
'''
Simple static length list type
'''
size = 0
abbr_name = 'list'
def __init__(self, values, type):
self.values = values
self.length = len(values)
self.size = List.size
self.offset = 0
self.type = type