Пример #1
0
 protected String llniType(Type t, boolean handleize, boolean longDoubleOK) {
   String res = null;
   String elmt = t.typeName();
   if (t.dimension().indexOf("[]") != -1) {
     if ((t.dimension().indexOf("[][]") != -1) || (t.asClassDoc() != null)) res = "IArrayOfRef";
     else if (elmt.equals("boolean")) res = "IArrayOfBoolean";
     else if (elmt.equals("byte")) res = "IArrayOfByte";
     else if (elmt.equals("char")) res = "IArrayOfChar";
     else if (elmt.equals("int")) res = "IArrayOfInt";
     else if (elmt.equals("long")) res = "IArrayOfLong";
     else if (elmt.equals("float")) res = "IArrayOfFloat";
     else if (elmt.equals("double")) res = "IArrayOfDouble";
     if (!handleize) res = "DEREFERENCED_" + res;
   } else {
     if (elmt.equals("void")) res = "void";
     else if ((elmt.equals("boolean"))
         || (elmt.equals("byte"))
         || (elmt.equals("char"))
         || (elmt.equals("short"))
         || (elmt.equals("int"))) res = "java_int";
     else if (elmt.equals("long")) res = longDoubleOK ? "java_long" : "val32 /* java_long */";
     else if (elmt.equals("float")) res = "java_float";
     else if (elmt.equals("double"))
       res = res = longDoubleOK ? "java_double" : "val32 /* java_double */";
     else if (t.asClassDoc() != null) {
       res = "I" + mangleClassName(t.asClassDoc().qualifiedName());
       if (!handleize) res = "DEREFERENCED_" + res;
     }
   }
   return res;
 }
Пример #2
0
  private void printOutputGenericType(Type type) {
    String link = null;
    if (!type.isPrimitive()) {
      link = Utils.getExternalLink(configuration.parentConfiguration, type, writer);
    }

    if (link == null) {
      print(type.qualifiedTypeName());
    } else {
      around("a href='" + link + "'", type.typeName());
    }
    ParameterizedType pType = type.asParameterizedType();
    if (pType != null) {
      boolean first = true;
      print("<");
      for (Type genericType : pType.typeArguments()) {
        if (first) {
          first = false;
        } else {
          print(",");
        }
        printOutputGenericType(genericType);
      }
      print(">");
    }
    print(type.dimension());
  }
Пример #3
0
 protected final String jniType(Type t) {
   String elmT = t.typeName();
   if (t.dimension().indexOf("[]") != -1) {
     if (elmT.equals("boolean")) return "jbooleanArray";
     else if (elmT.equals("byte")) return "jbyteArray";
     else if (elmT.equals("char")) return "jcharArray";
     else if (elmT.equals("short")) return "jshortArray";
     else if (elmT.equals("int")) return "jintArray";
     else if (elmT.equals("long")) return "jlongArray";
     else if (elmT.equals("float")) return "jfloatArray";
     else if (elmT.equals("double")) return "jdoubleArray";
     else if ((t.dimension().indexOf("[][]") != -1) || (t.asClassDoc() != null))
       return "jobjectArray";
   } else {
     if (elmT.equals("void")) return "void";
     else if (elmT.equals("boolean")) return "jboolean";
     else if (elmT.equals("byte")) return "jbyte";
     else if (elmT.equals("char")) return "jchar";
     else if (elmT.equals("short")) return "jshort";
     else if (elmT.equals("int")) return "jint";
     else if (elmT.equals("long")) return "jlong";
     else if (elmT.equals("float")) return "jfloat";
     else if (elmT.equals("double")) return "jdouble";
     else if (t.asClassDoc() != null) {
       if (elmT.equals("String")) return "jstring";
       else if (t.asClassDoc().subclassOf(root.classNamed("java.lang.Class"))) return "jclass";
       else return "jobject";
     }
   }
   Util.bug("jni.unknown.type");
   return null; /* dead code. */
 }
Пример #4
0
 /** Print a a basic type t */
 private String type(Options opt, Type t) {
   String type = "";
   if (opt.showQualified) type = t.qualifiedTypeName();
   else type = t.typeName();
   type += typeParameters(opt, t.asParameterizedType());
   return type;
 }
Пример #5
0
 /** Annotate an field/argument with its type t */
 private String typeAnnotation(Options opt, Type t) {
   String ta = "";
   if (t.typeName().equals("void")) return ta;
   ta += " : ";
   ta += type(opt, t);
   ta += t.dimension();
   return ta;
 }
Пример #6
0
  protected final String jniMethodName(MethodDoc method, String cname, boolean longName) {
    String res = "Java_" + cname + "_" + method.name();

    if (longName) {
      Type mType = method.returnType();
      Parameter[] params = method.parameters();
      Type argTypes[] = new Type[params.length];
      for (int p = 0; p < params.length; p++) {
        argTypes[p] = params[p].type();
      }

      res = res + "__";
      for (int i = 0; i < argTypes.length; i++) {
        Type t = argTypes[i];
        String tname = t.typeName();
        TypeSignature newTypeSig = new TypeSignature(root);
        String sig = newTypeSig.getTypeSignature(tname);
        res = res + nameToIdentifier(sig);
      }
    }
    return res;
  }
Пример #7
0
 /**
  * Get type name of this parameter. For example if parameter is the short 'index', returns
  * "short".
  */
 public String typeName() {
   return (type instanceof ClassDoc || type instanceof TypeVariable)
       ? type.typeName() // omit formal type params or bounds
       : type.toString();
 }
Пример #8
0
 protected final boolean isLongOrDouble(Type t) {
   String tc = t.typeName();
   return (tc.equals("long") || tc.equals("double"));
 }
Пример #9
0
 public static String getExternalLink(
     Configuration configuration, Type type, HtmlDocletWriter writer) {
   return getExternalLink(
       configuration, type.asClassDoc().containingPackage().name(), type.typeName(), writer);
 }