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 GLES2 command buffers.""" | 6 """code generator for GLES2 command buffers.""" |
7 | 7 |
8 import itertools | 8 import itertools |
9 import os | 9 import os |
10 import os.path | 10 import os.path |
(...skipping 8280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8291 if _NAMED_TYPE_INFO[type_info]['type'] == 'GLenum': | 8291 if _NAMED_TYPE_INFO[type_info]['type'] == 'GLenum': |
8292 file.Write("static std::string GetString%s(uint32_t value);\n" % | 8292 file.Write("static std::string GetString%s(uint32_t value);\n" % |
8293 type_info) | 8293 type_info) |
8294 file.Write("\n") | 8294 file.Write("\n") |
8295 file.Close() | 8295 file.Close() |
8296 self.generated_cpp_filenames.append(file.filename) | 8296 self.generated_cpp_filenames.append(file.filename) |
8297 | 8297 |
8298 def WriteCommonUtilsImpl(self, filename): | 8298 def WriteCommonUtilsImpl(self, filename): |
8299 """Writes the gles2 common utility header.""" | 8299 """Writes the gles2 common utility header.""" |
8300 enum_re = re.compile(r'\#define\s+(GL_[a-zA-Z0-9_]+)\s+([0-9A-Fa-fx]+)') | 8300 enum_re = re.compile(r'\#define\s+(GL_[a-zA-Z0-9_]+)\s+([0-9A-Fa-fx]+)') |
8301 chromium_re = re.compile(r'[a-zA-Z0-9_]+_CHROMIUM$') | |
8301 dict = {} | 8302 dict = {} |
8302 for fname in ['third_party/khronos/GLES2/gl2.h', | 8303 for fname in ['third_party/khronos/GLES2/gl2.h', |
8303 'third_party/khronos/GLES2/gl2ext.h', | 8304 'third_party/khronos/GLES2/gl2ext.h', |
8304 'gpu/GLES2/gl2chromium.h', | 8305 'gpu/GLES2/gl2chromium.h', |
8305 'gpu/GLES2/gl2extchromium.h']: | 8306 'gpu/GLES2/gl2extchromium.h']: |
8306 lines = open(fname).readlines() | 8307 lines = open(fname).readlines() |
8307 for line in lines: | 8308 for line in lines: |
8308 m = enum_re.match(line) | 8309 m = enum_re.match(line) |
8309 if m: | 8310 if m: |
8310 name = m.group(1) | 8311 name = m.group(1) |
8311 value = m.group(2) | 8312 value = m.group(2) |
8312 if len(value) <= 10 and not value in dict: | 8313 if len(value) <= 10: |
8313 dict[value] = name | 8314 if not value in dict: |
8315 dict[value] = name | |
8316 # check our own _CHROMIUM macro conflicts with khronos GL headers. | |
8317 elif dict[value] != name and (chromium_re.match(name) | |
no sievers
2014/11/18 19:57:20
I think and takes precedence and you need to group
| |
8318 or chromium_re.match(dict[value])): | |
8319 self.Error("code conflict %s and %s have the same code %s" % | |
8320 (dict[value], name, value)) | |
8314 | 8321 |
8315 file = CHeaderWriter(filename) | 8322 file = CHeaderWriter(filename) |
8316 file.Write("static const GLES2Util::EnumToString " | 8323 file.Write("static const GLES2Util::EnumToString " |
8317 "enum_to_string_table[] = {\n") | 8324 "enum_to_string_table[] = {\n") |
8318 for value in dict: | 8325 for value in dict: |
8319 file.Write(' { %s, "%s", },\n' % (value, dict[value])) | 8326 file.Write(' { %s, "%s", },\n' % (value, dict[value])) |
8320 file.Write("""}; | 8327 file.Write("""}; |
8321 | 8328 |
8322 const GLES2Util::EnumToString* const GLES2Util::enum_to_string_table_ = | 8329 const GLES2Util::EnumToString* const GLES2Util::enum_to_string_table_ = |
8323 enum_to_string_table; | 8330 enum_to_string_table; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8687 Format(gen.generated_cpp_filenames) | 8694 Format(gen.generated_cpp_filenames) |
8688 | 8695 |
8689 if gen.errors > 0: | 8696 if gen.errors > 0: |
8690 print "%d errors" % gen.errors | 8697 print "%d errors" % gen.errors |
8691 return 1 | 8698 return 1 |
8692 return 0 | 8699 return 0 |
8693 | 8700 |
8694 | 8701 |
8695 if __name__ == '__main__': | 8702 if __name__ == '__main__': |
8696 sys.exit(main(sys.argv[1:])) | 8703 sys.exit(main(sys.argv[1:])) |
OLD | NEW |