20from typing
import List, Optional, Tuple, Union
24 "Combine the type T and the name N into a C declaration."
25 if t.endswith(
"*")
or t.endswith(
"&"):
32 """Given a sequence of (TYPE, NAME) pairs, generate a comma-separated
33 list of declarations."""
38 "Base class for all components."
44 printer: Optional[str] =
None,
45 comment: Optional[str] =
None,
46 predicate: bool =
False,
47 predefault: Optional[str] =
None,
48 postdefault: Optional[str] =
None,
49 invalid: Union[bool, str] =
True,
50 params: Optional[List[Tuple[str, str]]] =
None,
51 param_checks: Optional[List[str]] =
None,
52 result_checks: Optional[List[str]] =
None,
53 implement: bool =
True,
68 components.append(self)
73 raise Exception(
"can't have result checks with a void return type")
76 "Return the expression used for validity checking."
78 predicate = f
"gdbarch->{self.name} != {self.predefault}"
80 predicate = f
"gdbarch->{self.name} != NULL"
85 "An Info component is copied from the gdbarch_info."
88class Value(Component):
89 "A Value component is just a data member."
96 comment: Optional[str] =
None,
97 predicate: bool =
False,
98 predefault: Optional[str] =
None,
99 postdefault: Optional[str] =
None,
100 invalid: Union[bool, str] =
True,
101 printer: Optional[str] =
None,
108 predefault=predefault,
109 postdefault=postdefault,
116 "A Function component is a function pointer member."
123 params: List[Tuple[str, str]],
124 comment: Optional[str] =
None,
125 predicate: bool =
False,
126 predefault: Optional[str] =
None,
127 postdefault: Optional[str] =
None,
128 invalid: Union[bool, str] =
True,
129 printer: Optional[str] =
None,
130 param_checks: Optional[List[str]] =
None,
131 result_checks: Optional[List[str]] =
None,
132 implement: bool =
True,
139 predefault=predefault,
140 postdefault=postdefault,
144 param_checks=param_checks,
145 result_checks=result_checks,
150 "Return the name of the function typedef to use."
151 return f
"gdbarch_{self.name}_ftype"
154 "Return the formal parameter list as a string."
158 """Return the formal parameter list of the caller function,
159 as a string. This list includes the gdbarch."""
160 arch_arg = (
"struct gdbarch *",
"gdbarch")
161 arch_tuple = [arch_arg]
165 "Return the actual parameters to forward, as a string."
170 "A Method is like a Function but passes the gdbarch through."
178 result = [
"gdbarch"] + [p[1]
for p
in self.
paramsparams]
179 return ", ".join(result)
183components: List[Component] = []
__init__(self, str name, str type, Optional[str] printer=None, Optional[str] comment=None, bool predicate=False, Optional[str] predefault=None, Optional[str] postdefault=None, Union[bool, str] invalid=True, Optional[List[Tuple[str, str]]] params=None, Optional[List[str]] param_checks=None, Optional[List[str]] result_checks=None, bool implement=True)
__init__(self, *str name, str type, List[Tuple[str, str]] params, Optional[str] comment=None, bool predicate=False, Optional[str] predefault=None, Optional[str] postdefault=None, Union[bool, str] invalid=True, Optional[str] printer=None, Optional[List[str]] param_checks=None, Optional[List[str]] result_checks=None, bool implement=True)
__init__(self, *str name, str type, Optional[str] comment=None, bool predicate=False, Optional[str] predefault=None, Optional[str] postdefault=None, Union[bool, str] invalid=True, Optional[str] printer=None)
join_type_and_name(str t, str n)
join_params(List[Tuple[str, str]] params)