| 1797 | """Stores information about a class.""" |
| 1798 | |
| 1799 | def __init__(self, name, class_or_struct, clean_lines, linenum): |
| 1800 | _BlockInfo.__init__(self, False) |
| 1801 | self.name = name |
| 1802 | self.starting_linenum = linenum |
| 1803 | self.is_derived = False |
| 1804 | if class_or_struct == 'struct': |
| 1805 | self.access = 'public' |
| 1806 | self.is_struct = True |
| 1807 | else: |
| 1808 | self.access = 'private' |
| 1809 | self.is_struct = False |
| 1810 | |
| 1811 | # Remember initial indentation level for this class. Using raw_lines here |
| 1812 | # instead of elided to account for leading comments. |
| 1813 | initial_indent = Match(r'^( *)\S', clean_lines.raw_lines[linenum]) |
| 1814 | if initial_indent: |
| 1815 | self.class_indent = len(initial_indent.group(1)) |
| 1816 | else: |
| 1817 | self.class_indent = 0 |
| 1818 | |
| 1819 | # Try to find the end of the class. This will be confused by things like: |
| 1820 | # class A { |
| 1821 | # } *x = { ... |
| 1822 | # |
| 1823 | # But it's still good enough for CheckSectionSpacing. |
| 1824 | self.last_line = 0 |
| 1825 | depth = 0 |
| 1826 | for i in range(linenum, clean_lines.NumLines()): |
| 1827 | line = clean_lines.elided[i] |
| 1828 | depth += line.count('{') - line.count('}') |
| 1829 | if not depth: |
| 1830 | self.last_line = i |
| 1831 | break |
| 1832 | |
| 1833 | def CheckBegin(self, filename, clean_lines, linenum, error): |
| 1834 | # Look for a bare ':' |