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

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

Issue 1775353002: Add DCHECK for nullptr in gl bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | ui/gl/gl_bindings_autogen_egl.cc » ('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/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 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 log_argument_names = log_argument_names.replace(',', ' << ", " <<') 2167 log_argument_names = log_argument_names.replace(',', ' << ", " <<')
2168 if argument_names == 'void' or argument_names == '': 2168 if argument_names == 'void' or argument_names == '':
2169 argument_names = '' 2169 argument_names = ''
2170 log_argument_names = '' 2170 log_argument_names = ''
2171 else: 2171 else:
2172 log_argument_names = " << " + log_argument_names 2172 log_argument_names = " << " + log_argument_names
2173 function_name = func['known_as'] 2173 function_name = func['known_as']
2174 if return_type == 'void': 2174 if return_type == 'void':
2175 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' % 2175 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
2176 (function_name, log_argument_names)) 2176 (function_name, log_argument_names))
2177 file.write(' DCHECK(g_driver_%s.debug_fn.%sFn != nullptr);\n' %
2178 (set_name.lower(), function_name))
2177 file.write(' g_driver_%s.debug_fn.%sFn(%s);\n' % 2179 file.write(' g_driver_%s.debug_fn.%sFn(%s);\n' %
2178 (set_name.lower(), function_name, argument_names)) 2180 (set_name.lower(), function_name, argument_names))
2179 if 'logging_code' in func: 2181 if 'logging_code' in func:
2180 file.write("%s\n" % func['logging_code']) 2182 file.write("%s\n" % func['logging_code'])
2181 if options.generate_dchecks and set_name == 'gl': 2183 if options.generate_dchecks and set_name == 'gl':
2182 file.write(' {\n') 2184 file.write(' {\n')
2183 file.write(' GLenum error = g_driver_gl.debug_fn.glGetErrorFn();\n') 2185 file.write(' GLenum error = g_driver_gl.debug_fn.glGetErrorFn();\n')
2184 file.write(' DCHECK(error == 0);\n') 2186 file.write(' DCHECK(error == 0);\n')
2185 file.write(' }\n') 2187 file.write(' }\n')
2186 else: 2188 else:
2187 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' % 2189 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
2188 (function_name, log_argument_names)) 2190 (function_name, log_argument_names))
2191 file.write(' DCHECK(g_driver_%s.debug_fn.%sFn != nullptr);\n' %
2192 (set_name.lower(), function_name))
2189 file.write(' %s result = g_driver_%s.debug_fn.%sFn(%s);\n' % 2193 file.write(' %s result = g_driver_%s.debug_fn.%sFn(%s);\n' %
2190 (return_type, set_name.lower(), function_name, argument_names)) 2194 (return_type, set_name.lower(), function_name, argument_names))
2191 if 'logging_code' in func: 2195 if 'logging_code' in func:
2192 file.write("%s\n" % func['logging_code']) 2196 file.write("%s\n" % func['logging_code'])
2193 else: 2197 else:
2194 file.write(' GL_SERVICE_LOG("GL_RESULT: " << result);\n') 2198 file.write(' GL_SERVICE_LOG("GL_RESULT: " << result);\n')
2195 if options.generate_dchecks and set_name == 'gl': 2199 if options.generate_dchecks and set_name == 'gl':
2196 file.write(' {\n') 2200 file.write(' {\n')
2197 file.write(' GLenum _error = g_driver_gl.debug_fn.glGetErrorFn();\n') 2201 file.write(' GLenum _error = g_driver_gl.debug_fn.glGetErrorFn();\n')
2198 file.write(' DCHECK(_error == 0);\n') 2202 file.write(' DCHECK(_error == 0);\n')
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 'gl_enums_implementation_autogen.h'), 2779 'gl_enums_implementation_autogen.h'),
2776 'wb') 2780 'wb')
2777 GenerateEnumUtils(header_file, enum_header_filenames) 2781 GenerateEnumUtils(header_file, enum_header_filenames)
2778 header_file.close() 2782 header_file.close()
2779 ClangFormat(header_file.name) 2783 ClangFormat(header_file.name)
2780 return 0 2784 return 0
2781 2785
2782 2786
2783 if __name__ == '__main__': 2787 if __name__ == '__main__':
2784 sys.exit(main(sys.argv[1:])) 2788 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | ui/gl/gl_bindings_autogen_egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698