| 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 2006-2008 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 197           args = map(string.strip, python_match.group(2).split(',')) | 197           args = map(string.strip, python_match.group(2).split(',')) | 
| 198           body = python_match.group(3).strip() | 198           body = python_match.group(3).strip() | 
| 199           fun = eval("lambda " + ",".join(args) + ': ' + body) | 199           fun = eval("lambda " + ",".join(args) + ': ' + body) | 
| 200           macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun))) | 200           macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun))) | 
| 201         else: | 201         else: | 
| 202           raise ("Illegal line: " + line) | 202           raise ("Illegal line: " + line) | 
| 203   return (constants, macros) | 203   return (constants, macros) | 
| 204 | 204 | 
| 205 | 205 | 
| 206 HEADER_TEMPLATE = """\ | 206 HEADER_TEMPLATE = """\ | 
| 207 // Copyright 2008 Google Inc. All Rights Reserved. | 207 // Copyright 2011 Google Inc. All Rights Reserved. | 
| 208 | 208 | 
| 209 // This file was generated from .js source files by SCons.  If you | 209 // This file was generated from .js source files by SCons.  If you | 
| 210 // want to make changes to this file you should either change the | 210 // want to make changes to this file you should either change the | 
| 211 // javascript source files or the SConstruct script. | 211 // javascript source files or the SConstruct script. | 
| 212 | 212 | 
| 213 #include "v8.h" | 213 #include "v8.h" | 
| 214 #include "natives.h" | 214 #include "natives.h" | 
| 215 | 215 | 
| 216 namespace v8 { | 216 namespace v8 { | 
| 217 namespace internal { | 217 namespace internal { | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 281     if 'macros.py' == (os.path.split(str(s))[1]): | 281     if 'macros.py' == (os.path.split(str(s))[1]): | 
| 282       (consts, macros) = ReadMacros(ReadLines(str(s))) | 282       (consts, macros) = ReadMacros(ReadLines(str(s))) | 
| 283     else: | 283     else: | 
| 284       modules.append(s) | 284       modules.append(s) | 
| 285 | 285 | 
| 286   # Build source code lines | 286   # Build source code lines | 
| 287   source_lines = [ ] | 287   source_lines = [ ] | 
| 288 | 288 | 
| 289   minifier = jsmin.JavaScriptMinifier() | 289   minifier = jsmin.JavaScriptMinifier() | 
| 290 | 290 | 
| 291   source_lines_empty = [] |  | 
| 292   for module in modules: | 291   for module in modules: | 
| 293     filename = str(module) | 292     filename = str(module) | 
| 294     debugger = filename.endswith('-debugger.js') | 293     debugger = filename.endswith('-debugger.js') | 
| 295     lines = ReadFile(filename) | 294     lines = ReadFile(filename) | 
| 296     lines = ExpandConstants(lines, consts) | 295     lines = ExpandConstants(lines, consts) | 
| 297     lines = ExpandMacros(lines, macros) | 296     lines = ExpandMacros(lines, macros) | 
| 298     Validate(lines, filename) | 297     Validate(lines, filename) | 
| 299     lines = minifier.JSMinify(lines) | 298     lines = minifier.JSMinify(lines) | 
| 300     data = ToCArray(lines) | 299     data = ToCArray(lines) | 
| 301     id = (os.path.split(filename)[1])[:-3] | 300     id = (os.path.split(filename)[1])[:-3] | 
| 302     if debugger: id = id[:-9] | 301     if debugger: id = id[:-9] | 
| 303     if debugger: | 302     if debugger: | 
| 304       debugger_ids.append((id, len(lines))) | 303       debugger_ids.append((id, len(lines))) | 
| 305     else: | 304     else: | 
| 306       ids.append((id, len(lines))) | 305       ids.append((id, len(lines))) | 
| 307     source_lines.append(SOURCE_DECLARATION % { 'id': id, 'data': data }) | 306     source_lines.append(SOURCE_DECLARATION % { 'id': id, 'data': data }) | 
| 308     source_lines_empty.append(SOURCE_DECLARATION % { 'id': id, 'data': data }) |  | 
| 309 | 307 | 
| 310   # Build debugger support functions | 308   # Build debugger support functions | 
| 311   get_index_cases = [ ] | 309   get_index_cases = [ ] | 
| 312   get_script_source_cases = [ ] | 310   get_script_source_cases = [ ] | 
| 313   get_script_name_cases = [ ] | 311   get_script_name_cases = [ ] | 
| 314 | 312 | 
| 315   i = 0 | 313   i = 0 | 
| 316   for (id, length) in debugger_ids: | 314   for (id, length) in debugger_ids: | 
| 317     native_name = "native %s.js" % id | 315     native_name = "native %s.js" % id | 
| 318     get_index_cases.append(GET_DEBUGGER_INDEX_CASE % { 'id': id, 'i': i }) | 316     get_index_cases.append(GET_DEBUGGER_INDEX_CASE % { 'id': id, 'i': i }) | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 349     'builtin_count': len(ids) + len(debugger_ids), | 347     'builtin_count': len(ids) + len(debugger_ids), | 
| 350     'debugger_count': len(debugger_ids), | 348     'debugger_count': len(debugger_ids), | 
| 351     'source_lines': "\n".join(source_lines), | 349     'source_lines': "\n".join(source_lines), | 
| 352     'get_index_cases': "".join(get_index_cases), | 350     'get_index_cases': "".join(get_index_cases), | 
| 353     'get_script_source_cases': "".join(get_script_source_cases), | 351     'get_script_source_cases': "".join(get_script_source_cases), | 
| 354     'get_script_name_cases': "".join(get_script_name_cases), | 352     'get_script_name_cases': "".join(get_script_name_cases), | 
| 355     'type': env['TYPE'] | 353     'type': env['TYPE'] | 
| 356   }) | 354   }) | 
| 357   output.close() | 355   output.close() | 
| 358 | 356 | 
| 359   if len(target) > 1: |  | 
| 360     output = open(str(target[1]), "w") |  | 
| 361     output.write(HEADER_TEMPLATE % { |  | 
| 362       'builtin_count': len(ids) + len(debugger_ids), |  | 
| 363       'debugger_count': len(debugger_ids), |  | 
| 364       'source_lines': "\n".join(source_lines_empty), |  | 
| 365       'get_index_cases': "".join(get_index_cases), |  | 
| 366       'get_script_source_cases': "".join(get_script_source_cases), |  | 
| 367       'get_script_name_cases': "".join(get_script_name_cases), |  | 
| 368       'type': env['TYPE'] |  | 
| 369     }) |  | 
| 370     output.close() |  | 
| 371 |  | 
| 372 def main(): | 357 def main(): | 
| 373   natives = sys.argv[1] | 358   natives = sys.argv[1] | 
| 374   natives_empty = sys.argv[2] | 359   type = sys.argv[2] | 
| 375   type = sys.argv[3] | 360   source_files = sys.argv[3:] | 
| 376   source_files = sys.argv[4:] | 361   JS2C(source_files, [natives], { 'TYPE': type }) | 
| 377   JS2C(source_files, [natives, natives_empty], { 'TYPE': type }) |  | 
| 378 | 362 | 
| 379 if __name__ == "__main__": | 363 if __name__ == "__main__": | 
| 380   main() | 364   main() | 
| OLD | NEW | 
|---|