+ features = root.getElementsByTagName("feature")
+ for feat in features:
+ api = feat.getAttribute("api")
+ if api=="gl":
+ version = feat.getAttribute("number")
+
+ commands = get_nested_elements(feat, "require/command")
+ enums = get_nested_elements(feat, "require/enum")
+ for t in itertools.chain(commands, enums):
+ name = t.getAttribute("name")
+ thing = things.get(name)
+ if thing:
+ thing.version = version
+
+ if feat.getAttribute("name")=="MSPGL_REMOVE":
+ commands = get_nested_elements(feat, "remove/command")
+ enums = get_nested_elements(feat, "require/enum")
+ for t in itertools.chain(commands, enums):
+ name = t.getAttribute("name")
+ if name in things:
+ del things[name]
+
+ extensions = get_nested_elements(root, "extensions/extension")
+ for ext in extensions:
+ ext_name = ext.getAttribute("name")
+ if ext_name.startswith("GL_"):
+ ext_name = ext_name[3:]
+ supported = ext.getAttribute("supported").split('|')
+ if "gl" in supported:
+ commands = get_nested_elements(ext, "require/command")
+ enums = get_nested_elements(ext, "require/enum")
+ for t in itertools.chain(commands, enums):
+ name = t.getAttribute("name")
+ thing = things.get(name)
+ if thing:
+ thing.extension = ext_name
+
+parse_file("gl.xml")
+parse_file("gl.fixes.xml")
+
+### Additional processing ###
+
+# Find aliases for enums
+enums = [t for t in things.itervalues() if t.kind==Thing.ENUM]
+core_enums_by_value = dict((e.value, e) for e in enums if e.version)
+
+for e in enums:
+ if e.kind==t.ENUM and e.extension:
+ ce = core_enums_by_value.get(e.value)
+ if ce and ce!=e:
+ e.aliases.append(ce.name)
+
+# Create references from core things to their extension counterparts
+for t in things.itervalues():
+ if t.extension==ext or t.extension in secondary:
+ for a in t.aliases:
+ alias = things.get(a)
+ if alias:
+ alias.source = t
+
+def is_relevant(t):
+ # Unpromoted extension things are relevant
+ if t.extension==ext and not t.aliases: