def FindOffset(funcName): for (name, alias, offset) in records: if name == funcName: return offset #endif #endfor return -1 #enddef def EmitEntry(name, returnType, argTypeList, argNameList, alias, offset): if alias == '': dispatchName = name else: dispatchName = alias if offset < 0: offset = FindOffset(dispatchName) if offset >= 0 and string.find(name, "unused") == -1: print '\tgl%s' % (name) # save this info in case we need to look up an alias later records.append((name, dispatchName, offset)) #enddef PrintHead() apiparser.ProcessSpecFile("APIspec", EmitEntry) PrintTail()
print '#endif /* DISPATCH_TABLE_NAME */' print '' #enddef def PrintAliasedTable(): print """ /* * This is just used to silence compiler warnings. * We list the functions which aren't otherwise used. */ #ifdef UNUSED_TABLE_NAME void *UNUSED_TABLE_NAME[] = {""" for alias in aliasedFuncs: print ' TABLE_ENTRY(%s),' % (alias) #endfor print '};' print '#endif /*UNUSED_TABLE_NAME*/' print '' #enddef PrintHead() apiparser.ProcessSpecFile("APIspec", EmitFunction) PrintInitDispatch() PrintAliasedTable() PrintTail()
def DoRecord(name, returnType, argTypeList, argNameList, alias, offset): argList = apiparser.MakeArgList(argTypeList, argNameList) if offset >= 0 and not records.has_key(offset): records[offset] = (name, returnType, argList) #print '#define _gloffset_%s %d' % (name, offset) #endif def PrintRecords(): keys = records.keys() keys.sort() prevk = -1 for k in keys: if k != prevk + 1: #print 'Missing offset %d' % (prevk) pass prevk = int(k) (name, returnType, argList) = records[k] print ' %s (GLAPIENTRYP %s)(%s); /* %d */' % (returnType, name, argList, k) #endef PrintHead() apiparser.ProcessSpecFile("APIspec", DoRecord) PrintRecords() PrintTail()
def AddOffset(name, returnType, argTypeList, argNameList, alias, offset): argList = apiparser.MakeArgList(argTypeList, argNameList) if offset >= 0 and not records.has_key(offset): records[offset] = name #print '#define _gloffset_%s %d' % (name, offset) #enddef def PrintRecords(): keys = records.keys() keys.sort() prevk = -1 for k in keys: if k != prevk + 1: #print 'Missing offset %d' % (prevk) pass prevk = int(k) name = records[k] print '#define _gloffset_%s %d' % (name, k) #endef PrintHead() apiparser.ProcessSpecFile("APIspec", AddOffset) PrintRecords() PrintTail()