• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (c) 2017 The Khronos Group Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# printreg(reg, varname)
17# Prints a registry Python data structure (see registry.py) in a consistent
18# fashion.
19
20def tab():
21    return '        '
22
23def quote(str):
24    return '\'' + str + '\''
25
26def printKey(key, value):
27    print(tab() + quote(key), ':', value + ',')
28
29def printNum(ext, key):
30    if (key in ext.keys()):
31        printKey(key, str(ext[key]))
32
33def printSet(ext, key):
34    if (key in ext.keys()):
35        value = ( '{ ' +
36                  ', '.join([quote(str(tag)) for tag in sorted(ext[key])]) +
37                  ' }' )
38        printKey(key, value)
39
40def printStr(ext, key):
41    if (key in ext.keys()):
42        printKey(key, quote(str(ext[key])))
43
44def striplibs(s):
45    return ( s.replace('GL_','').
46               replace('GLU_','').
47               replace('GLX_','').
48               replace('WGL_','') )
49
50def printreg(reg, varname):
51    print(varname, '= {')
52
53    # print('keys in registry =', len(reg.keys()))
54
55    print('# OpenGL extension number and name registry')
56    print('')
57
58    for key in sorted(reg.keys(), key = striplibs):
59        ext = reg[key]
60
61        print('    ' + quote(key), ': {')
62        printNum(ext, 'arbnumber')
63        printNum(ext, 'number')
64        printNum(ext, 'esnumber')
65        printSet(ext, 'flags')
66        printSet(ext, 'supporters')
67        printStr(ext, 'url')
68        printStr(ext, 'esurl')
69        printSet(ext, 'alias')
70        printStr(ext, 'comments')
71        print('    },')
72
73    print('}')
74
75