1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.gltrace.format; 18 19 import com.android.ide.eclipse.gltrace.GLProtoBuf.GLMessage.DataType.Type; 20 21 public class GLDataTypeSpec { 22 private final String mCType; 23 private final Type mType; 24 private final String mName; 25 private final boolean mIsPointer; 26 GLDataTypeSpec(String type, String name)27 public GLDataTypeSpec(String type, String name) { 28 mCType = type; 29 mName = name; 30 31 mType = getDataType(type); 32 mIsPointer = type.contains("*"); //$NON-NLS-1$ 33 } 34 getDataType(String type)35 private Type getDataType(String type) { 36 type = type.toLowerCase(); 37 38 // We use type.contains() rather than type.equals since we are matching against 39 // the type name along with qualifiers. e.g. "void", "GLvoid" and "void*" should 40 // all be assigned the same type. 41 if (type.contains("boolean")) { //$NON-NLS-1$ 42 return Type.BOOL; 43 } else if (type.contains("enum")) { //$NON-NLS-1$ 44 return Type.ENUM; 45 } else if (type.contains("float") || type.contains("clampf")) { //$NON-NLS-1$ //$NON-NLS-2$ 46 return Type.FLOAT; 47 } else if (type.contains("void")) { //$NON-NLS-1$ 48 return Type.VOID; 49 } else if (type.contains("char")) { //$NON-NLS-1$ 50 return Type.CHAR; 51 } else { 52 // Matches all of the following types: 53 // glclampx, gluint, glint, glshort, glsizei, glfixed, 54 // glsizeiptr, glintptr, glbitfield, glfixed, glubyte. 55 // We might do custom formatting for these types in the future. 56 return Type.INT; 57 } 58 } 59 getDataType()60 public Type getDataType() { 61 return mType; 62 } 63 getCType()64 public String getCType() { 65 return mCType; 66 } 67 getArgName()68 public String getArgName() { 69 return mName; 70 } 71 isPointer()72 public boolean isPointer() { 73 return mIsPointer; 74 } 75 } 76