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 8291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8302 for fname in ['third_party/khronos/GLES2/gl2.h', | 8302 for fname in ['third_party/khronos/GLES2/gl2.h', |
8303 'third_party/khronos/GLES2/gl2ext.h', | 8303 'third_party/khronos/GLES2/gl2ext.h', |
8304 'gpu/GLES2/gl2chromium.h', | 8304 'gpu/GLES2/gl2chromium.h', |
8305 'gpu/GLES2/gl2extchromium.h']: | 8305 'gpu/GLES2/gl2extchromium.h']: |
8306 lines = open(fname).readlines() | 8306 lines = open(fname).readlines() |
8307 for line in lines: | 8307 for line in lines: |
8308 m = enum_re.match(line) | 8308 m = enum_re.match(line) |
8309 if m: | 8309 if m: |
8310 name = m.group(1) | 8310 name = m.group(1) |
8311 value = m.group(2) | 8311 value = m.group(2) |
8312 if len(value) <= 10 and not value in dict: | 8312 if len(value) <= 10: |
8313 dict[value] = name | 8313 if not value in dict: |
| 8314 dict[value] = name |
| 8315 # check our own _CHROMIUM macro conflicts with khronos GL headers. |
| 8316 elif dict[value] != name and (name.endswith('_CHROMIUM') or |
| 8317 dict[value].endswith('_CHROMIUM')): |
| 8318 self.Error("code collision: %s and %s have the same code %s" % |
| 8319 (dict[value], name, value)) |
8314 | 8320 |
8315 file = CHeaderWriter(filename) | 8321 file = CHeaderWriter(filename) |
8316 file.Write("static const GLES2Util::EnumToString " | 8322 file.Write("static const GLES2Util::EnumToString " |
8317 "enum_to_string_table[] = {\n") | 8323 "enum_to_string_table[] = {\n") |
8318 for value in dict: | 8324 for value in dict: |
8319 file.Write(' { %s, "%s", },\n' % (value, dict[value])) | 8325 file.Write(' { %s, "%s", },\n' % (value, dict[value])) |
8320 file.Write("""}; | 8326 file.Write("""}; |
8321 | 8327 |
8322 const GLES2Util::EnumToString* const GLES2Util::enum_to_string_table_ = | 8328 const GLES2Util::EnumToString* const GLES2Util::enum_to_string_table_ = |
8323 enum_to_string_table; | 8329 enum_to_string_table; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8687 Format(gen.generated_cpp_filenames) | 8693 Format(gen.generated_cpp_filenames) |
8688 | 8694 |
8689 if gen.errors > 0: | 8695 if gen.errors > 0: |
8690 print "%d errors" % gen.errors | 8696 print "%d errors" % gen.errors |
8691 return 1 | 8697 return 1 |
8692 return 0 | 8698 return 0 |
8693 | 8699 |
8694 | 8700 |
8695 if __name__ == '__main__': | 8701 if __name__ == '__main__': |
8696 sys.exit(main(sys.argv[1:])) | 8702 sys.exit(main(sys.argv[1:])) |
OLD | NEW |