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

Class _ClassInfo

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

Stores information about a class.

Source from the content-addressed store, hash-verified

2051
2052
2053class _ClassInfo(_BlockInfo):
2054 """Stores information about a class."""
2055
2056 def __init__(self, name, class_or_struct, clean_lines, linenum):
2057 _BlockInfo.__init__(self, False)
2058 self.name = name
2059 self.starting_linenum = linenum
2060 self.is_derived = False
2061 self.check_namespace_indentation = True
2062 if class_or_struct == 'struct':
2063 self.access = 'public'
2064 self.is_struct = True
2065 else:
2066 self.access = 'private'
2067 self.is_struct = False
2068
2069 # Remember initial indentation level for this class. Using raw_lines here
2070 # instead of elided to account for leading comments.
2071 self.class_indent = GetIndentLevel(clean_lines.raw_lines[linenum])
2072
2073 # Try to find the end of the class. This will be confused by things like:
2074 # class A {
2075 # } *x = { ...
2076 #
2077 # But it's still good enough for CheckSectionSpacing.
2078 self.last_line = 0
2079 depth = 0
2080 for i in range(linenum, clean_lines.NumLines()):
2081 line = clean_lines.elided[i]
2082 depth += line.count('{') - line.count('}')
2083 if not depth:
2084 self.last_line = i
2085 break
2086
2087 def CheckBegin(self, filename, clean_lines, linenum, error):
2088 # Look for a bare ':'
2089 if Search('(^|[^:]):($|[^:])', clean_lines.elided[linenum]):
2090 self.is_derived = True
2091
2092 def CheckEnd(self, filename, clean_lines, linenum, error):
2093 # If there is a DISALLOW macro, it should appear near the end of
2094 # the class.
2095 seen_last_thing_in_class = False
2096 for i in xrange(linenum - 1, self.starting_linenum, -1):
2097 match = Search(
2098 r'\b(DISALLOW_COPY_AND_ASSIGN|DISALLOW_IMPLICIT_CONSTRUCTORS)\(' +
2099 self.name + r'\)',
2100 clean_lines.elided[i])
2101 if match:
2102 if seen_last_thing_in_class:
2103 error(filename, i, 'readability/constructors', 3,
2104 match.group(1) + ' should be the last thing in the class')
2105 break
2106
2107 if not Match(r'^\s*$', clean_lines.elided[i]):
2108 seen_last_thing_in_class = True
2109
2110 # Check that closing brace is aligned with beginning of the class.

Callers 1

UpdateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected