-for line in file("gl.spec"):
- if line[0]=='#' or line.find(':')>=0:
- continue
- elif line[0]=='\t' and cur_func:
- parts = line.split()
- if parts[0]=="category" and parts[1]==ext:
- funcs.append(cur_func)
- else:
- paren = line.find('(')
- if paren>0:
- cur_func = line[:paren]
+
+def parse_file(fn):
+ for line in open(fn):
+ if line[0]=='#' or line.find(':')>=0:
+ continue
+ elif line[0]=='\t':
+ if cur_func:
+ parts = line.split()
+ if parts[0]=="category":
+ cur_func.category = parts[1]
+ elif parts[0]=="vectorequiv":
+ cur_func.vectorequiv = parts[1]
+ elif parts[0]=="alias":
+ cur_func.aliases.append(parts[1])
+ elif parts[0]=="version":
+ cur_func.version = parts[1]
+ elif parts[0]=="delete":
+ del funcs[cur_func.name]
+ cur_func = None
+ else:
+ 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
+
+ for a in f.aliases:
+ if a in funcs:
+ funcs[a].extfunc = f
+
+def is_relevant(f):
+ if f.category==ext and not f.aliases:
+ return True
+ if f.extfunc:
+ e = f.extfunc
+ if e.category==ext or e.category in secondary:
+ return True
+ return False
+
+funcs = [f for f in funcs.itervalues() if is_relevant(f)]
+funcs.sort(key=(lambda f: f.name))
+
+for f in funcs:
+ if f.extfunc:
+ if not ver:
+ ver = f.version
+ if not f.category.startswith("VERSION_"):
+ bp_ext = f.category
+ if not f.extfunc and not f.name.endswith(exttype):
+ bp_ext = f.category
+
+if ver:
+ ver = map(int, ver.split('.'))