summaryrefslogtreecommitdiffstats
path: root/opengl/libs/GLES2_dbg/generate_debug_in.py
blob: 830bcb99feb99f73611c604f8a6b992695e1e1d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys

def append_functions(functions, lines):
	i = 0
	for line in lines:
		if line.find("API_ENTRY(") >= 0: # a function prototype
			returnType = line[0: line.find(" API_ENTRY(")]
			functionName = line[line.find("(") + 1: line.find(")")] #extract GL function name
			parameterList = line[line.find(")(") + 2: line.find(") {")]
			
			functions.append(functionName)
			#print functionName
			continue
				
			parameters = parameterList.split(',')
			paramIndex = 0
			if line.find("*") >= 0:
				print "// FIXME: this function has pointers, it should be hand written"
				externs.append("%s Tracing_%s(%s);" % (returnType, functionName, parameterList))
			print "%s Tracing_%s(%s)\n{" % (returnType, functionName, parameterList)
			
			if parameterList == "void":
				parameters = []
			
			arguments = ""
			 
			for parameter in parameters:
				parameter = parameter.replace("const", "")
				parameter = parameter.strip()
				paramType = parameter.split(' ')[0]
				paramName = parameter.split(' ')[1]
				
				paramIndex += 1
				
	return functions
	


if __name__ == "__main__":
	definedFunctions = []
	lines = open("gl2_api.in").readlines()
	definedFunctions = append_functions(definedFunctions, lines)
	
	output = open("debug.in", "w")
	lines = open("trace.in").readlines()
	output.write("// the following functions are not defined in GLESv2_dbg\n")
	for line in lines:
		functionName = ""
		if line.find("TRACE_GL(") >= 0: # a function prototype
			functionName = line.split(',')[1].strip()
		elif line.find("TRACE_GL_VOID(") >= 0: # a function prototype
			functionName = line[line.find("(") + 1: line.find(",")] #extract GL function name
		else:
			continue
		if functionName in definedFunctions:
			#print functionName
			continue
		else:
			output.write(line)