Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: tools/js2c.py

Issue 10412022: Fixing python deprecations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/jsmin.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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()
OLDNEW
« no previous file with comments | « no previous file | tools/jsmin.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698