mirror of
https://github.com/Perlmint/glew-cmake.git
synced 2024-11-11 09:33:49 +00:00
Use parse_xml.py for WGL code generation
This commit is contained in:
parent
278a314d99
commit
62b9213b44
@ -111,11 +111,19 @@ $(EXT)/.dummy: OpenGL-Registry/.dummy EGL-Registry/.dummy
|
|||||||
cp -r glfixes/gl/specs/ANGLE OpenGL-Registry/extensions
|
cp -r glfixes/gl/specs/ANGLE OpenGL-Registry/extensions
|
||||||
cp -r glfixes/gl/specs/REGAL OpenGL-Registry/extensions
|
cp -r glfixes/gl/specs/REGAL OpenGL-Registry/extensions
|
||||||
$(BIN)/update_ext.sh $(EXT) OpenGL-Registry/extensions $(BLACKLIST)
|
$(BIN)/update_ext.sh $(EXT) OpenGL-Registry/extensions $(BLACKLIST)
|
||||||
$(BIN)/filter_gl_ext.sh $(EXT)
|
@echo "--------------------------------------------------------------------"
|
||||||
|
@echo "WGL descriptors"
|
||||||
|
@echo "--------------------------------------------------------------------"
|
||||||
|
rm -f $(EXT)/WGL_*
|
||||||
|
$(PYTHON) $(BIN)/parse_xml.py OpenGL-Registry/xml/wgl.xml --api wgl --extensions extensions/gl
|
||||||
@echo "--------------------------------------------------------------------"
|
@echo "--------------------------------------------------------------------"
|
||||||
@echo "EGL descriptors"
|
@echo "EGL descriptors"
|
||||||
@echo "--------------------------------------------------------------------"
|
@echo "--------------------------------------------------------------------"
|
||||||
$(PYTHON) $(BIN)/parse_xml.py EGL-Registry/api/egl.xml --extensions extensions/gl
|
$(PYTHON) $(BIN)/parse_xml.py EGL-Registry/api/egl.xml --api egl --extensions extensions/gl
|
||||||
|
@echo "--------------------------------------------------------------------"
|
||||||
|
@echo "filter descriptors"
|
||||||
|
@echo "--------------------------------------------------------------------"
|
||||||
|
$(BIN)/filter_gl_ext.sh $(EXT)
|
||||||
ifeq ($(patsubst Darwin%,Darwin,$(SYSTEM)), Darwin)
|
ifeq ($(patsubst Darwin%,Darwin,$(SYSTEM)), Darwin)
|
||||||
find $(CORE) -maxdepth 1 -type f | grep -v VERSION | grep -v "~" | \
|
find $(CORE) -maxdepth 1 -type f | grep -v VERSION | grep -v "~" | \
|
||||||
xargs -J % cp % $(EXT)
|
xargs -J % cp % $(EXT)
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from xml.dom.minidom import parse, Node
|
from xml.dom.minidom import parse, Node
|
||||||
|
|
||||||
|
#
|
||||||
|
# DOM traversal utility functions
|
||||||
|
#
|
||||||
|
|
||||||
def findChildren(node, path):
|
def findChildren(node, path):
|
||||||
result = []
|
result = []
|
||||||
if len(path)==1:
|
if len(path)==1:
|
||||||
@ -21,7 +25,9 @@ def findChildren(node, path):
|
|||||||
def findData(node, path):
|
def findData(node, path):
|
||||||
return [ i.firstChild.data for i in findChildren(node, path) ]
|
return [ i.firstChild.data for i in findChildren(node, path) ]
|
||||||
|
|
||||||
def findParams(node):
|
isPointer = re.compile('(.*)([ ]+)([*]+)')
|
||||||
|
|
||||||
|
def findParams(node, typeMap = {}):
|
||||||
n = findData(node, ['name'])[0]
|
n = findData(node, ['name'])[0]
|
||||||
t = ''
|
t = ''
|
||||||
for i in node.childNodes:
|
for i in node.childNodes:
|
||||||
@ -29,7 +35,14 @@ def findParams(node):
|
|||||||
t += i.data
|
t += i.data
|
||||||
if i.nodeType==Node.ELEMENT_NODE and i.tagName=='ptype':
|
if i.nodeType==Node.ELEMENT_NODE and i.tagName=='ptype':
|
||||||
t += i.firstChild.data
|
t += i.firstChild.data
|
||||||
return ( t, n)
|
|
||||||
|
t.strip()
|
||||||
|
m = isPointer.match(t)
|
||||||
|
if m:
|
||||||
|
t = ('%s%s'%(m.group(1), m.group(3))).strip()
|
||||||
|
if t in typeMap:
|
||||||
|
t = typeMap[t]
|
||||||
|
return ( t, n.strip())
|
||||||
|
|
||||||
def findEnums(dom):
|
def findEnums(dom):
|
||||||
ret = {}
|
ret = {}
|
||||||
@ -39,11 +52,11 @@ def findEnums(dom):
|
|||||||
ret[n] = v
|
ret[n] = v
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def findCommands(dom):
|
def findCommands(dom, typeMap = {}):
|
||||||
ret = {}
|
ret = {}
|
||||||
for i in findChildren(dom, [ 'registry', 'commands', 'command' ]):
|
for i in findChildren(dom, [ 'registry', 'commands', 'command' ]):
|
||||||
r,n = findParams(findChildren(i, ['proto'])[0])
|
r,n = findParams(findChildren(i, ['proto'])[0], typeMap)
|
||||||
p = [ findParams(j) for j in findChildren(i, ['param'])]
|
p = [ findParams(j, typeMap) for j in findChildren(i, ['param'])]
|
||||||
ret[n] = (r, p)
|
ret[n] = (r, p)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -74,29 +87,48 @@ def findExtensions(dom):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
def findApi(dom, name):
|
def findApi(dom, name):
|
||||||
|
typeMap = {}
|
||||||
|
# if name=='wgl':
|
||||||
|
# typeMap = { 'int' : 'INT', 'void' : 'VOID' }
|
||||||
enums = findEnums(dom)
|
enums = findEnums(dom)
|
||||||
commands = findCommands(dom)
|
commands = findCommands(dom, typeMap)
|
||||||
features = findFeatures(dom)
|
features = findFeatures(dom)
|
||||||
extensions = findExtensions(dom)
|
extensions = findExtensions(dom)
|
||||||
return (enums, commands, features, extensions)
|
return (enums, commands, features, extensions)
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
isWGL = re.compile('WGL_([A-Z0-9]+)_.*')
|
||||||
|
|
||||||
def writeExtension(f, name, extension, enums, commands):
|
def writeExtension(f, name, extension, enums, commands):
|
||||||
f.write('%s\n'%name)
|
f.write('%s\n'%name)
|
||||||
f.write('%s\n'%'https://www.khronos.org/registry/egl/specs/eglspec.1.5.pdf')
|
|
||||||
|
url = 'https://www.khronos.org/registry/egl/specs/eglspec.1.5.pdf'
|
||||||
|
|
||||||
|
m = isWGL.match(name)
|
||||||
|
if m:
|
||||||
|
url = 'https://www.khronos.org/registry/OpenGL/extensions/%s/%s.txt'%(m.group(1), name)
|
||||||
|
|
||||||
|
f.write('%s\n'%(url))
|
||||||
|
|
||||||
if name.find('_VERSION_')==-1:
|
if name.find('_VERSION_')==-1:
|
||||||
f.write('%s\n'%name)
|
f.write('%s\n'%name)
|
||||||
else:
|
else:
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
enums = [ (j, enums[j]) for j in extension[0] ]
|
enums = [ (j, enums[j]) for j in extension[0] ]
|
||||||
for e in sorted(enums, key=lambda i: i[1]):
|
for e in sorted(enums, key=lambda i: i[1]):
|
||||||
f.write('\t%s %s\n'%(e[0], e[1]))
|
f.write('\t%s %s\n'%(e[0], e[1]))
|
||||||
|
|
||||||
commands = [ (j, commands[j]) for j in extension[1] ]
|
commands = [ (j, commands[j]) for j in extension[1] ]
|
||||||
for c in sorted(commands):
|
for c in sorted(commands):
|
||||||
params = ', '.join( [ '%s %s'%(j[0], j[1]) for j in c[1][1] ] )
|
params = ', '.join( [ '%s %s'%(j[0].strip(), j[1].strip()) for j in c[1][1] ] )
|
||||||
if len(params)==0:
|
if len(params)==0:
|
||||||
params = ' void '
|
params = 'void'
|
||||||
f.write('\t%s %s (%s)\n'%(c[1][0], c[0], params))
|
f.write('\t%s %s (%s)\n'%(c[1][0].strip(), c[0].strip(), params))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
@ -105,6 +137,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
parser = OptionParser('usage: %prog [options] [XML specs...]')
|
parser = OptionParser('usage: %prog [options] [XML specs...]')
|
||||||
parser.add_option("--core", dest="core", help="location for core outputs", default='')
|
parser.add_option("--core", dest="core", help="location for core outputs", default='')
|
||||||
|
parser.add_option("--api", dest="name", help="API name: egl, wgl, glx, etc", default='')
|
||||||
parser.add_option("--extensions", dest="extensions", help="location for extensions outputs", default='')
|
parser.add_option("--extensions", dest="extensions", help="location for extensions outputs", default='')
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
@ -112,7 +145,7 @@ if __name__ == '__main__':
|
|||||||
for i in args:
|
for i in args:
|
||||||
|
|
||||||
dom = parse(i)
|
dom = parse(i)
|
||||||
api = findApi(dom, 'egl')
|
api = findApi(dom, options.name)
|
||||||
|
|
||||||
print('Found {} enums, {} commands, {} features and {} extensions.'.format(
|
print('Found {} enums, {} commands, {} features and {} extensions.'.format(
|
||||||
len(api[0]), len(api[1]), len(api[2]), len(api[3])))
|
len(api[0]), len(api[1]), len(api[2]), len(api[3])))
|
||||||
|
@ -9,5 +9,4 @@ WGL_ARB_create_context
|
|||||||
WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||||
WGL_CONTEXT_FLAGS_ARB 0x2094
|
WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||||
ERROR_INVALID_VERSION_ARB 0x2095
|
ERROR_INVALID_VERSION_ARB 0x2095
|
||||||
ERROR_INVALID_PROFILE_ARB 0x2096
|
|
||||||
HGLRC wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int* attribList)
|
HGLRC wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int* attribList)
|
||||||
|
Loading…
Reference in New Issue
Block a user