MCPcopy Create free account
hub / github.com/apache/mesos / _IncludeState

Class _IncludeState

support/cpplint.py:702–864  ·  view source on GitHub ↗

Tracks line numbers for includes, and the order in which includes appear. include_list contains list of lists of (header, line number) pairs. It's a lists of lists rather than just one flat list to make it easier to update across preprocessor boundaries. Call CheckNextIncludeOrder() once f

Source from the content-addressed store, hash-verified

700
701
702class _IncludeState(object):
703 """Tracks line numbers for includes, and the order in which includes appear.
704
705 include_list contains list of lists of (header, line number) pairs.
706 It's a lists of lists rather than just one flat list to make it
707 easier to update across preprocessor boundaries.
708
709 Call CheckNextIncludeOrder() once for each header in the file, passing
710 in the type constants defined above. Calls in an illegal order will
711 raise an _IncludeError with an appropriate error message.
712
713 """
714 # self._section will move monotonically through this set. If it ever
715 # needs to move backwards, CheckNextIncludeOrder will raise an error.
716 _INITIAL_SECTION = 0
717 _MY_H_SECTION = 1
718 _C_SECTION = 2
719 _CPP_SECTION = 3
720 _OTHER_H_SECTION = 4
721
722 _TYPE_NAMES = {
723 _C_SYS_HEADER: 'C system header',
724 _CPP_SYS_HEADER: 'C++ system header',
725 _LIKELY_MY_HEADER: 'header this file implements',
726 _POSSIBLE_MY_HEADER: 'header this file may implement',
727 _OTHER_HEADER: 'other header',
728 }
729 _SECTION_NAMES = {
730 _INITIAL_SECTION: "... nothing. (This can't be an error.)",
731 _MY_H_SECTION: 'a header this file implements',
732 _C_SECTION: 'C system header',
733 _CPP_SECTION: 'C++ system header',
734 _OTHER_H_SECTION: 'other header',
735 }
736
737 def __init__(self):
738 self.include_list = [[]]
739 self.ResetSection('')
740
741 def FindHeader(self, header):
742 """Check if a header has already been included.
743
744 Args:
745 header: header to check.
746 Returns:
747 Line number of previous occurrence, or -1 if the header has not
748 been seen before.
749 """
750 for section_list in self.include_list:
751 for f in section_list:
752 if f[0] == header:
753 return f[1]
754 return -1
755
756 def ResetSection(self, directive):
757 """Reset section checking for preprocessor directive.
758
759 Args:

Callers 1

ProcessFileDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected