def GenerateSymbolMapping()

in GenForwarders.py [0:0]


def GenerateSymbolMapping(importLibPath):
	symbolTable = {}
	output = subprocess.Popen([GetDumpbin(), "/headers", importLibPath], stdout=subprocess.PIPE)
	for line in iter(output.stdout.readline,b''):
		strippedLine = line.strip().decode("windows-1251") 

		# ignore all lines other than for symbol entry
		if "Symbol name" not in strippedLine:
			continue

		# skip a few lines to get to the nameType and name field
		output.stdout.readline() # type
		nameType = output.stdout.readline().strip().decode("windows-1251")
		output.stdout.readline() # hint
		name = output.stdout.readline().strip().decode("windows-1251")
		
		# symbol line is in format of Symbol name : <symbol> [(extra info)]
		symbol = strippedLine.split(":")[1].strip().split(" ")[0].strip()
		name = name.split(":")[1].strip()
		nameType = nameType.split(":")[1].strip()
		
		if name in symbolTable:
			raise ValueError

		if nameType == "no prefix":
			symbolTable[name] = symbol
		elif nameType == "name":
			symbolTable[name] = name
		elif nameType == "undecorate":
			symbolTable[name] = "_" + name
		else:
			raise ValueError(nameType)

	return symbolTable