MCPcopy Create free account
hub / github.com/Kitware/VTK / CheckForCopyAndAssignment

Method CheckForCopyAndAssignment

Testing/Core/HeaderTesting.py:412–465  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

410 self.Error("No type macro")
411
412 def CheckForCopyAndAssignment(self):
413 if not self.ClassName:
414 return
415 count = 0
416 lines = []
417 oldlines = []
418 copyoperator = "^\\s*%s\\s*\\(\\s*const\\s*%s\\s*&\\s*\\) = delete;" % ( self.ClassName, self.ClassName)
419 asgnoperator = "^\\s*(void|%s\\s*&)\\s*operator\\s*=\\s*\\(\\s*const\\s*%s\\s*&\\s*\\) = delete;" % (self.ClassName, self.ClassName)
420 #self.Print( copyoperator
421 regx1 = re.compile(copyoperator)
422 regx2 = re.compile(asgnoperator)
423 foundcopy = 0
424 foundasgn = 0
425 for a in self.FileLines:
426 line = a.strip()
427 if regx1.match(line):
428 foundcopy = foundcopy + 1
429 if regx2.match(line):
430 foundasgn = foundasgn + 1
431 lastline = ""
432 if foundcopy < 1:
433 for a in self.FileLines:
434 line = a.strip()
435 if regx1.match(lastline + line):
436 foundcopy = foundcopy + 1
437 lastline = a
438 lastline = ""
439 if foundasgn < 1:
440 for a in self.FileLines:
441 line = a.strip()
442 if regx2.match(lastline + line):
443 foundasgn = foundasgn + 1
444 lastline = a
445
446 if foundcopy < 1:
447 self.Print( "File: %s does not define copy constructor" %
448 self.FileName )
449 self.Print( "Should be:\n%s(const %s&) = delete;" %
450 (self.ClassName, self.ClassName) )
451 self.Error("No private copy constructor")
452 if foundcopy > 1:
453 self.Print( "File: %s defines multiple copy constructors" %
454 self.FileName )
455 self.Error("Multiple copy constructor")
456 if foundasgn < 1:
457 self.Print( "File: %s does not define assignment operator" %
458 self.FileName )
459 self.Print( "Should be:\nvoid operator=(const %s&) = delete;"
460 % self.ClassName )
461 self.Error("No private assignment operator")
462 if foundcopy > 1:
463 self.Print( "File: %s defines multiple assignment operators" %
464 self.FileName )
465 self.Error("Multiple assignment operators")
466
467 def CheckWeirdConstructors(self):
468 if not self.HasClass:

Callers 1

HeaderTesting.pyFile · 0.80

Calls 4

PrintMethod · 0.95
ErrorMethod · 0.95
compileMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected