| 262 | self.Error("Does not include parent") |
| 263 | |
| 264 | def CheckGuard(self): |
| 265 | guardre = r"^#ifndef\s+([^ ]*)_h$" |
| 266 | guardsetre = r"^#define\s+([^ ]*)_h$" |
| 267 | guardpragmare = r"^#pragma\s+once$" |
| 268 | guardrex = re.compile(guardre) |
| 269 | guardsetrex = re.compile(guardsetre) |
| 270 | guardpragmarex = re.compile(guardpragmare) |
| 271 | |
| 272 | guard = None |
| 273 | guard_set = None |
| 274 | expect_trigger = False |
| 275 | for line in self.FileLines: |
| 276 | line = line.strip() |
| 277 | if expect_trigger: |
| 278 | gs = guardsetrex.match(line) |
| 279 | if gs: |
| 280 | guard_set = gs.group(1) |
| 281 | break |
| 282 | g = guardrex.match(line) |
| 283 | gp = guardpragmarex.match(line) |
| 284 | if g: |
| 285 | guard = g.group(1) |
| 286 | expect_trigger = True |
| 287 | elif gp: |
| 288 | guard = self.FileName |
| 289 | guard_set = guard |
| 290 | |
| 291 | if not guard or not guard_set: |
| 292 | self.Print("File: %s is missing a header guard." % self.FileName) |
| 293 | self.Error("Missing header guard") |
| 294 | elif not guard == guard_set: |
| 295 | self.Print("File: %s is not guarded properly." % self.FileName) |
| 296 | self.Error("Guard does is not set properly") |
| 297 | elif not os.path.basename(self.FileName) in ('%s.h' % guard): |
| 298 | self.Print("File: %s has a guard (%s) which does not match its filename." % (self.FileName, guard)) |
| 299 | self.Error("Guard does not match the filename") |
| 300 | |
| 301 | def CheckParent(self): |
| 302 | if not self.HasClass: |