MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / ProcessClassFromFile

Class ProcessClassFromFile

Utilities/ParseForExplicitInstantiation.py:42–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41
42class ProcessClassFromFile:
43 def __init__(
44 self, inputHeader, minimumRepeatNumber, inputSymbolsFile="/tmp/Symbols.list"
45 ):
46
47 self.minimumRepeatNumber = minimumRepeatNumber
48
49 self.inputHeaderFullPath = os.path.realpath(inputHeader)
50 self.FileClassToMakeExplicit = os.path.basename(self.inputHeaderFullPath)
51 self.BaseClassName = self.FileClassToMakeExplicit.replace("itk", "").replace(
52 ".h", ""
53 )
54 self.basePath = os.path.dirname(os.path.dirname(self.inputHeaderFullPath))
55 print("basePath: ", self.basePath)
56 print("BaseClassName: ", self.BaseClassName)
57
58 self.ExplicitHeaderFileName = os.path.join(
59 self.basePath, "include", "sitkExplicitITK{0}.h".format(self.BaseClassName)
60 )
61 self.CodeFileName = os.path.join(
62 self.basePath, "src", "sitkExplicitITK{0}.cxx".format(self.BaseClassName)
63 )
64 self._ParseForExtraDirectives()
65 self.HeaderString = ""
66 self.CodeString = ""
67 self._ParseSymbolFile(inputSymbolsFile)
68 self._MakeHeaderAndCodeStrings()
69 self._GenerateFiles()
70
71 def _ParseSymbolFile(self, inputSymbolsFile):
72 self.SymbolsMapping = collections.defaultdict(int)
73
74 nm_link_objects = re.compile(
75 "[0-9a-f]* [SWwn] itk::"
76 + self.BaseClassName
77 + "<(.*)>::~"
78 + self.BaseClassName
79 + "\(\)"
80 )
81
82 with open(inputSymbolsFile, "r") as isf:
83 all_lines = isf.readlines()
84
85 for thisline in all_lines:
86 # Do requested substitutions
87 for subsPat in self.subsPatterns:
88 thisline = thisline.replace("std::__1::", "std::")
89 thisline = thisline.replace(subsPat[0], subsPat[1])
90 # Remove items from exclude matches
91 for excludePat in self.excludePatterns:
92 if thisline.find(excludePat) != -1:
93 thisline = ""
94 nm_search_match = nm_link_objects.search(thisline)
95 if nm_search_match:
96 TemplatePayLoad = nm_search_match.groups()[0]
97 TemplateInstance = "itk::{0}<{1}>".format(
98 self.BaseClassName, TemplatePayLoad
99 )

Calls

no outgoing calls

Tested by

no test coverage detected