class documentation

class NestingState(object):

View In Hierarchy

Holds states related to parsing braces.

Method __init__ Undocumented
Method CheckCompletedBlocks Checks that all classes and namespaces have been completely parsed.
Method InAsmBlock Check if we are currently one level inside an inline ASM block.
Method InClassDeclaration Check if we are currently one level inside a class or struct declaration.
Method InExternC Check if we are currently one level inside an 'extern "C"' block.
Method InNamespaceBody Check if we are currently one level inside a namespace body.
Method InnermostClass Get class info on the top of the stack.
Method InTemplateArgumentList Check if current position is inside template argument list.
Method SeenOpenBrace Check if we have seen the opening brace for the innermost block.
Method Update Update nesting state with current line.
Method UpdatePreprocessor Update preprocessor stack.
Instance Variable pp_stack Undocumented
Instance Variable previous_stack_top Undocumented
Instance Variable stack Undocumented
def __init__(self):

Undocumented

def CheckCompletedBlocks(self, filename, error):

Checks that all classes and namespaces have been completely parsed.

Call this when all lines in a file have been processed. Args:

filename: The name of the current file. error: The function to call with any errors found.
def InAsmBlock(self):

Check if we are currently one level inside an inline ASM block.

Returns:
True if the top of the stack is a block containing inline ASM.
def InClassDeclaration(self):

Check if we are currently one level inside a class or struct declaration.

Returns:
True if top of the stack is a class/struct, False otherwise.
def InExternC(self):

Check if we are currently one level inside an 'extern "C"' block.

Returns:
True if top of the stack is an extern block, False otherwise.
def InNamespaceBody(self):

Check if we are currently one level inside a namespace body.

Returns:
True if top of the stack is a namespace block, False otherwise.
def InnermostClass(self):

Get class info on the top of the stack.

Returns:
A _ClassInfo object if we are inside a class, or None otherwise.
def InTemplateArgumentList(self, clean_lines, linenum, pos):

Check if current position is inside template argument list.

Args:
clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. pos: position just after the suspected template argument.
Returns:
True if (linenum, pos) is inside template arguments.
def SeenOpenBrace(self):

Check if we have seen the opening brace for the innermost block.

Returns:
True if we have seen the opening brace, False if the innermost block is still expecting an opening brace.
def Update(self, filename, clean_lines, linenum, error):

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.
def UpdatePreprocessor(self, line):

Update preprocessor stack.

We need to handle preprocessors due to classes like this:
#ifdef SWIG struct ResultDetailsPageElementExtensionPoint { #else struct ResultDetailsPageElementExtensionPoint : public Extension { #endif

We make the following assumptions (good enough for most files): - Preprocessor condition evaluates to true from #if up to first

#else/#elif/#endif.
  • Preprocessor condition evaluates to false from #else/#elif up to #endif. We still perform lint checks on these lines, but these do not affect nesting stack.
Args:
line: current line to check.
pp_stack: list =

Undocumented

previous_stack_top =

Undocumented

stack: list =

Undocumented