6 TA_NAME
, TA_LINE
, TA_LOCAL
, TA_POS
, TA_TYPE
, TA_ARGLIST
, TA_SCOPE
, \
7 TA_VARTYPE
, TA_INHERITS
, TA_TIME
, TA_ACCESS
, TA_IMPL
, TA_LANG
, \
8 TA_INACTIVE
, TA_FLAGS
= range(200, 215)
10 # see TMTagType in tm_parser.h
12 "undef", "class", "enum", "enumerator", "field", "function",
13 "interface", "member", "method", "namespace", "package",
14 "prototype", "struct", "typedef", "union", "variable", "externvar",
15 "macro", "macro_arg", "file", "other",
16 "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN",
19 type_dct
= {0: types
[0]}
20 for i
in range(len(types
) - 1):
21 type_dct
[1 << i
] = types
[i
+ 1]
24 def decode_kind(kind
, value
):
27 val
= value
.decode('utf-8')
30 elif kind
== TA_LOCAL
:
33 val
= type_dct
[int(value
)]
34 elif kind
== TA_ARGLIST
:
35 val
= value
.decode('utf-8')
36 elif kind
== TA_SCOPE
:
37 val
= value
.decode('utf-8')
38 elif kind
== TA_FLAGS
:
40 elif kind
== TA_VARTYPE
:
41 val
= value
.decode('utf-8')
42 elif kind
== TA_INHERITS
:
43 val
= value
.decode('utf-8')
48 elif kind
== TA_INACTIVE
:
50 elif kind
== TA_ACCESS
:
51 val
= value
.decode('utf-8')
53 val
= value
.decode('utf-8')
58 res
= '{:<12}'.format(tag
[TA_TYPE
] + ': ')
60 res
+= tag
[TA_VARTYPE
] + ' '
62 res
+= tag
[TA_SCOPE
] + ' :: '
65 res
+= tag
[TA_ARGLIST
]
66 if TA_INHERITS
in tag
:
67 res
+= ' extends ' + tag
[TA_INHERITS
]
68 if TA_FLAGS
in tag
and tag
[TA_FLAGS
] > 0:
69 res
+= ' flags: ' + str(tag
[TA_FLAGS
])
70 # stdout.buffer (stdin.buffer) needed to write (read) binary data, see:
71 # https://docs.python.org/3/library/sys.html?highlight=stdout#sys.stdout
72 sys
.stdout
.buffer.write(res
.encode('utf-8'))
73 sys
.stdout
.buffer.write(b
'\n')
76 def get_next_part(inp
, pos
, first
):
85 while c
< TA_NAME
and c
!= ord('\n'):
89 return part
, kind
, pos
92 inp
= sys
.stdin
.buffer.read()
100 part
, kind
, pos
= get_next_part(inp
, pos
, line_start
)
101 value
= decode_kind(kind
, part
)
104 if inp
[pos
] == ord('\n'):
106 pass # first line contains '# format=tagmanager' we want to skip
108 sys
.stdout
.buffer.write(inp
[line_start_pos
:pos
])
109 sys
.stdout
.buffer.write(b
'\n')