OLD | NEW |
---|---|
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import ast | 5 import ast |
6 import optparse | 6 import optparse |
7 import os.path | 7 import os.path |
8 import re | 8 import re |
9 import sys | 9 import sys |
10 | 10 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 min_type_tokens = 2 if re.match("(const|unsigned long) ", param_decl) el se 1 | 148 min_type_tokens = 2 if re.match("(const|unsigned long) ", param_decl) el se 1 |
149 | 149 |
150 if len(param_decl.split(" ")) > min_type_tokens: | 150 if len(param_decl.split(" ")) > min_type_tokens: |
151 parts = param_decl.split(" ") | 151 parts = param_decl.split(" ") |
152 self.type = " ".join(parts[:-1]) | 152 self.type = " ".join(parts[:-1]) |
153 self.name = parts[-1] | 153 self.name = parts[-1] |
154 else: | 154 else: |
155 self.type = param_decl | 155 self.type = param_decl |
156 self.name = build_param_name(self.type) | 156 self.name = build_param_name(self.type) |
157 | 157 |
158 self.value = self.name | 158 self.is_rp = re.match(r"RefPtr<", param_decl) is not None |
alph
2017/04/27 22:57:04
doesn't seems to be used outside the function.
| |
159 self.is_prp = re.match(r"PassRefPtr<", param_decl) is not None | 159 if self.is_rp: |
160 if self.is_prp: | 160 self.name = "rp" + self.name[0].upper() + self.name[1:] |
alph
2017/04/27 22:57:04
In fact, you don't really need to mangle the name
Bugs Nash
2017/04/27 23:05:59
Nope, I just thought rpInnerTypeName was more read
| |
161 self.name = "prp" + self.name[0].upper() + self.name[1:] | |
162 self.inner_type = re.match(r"PassRefPtr<(.+)>", param_decl).group(1) | |
163 | 161 |
164 if self.type[-1] == "*" and "char" not in self.type: | 162 if self.type[-1] == "*" and "char" not in self.type: |
165 self.member_type = "Member<%s>" % self.type[:-1] | 163 self.member_type = "Member<%s>" % self.type[:-1] |
166 else: | 164 else: |
167 self.member_type = self.type | 165 self.member_type = self.type |
168 | 166 |
169 | 167 |
170 def build_param_name(param_type): | 168 def build_param_name(param_type): |
171 base_name = re.match(r"(const |PassRefPtr<)?(\w*)", param_type).group(2) | 169 return "param" + re.match(r"(const |RefPtr<)?(\w*)", param_type).group(2) |
172 return "param" + base_name | |
173 | 170 |
174 | 171 |
175 def load_config(file_name): | 172 def load_config(file_name): |
176 default_config = { | 173 default_config = { |
177 "settings": {}, | 174 "settings": {}, |
178 "observers": {} | 175 "observers": {} |
179 } | 176 } |
180 if not file_name: | 177 if not file_name: |
181 return default_config | 178 return default_config |
182 with open(file_name) as config_file: | 179 with open(file_name) as config_file: |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "Sink.h", "w" ) | 256 sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "Sink.h", "w" ) |
260 sink_h_file.write(sink_h_template.render(template_context)) | 257 sink_h_file.write(sink_h_template.render(template_context)) |
261 sink_h_file.close() | 258 sink_h_file.close() |
262 | 259 |
263 for f in files: | 260 for f in files: |
264 template_context["file"] = f | 261 template_context["file"] = f |
265 h_template = jinja_env.get_template("/InstrumentingProbesInl.h.tmpl") | 262 h_template = jinja_env.get_template("/InstrumentingProbesInl.h.tmpl") |
266 h_file = open(output_dirpath + "/" + f.header_name + ".h", "w") | 263 h_file = open(output_dirpath + "/" + f.header_name + ".h", "w") |
267 h_file.write(h_template.render(template_context)) | 264 h_file.write(h_template.render(template_context)) |
268 h_file.close() | 265 h_file.close() |
OLD | NEW |