replicant-frameworks_native/opengl/libs/GLES2_dbg/generate_GLEnum_java.py

44 lines
829 B
Python
Raw Normal View History

#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
if __name__ == "__main__":
externs = []
lines = open("enums.in").readlines()
i = 0
print "// auto generated by generate_GLFunction_java.py"
print """package GLESv2Debugger;
public enum GLEnum
{"""
index = 0
for line in lines:
value = line[line.find("(") + 1: line.find(",")]
name = line[line.find(",") + 1: line.find(")")]
print "\t%s(%s)," % (name, value)
print """\t;
\tpublic final int value;
\tGLEnum(final int value)
\t{
\t\tthis.value = value;
\t}
\tprivate static final java.util.HashMap<Integer, GLEnum> reverseMap = new java.util.HashMap<Integer, GLEnum>();
\tstatic
\t{
\t\tfor (GLEnum e : GLEnum.values())
\t\t\treverseMap.put(e.value, e);
\t}
\tpublic static GLEnum valueOf(final int value)
\t{
\t\treturn reverseMap.get(value);
\t}
}"""