| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """code generator for GL/GLES extension wrangler.""" | 7 """code generator for GL/GLES extension wrangler.""" |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 GL_FUNCTIONS = [ | 13 GL_FUNCTIONS = [ |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 [OSMESA_FUNCTIONS, 'osmesa'], | 430 [OSMESA_FUNCTIONS, 'osmesa'], |
| 431 [EGL_FUNCTIONS, 'egl'], | 431 [EGL_FUNCTIONS, 'egl'], |
| 432 [WGL_FUNCTIONS, 'wgl'], | 432 [WGL_FUNCTIONS, 'wgl'], |
| 433 [GLX_FUNCTIONS, 'glx'], | 433 [GLX_FUNCTIONS, 'glx'], |
| 434 ] | 434 ] |
| 435 | 435 |
| 436 def GenerateHeader(file, functions, set_name): | 436 def GenerateHeader(file, functions, set_name): |
| 437 """Generates gl_binding_autogen_x.h""" | 437 """Generates gl_binding_autogen_x.h""" |
| 438 | 438 |
| 439 # Write file header. | 439 # Write file header. |
| 440 file.write('// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n
') | 440 file.write('// Copyright (c) 2011 The Chromium Authors. All rights reserved.\n
') |
| 441 file.write('// Use of this source code is governed by a BSD-style license that
can be\n') | 441 file.write('// Use of this source code is governed by a BSD-style license that
can be\n') |
| 442 file.write('// found in the LICENSE file.\n') | 442 file.write('// found in the LICENSE file.\n') |
| 443 file.write('\n') | 443 file.write('\n') |
| 444 file.write('// This file is automatically generated.\n') | 444 file.write('// This file is automatically generated.\n') |
| 445 file.write('\n') | 445 file.write('\n') |
| 446 file.write('#ifndef APP_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % set_name.upper()
) | 446 file.write('#ifndef UI_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % set_name.upper()) |
| 447 file.write('#define APP_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % set_name.upper()
) | 447 file.write('#define UI_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % set_name.upper()) |
| 448 | 448 |
| 449 # Write prototype for initialization function. | 449 # Write prototype for initialization function. |
| 450 file.write('\n') | 450 file.write('\n') |
| 451 file.write('namespace gfx {\n') | 451 file.write('namespace gfx {\n') |
| 452 file.write('\n') | 452 file.write('\n') |
| 453 file.write('void InitializeGLBindings%s();\n' % set_name.upper()) | 453 file.write('void InitializeGLBindings%s();\n' % set_name.upper()) |
| 454 file.write('void InitializeDebugGLBindings%s();\n' % set_name.upper()) | 454 file.write('void InitializeDebugGLBindings%s();\n' % set_name.upper()) |
| 455 | 455 |
| 456 # Write typedefs for function pointer types. Always use the GL name for the | 456 # Write typedefs for function pointer types. Always use the GL name for the |
| 457 # typedef. | 457 # typedef. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 469 file.write( '} // namespace gfx\n') | 469 file.write( '} // namespace gfx\n') |
| 470 | 470 |
| 471 # Write macros to invoke function pointers. Always use the GL name for the | 471 # Write macros to invoke function pointers. Always use the GL name for the |
| 472 # macro. | 472 # macro. |
| 473 file.write('\n') | 473 file.write('\n') |
| 474 for [return_type, names, arguments] in functions: | 474 for [return_type, names, arguments] in functions: |
| 475 file.write('#define %s ::gfx::g_%s\n' % | 475 file.write('#define %s ::gfx::g_%s\n' % |
| 476 (names[0], names[0])) | 476 (names[0], names[0])) |
| 477 | 477 |
| 478 file.write('\n') | 478 file.write('\n') |
| 479 file.write('#endif // APP_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % | 479 file.write('#endif // UI_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % |
| 480 set_name.upper()) | 480 set_name.upper()) |
| 481 | 481 |
| 482 | 482 |
| 483 def GenerateSource(file, functions, set_name): | 483 def GenerateSource(file, functions, set_name): |
| 484 """Generates gl_binding_autogen_x.cc""" | 484 """Generates gl_binding_autogen_x.cc""" |
| 485 | 485 |
| 486 # Write file header. | 486 # Write file header. |
| 487 file.write('// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n
') | 487 file.write('// Copyright (c) 2011 The Chromium Authors. All rights reserved.\n
') |
| 488 file.write('// Use of this source code is governed by a BSD-style license that
can be\n') | 488 file.write('// Use of this source code is governed by a BSD-style license that
can be\n') |
| 489 file.write('// found in the LICENSE file.\n') | 489 file.write('// found in the LICENSE file.\n') |
| 490 file.write('\n') | 490 file.write('\n') |
| 491 file.write('// This file is automatically generated.\n') | 491 file.write('// This file is automatically generated.\n') |
| 492 file.write('\n') | 492 file.write('\n') |
| 493 file.write('#include "app/gfx/gl/gl_bindings.h"\n') | 493 file.write('#include "ui/gfx/gl/gl_bindings.h"\n') |
| 494 file.write('#include "app/gfx/gl/gl_implementation.h"\n') | 494 file.write('#include "ui/gfx/gl/gl_implementation.h"\n') |
| 495 | 495 |
| 496 # Write definitions of function pointers. | 496 # Write definitions of function pointers. |
| 497 file.write('\n') | 497 file.write('\n') |
| 498 file.write('namespace gfx {\n') | 498 file.write('namespace gfx {\n') |
| 499 file.write('\n') | 499 file.write('\n') |
| 500 for [return_type, names, arguments] in functions: | 500 for [return_type, names, arguments] in functions: |
| 501 file.write('%sProc g_%s;\n' % (names[0], names[0])) | 501 file.write('%sProc g_%s;\n' % (names[0], names[0])) |
| 502 | 502 |
| 503 file.write('\n') | 503 file.write('\n') |
| 504 for [return_type, names, arguments] in functions: | 504 for [return_type, names, arguments] in functions: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 file.write(' }\n') | 559 file.write(' }\n') |
| 560 file.write('}\n') | 560 file.write('}\n') |
| 561 file.write('\n') | 561 file.write('\n') |
| 562 | 562 |
| 563 file.write( '} // namespace gfx\n') | 563 file.write( '} // namespace gfx\n') |
| 564 | 564 |
| 565 | 565 |
| 566 def GenerateMockSource(file, functions): | 566 def GenerateMockSource(file, functions): |
| 567 """Generates functions that invoke a mock GLInterface""" | 567 """Generates functions that invoke a mock GLInterface""" |
| 568 | 568 |
| 569 file.write('// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n
') | 569 file.write('// Copyright (c) 2011 The Chromium Authors. All rights reserved.\n
') |
| 570 file.write('// Use of this source code is governed by a BSD-style license that
can be\n') | 570 file.write('// Use of this source code is governed by a BSD-style license that
can be\n') |
| 571 file.write('// found in the LICENSE file.\n') | 571 file.write('// found in the LICENSE file.\n') |
| 572 file.write('\n') | 572 file.write('\n') |
| 573 file.write('// This file is automatically generated.\n') | 573 file.write('// This file is automatically generated.\n') |
| 574 file.write('\n') | 574 file.write('\n') |
| 575 file.write('#include <string.h>\n') | 575 file.write('#include <string.h>\n') |
| 576 file.write('\n') | 576 file.write('\n') |
| 577 file.write('#include "app/gfx/gl/gl_interface.h"\n') | 577 file.write('#include "ui/gfx/gl/gl_interface.h"\n') |
| 578 | 578 |
| 579 file.write('\n') | 579 file.write('\n') |
| 580 file.write('namespace gfx {\n') | 580 file.write('namespace gfx {\n') |
| 581 | 581 |
| 582 # Write function that trampoline into the GLInterface. | 582 # Write function that trampoline into the GLInterface. |
| 583 for [return_type, names, arguments] in functions: | 583 for [return_type, names, arguments] in functions: |
| 584 file.write('\n') | 584 file.write('\n') |
| 585 file.write('%s GL_BINDING_CALL Mock_%s(%s) {\n' % | 585 file.write('%s GL_BINDING_CALL Mock_%s(%s) {\n' % |
| 586 (return_type, names[0], arguments)) | 586 (return_type, names[0], arguments)) |
| 587 argument_names = re.sub(r'(const )?[a-zA-Z0-9]+\** ([a-zA-Z0-9]+)', r'\2', | 587 argument_names = re.sub(r'(const )?[a-zA-Z0-9]+\** ([a-zA-Z0-9]+)', r'\2', |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 GenerateSource(source_file, functions, set_name) | 629 GenerateSource(source_file, functions, set_name) |
| 630 source_file.close() | 630 source_file.close() |
| 631 | 631 |
| 632 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') | 632 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') |
| 633 GenerateMockSource(source_file, GL_FUNCTIONS) | 633 GenerateMockSource(source_file, GL_FUNCTIONS) |
| 634 source_file.close() | 634 source_file.close() |
| 635 | 635 |
| 636 | 636 |
| 637 if __name__ == '__main__': | 637 if __name__ == '__main__': |
| 638 main(sys.argv[1:]) | 638 main(sys.argv[1:]) |
| OLD | NEW |