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

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

Issue 2136223002: Introduce GLStubApi (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 'GLES2/gl2.h', 1862 'GLES2/gl2.h',
1863 'GLES2/gl2ext.h', 1863 'GLES2/gl2ext.h',
1864 'GLES2/gl2chromium.h', 1864 'GLES2/gl2chromium.h',
1865 'GLES2/gl2extchromium.h', 1865 'GLES2/gl2extchromium.h',
1866 'GLES3/gl3.h', 1866 'GLES3/gl3.h',
1867 ] 1867 ]
1868 1868
1869 SELF_LOCATION = os.path.dirname(os.path.abspath(__file__)) 1869 SELF_LOCATION = os.path.dirname(os.path.abspath(__file__))
1870 1870
1871 LICENSE_AND_HEADER = """\ 1871 LICENSE_AND_HEADER = """\
1872 // Copyright 2014 The Chromium Authors. All rights reserved. 1872 // Copyright 2016 The Chromium Authors. All rights reserved.
1873 // Use of this source code is governed by a BSD-style license that can be 1873 // Use of this source code is governed by a BSD-style license that can be
1874 // found in the LICENSE file. 1874 // found in the LICENSE file.
1875 // 1875 //
1876 // This file is auto-generated from 1876 // This file is auto-generated from
1877 // ui/gl/generate_bindings.py 1877 // ui/gl/generate_bindings.py
1878 // It's formatted by clang-format using chromium coding style: 1878 // It's formatted by clang-format using chromium coding style:
1879 // clang-format -i -style=chromium filename 1879 // clang-format -i -style=chromium filename
1880 // DO NOT EDIT! 1880 // DO NOT EDIT!
1881 1881
1882 """ 1882 """
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 if arg_count <= 10: 2030 if arg_count <= 10:
2031 file.write(' MOCK_METHOD%d(%s, %s(%s));\n' % 2031 file.write(' MOCK_METHOD%d(%s, %s(%s));\n' %
2032 (arg_count, func['known_as'][2:], func['return_type'], args)) 2032 (arg_count, func['known_as'][2:], func['return_type'], args))
2033 else: 2033 else:
2034 file.write(' // TODO(zmo): crbug.com/456340\n') 2034 file.write(' // TODO(zmo): crbug.com/456340\n')
2035 file.write(' // %s cannot be mocked because it has %d args.\n' % 2035 file.write(' // %s cannot be mocked because it has %d args.\n' %
2036 (func['known_as'], arg_count)) 2036 (func['known_as'], arg_count))
2037 2037
2038 file.write('\n') 2038 file.write('\n')
2039 2039
2040 def GenerateStubHeader(file, functions):
2041 """Generates gl_stub_autogen_gl.h"""
2042
2043 # Write file header.
2044 file.write(LICENSE_AND_HEADER)
2045
2046 # Write API declaration.
2047 for func in functions:
2048 args = func['arguments']
2049 if args == 'void':
2050 args = ''
2051 return_type = func['return_type'];
2052 file.write(' %s gl%sFn(%s) override' % (return_type, func['known_as'][2:],
2053 args))
2054 if return_type == 'void':
2055 file.write(' {}\n');
2056 else:
2057 file.write(';\n');
2058
2059 file.write('\n')
2060
2061 def GenerateStubSource(file, functions):
2062 """Generates gl_stub_autogen_gl.cc"""
2063
2064 # Write file header.
2065 file.write(LICENSE_AND_HEADER)
2066 file.write('\n#include "ui/gl/gl_stub_api_base.h"\n\n')
2067 file.write('namespace gl {\n\n')
2068
2069 # Write API declaration.
2070 for func in functions:
2071 return_type = func['return_type'];
2072 if return_type == 'void':
2073 continue
2074 args = func['arguments']
2075 if args == 'void':
2076 args = ''
2077 file.write('%s GLStubApiBase::gl%sFn(%s) {\n' % (return_type,
2078 func['known_as'][2:],
2079 args))
2080 file.write(' return 0;\n');
2081 file.write('}\n\n');
2082
2083 file.write('\n} // namespace gl\n')
2084
2040 2085
2041 def GenerateSource(file, functions, set_name, used_extensions, 2086 def GenerateSource(file, functions, set_name, used_extensions,
2042 used_client_extensions, options): 2087 used_client_extensions, options):
2043 """Generates gl_bindings_autogen_x.cc""" 2088 """Generates gl_bindings_autogen_x.cc"""
2044 2089
2045 set_header_name = "ui/gl/gl_" + set_name.lower() + "_api_implementation.h" 2090 set_header_name = "ui/gl/gl_" + set_name.lower() + "_api_implementation.h"
2046 include_list = [ 'base/trace_event/trace_event.h', 2091 include_list = [ 'base/trace_event/trace_event.h',
2047 'ui/gl/gl_enums.h', 2092 'ui/gl/gl_enums.h',
2048 'ui/gl/gl_bindings.h', 2093 'ui/gl/gl_bindings.h',
2049 'ui/gl/gl_context.h', 2094 'ui/gl/gl_context.h',
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 ClangFormat(source_file.name) 2916 ClangFormat(source_file.name)
2872 2917
2873 enum_header_filenames = [ResolveHeader(h, HEADER_PATHS) 2918 enum_header_filenames = [ResolveHeader(h, HEADER_PATHS)
2874 for h in GLES2_HEADERS_WITH_ENUMS] 2919 for h in GLES2_HEADERS_WITH_ENUMS]
2875 header_file = open(os.path.join(directory, 2920 header_file = open(os.path.join(directory,
2876 'gl_enums_implementation_autogen.h'), 2921 'gl_enums_implementation_autogen.h'),
2877 'wb') 2922 'wb')
2878 GenerateEnumUtils(header_file, enum_header_filenames) 2923 GenerateEnumUtils(header_file, enum_header_filenames)
2879 header_file.close() 2924 header_file.close()
2880 ClangFormat(header_file.name) 2925 ClangFormat(header_file.name)
2926
2927 header_file = open(
2928 os.path.join(directory, 'gl_stub_autogen_gl.h'), 'wb')
2929 GenerateStubHeader(header_file, GL_FUNCTIONS)
2930 header_file.close()
2931 ClangFormat(header_file.name)
2932
2933 header_file = open(
2934 os.path.join(directory, 'gl_stub_autogen_gl.cc'), 'wb')
2935 GenerateStubSource(header_file, GL_FUNCTIONS)
2936 header_file.close()
2937 ClangFormat(header_file.name)
2881 return 0 2938 return 0
2882 2939
2883 2940
2884 if __name__ == '__main__': 2941 if __name__ == '__main__':
2885 sys.exit(main(sys.argv[1:])) 2942 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « ui/gl/BUILD.gn ('k') | ui/gl/gl.gyp » ('j') | ui/gl/gl_gl_api_implementation.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698