| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // javascript source files or the SConstruct script. | 193 // javascript source files or the SConstruct script. |
| 194 | 194 |
| 195 #include "v8.h" | 195 #include "v8.h" |
| 196 #include "natives.h" | 196 #include "natives.h" |
| 197 | 197 |
| 198 namespace v8 { | 198 namespace v8 { |
| 199 namespace internal { | 199 namespace internal { |
| 200 | 200 |
| 201 %(source_lines)s\ | 201 %(source_lines)s\ |
| 202 | 202 |
| 203 int Natives::GetBuiltinsCount() { | 203 template <> |
| 204 int NativesCollection<%(type)s>::GetBuiltinsCount() { |
| 204 return %(builtin_count)i; | 205 return %(builtin_count)i; |
| 205 } | 206 } |
| 206 | 207 |
| 207 int Natives::GetDelayCount() { | 208 template <> |
| 209 int NativesCollection<%(type)s>::GetDelayCount() { |
| 208 return %(delay_count)i; | 210 return %(delay_count)i; |
| 209 } | 211 } |
| 210 | 212 |
| 211 int Natives::GetIndex(const char* name) { | 213 template <> |
| 214 int NativesCollection<%(type)s>::GetIndex(const char* name) { |
| 212 %(get_index_cases)s\ | 215 %(get_index_cases)s\ |
| 213 return -1; | 216 return -1; |
| 214 } | 217 } |
| 215 | 218 |
| 216 Vector<const char> Natives::GetScriptSource(int index) { | 219 template <> |
| 220 Vector<const char> NativesCollection<%(type)s>::GetScriptSource(int index) { |
| 217 %(get_script_source_cases)s\ | 221 %(get_script_source_cases)s\ |
| 218 return Vector<const char>("", 0); | 222 return Vector<const char>("", 0); |
| 219 } | 223 } |
| 220 | 224 |
| 221 Vector<const char> Natives::GetScriptName(int index) { | 225 template <> |
| 226 Vector<const char> NativesCollection<%(type)s>::GetScriptName(int index) { |
| 222 %(get_script_name_cases)s\ | 227 %(get_script_name_cases)s\ |
| 223 return Vector<const char>("", 0); | 228 return Vector<const char>("", 0); |
| 224 } | 229 } |
| 225 | 230 |
| 226 } // internal | 231 } // internal |
| 227 } // v8 | 232 } // v8 |
| 228 """ | 233 """ |
| 229 | 234 |
| 230 | 235 |
| 231 SOURCE_DECLARATION = """\ | 236 SOURCE_DECLARATION = """\ |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 i = i + 1 | 321 i = i + 1 |
| 317 | 322 |
| 318 # Emit result | 323 # Emit result |
| 319 output = open(str(target[0]), "w") | 324 output = open(str(target[0]), "w") |
| 320 output.write(HEADER_TEMPLATE % { | 325 output.write(HEADER_TEMPLATE % { |
| 321 'builtin_count': len(ids) + len(delay_ids), | 326 'builtin_count': len(ids) + len(delay_ids), |
| 322 'delay_count': len(delay_ids), | 327 'delay_count': len(delay_ids), |
| 323 'source_lines': "\n".join(source_lines), | 328 'source_lines': "\n".join(source_lines), |
| 324 'get_index_cases': "".join(get_index_cases), | 329 'get_index_cases': "".join(get_index_cases), |
| 325 'get_script_source_cases': "".join(get_script_source_cases), | 330 'get_script_source_cases': "".join(get_script_source_cases), |
| 326 'get_script_name_cases': "".join(get_script_name_cases) | 331 'get_script_name_cases': "".join(get_script_name_cases), |
| 332 'type': env['TYPE'] |
| 327 }) | 333 }) |
| 328 output.close() | 334 output.close() |
| 329 output = open(str(target[1]), "w") | 335 |
| 330 output.write(HEADER_TEMPLATE % { | 336 if len(target) > 1: |
| 331 'builtin_count': len(ids) + len(delay_ids), | 337 output = open(str(target[1]), "w") |
| 332 'delay_count': len(delay_ids), | 338 output.write(HEADER_TEMPLATE % { |
| 333 'source_lines': "\n".join(source_lines_empty), | 339 'builtin_count': len(ids) + len(delay_ids), |
| 334 'get_index_cases': "".join(get_index_cases), | 340 'delay_count': len(delay_ids), |
| 335 'get_script_source_cases': "".join(get_script_source_cases), | 341 'source_lines': "\n".join(source_lines_empty), |
| 336 'get_script_name_cases': "".join(get_script_name_cases) | 342 'get_index_cases': "".join(get_index_cases), |
| 337 }) | 343 'get_script_source_cases': "".join(get_script_source_cases), |
| 338 output.close() | 344 'get_script_name_cases': "".join(get_script_name_cases), |
| 345 'type': env['TYPE'] |
| 346 }) |
| 347 output.close() |
| 339 | 348 |
| 340 def main(): | 349 def main(): |
| 341 natives = sys.argv[1] | 350 natives = sys.argv[1] |
| 342 natives_empty = sys.argv[2] | 351 natives_empty = sys.argv[2] |
| 343 source_files = sys.argv[3:] | 352 source_files = sys.argv[3:] |
| 344 JS2C(source_files, [natives, natives_empty], None) | 353 JS2C(source_files, [natives, natives_empty], None) |
| 345 | 354 |
| 346 if __name__ == "__main__": | 355 if __name__ == "__main__": |
| 347 main() | 356 main() |
| OLD | NEW |