| 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 2958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 # Write an 'invalid' function to catch code calling through uninitialized | 2969 # Write an 'invalid' function to catch code calling through uninitialized |
| 2970 # function pointers or trying to interpret the return value of | 2970 # function pointers or trying to interpret the return value of |
| 2971 # GLProcAddress(). | 2971 # GLProcAddress(). |
| 2972 file.write('\n') | 2972 file.write('\n') |
| 2973 file.write('static void MockInvalidFunction() {\n') | 2973 file.write('static void MockInvalidFunction() {\n') |
| 2974 file.write(' NOTREACHED();\n') | 2974 file.write(' NOTREACHED();\n') |
| 2975 file.write('}\n') | 2975 file.write('}\n') |
| 2976 | 2976 |
| 2977 # Write a function to lookup a mock GL function based on its name. | 2977 # Write a function to lookup a mock GL function based on its name. |
| 2978 file.write('\n') | 2978 file.write('\n') |
| 2979 file.write('void* GL_BINDING_CALL ' + | 2979 file.write('GLFunctionPointerType GL_BINDING_CALL ' + |
| 2980 'MockGLInterface::GetGLProcAddress(const char* name) {\n') | 2980 'MockGLInterface::GetGLProcAddress(const char* name) {\n') |
| 2981 for key in sorted_function_names: | 2981 for key in sorted_function_names: |
| 2982 name = uniquely_named_functions[key]['name'] | 2982 name = uniquely_named_functions[key]['name'] |
| 2983 file.write(' if (strcmp(name, "%s") == 0)\n' % name) | 2983 file.write(' if (strcmp(name, "%s") == 0)\n' % name) |
| 2984 file.write(' return reinterpret_cast<void*>(Mock_%s);\n' % name) | 2984 file.write( |
| 2985 ' return reinterpret_cast<GLFunctionPointerType>(Mock_%s);\n' % |
| 2986 name) |
| 2985 # Always return a non-NULL pointer like some EGL implementations do. | 2987 # Always return a non-NULL pointer like some EGL implementations do. |
| 2986 file.write(' return reinterpret_cast<void*>(&MockInvalidFunction);\n') | 2988 file.write(' return reinterpret_cast<GLFunctionPointerType>(' |
| 2989 '&MockInvalidFunction);\n') |
| 2987 file.write('}\n') | 2990 file.write('}\n') |
| 2988 | 2991 |
| 2989 file.write('\n') | 2992 file.write('\n') |
| 2990 file.write('} // namespace gl\n') | 2993 file.write('} // namespace gl\n') |
| 2991 | 2994 |
| 2992 def GenerateEnumUtils(out_file, input_filenames): | 2995 def GenerateEnumUtils(out_file, input_filenames): |
| 2993 enum_re = re.compile(r'\#define\s+(GL_[a-zA-Z0-9_]+)\s+([0-9A-Fa-fx]+)') | 2996 enum_re = re.compile(r'\#define\s+(GL_[a-zA-Z0-9_]+)\s+([0-9A-Fa-fx]+)') |
| 2994 dict = {} | 2997 dict = {} |
| 2995 for fname in input_filenames: | 2998 for fname in input_filenames: |
| 2996 lines = open(fname).readlines() | 2999 lines = open(fname).readlines() |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3382 header_file = open( | 3385 header_file = open( |
| 3383 os.path.join(directory, 'gl_stub_autogen_gl.cc'), 'wb') | 3386 os.path.join(directory, 'gl_stub_autogen_gl.cc'), 'wb') |
| 3384 GenerateStubSource(header_file, GL_FUNCTIONS) | 3387 GenerateStubSource(header_file, GL_FUNCTIONS) |
| 3385 header_file.close() | 3388 header_file.close() |
| 3386 ClangFormat(header_file.name) | 3389 ClangFormat(header_file.name) |
| 3387 return 0 | 3390 return 0 |
| 3388 | 3391 |
| 3389 | 3392 |
| 3390 if __name__ == '__main__': | 3393 if __name__ == '__main__': |
| 3391 sys.exit(main(sys.argv[1:])) | 3394 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |