| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ Generator for C++ style thunks """ | 6 """ Generator for C++ style thunks """ |
| 7 | 7 |
| 8 import glob | 8 import glob |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 453 |
| 454 if meta.BuiltinIncludes(): | 454 if meta.BuiltinIncludes(): |
| 455 for include in sorted(meta.BuiltinIncludes()): | 455 for include in sorted(meta.BuiltinIncludes()): |
| 456 out.Write('#include <%s>\n' % include) | 456 out.Write('#include <%s>\n' % include) |
| 457 out.Write('\n') | 457 out.Write('\n') |
| 458 | 458 |
| 459 # TODO(teravest): Don't emit includes we don't need. | 459 # TODO(teravest): Don't emit includes we don't need. |
| 460 includes = ['ppapi/c/pp_errors.h', | 460 includes = ['ppapi/c/pp_errors.h', |
| 461 'ppapi/shared_impl/tracked_callback.h', | 461 'ppapi/shared_impl/tracked_callback.h', |
| 462 'ppapi/thunk/enter.h', | 462 'ppapi/thunk/enter.h', |
| 463 'ppapi/thunk/ppb_instance_api.h', | 463 'ppapi/thunk/ppapi_thunk_export.h'] |
| 464 'ppapi/thunk/resource_creation_api.h', | |
| 465 'ppapi/thunk/thunk.h'] | |
| 466 includes.append(_GetHeaderFileName(filenode)) | 464 includes.append(_GetHeaderFileName(filenode)) |
| 467 for api in meta.Apis(): | 465 for api in meta.Apis(): |
| 468 includes.append('%s' % api.lower()) | 466 includes.append('%s' % api.lower()) |
| 469 for i in meta.Includes(): | 467 for i in meta.Includes(): |
| 470 includes.append(i) | 468 includes.append(i) |
| 471 for include in sorted(includes): | 469 for include in sorted(includes): |
| 472 out.Write('#include "%s"\n' % include) | 470 out.Write('#include "%s"\n' % include) |
| 473 out.Write('\n') | 471 out.Write('\n') |
| 474 out.Write('namespace ppapi {\n') | 472 out.Write('namespace ppapi {\n') |
| 475 out.Write('namespace thunk {\n') | 473 out.Write('namespace thunk {\n') |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 version = child.GetVersion( | 538 version = child.GetVersion( |
| 541 child.first_release[build]).replace('.', '_') | 539 child.first_release[build]).replace('.', '_') |
| 542 name += '_' + version | 540 name += '_' + version |
| 543 generated_functions.append(name) | 541 generated_functions.append(name) |
| 544 out.Write(',\n'.join([' &%s' % f for f in generated_functions])) | 542 out.Write(',\n'.join([' &%s' % f for f in generated_functions])) |
| 545 out.Write('\n};\n\n') | 543 out.Write('\n};\n\n') |
| 546 | 544 |
| 547 out.Write('} // namespace\n') | 545 out.Write('} // namespace\n') |
| 548 out.Write('\n') | 546 out.Write('\n') |
| 549 for thunk_type, thunk_name in version_list: | 547 for thunk_type, thunk_name in version_list: |
| 550 thunk_decl = 'const %s* Get%s_Thunk() {\n' % (thunk_type, thunk_type) | 548 thunk_decl = ('PPAPI_THUNK_EXPORT const %s* Get%s_Thunk() {\n' % |
| 549 (thunk_type, thunk_type)) |
| 551 if len(thunk_decl) > 80: | 550 if len(thunk_decl) > 80: |
| 552 thunk_decl = 'const %s*\n Get%s_Thunk() {\n' % (thunk_type, | 551 thunk_decl = ('PPAPI_THUNK_EXPORT const %s*\n Get%s_Thunk() {\n' % |
| 553 thunk_type) | 552 (thunk_type, thunk_type)) |
| 554 out.Write(thunk_decl) | 553 out.Write(thunk_decl) |
| 555 out.Write(' return &%s;\n' % thunk_name) | 554 out.Write(' return &%s;\n' % thunk_name) |
| 556 out.Write('}\n') | 555 out.Write('}\n') |
| 557 out.Write('\n') | 556 out.Write('\n') |
| 558 out.Write('} // namespace thunk\n') | 557 out.Write('} // namespace thunk\n') |
| 559 out.Write('} // namespace ppapi\n') | 558 out.Write('} // namespace ppapi\n') |
| 560 | 559 |
| 561 | 560 |
| 562 tgen = TGen() | 561 tgen = TGen() |
| 563 | 562 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 578 print "Golden file for M13-M15 failed." | 577 print "Golden file for M13-M15 failed." |
| 579 failed = 1 | 578 failed = 1 |
| 580 else: | 579 else: |
| 581 print "Golden file for M13-M15 passed." | 580 print "Golden file for M13-M15 passed." |
| 582 | 581 |
| 583 return failed | 582 return failed |
| 584 | 583 |
| 585 | 584 |
| 586 if __name__ == '__main__': | 585 if __name__ == '__main__': |
| 587 sys.exit(Main(sys.argv[1:])) | 586 sys.exit(Main(sys.argv[1:])) |
| OLD | NEW |