blob: cf543c8e97726baa634cbf9f54c31db289132869 [file] [log] [blame]
David Li5d710c22011-03-04 17:47:18 -08001#!/usr/bin/python
2# -*- coding: utf-8 -*-
3
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
20if __name__ == "__main__":
21 externs = []
22 lines = open("../../../frameworks/base/opengl/libs/enums.in").readlines()
23 output = open("src/com/android/glesv2debugger/GLEnum.java", "w")
24 i = 0
25 output.write(
26"""/*
27 ** Copyright 2011, The Android Open Source Project
28 **
29 ** Licensed under the Apache License, Version 2.0 (the "License");
30 ** you may not use this file except in compliance with the License.
31 ** You may obtain a copy of the License at
32 **
33 ** http://www.apache.org/licenses/LICENSE-2.0
34 **
35 ** Unless required by applicable law or agreed to in writing, software
36 ** distributed under the License is distributed on an "AS IS" BASIS,
37 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38 ** See the License for the specific language governing permissions and
39 ** limitations under the License.
40 */
41
42// auto generated by generate_GLEnum_java.py"
43
44package com.android.glesv2debugger;
45
46public enum GLEnum {
47""")
48
49 index = 0
50 for line in lines:
51 value = line[line.find("(") + 1: line.find(",")]
52 name = line[line.find(",") + 1: line.find(")")]
53 output.write(" %s(%s),\n" % (name, value))
54
55 output.write(""" ;
56
57 public final int value;
58 GLEnum(final int value) {
59 this.value = value;
60 }
61
62 private static final java.util.HashMap<Integer, GLEnum> reverseMap = new java.util.HashMap<Integer, GLEnum>();
63 static {
64 for (GLEnum e : GLEnum.values())
65 reverseMap.put(e.value, e);
66 }
67
68 public static GLEnum valueOf(final int value) {
69 return reverseMap.get(value);
70 }
71}""")
72
73