Skip to content
Snippets Groups Projects
Commit 5fdcb9fe authored by Campbell Barton's avatar Campbell Barton
Browse files

code_clean: support for using const-casts

parent f99d29ae
No related branches found
No related tags found
No related merge requests found
......@@ -304,6 +304,18 @@ class edit_generators:
float abc[3]
With:
const float abc[3]
As well as casts.
Replace:
(float *)
With:
(const float *)
Replace:
(float (*))
With:
(const float (*))
"""
@staticmethod
def edit_list_from_file(_source: str, data: str, _shared_edit_data: Any) -> List[Edit]:
......@@ -325,6 +337,22 @@ class edit_generators:
content_fail='__ALWAYS_FAIL__',
))
# `(float *)` -> `(const float *)`
# `(float (*))` -> `(const float (*))`
# `(float (*)[4])` -> `(const float (*)[4])`
for match in re.finditer(
r"(\()"
r"([a-zA-Z_0-9]+\s*)"
r"(\*+\)|\(\*+\))"
r"(|\[[a-zA-Z_0-9]+\])",
data,
):
edits.append(Edit(
span=match.span(),
content='%sconst %s%s%s' % (match.group(1), match.group(2), match.group(3), match.group(4)),
content_fail='__ALWAYS_FAIL__',
))
return edits
class use_zero_before_float_suffix(EditGenerator):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment