| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 template <> | 253 template <> |
| 254 Vector<const char> NativesCollection<%(type)s>::GetRawScriptSource(int index)
{ | 254 Vector<const char> NativesCollection<%(type)s>::GetRawScriptSource(int index)
{ |
| 255 %(get_raw_script_source_cases)s\ | 255 %(get_raw_script_source_cases)s\ |
| 256 return Vector<const char>("", 0); | 256 return Vector<const char>("", 0); |
| 257 } | 257 } |
| 258 | 258 |
| 259 template <> | 259 template <> |
| 260 Vector<const char> NativesCollection<%(type)s>::GetScriptName(int index) { | 260 Vector<const char> NativesCollection<%(type)s>::GetScriptName(int index) { |
| 261 %(get_script_name_cases)s\ | 261 %(get_script_name_cases)s\ |
| 262 return Vector<const char>("", 0); | 262 return Vector<const char>("", 1); |
| 263 } | 263 } |
| 264 | 264 |
| 265 template <> | 265 template <> |
| 266 Vector<const byte> NativesCollection<%(type)s>::GetScriptsSource() { | 266 Vector<const byte> NativesCollection<%(type)s>::GetScriptsSource() { |
| 267 return Vector<const byte>(sources, %(total_length)i); | 267 return Vector<const byte>(sources, %(total_length)i); |
| 268 } | 268 } |
| 269 | 269 |
| 270 template <> | 270 template <> |
| 271 void NativesCollection<%(type)s>::SetRawScriptsSource(Vector<const char> raw_s
ource) { | 271 void NativesCollection<%(type)s>::SetRawScriptsSource(Vector<const char> raw_s
ource) { |
| 272 ASSERT(%(raw_total_length)i == raw_source.length()); | 272 ASSERT(%(raw_total_length)i == raw_source.length()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 for (id, raw_length, module_offset) in debugger_ids + ids: | 357 for (id, raw_length, module_offset) in debugger_ids + ids: |
| 358 native_name = "native %s.js" % id | 358 native_name = "native %s.js" % id |
| 359 get_index_cases.append(GET_INDEX_CASE % { 'id': id, 'i': i }) | 359 get_index_cases.append(GET_INDEX_CASE % { 'id': id, 'i': i }) |
| 360 get_raw_script_source_cases.append(GET_RAW_SCRIPT_SOURCE_CASE % { | 360 get_raw_script_source_cases.append(GET_RAW_SCRIPT_SOURCE_CASE % { |
| 361 'offset': module_offset, | 361 'offset': module_offset, |
| 362 'raw_length': raw_length, | 362 'raw_length': raw_length, |
| 363 'i': i | 363 'i': i |
| 364 }) | 364 }) |
| 365 get_script_name_cases.append(GET_SCRIPT_NAME_CASE % { | 365 get_script_name_cases.append(GET_SCRIPT_NAME_CASE % { |
| 366 'name': native_name, | 366 'name': native_name, |
| 367 'length': len(native_name), | 367 'length': len(native_name) + 1, |
| 368 'i': i | 368 'i': i |
| 369 }) | 369 }) |
| 370 i = i + 1 | 370 i = i + 1 |
| 371 | 371 |
| 372 # Emit result | 372 # Emit result |
| 373 output = open(str(target[0]), "w") | 373 output = open(str(target[0]), "w") |
| 374 output.write(HEADER_TEMPLATE % { | 374 output.write(HEADER_TEMPLATE % { |
| 375 'builtin_count': len(ids) + len(debugger_ids), | 375 'builtin_count': len(ids) + len(debugger_ids), |
| 376 'debugger_count': len(debugger_ids), | 376 'debugger_count': len(debugger_ids), |
| 377 'sources_data': sources_data, | 377 'sources_data': sources_data, |
| 378 'raw_sources_declaration': raw_sources_declaration, | 378 'raw_sources_declaration': raw_sources_declaration, |
| 379 'raw_total_length': raw_total_length, | 379 'raw_total_length': raw_total_length, |
| 380 'total_length': total_length, | 380 'total_length': total_length, |
| 381 'get_index_cases': "".join(get_index_cases), | 381 'get_index_cases': "".join(get_index_cases), |
| 382 'get_raw_script_source_cases': "".join(get_raw_script_source_cases), | 382 'get_raw_script_source_cases': "".join(get_raw_script_source_cases), |
| 383 'get_script_name_cases': "".join(get_script_name_cases), | 383 'get_script_name_cases': "".join(get_script_name_cases), |
| 384 'type': env['TYPE'] | 384 'type': env['TYPE'] |
| 385 }) | 385 }) |
| 386 output.close() | 386 output.close() |
| 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 |