third_party/blink/tools/blinkpy/style/checkers/cpp.py
def check_for_object_static_cast(processing_file, line_number, line, error):
    """Checks for a Cpp-style static cast on objects by looking for the pattern.

    Args:
      processing_file: The name of the processing file.
      line_number: The number of the line to check.
      line: The line of code to check.
      error: The function to call with any errors found.
    """
    matched = search(r'\bstatic_cast<(\s*\w*:?:?\w+\s*\*+\s*)>', line)
    if not matched:
        return

    class_name = re.sub(r'[\*]', '', matched.group(1))
    class_name = class_name.strip()
    # Ignore (for now) when the casting is to void*,
    if class_name == 'void':
        return

    namespace_pos = class_name.find(':')
    if not namespace_pos == -1:
        class_name = class_name[namespace_pos + 2:]

    header_file = ''.join((class_name, '.h'))
    matches = check_for_toFoo_definition(header_file, ''.join(
        ('to', class_name)), error)
    # Ignore (for now) if not able to find the header where toFoo might be defined.
    # TODO: Handle cases where Classname might be defined in some other header or cpp file.
    if matches is None:
        return

    report_error = True
    # Ensure found static_cast instance is not from within toFoo definition itself.
    if os.path.basename(processing_file) == header_file:
        for item in matches:
            if line_number in range(item[1], item[2]):
                report_error = False
                break

    if report_error:
        if len(matches):
            # toFoo is defined - enforce using it.
            # TODO: Suggest an appropriate toFoo from the alternatives present in matches.
            error(
                line_number, 'runtime/casting', 4,
                'static_cast of class objects is not allowed. Use to%s defined in %s.'
                % (class_name, header_file))
        else:
            # No toFoo defined - enforce definition & usage.
            # TODO: Automate the generation of toFoo() to avoid any slippages ever.
            error(
                line_number, 'runtime/casting', 4,
                'static_cast of class objects is not allowed. Add to%s in %s and use it instead.'
                % (class_name, header_file))
Checks for a Cpp-style static cast on objects by looking for the pattern.

    Args:
      processing_file: The name of the processing file.
      line_number: The number of the line to check.
      line: The line of code to check.
      error: The function to call with any errors found.
    
Checks for a Cpp-style static cast on objects by looking for the pattern.
Checks for a Cpp - style static cast on objects by looking for the pattern .
def check_for_object_static_cast(processing_file, line_number, line, error):
    matched = search(r'\bstatic_cast<(\s*\w*:?:?\w+\s*\*+\s*)>', line)
    if not matched:
        return
    class_name = re.sub(r'[\*]', '', matched.group(1))
    class_name = class_name.strip()
    if class_name == 'void':
        return
    namespace_pos = class_name.find(':')
    if not namespace_pos == -1:
        class_name = class_name[namespace_pos + 2:]
    header_file = ''.join((class_name, '.h'))
    matches = check_for_toFoo_definition(header_file, ''.join(
        ('to', class_name)), error)
    if matches is None:
        return
    report_error = True
    if os.path.basename(processing_file) == header_file:
        for item in matches:
            if line_number in range(item[1], item[2]):
                report_error = False
                break
    if report_error:
        if len(matches):
            error(
                line_number, 'runtime/casting', 4,
                'static_cast of class objects is not allowed. Use to%s defined in %s.'
                % (class_name, header_file))
        else:
            error(
                line_number, 'runtime/casting', 4,
                'static_cast of class objects is not allowed. Add to%s in %s and use it instead.'
                % (class_name, header_file))
def check_for_object_static_cast ( processing_file , line_number , line , error ) : matched = search ( r'\bstatic_cast<(\s*\w*:?:?\w+\s*\*+\s*)>' , line ) if not matched : return class_name = re . sub ( r'[\*]' , '' , matched . group ( 1 ) ) class_name = class_name . strip ( ) if class_name == 'void' : return namespace_pos = class_name . find ( ':' ) if not namespace_pos == - 1 : class_name = class_name [ namespace_pos + 2 : ] header_file = '' . join ( ( class_name , '.h' ) ) matches = check_for_toFoo_definition ( header_file , '' . join ( ( 'to' , class_name ) ) , error ) if matches is None : return report_error = True if os . path . basename ( processing_file ) == header_file : for item in matches : if line_number in range ( item [ 1 ] , item [ 2 ] ) : report_error = False break if report_error : if len ( matches ) : error ( line_number , 'runtime/casting' , 4 , 'static_cast of class objects is not allowed. Use to%s defined in %s.' % ( class_name , header_file ) ) else : error ( line_number , 'runtime/casting' , 4 , 'static_cast of class objects is not allowed. Add to%s in %s and use it instead.' % ( class_name , header_file ) )
Checks for a Cpp-style static cast on objects by looking for the pattern.
Checks for a Cpp - style static cast on objects by looking for the pattern .
"""Checks for a Cpp-style static cast on objects by looking for the pattern.

    Args:
      processing_file: The name of the processing file.
      line_number: The number of the line to check.
      line: The line of code to check.
      error: The function to call with any errors found.
    """ # Ignore (for now) when the casting is to void*, # Ignore (for now) if not able to find the header where toFoo might be defined. # TODO: Handle cases where Classname might be defined in some other header or cpp file. # Ensure found static_cast instance is not from within toFoo definition itself. # toFoo is defined - enforce using it. # TODO: Suggest an appropriate toFoo from the alternatives present in matches. # No toFoo defined - enforce definition & usage. # TODO: Automate the generation of toFoo() to avoid any slippages ever.
processing_file
The name of the processing file.
The name of the processing file .
line_number
The number of the line to check.
The number of the line to check .
line
The line of code to check.
The line of code to check .
error
The function to call with any errors found.
The function to call with any errors found .