- paren = line.find('(')
- if paren>0:
- name = line[:paren]
- if name in funcs:
- cur_func = funcs[name]
- else:
- cur_func = Function(name)
- funcs[name] = cur_func
-
-parse_file("gl.spec")
-parse_file("gl.spec.fixes")
-
-for f in funcs.itervalues():
- if f.category==ext or f.category in secondary:
- if not f.aliases and f.vectorequiv:
- for g in funcs.itervalues():
- if g!=f and g.vectorequiv==f.vectorequiv and f.name.startswith(g.name):
- f.aliases.append(g.name)
- break
+ result += get_text_contents(c)
+ return result
+
+def parse_command(cmd):
+ proto = get_first_child(cmd, "proto")
+ name = get_text_contents(get_first_child(proto, "name"))
+ func = things.get(name)
+ if not func:
+ func = Function(name)
+ things[name] = func
+
+ aliases = get_nested_elements(cmd, "alias")
+ func.aliases = [a.getAttribute("name") for a in aliases]
+
+ ptype = get_first_child(proto, "ptype")
+ if ptype:
+ func.return_type = get_text_contents(ptype)
+ else:
+ for c in proto.childNodes:
+ if c.nodeType==xml.dom.Node.TEXT_NODE and c.data.strip():
+ func.return_type = c.data.strip()
+ break
+
+ params = get_nested_elements(cmd, "param")
+ func.params = map(get_text_contents, params)
+
+def parse_enum(en):
+ name = en.getAttribute("name")
+ enum = things.get(name)
+ if not enum:
+ enum = Enum(name)
+ things[name] = enum
+
+ enum.value = int(en.getAttribute("value"), 16)
+
+def parse_feature(feat):
+ api = feat.getAttribute("api")
+ version = feat.getAttribute("number")
+ if version:
+ version = map(int, version.split('.'))
+ else:
+ version = None
+
+ requires = get_nested_elements(feat, "require")
+ for req in requires:
+ commands = get_nested_elements(req, "command")
+ enums = get_nested_elements(req, "enum")
+ for t in itertools.chain(commands, enums):
+ name = t.getAttribute("name")
+ thing = things.get(name)
+ if thing:
+ thing.supported_apis.setdefault(api, version)
+
+ if not api or api==target_api:
+ removes = get_nested_elements(feat, "remove")
+ for rem in removes:
+ profile = rem.getAttribute("profile")
+ commands = get_nested_elements(rem, "command")
+ enums = get_nested_elements(rem, "enum")