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 """code generator for GL/GLES extension wrangler.""" | 6 """code generator for GL/GLES extension wrangler.""" |
7 | 7 |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import collections | 10 import collections |
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 'arguments': | 1145 'arguments': |
1146 'Display* dpy, GLXDrawable drawable, int32* numerator, ' | 1146 'Display* dpy, GLXDrawable drawable, int32* numerator, ' |
1147 'int32* denominator' }, | 1147 'int32* denominator' }, |
1148 ] | 1148 ] |
1149 | 1149 |
1150 FUNCTION_SETS = [ | 1150 FUNCTION_SETS = [ |
1151 [GL_FUNCTIONS, 'gl', [ | 1151 [GL_FUNCTIONS, 'gl', [ |
1152 'GL/glext.h', | 1152 'GL/glext.h', |
1153 'GLES2/gl2ext.h', | 1153 'GLES2/gl2ext.h', |
1154 # Files below are Chromium-specific and shipped with Chromium sources. | 1154 # Files below are Chromium-specific and shipped with Chromium sources. |
| 1155 'GL/glextchromium.h', |
1155 'GLES2/gl2chromium.h', | 1156 'GLES2/gl2chromium.h', |
1156 'GLES2/gl2extchromium.h' | 1157 'GLES2/gl2extchromium.h' |
1157 ], []], | 1158 ], []], |
1158 [OSMESA_FUNCTIONS, 'osmesa', [], []], | 1159 [OSMESA_FUNCTIONS, 'osmesa', [], []], |
1159 [EGL_FUNCTIONS, 'egl', ['EGL/eglext.h'], | 1160 [EGL_FUNCTIONS, 'egl', [ |
| 1161 'EGL/eglext.h', |
| 1162 # Files below are Chromium-specific and shipped with Chromium sources. |
| 1163 'EGL/eglextchromium.h', |
| 1164 ], |
1160 [ | 1165 [ |
1161 'EGL_ANGLE_d3d_share_handle_client_buffer', | 1166 'EGL_ANGLE_d3d_share_handle_client_buffer', |
1162 'EGL_ANGLE_surface_d3d_texture_2d_share_handle', | 1167 'EGL_ANGLE_surface_d3d_texture_2d_share_handle', |
1163 ], | 1168 ], |
1164 ], | 1169 ], |
1165 [WGL_FUNCTIONS, 'wgl', ['GL/wglext.h'], []], | 1170 [WGL_FUNCTIONS, 'wgl', ['GL/wglext.h'], []], |
1166 [GLX_FUNCTIONS, 'glx', ['GL/glx.h', 'GL/glxext.h'], []], | 1171 [GLX_FUNCTIONS, 'glx', ['GL/glx.h', 'GL/glxext.h'], []], |
1167 ] | 1172 ] |
1168 | 1173 |
1169 def GenerateHeader(file, functions, set_name, used_extension_functions): | 1174 def GenerateHeader(file, functions, set_name, used_extension_functions): |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 | 1591 |
1587 def ParseExtensionFunctionsFromHeader(header_file): | 1592 def ParseExtensionFunctionsFromHeader(header_file): |
1588 """Parse a C extension header file and return a map from extension names to | 1593 """Parse a C extension header file and return a map from extension names to |
1589 a list of functions. | 1594 a list of functions. |
1590 | 1595 |
1591 Args: | 1596 Args: |
1592 header_file: Line-iterable C header file. | 1597 header_file: Line-iterable C header file. |
1593 Returns: | 1598 Returns: |
1594 Map of extension name => functions. | 1599 Map of extension name => functions. |
1595 """ | 1600 """ |
1596 extension_start = re.compile(r'#define ([A-Z]+_[A-Z]+_[a-zA-Z]\w+) 1') | 1601 extension_start = re.compile( |
| 1602 r'#ifndef ((?:GL|EGL|WGL|GLX)_[A-Z]+_[a-zA-Z]\w+)') |
1597 extension_function = re.compile(r'.+\s+([a-z]+\w+)\s*\(') | 1603 extension_function = re.compile(r'.+\s+([a-z]+\w+)\s*\(') |
1598 typedef = re.compile(r'typedef .*') | 1604 typedef = re.compile(r'typedef .*') |
1599 macro_start = re.compile(r'^#(if|ifdef|ifndef).*') | 1605 macro_start = re.compile(r'^#(if|ifdef|ifndef).*') |
1600 macro_end = re.compile(r'^#endif.*') | 1606 macro_end = re.compile(r'^#endif.*') |
1601 macro_depth = 0 | 1607 macro_depth = 0 |
1602 current_extension = None | 1608 current_extension = None |
1603 current_extension_depth = 0 | 1609 current_extension_depth = 0 |
1604 extensions = collections.defaultdict(lambda: []) | 1610 extensions = collections.defaultdict(lambda: []) |
1605 for line in header_file: | 1611 for line in header_file: |
1606 if macro_start.match(line): | 1612 if macro_start.match(line): |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 header_file.close() | 1787 header_file.close() |
1782 | 1788 |
1783 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') | 1789 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') |
1784 GenerateMockSource(source_file, GL_FUNCTIONS) | 1790 GenerateMockSource(source_file, GL_FUNCTIONS) |
1785 source_file.close() | 1791 source_file.close() |
1786 return 0 | 1792 return 0 |
1787 | 1793 |
1788 | 1794 |
1789 if __name__ == '__main__': | 1795 if __name__ == '__main__': |
1790 sys.exit(main(sys.argv[1:])) | 1796 sys.exit(main(sys.argv[1:])) |
OLD | NEW |