Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: ui/gfx/gl/generate_bindings.py

Issue 6722026: Refactor: Move app/gfx/gl ==> ui/gfx/gl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try removing a dep. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/compositor/compositor_gl.cc ('k') | ui/gfx/gl/gl.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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:])
OLDNEW
« no previous file with comments | « ui/gfx/compositor/compositor_gl.cc ('k') | ui/gfx/gl/gl.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698