GlFunction(Void, "glCallList", [(GLlist, "list")]),
GlFunction(Void, "glCallLists", [(GLsizei, "n"), (GLenum, "type"), (Blob(Const(GLvoid), "__glCallLists_size(n, type)"), "lists")]), # XXX
GlFunction(Void, "glDeleteLists", [(GLlist, "list"), (GLsizei, "range")]), # XXX
- GlFunction(GLlist, "glGenLists", [(GLsizei, "range")]), # XXX
+ GlFunction(Handle("list", GLuint, "range"), "glGenLists", [(GLsizei, "range")]), # XXX
GlFunction(Void, "glListBase", [(GLuint, "base")]),
GlFunction(Void, "glBegin", [(GLenum_mode, "mode")]),
GlFunction(Void, "glBitmap", [(GLsizei, "width"), (GLsizei, "height"), (GLfloat, "xorig"), (GLfloat, "yorig"), (GLfloat, "xmove"), (GLfloat, "ymove"), (Blob(Const(GLubyte), "__glBitmap_size(width, height)"), "bitmap")]),
def visit_handle(self, handle, lvalue, rvalue):
- print " __%s_map[static_cast<%s>(%s)] = %s;" % (handle.name, handle.type, rvalue, lvalue)
- print ' if (verbosity >= 2)'
- print ' std::cout << "%s " << static_cast<%s>(%s) << " -> " << %s << "\\n";' % (handle.name, handle.type, rvalue, lvalue)
+ if handle.range is None:
+ print " __{handle.name}_map[static_cast<{handle.type}>({rvalue})] = {lvalue};".format(**locals())
+ print ' if (verbosity >= 2)'
+ print ' std::cout << "{handle.name} " << static_cast<{handle.type}>({rvalue}) << " -> " << {lvalue} << "\\n";'.format(**locals())
+ else:
+ i = '__h' + handle.id
+ print ' for({handle.type} {i} = 0; {i} < {handle.range}; ++{i}) {{'.format(**locals())
+ print ' __{handle.name}_map[static_cast<{handle.type}>({rvalue}) + {i}] = {lvalue} + {i};'.format(**locals())
+ print ' if (verbosity >= 2)'
+ print ' std::cout << "{handle.name} " << (static_cast<{handle.type}>({rvalue}) + {i}) << " -> " << ({lvalue} + {i}) << "\\n";'.format(**locals())
+ print ' }'
def visit_blob(self, blob, lvalue, rvalue):
pass
types = api.all_types()
handles = [type for type in types if isinstance(type, stdapi.Handle)]
+ handle_names = set()
for handle in handles:
- print 'static std::map<%s, %s> __%s_map;' % (handle.type, handle.type, handle.name)
+ if handle.name not in handle_names:
+ print 'static std::map<%s, %s> __%s_map;' % (handle.type, handle.type, handle.name)
+ handle_names.add(handle.name)
print
print 'unsigned verbosity = 0;'
def visit_handle(self, handle):
type = self.visit(handle.type)
- return Handle(handle.name, type)
+ return Handle(handle.name, type, handle.range)
def visit_alias(self, alias):
type = self.visit(alias.type)
class Handle(Type):
- def __init__(self, name, type):
+ def __init__(self, name, type, range=None):
Type.__init__(self, type.expr, 'P' + type.id)
self.name = name
self.type = type
+ self.range = range
def visit(self, visitor, *args, **kwargs):
return visitor.visit_handle(self, *args, **kwargs)