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 os | 8 import os |
9 import collections | 9 import collections |
10 import re | 10 import re |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 """ % {'name': set_name.upper()}) | 1240 """ % {'name': set_name.upper()}) |
1241 | 1241 |
1242 # Write API declaration. | 1242 # Write API declaration. |
1243 for func in functions: | 1243 for func in functions: |
1244 file.write(' virtual %s %sFn(%s) OVERRIDE;\n' % | 1244 file.write(' virtual %s %sFn(%s) OVERRIDE;\n' % |
1245 (func['return_type'], func['names'][0], func['arguments'])) | 1245 (func['return_type'], func['names'][0], func['arguments'])) |
1246 | 1246 |
1247 file.write('\n') | 1247 file.write('\n') |
1248 | 1248 |
1249 | 1249 |
| 1250 def GenerateMockHeader(file, functions, set_name, used_extension_functions): |
| 1251 """Generates gl_mock_autogen_x.h""" |
| 1252 |
| 1253 # Write file header. |
| 1254 file.write( |
| 1255 """// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 1256 // Use of this source code is governed by a BSD-style license that can be |
| 1257 // found in the LICENSE file. |
| 1258 |
| 1259 // This file is automatically generated. |
| 1260 |
| 1261 """ % {'name': set_name.upper()}) |
| 1262 |
| 1263 # Write API declaration. |
| 1264 for func in functions: |
| 1265 args = func['arguments'] |
| 1266 if args == 'void': |
| 1267 args = '' |
| 1268 arg_count = 0 |
| 1269 if len(args): |
| 1270 arg_count = func['arguments'].count(',') + 1 |
| 1271 file.write(' MOCK_METHOD%d(%s, %s(%s));\n' % |
| 1272 (arg_count, func['names'][0][2:], func['return_type'], args)) |
| 1273 |
| 1274 file.write('\n') |
| 1275 |
| 1276 |
| 1277 def GenerateInterfaceHeader( |
| 1278 file, functions, set_name, used_extension_functions): |
| 1279 """Generates gl_interface_autogen_x.h""" |
| 1280 |
| 1281 # Write file header. |
| 1282 file.write( |
| 1283 """// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 1284 // Use of this source code is governed by a BSD-style license that can be |
| 1285 // found in the LICENSE file. |
| 1286 |
| 1287 // This file is automatically generated. |
| 1288 |
| 1289 """ % {'name': set_name.upper()}) |
| 1290 |
| 1291 # Write API declaration. |
| 1292 for func in functions: |
| 1293 args = func['arguments'] |
| 1294 if args == 'void': |
| 1295 args = '' |
| 1296 file.write(' virtual %s %s(%s) = 0;\n' % |
| 1297 (func['return_type'], func['names'][0][2:], args)) |
| 1298 |
| 1299 file.write('\n') |
| 1300 |
| 1301 |
1250 def GenerateSource(file, functions, set_name, used_extension_functions): | 1302 def GenerateSource(file, functions, set_name, used_extension_functions): |
1251 """Generates gl_binding_autogen_x.cc""" | 1303 """Generates gl_binding_autogen_x.cc""" |
1252 | 1304 |
1253 # Write file header. | 1305 # Write file header. |
1254 file.write( | 1306 file.write( |
1255 """// Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1307 """// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
1256 // Use of this source code is governed by a BSD-style license that can be | 1308 // Use of this source code is governed by a BSD-style license that can be |
1257 // found in the LICENSE file. | 1309 // found in the LICENSE file. |
1258 | 1310 |
1259 // This file is automatically generated. | 1311 // This file is automatically generated. |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 os.path.join(dir, 'gl_bindings_api_autogen_%s.h' % set_name), 'wb') | 1700 os.path.join(dir, 'gl_bindings_api_autogen_%s.h' % set_name), 'wb') |
1649 GenerateAPIHeader( | 1701 GenerateAPIHeader( |
1650 header_file, functions, set_name, used_extension_functions) | 1702 header_file, functions, set_name, used_extension_functions) |
1651 header_file.close() | 1703 header_file.close() |
1652 | 1704 |
1653 source_file = open( | 1705 source_file = open( |
1654 os.path.join(dir, 'gl_bindings_autogen_%s.cc' % set_name), 'wb') | 1706 os.path.join(dir, 'gl_bindings_autogen_%s.cc' % set_name), 'wb') |
1655 GenerateSource(source_file, functions, set_name, used_extension_functions) | 1707 GenerateSource(source_file, functions, set_name, used_extension_functions) |
1656 source_file.close() | 1708 source_file.close() |
1657 | 1709 |
| 1710 header_file = open( |
| 1711 os.path.join(dir, 'gl_interface_autogen_%s.h' % set_name), 'wb') |
| 1712 GenerateInterfaceHeader( |
| 1713 header_file, functions, set_name, used_extension_functions) |
| 1714 header_file.close() |
| 1715 |
| 1716 header_file = open( |
| 1717 os.path.join(dir, 'gl_mock_autogen_%s.h' % set_name), 'wb') |
| 1718 GenerateMockHeader( |
| 1719 header_file, functions, set_name, used_extension_functions) |
| 1720 header_file.close() |
| 1721 |
1658 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') | 1722 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') |
1659 GenerateMockSource(source_file, GL_FUNCTIONS) | 1723 GenerateMockSource(source_file, GL_FUNCTIONS) |
1660 source_file.close() | 1724 source_file.close() |
1661 return 0 | 1725 return 0 |
1662 | 1726 |
1663 | 1727 |
1664 if __name__ == '__main__': | 1728 if __name__ == '__main__': |
1665 sys.exit(main(sys.argv[1:])) | 1729 sys.exit(main(sys.argv[1:])) |
OLD | NEW |