예제 #1
0
 public Class[] getValidAnnotationTypes(Class type) {
   Class[] valid_types;
   if (Buffer.class.isAssignableFrom(type)) valid_types = getValidBufferTypes(type);
   else if (type.isPrimitive()) valid_types = getValidPrimitiveTypes(type);
   else if (String.class.equals(type)) valid_types = new Class[] {GLubyte.class};
   else valid_types = new Class[] {};
   return valid_types;
 }
예제 #2
0
  /**
   * Returns compact class host.
   *
   * @param obj Object to compact.
   * @return String.
   */
  @Nullable
  public static Object compactObject(Object obj) {
    if (obj == null) return null;

    if (obj instanceof Enum) return obj.toString();

    if (obj instanceof String || obj instanceof Boolean || obj instanceof Number) return obj;

    if (obj instanceof Collection) {
      Collection col = (Collection) obj;

      Object[] res = new Object[col.size()];

      int i = 0;

      for (Object elm : col) res[i++] = compactObject(elm);

      return res;
    }

    if (obj.getClass().isArray()) {
      Class<?> arrType = obj.getClass().getComponentType();

      if (arrType.isPrimitive()) {
        if (obj instanceof boolean[]) return Arrays.toString((boolean[]) obj);
        if (obj instanceof byte[]) return Arrays.toString((byte[]) obj);
        if (obj instanceof short[]) return Arrays.toString((short[]) obj);
        if (obj instanceof int[]) return Arrays.toString((int[]) obj);
        if (obj instanceof long[]) return Arrays.toString((long[]) obj);
        if (obj instanceof float[]) return Arrays.toString((float[]) obj);
        if (obj instanceof double[]) return Arrays.toString((double[]) obj);
      }

      Object[] arr = (Object[]) obj;

      int iMax = arr.length - 1;

      StringBuilder sb = new StringBuilder("[");

      for (int i = 0; i <= iMax; i++) {
        sb.append(compactObject(arr[i]));

        if (i != iMax) sb.append(", ");
      }

      sb.append("]");

      return sb.toString();
    }

    return U.compact(obj.getClass().getName());
  }
예제 #3
0
 public Class[] getValidAnnotationTypes(Class type) {
   Class[] valid_types;
   if (Buffer.class.isAssignableFrom(type)) valid_types = getValidBufferTypes(type);
   else if (type.isPrimitive()) valid_types = getValidPrimitiveTypes(type);
   else if (String.class.equals(type)) valid_types = new Class[] {GLubyte.class};
   else if (org.lwjgl.PointerWrapper.class.isAssignableFrom(type))
     valid_types = new Class[] {PointerWrapper.class};
   else if (void.class.equals(type)) valid_types = new Class[] {GLreturn.class};
   else if (PointerBuffer.class.equals(type))
     valid_types =
         new Class[] {GLintptr.class, GLintptrARB.class, GLsizeiptr.class, GLsizeiptrARB.class};
   else valid_types = new Class[] {};
   return valid_types;
 }
예제 #4
0
파일: CLTypeMap.java 프로젝트: mrasif/lwjgl
 @Override
 public Class[] getValidAnnotationTypes(Class type) {
   Class[] valid_types;
   if (Buffer.class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type))
     valid_types = getValidBufferTypes(type);
   else if (type.isPrimitive()) valid_types = getValidPrimitiveTypes(type);
   else if (String.class.equals(type)) valid_types = new Class[] {cl_byte.class};
   else if (org.lwjgl.PointerWrapper.class.isAssignableFrom(type))
     valid_types = new Class[] {PointerWrapper.class};
   else if (ByteBuffer[].class == type) valid_types = new Class[] {cl_char.class, cl_uchar.class};
   else if (void.class.equals(type)) valid_types = new Class[] {GLreturn.class};
   else valid_types = new Class[] {};
   return valid_types;
 }
예제 #5
0
 private static String getDefaultResultValue(ExecutableElement method) {
   if (method.getAnnotation(GLreturn.class) != null) {
     final String type =
         Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false);
     if ("boolean".equals(type)) {
       return "false";
     } else if (Character.isLowerCase(type.charAt(0))) {
       return "0";
     } else {
       return "null";
     }
   } else {
     final Class type = Utils.getJavaType(Utils.getMethodReturnType(method));
     if (type.isPrimitive()) {
       if (type == boolean.class) {
         return "false";
       } else {
         return "0";
       }
     } else {
       return "null";
     }
   }
 }