Lines Matching refs:self

45     # Prepends self.source_path to file_path if needed.
46 def actual_path(self, file_path):
48 file_path = os.path.join(self.source_path, file_path)
51 # Search included file_path in self.include_paths and
53 def find_included_file(self, file_path, source_dir):
54 search_dirs = self.include_paths[:]
60 if os.path.isfile(self.actual_path(search_path)):
64 def __init__(self, args):
68 setattr(self, key, config[key])
70 self.verbose = args.verbose == "yes"
71 self.prologue = args.prologue
72 self.source_path = args.source_path
73 self.included_files = []
76 def generate(self):
79 if self.prologue:
80 with open(self.prologue, 'r') as f:
83 if self.verbose:
85 print(" target = {0}".format(self.target))
87 print(" include_paths = {0}".format(self.include_paths))
89 for file_path in self.sources:
92 # actual_path = self.actual_path(file_path)
94 t = TranslationUnit(file_path, self, True)
97 with open(self.target, 'w') as f:
101 if self.verbose:
102 print("Files processed: {0}".format(self.sources))
103 print("Files included: {0}".format(self.included_files))
134 # Search for pattern in self.content, add the match to
136 def _search_content(self, index, pattern, contexts):
137 match = pattern.search(self.content, index)
144 def _find_skippable_contexts(self):
152 content_len = len(self.content)
155 current = self.content[i]
156 previous = self.content[j]
160 i = self._search_content(j, self.string_pattern,
164 i = self._search_content(j, self.c_comment_pattern,
168 i = self._search_content(j, self.cpp_comment_pattern,
179 def _process_pragma_once(self):
180 content_len = len(self.content)
186 skippable_contexts = self._find_skippable_contexts()
189 pragma_once_match = self.pragma_once_pattern.search(self.content)
194 pragma_once_match = self.pragma_once_pattern.search(self.content,
201 tmp_content += self.content[prev_end:pragma_match.start()]
203 tmp_content += self.content[prev_end:]
204 self.content = tmp_content
206 # Include all trivial #include directives into self.content.
207 def _process_includes(self):
208 content_len = len(self.content)
214 skippable_contexts = self._find_skippable_contexts()
219 include_match = self.include_pattern.search(self.content)
224 found_included_path = self.amalgamation.find_included_file(
225 include_path, self.file_dir if search_same_dir else None)
229 include_match = self.include_pattern.search(self.content,
237 tmp_content += self.content[prev_end:include_match.start()]
239 if found_included_path not in self.amalgamation.included_files:
240 t = TranslationUnit(found_included_path, self.amalgamation, False)
243 tmp_content += self.content[prev_end:]
244 self.content = tmp_content
249 def _process(self):
250 if not self.is_root:
251 self._process_pragma_once()
252 self._process_includes()
254 def __init__(self, file_path, amalgamation, is_root):
255 self.file_path = file_path
256 self.file_dir = os.path.dirname(file_path)
257 self.amalgamation = amalgamation
258 self.is_root = is_root
260 self.amalgamation.included_files.append(self.file_path)
262 actual_path = self.amalgamation.actual_path(file_path)
266 self.content = f.read()
267 self._process()