OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2006-2008 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 |
11 # copyright notice, this list of conditions and the following | 11 # copyright notice, this list of conditions and the following |
12 # disclaimer in the documentation and/or other materials provided | 12 # disclaimer in the documentation and/or other materials provided |
13 # with the distribution. | 13 # with the distribution. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 if len(line) is 0: continue | 188 if len(line) is 0: continue |
189 const_match = CONST_PATTERN.match(line) | 189 const_match = CONST_PATTERN.match(line) |
190 if const_match: | 190 if const_match: |
191 name = const_match.group(1) | 191 name = const_match.group(1) |
192 value = const_match.group(2).strip() | 192 value = const_match.group(2).strip() |
193 constants.append((re.compile("\\b%s\\b" % name), value)) | 193 constants.append((re.compile("\\b%s\\b" % name), value)) |
194 else: | 194 else: |
195 macro_match = MACRO_PATTERN.match(line) | 195 macro_match = MACRO_PATTERN.match(line) |
196 if macro_match: | 196 if macro_match: |
197 name = macro_match.group(1) | 197 name = macro_match.group(1) |
198 args = map(string.strip, macro_match.group(2).split(',')) | 198 args = [match.strip() for match in macro_match.group(2).split(',')] |
199 body = macro_match.group(3).strip() | 199 body = macro_match.group(3).strip() |
200 macros.append((re.compile("\\b%s\\(" % name), TextMacro(args, body))) | 200 macros.append((re.compile("\\b%s\\(" % name), TextMacro(args, body))) |
201 else: | 201 else: |
202 python_match = PYTHON_MACRO_PATTERN.match(line) | 202 python_match = PYTHON_MACRO_PATTERN.match(line) |
203 if python_match: | 203 if python_match: |
204 name = python_match.group(1) | 204 name = python_match.group(1) |
205 args = map(string.strip, python_match.group(2).split(',')) | 205 args = [match.strip() for match in python_match.group(2).split(',')] |
206 body = python_match.group(3).strip() | 206 body = python_match.group(3).strip() |
207 fun = eval("lambda " + ",".join(args) + ': ' + body) | 207 fun = eval("lambda " + ",".join(args) + ': ' + body) |
208 macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun))) | 208 macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun))) |
209 else: | 209 else: |
210 raise ("Illegal line: " + line) | 210 raise ("Illegal line: " + line) |
211 return (constants, macros) | 211 return (constants, macros) |
212 | 212 |
213 | 213 |
214 HEADER_TEMPLATE = """\ | 214 HEADER_TEMPLATE = """\ |
215 // Copyright 2011 Google Inc. All Rights Reserved. | 215 // Copyright 2011 Google Inc. All Rights Reserved. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 387 |
388 def main(): | 388 def main(): |
389 natives = sys.argv[1] | 389 natives = sys.argv[1] |
390 type = sys.argv[2] | 390 type = sys.argv[2] |
391 compression = sys.argv[3] | 391 compression = sys.argv[3] |
392 source_files = sys.argv[4:] | 392 source_files = sys.argv[4:] |
393 JS2C(source_files, [natives], { 'TYPE': type, 'COMPRESSION': compression }) | 393 JS2C(source_files, [natives], { 'TYPE': type, 'COMPRESSION': compression }) |
394 | 394 |
395 if __name__ == "__main__": | 395 if __name__ == "__main__": |
396 main() | 396 main() |
OLD | NEW |