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

Class _IncludeState

engine/3rdparty/tinyobjloader/deps/cpplint.py:592–754  ·  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

590
591
592class _IncludeState(object):
593 """Tracks line numbers for includes, and the order in which includes appear.
594
595 include_list contains list of lists of (header, line number) pairs.
596 It's a lists of lists rather than just one flat list to make it
597 easier to update across preprocessor boundaries.
598
599 Call CheckNextIncludeOrder() once for each header in the file, passing
600 in the type constants defined above. Calls in an illegal order will
601 raise an _IncludeError with an appropriate error message.
602
603 """
604 # self._section will move monotonically through this set. If it ever
605 # needs to move backwards, CheckNextIncludeOrder will raise an error.
606 _INITIAL_SECTION = 0
607 _MY_H_SECTION = 1
608 _C_SECTION = 2
609 _CPP_SECTION = 3
610 _OTHER_H_SECTION = 4
611
612 _TYPE_NAMES = {
613 _C_SYS_HEADER: 'C system header',
614 _CPP_SYS_HEADER: 'C++ system header',
615 _LIKELY_MY_HEADER: 'header this file implements',
616 _POSSIBLE_MY_HEADER: 'header this file may implement',
617 _OTHER_HEADER: 'other header',
618 }
619 _SECTION_NAMES = {
620 _INITIAL_SECTION: "... nothing. (This can't be an error.)",
621 _MY_H_SECTION: 'a header this file implements',
622 _C_SECTION: 'C system header',
623 _CPP_SECTION: 'C++ system header',
624 _OTHER_H_SECTION: 'other header',
625 }
626
627 def __init__(self):
628 self.include_list = [[]]
629 self.ResetSection('')
630
631 def FindHeader(self, header):
632 """Check if a header has already been included.
633
634 Args:
635 header: header to check.
636 Returns:
637 Line number of previous occurrence, or -1 if the header has not
638 been seen before.
639 """
640 for section_list in self.include_list:
641 for f in section_list:
642 if f[0] == header:
643 return f[1]
644 return -1
645
646 def ResetSection(self, directive):
647 """Reset section checking for preprocessor directive.
648
649 Args:

Callers 1

ProcessFileDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected