Rev 3262 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3262 | Rev 3263 | ||
---|---|---|---|
Line 56... | Line 56... | ||
56 | inst = Struct() |
56 | inst = Struct() |
57 | list = [] |
57 | list = [] |
58 | 58 | ||
59 | # Member tags |
59 | # Member tags |
60 | comment = False |
60 | comment = False |
61 | variable = False |
61 | variable = None |
62 | for token in tokens[1:]: |
62 | for token in tokens[1:]: |
63 | if (comment): |
63 | if (comment): |
64 | if (token == "*/"): |
64 | if (token == "*/"): |
65 | comment = False |
65 | comment = False |
66 | continue |
66 | continue |
67 | 67 | ||
68 | if (variable): |
- | |
69 | inst.__dict__[token] = None |
- | |
70 | list.append(token) |
- | |
71 | variable = False |
- | |
72 | continue |
- | |
73 | - | ||
74 | if (token == "/*"): |
68 | if (token == "/*"): |
75 | comment = True |
69 | comment = True |
- | 70 | continue |
|
- | 71 | ||
- | 72 | if (variable != None): |
|
- | 73 | subtokens = token.split("[") |
|
- | 74 | ||
- | 75 | if (len(subtokens) > 1): |
|
- | 76 | format += "%d" % int(subtokens[1].split("]")[0]) |
|
- | 77 | ||
- | 78 | format += variable |
|
- | 79 | ||
- | 80 | inst.__dict__[subtokens[0]] = None |
|
- | 81 | list.append(subtokens[0]) |
|
- | 82 | ||
- | 83 | variable = None |
|
- | 84 | continue |
|
- | 85 | ||
76 | elif (token[0:8] == "padding["): |
86 | if (token[0:8] == "padding["): |
77 | size = token[8:].split("]")[0] |
87 | size = token[8:].split("]")[0] |
78 | format += "%dx" % int(size) |
88 | format += "%dx" % int(size) |
79 | elif (token[0:5] == "char["): |
- | |
80 | size = token[5:].split("]")[0] |
- | |
81 | format += "%ds" % int(size) |
- | |
82 | variable = True |
89 | continue |
83 | else: |
90 | |
84 | format += { |
91 | variable = { |
- | 92 | "char": lambda: "s", |
|
85 | "uint8_t": lambda: "B", |
93 | "uint8_t": lambda: "B", |
86 | "uint16_t": lambda: "H", |
94 | "uint16_t": lambda: "H", |
87 | "uint32_t": lambda: "L", |
95 | "uint32_t": lambda: "L", |
88 | "uint64_t": lambda: "Q", |
96 | "uint64_t": lambda: "Q", |
89 | 97 | ||
90 | "int8_t": lambda: "b", |
98 | "int8_t": lambda: "b", |
91 | "int16_t": lambda: "h", |
99 | "int16_t": lambda: "h", |
92 | "int32_t": lambda: "l", |
100 | "int32_t": lambda: "l", |
93 | "int64_t": lambda: "q" |
101 | "int64_t": lambda: "q" |
94 | }[token]() |
102 | }[token]() |
95 | variable = True |
- | |
96 | 103 | ||
97 | inst.__dict__['_format_'] = format |
104 | inst.__dict__['_format_'] = format |
98 | inst.__dict__['_list_'] = list |
105 | inst.__dict__['_list_'] = list |
99 | return inst |
106 | return inst |