OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 name = python_match.group(1) | 185 name = python_match.group(1) |
186 args = [match.strip() for match in python_match.group(2).split(',')] | 186 args = [match.strip() for match in python_match.group(2).split(',')] |
187 body = python_match.group(3).strip() | 187 body = python_match.group(3).strip() |
188 fun = eval("lambda " + ",".join(args) + ': ' + body) | 188 fun = eval("lambda " + ",".join(args) + ': ' + body) |
189 macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun))) | 189 macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun))) |
190 else: | 190 else: |
191 raise Error("Illegal line: " + line) | 191 raise Error("Illegal line: " + line) |
192 return (constants, macros) | 192 return (constants, macros) |
193 | 193 |
194 | 194 |
195 TEMPLATE_PATTERN = re.compile(r'^\s+T\(([a-zA-Z]+), ".+"\)') | 195 TEMPLATE_PATTERN = re.compile(r'^\s+T\(([A-Z][a-zA-Z]*),') |
196 | 196 |
197 def ReadMessageTemplates(lines): | 197 def ReadMessageTemplates(lines): |
198 templates = [] | 198 templates = [] |
199 index = 0 | 199 index = 0 |
200 for line in lines.split('\n'): | 200 for line in lines.split('\n'): |
201 template_match = TEMPLATE_PATTERN.match(line) | 201 template_match = TEMPLATE_PATTERN.match(line) |
202 if template_match: | 202 if template_match: |
203 name = "k%s" % template_match.group(1) | 203 name = "k%s" % template_match.group(1) |
204 value = index | 204 value = index |
205 index = index + 1 | 205 index = index + 1 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 out.cc: C code to be generated. | 557 out.cc: C code to be generated. |
558 type: type parameter for NativesCollection template. | 558 type: type parameter for NativesCollection template. |
559 sources.js: JS internal sources or macros.py.""") | 559 sources.js: JS internal sources or macros.py.""") |
560 (options, args) = parser.parse_args() | 560 (options, args) = parser.parse_args() |
561 | 561 |
562 JS2C(args[2:], args[0], args[1], options.raw, options.startup_blob) | 562 JS2C(args[2:], args[0], args[1], options.raw, options.startup_blob) |
563 | 563 |
564 | 564 |
565 if __name__ == "__main__": | 565 if __name__ == "__main__": |
566 main() | 566 main() |
OLD | NEW |