diff options
Diffstat (limited to 'src/mapi/glapi/gen/glX_server_table.py')
-rw-r--r-- | src/mapi/glapi/gen/glX_server_table.py | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/mapi/glapi/gen/glX_server_table.py b/src/mapi/glapi/gen/glX_server_table.py index 7d23669877..29a3075d0a 100644 --- a/src/mapi/glapi/gen/glX_server_table.py +++ b/src/mapi/glapi/gen/glX_server_table.py @@ -27,7 +27,12 @@ import argparse +from mako.lookup import TemplateLookup + import gl_XML, glX_XML, glX_proto_common, license +from python.mako.preprocessor import expand_tab + +_LOOKUP = TemplateLookup(['templates'], preprocessor=expand_tab) def log2(value): @@ -68,7 +73,6 @@ class function_table: self.min_op_count = (1 << self.min_op_bits) return - def append(self, opcode, func): self.functions[opcode] = func @@ -84,7 +88,6 @@ class function_table: self.next_opcode_threshold = 1 << bits return - def divide_group(self, min_opcode, total): """Divide the group starting min_opcode into subgroups. Returns a tuple containing the number of bits consumed by @@ -153,7 +156,6 @@ class function_table: else: return [M, children, count, depth] - def is_empty_leaf(self, base_opcode, M): for op in xrange(base_opcode, base_opcode + (1 << M)): if op in self.functions: @@ -161,7 +163,6 @@ class function_table: return True - def dump_tree(self, node, base_opcode, remaining_bits, base_entry, depth): M = node[0] children = node[1] @@ -233,7 +234,6 @@ class function_table: base_opcode += 1 << (remaining_bits - M) - def Print(self): # Each dispatch table consists of two data structures. # @@ -383,6 +383,24 @@ class PrintGlxDispatchTables(glX_proto_common.glx_print_proto): return +def _make_tables(api): + """Build tables to pass into the template.""" + rop_functions = function_table("Render", True) + sop_functions = function_table("Single", False) + vop_functions = function_table("VendorPriv", False) + + for f in api.functionIterateAll(): + if not f.ignore and f.vectorequiv is None: + if f.glx_rop != 0: + rop_functions.append(f.glx_rop, f) + if f.glx_sop != 0: + sop_functions.append(f.glx_sop, f) + if f.glx_vendorpriv != 0: + vop_functions.append(f.glx_vendorpriv, f) + + return rop_functions, sop_functions, vop_functions + + def _parser(): """Parse arguments and return namespace.""" parser = argparse.ArgumentParser() @@ -396,10 +414,15 @@ def _parser(): def main(): """Main function.""" args = _parser() - printer = PrintGlxDispatchTables() + template = _LOOKUP.get_template('indirect_table.c.mako') api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) - printer.Print(api) + try: + print template.render(tables=_make_tables(api)) + except: + from mako.exceptions import text_error_template + import sys + print >> sys.stderr, text_error_template().render() if __name__ == '__main__': |