MCPcopy Create free account
hub / github.com/FastLED/FastLED / insert_fl_noexcept_in_line

Function insert_fl_noexcept_in_line

ci/tools/add_fl_noexcept.py:126–207  ·  view source on GitHub ↗

Insert FL_NOEXCEPT into a function signature line. Returns modified line, or None if can't insert.

(line: str)

Source from the content-addressed store, hash-verified

124
125
126def insert_fl_noexcept_in_line(line: str) -> str | None:
127 """Insert FL_NOEXCEPT into a function signature line.
128
129 Returns modified line, or None if can't insert.
130 """
131 if "FL_NOEXCEPT" in line or "noexcept" in line:
132 return None
133
134 code = line.rstrip()
135
136 # Skip lines with trailing return types (-> decltype)
137 if "->" in code:
138 return None
139
140 # Skip constructor initializer list lines (start with : or ,)
141 stripped = code.lstrip()
142 if stripped.startswith(":") or stripped.startswith(","):
143 return None
144
145 # Find balanced closing paren
146 depth = 0
147 close_pos = -1
148 for i, ch in enumerate(code):
149 if ch == "(":
150 depth += 1
151 elif ch == ")":
152 depth -= 1
153 if depth == 0:
154 close_pos = i
155 break
156
157 if close_pos == -1:
158 return None
159
160 # Skip if followed by [ (array subscript — variable declaration)
161 after_paren = code[close_pos + 1 :].lstrip()
162 if after_paren.startswith("["):
163 return None
164
165 # Skip past ) and any const/volatile
166 pos = close_pos + 1
167 rest_raw = code[pos:]
168 rest = rest_raw.lstrip()
169 skip = len(rest_raw) - len(rest)
170 pos += skip
171
172 if rest.startswith("const") and (len(rest) == 5 or not rest[5].isalnum()):
173 pos += 5
174 rest = code[pos:].lstrip()
175 skip2 = len(code[pos:]) - len(rest)
176 pos += skip2
177
178 if rest.startswith("volatile") and (len(rest) == 8 or not rest[8].isalnum()):
179 pos += 8
180 rest = code[pos:].lstrip()
181 skip2 = len(code[pos:]) - len(rest)
182 pos += skip2
183

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected