当前位置: 首页>>代码示例>>Java>>正文


Java PrimitiveType.Kind方法代码示例

本文整理汇总了Java中com.sun.mirror.type.PrimitiveType.Kind方法的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveType.Kind方法的具体用法?Java PrimitiveType.Kind怎么用?Java PrimitiveType.Kind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.mirror.type.PrimitiveType的用法示例。


在下文中一共展示了PrimitiveType.Kind方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMethodReturnType

import com.sun.mirror.type.PrimitiveType; //导入方法依赖的package包/类
public static String getMethodReturnType(MethodDeclaration method, GLreturn return_annotation, boolean buffer) {
	ParameterDeclaration return_param = null;
	for ( ParameterDeclaration param : method.getParameters() ) {
		if ( param.getSimpleName().equals(return_annotation.value()) ) {
			return_param = param;
			break;
		}
	}
	if ( return_param == null )
		throw new RuntimeException("The @GLreturn parameter \"" + return_annotation.value() + "\" could not be found in method: " + method);

	PrimitiveType.Kind kind = NativeTypeTranslator.getPrimitiveKindFromBufferClass(Utils.getJavaType(return_param.getType()));
	if ( return_param.getAnnotation(GLboolean.class) != null )
		kind = PrimitiveType.Kind.BOOLEAN;

	if ( kind == PrimitiveType.Kind.BYTE && (return_param.getAnnotation(GLchar.class) != null || return_param.getAnnotation(GLcharARB.class) != null) )
		return "String";
	else {
		final String type = JavaTypeTranslator.getPrimitiveClassFromKind(kind).getName();
		return buffer ? Character.toUpperCase(type.charAt(0)) + type.substring(1) : type;
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:Utils.java

示例2: getNativeTypeFromPrimitiveType

import com.sun.mirror.type.PrimitiveType; //导入方法依赖的package包/类
public Class<? extends Annotation> getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
	Class<? extends Annotation> type;
	switch ( kind ) {
		case INT:
			type = GLint.class;
			break;
		case FLOAT:
			type = GLfloat.class;
			break;
		case SHORT:
			type = GLshort.class;
			break;
		case BYTE:
			type = GLbyte.class;
			break;
		case BOOLEAN:
			type = GLboolean.class;
			break;
		case LONG:
			type = GLint64.class;
			break;
		default:
			throw new RuntimeException(kind + " is not allowed");
	}
	return type;
}
 
开发者ID:Superloup10,项目名称:Wolf_game,代码行数:27,代码来源:GLESTypeMap.java

示例3: getNativeTypeFromPrimitiveType

import com.sun.mirror.type.PrimitiveType; //导入方法依赖的package包/类
public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
	Class type;
	switch ( kind ) {
		case INT:
			type = GLint.class;
			break;
		case DOUBLE:
			type = GLdouble.class;
			break;
		case FLOAT:
			type = GLfloat.class;
			break;
		case SHORT:
			type = GLshort.class;
			break;
		case BYTE:
			type = GLbyte.class;
			break;
		case LONG:
			type = GLint64EXT.class;
			break;
		case BOOLEAN:
			type = GLboolean.class;
			break;
		default:
			throw new RuntimeException(kind + " is not allowed");
	}
	return type;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:GLTypeMap.java

示例4: getNativeTypeFromPrimitiveType

import com.sun.mirror.type.PrimitiveType; //导入方法依赖的package包/类
public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
	Class type;
	switch ( kind ) {
		case INT:
			type = cl_int.class;
			break;
		case DOUBLE:
			type = cl_double.class;
			break;
		case FLOAT:
			type = cl_float.class;
			break;
		case SHORT:
			type = cl_short.class;
			break;
		case BYTE:
			type = cl_byte.class;
			break;
		case LONG:
			type = cl_long.class;
			break;
		case BOOLEAN:
			type = cl_bool.class;
			break;
		default:
			throw new RuntimeException(kind + " is not allowed");
	}
	return type;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:CLTypeMap.java

示例5: validateField

import com.sun.mirror.type.PrimitiveType; //导入方法依赖的package包/类
private static void validateField(FieldDeclaration field) {
	// Check if field is "public static final"
	Collection<Modifier> modifiers = field.getModifiers();
	if ( modifiers.size() != 3
	     || !modifiers.contains(Modifier.PUBLIC)
	     || !modifiers.contains(Modifier.STATIC)
	     || !modifiers.contains(Modifier.FINAL) ) {
		throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final");
	}

	// Check suported types (int, long, float, String)
	TypeMirror field_type = field.getType();
	if ( field_type instanceof PrimitiveType ) {
		PrimitiveType field_type_prim = (PrimitiveType)field_type;
		PrimitiveType.Kind field_kind = field_type_prim.getKind();
		if ( field_kind != PrimitiveType.Kind.INT
		     && field_kind != PrimitiveType.Kind.LONG
		     && field_kind != PrimitiveType.Kind.FLOAT
		     && field_kind != PrimitiveType.Kind.BYTE ) {
			throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int', 'long' or 'float'");
		}
	} else if ( "java.lang.String".equals(field_type.toString()) ) {
	} else {
		throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type or String");
	}

	Object field_value = field.getConstantValue();
	if ( field_value == null ) {
		throw new RuntimeException("Field " + field.getSimpleName() + " has no initial value");
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:32,代码来源:FieldsGenerator.java

示例6: getPrimitiveTypeFromNativeType

import com.sun.mirror.type.PrimitiveType; //导入方法依赖的package包/类
public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
	PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
	if ( kind == null )
		throw new RuntimeException("Unsupported type " + native_type);
	return kind;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:GLTypeMap.java

示例7: getPrimitiveTypeFromNativeType

import com.sun.mirror.type.PrimitiveType; //导入方法依赖的package包/类
public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class<? extends Annotation> native_type) {
	PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
	if ( kind == null )
		throw new RuntimeException("Unsupported type " + native_type);
	return kind;
}
 
开发者ID:Superloup10,项目名称:Wolf_game,代码行数:7,代码来源:GLESTypeMap.java


注:本文中的com.sun.mirror.type.PrimitiveType.Kind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。