MCPcopy Index your code
hub / github.com/python/cpython / KIND

Class KIND

Tools/c-analyzer/c_parser/info.py:22–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21@enum.unique
22class KIND(enum.Enum):
23
24 # XXX Use these in the raw parser code.
25 TYPEDEF = 'typedef'
26 STRUCT = 'struct'
27 UNION = 'union'
28 ENUM = 'enum'
29 FUNCTION = 'function'
30 VARIABLE = 'variable'
31 STATEMENT = 'statement'
32
33 @classonly
34 def _from_raw(cls, raw):
35 if raw is None:
36 return None
37 elif isinstance(raw, cls):
38 return raw
39 elif type(raw) is str:
40 # We could use cls[raw] for the upper-case form,
41 # but there's no need to go to the trouble.
42 return cls(raw.lower())
43 else:
44 raise NotImplementedError(raw)
45
46 @classonly
47 def by_priority(cls, group=None):
48 if group is None:
49 return cls._ALL_BY_PRIORITY.copy()
50 elif group == 'type':
51 return cls._TYPE_DECLS_BY_PRIORITY.copy()
52 elif group == 'decl':
53 return cls._ALL_DECLS_BY_PRIORITY.copy()
54 elif isinstance(group, str):
55 raise NotImplementedError(group)
56 else:
57 # XXX Treat group as a set of kinds & return in priority order?
58 raise NotImplementedError(group)
59
60 @classonly
61 def is_type_decl(cls, kind):
62 if kind in cls.TYPES:
63 return True
64 if not isinstance(kind, cls):
65 raise TypeError(f'expected KIND, got {kind!r}')
66 return False
67
68 @classonly
69 def is_decl(cls, kind):
70 if kind in cls.DECLS:
71 return True
72 if not isinstance(kind, cls):
73 raise TypeError(f'expected KIND, got {kind!r}')
74 return False
75
76 @classonly
77 def get_group(cls, kind, *, groups=None):
78 if not isinstance(kind, cls):
79 raise TypeError(f'expected KIND, got {kind!r}')

Callers 2

from_rowMethod · 0.85
from_rowMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…