David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 4 | # |
| 5 | # Copyright 2011, The Android Open Source Project |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # |
| 19 | |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 20 | import os |
| 21 | import sys |
| 22 | |
| 23 | def append_functions(functions, lines): |
| 24 | i = 0 |
| 25 | for line in lines: |
| 26 | if line.find("API_ENTRY(") >= 0: # a function prototype |
| 27 | returnType = line[0: line.find(" API_ENTRY(")] |
| 28 | functionName = line[line.find("(") + 1: line.find(")")] #extract GL function name |
| 29 | parameterList = line[line.find(")(") + 2: line.find(") {")] |
| 30 | |
| 31 | functions.append(functionName) |
| 32 | #print functionName |
| 33 | continue |
| 34 | |
| 35 | parameters = parameterList.split(',') |
| 36 | paramIndex = 0 |
| 37 | if line.find("*") >= 0: |
| 38 | print "// FIXME: this function has pointers, it should be hand written" |
| 39 | externs.append("%s Tracing_%s(%s);" % (returnType, functionName, parameterList)) |
| 40 | print "%s Tracing_%s(%s)\n{" % (returnType, functionName, parameterList) |
| 41 | |
| 42 | if parameterList == "void": |
| 43 | parameters = [] |
| 44 | |
| 45 | arguments = "" |
| 46 | |
| 47 | for parameter in parameters: |
| 48 | parameter = parameter.replace("const", "") |
| 49 | parameter = parameter.strip() |
| 50 | paramType = parameter.split(' ')[0] |
| 51 | paramName = parameter.split(' ')[1] |
| 52 | |
| 53 | paramIndex += 1 |
| 54 | |
| 55 | return functions |
| 56 | |
| 57 | |
| 58 | |
| 59 | if __name__ == "__main__": |
| 60 | definedFunctions = [] |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 61 | lines = open("gl2_api_annotated.in").readlines() |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 62 | definedFunctions = append_functions(definedFunctions, lines) |
| 63 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 64 | output = open("../debug.in", "w") |
| 65 | lines = open("../trace.in").readlines() |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 66 | output.write("// the following functions are not defined in GLESv2_dbg\n") |
| 67 | for line in lines: |
| 68 | functionName = "" |
| 69 | if line.find("TRACE_GL(") >= 0: # a function prototype |
| 70 | functionName = line.split(',')[1].strip() |
| 71 | elif line.find("TRACE_GL_VOID(") >= 0: # a function prototype |
| 72 | functionName = line[line.find("(") + 1: line.find(",")] #extract GL function name |
| 73 | else: |
| 74 | continue |
| 75 | if functionName in definedFunctions: |
| 76 | #print functionName |
| 77 | continue |
| 78 | else: |
| 79 | output.write(line) |
| 80 | |