MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / Update

Method Update

engine/3rdparty/tinyobjloader/deps/cpplint.py:2375–2537  ·  view source on GitHub ↗

Update nesting state with current line. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.

(self, filename, clean_lines, linenum, error)

Source from the content-addressed store, hash-verified

2373
2374 # TODO(unknown): Update() is too long, but we will refactor later.
2375 def Update(self, filename, clean_lines, linenum, error):
2376 """Update nesting state with current line.
2377
2378 Args:
2379 filename: The name of the current file.
2380 clean_lines: A CleansedLines instance containing the file.
2381 linenum: The number of the line to check.
2382 error: The function to call with any errors found.
2383 """
2384 line = clean_lines.elided[linenum]
2385
2386 # Remember top of the previous nesting stack.
2387 #
2388 # The stack is always pushed/popped and not modified in place, so
2389 # we can just do a shallow copy instead of copy.deepcopy. Using
2390 # deepcopy would slow down cpplint by ~28%.
2391 if self.stack:
2392 self.previous_stack_top = self.stack[-1]
2393 else:
2394 self.previous_stack_top = None
2395
2396 # Update pp_stack
2397 self.UpdatePreprocessor(line)
2398
2399 # Count parentheses. This is to avoid adding struct arguments to
2400 # the nesting stack.
2401 if self.stack:
2402 inner_block = self.stack[-1]
2403 depth_change = line.count('(') - line.count(')')
2404 inner_block.open_parentheses += depth_change
2405
2406 # Also check if we are starting or ending an inline assembly block.
2407 if inner_block.inline_asm in (_NO_ASM, _END_ASM):
2408 if (depth_change != 0 and
2409 inner_block.open_parentheses == 1 and
2410 _MATCH_ASM.match(line)):
2411 # Enter assembly block
2412 inner_block.inline_asm = _INSIDE_ASM
2413 else:
2414 # Not entering assembly block. If previous line was _END_ASM,
2415 # we will now shift to _NO_ASM state.
2416 inner_block.inline_asm = _NO_ASM
2417 elif (inner_block.inline_asm == _INSIDE_ASM and
2418 inner_block.open_parentheses == 0):
2419 # Exit assembly block
2420 inner_block.inline_asm = _END_ASM
2421
2422 # Consume namespace declaration at the beginning of the line. Do
2423 # this in a loop so that we catch same line declarations like this:
2424 # namespace proto2 { namespace bridge { class MessageSet; } }
2425 while True:
2426 # Match start of namespace. The "\b\s*" below catches namespace
2427 # declarations even if it weren't followed by a whitespace, this
2428 # is so that we don't confuse our namespace checker. The
2429 # missing spaces will be flagged by CheckSpacing.
2430 namespace_decl_match = Match(r'^\s*namespace\b\s*([:\w]+)?(.*)$', line)
2431 if not namespace_decl_match:
2432 break

Callers 1

ProcessLineFunction · 0.45

Calls 15

UpdatePreprocessorMethod · 0.95
SeenOpenBraceMethod · 0.95
MatchFunction · 0.85
_NamespaceInfoClass · 0.85
_ClassInfoClass · 0.85
_ExternCInfoClass · 0.85
_BlockInfoClass · 0.85
errorFunction · 0.50
countMethod · 0.45
matchMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected