Search in sources :

Example 6 with Annotation

use of com.taobao.android.dx.rop.annotation.Annotation in project atlas by alibaba.

the class AnnotationUtils method makeInnerClass.

/**
 * Constructs a standard {@code InnerClass} annotation.
 *
 * @param name {@code null-ok;} the original name of the class, or
 * {@code null} to represent an anonymous class
 * @param accessFlags the original access flags
 * @return {@code non-null;} the annotation
 */
public static Annotation makeInnerClass(CstString name, int accessFlags) {
    Annotation result = new Annotation(INNER_CLASS_TYPE, SYSTEM);
    Constant nameCst = (name != null) ? name : CstKnownNull.THE_ONE;
    result.put(new NameValuePair(NAME_STRING, nameCst));
    result.put(new NameValuePair(ACCESS_FLAGS_STRING, CstInteger.make(accessFlags)));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.taobao.android.dx.rop.annotation.NameValuePair) Constant(com.taobao.android.dx.rop.cst.Constant) Annotation(com.taobao.android.dx.rop.annotation.Annotation) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation)

Example 7 with Annotation

use of com.taobao.android.dx.rop.annotation.Annotation in project atlas by alibaba.

the class AnnotationUtils method makeAnnotationDefault.

/**
 * Constructs a standard {@code AnnotationDefault} annotation.
 *
 * @param defaults {@code non-null;} the defaults, itself as an annotation
 * @return {@code non-null;} the constructed annotation
 */
public static Annotation makeAnnotationDefault(Annotation defaults) {
    Annotation result = new Annotation(ANNOTATION_DEFAULT_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, new CstAnnotation(defaults)));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.taobao.android.dx.rop.annotation.NameValuePair) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation) Annotation(com.taobao.android.dx.rop.annotation.Annotation) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation)

Example 8 with Annotation

use of com.taobao.android.dx.rop.annotation.Annotation in project atlas by alibaba.

the class AnnotationUtils method makeThrows.

/**
 * Constructs a standard {@code Throws} annotation.
 *
 * @param types {@code non-null;} the list of thrown types
 * @return {@code non-null;} the annotation
 */
public static Annotation makeThrows(TypeList types) {
    CstArray array = makeCstArray(types);
    Annotation result = new Annotation(THROWS_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, array));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.taobao.android.dx.rop.annotation.NameValuePair) CstArray(com.taobao.android.dx.rop.cst.CstArray) Annotation(com.taobao.android.dx.rop.annotation.Annotation) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation)

Example 9 with Annotation

use of com.taobao.android.dx.rop.annotation.Annotation in project atlas by alibaba.

the class AnnotationUtils method makeEnclosingMethod.

/**
 * Constructs a standard {@code EnclosingMethod} annotation.
 *
 * @param method {@code non-null;} the enclosing method
 * @return {@code non-null;} the annotation
 */
public static Annotation makeEnclosingMethod(CstMethodRef method) {
    Annotation result = new Annotation(ENCLOSING_METHOD_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, method));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.taobao.android.dx.rop.annotation.NameValuePair) Annotation(com.taobao.android.dx.rop.annotation.Annotation) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation)

Example 10 with Annotation

use of com.taobao.android.dx.rop.annotation.Annotation in project atlas by alibaba.

the class AnnotationUtils method makeSignature.

/**
 * Constructs a standard {@code Signature} annotation.
 *
 * @param signature {@code non-null;} the signature string
 * @return {@code non-null;} the annotation
 */
public static Annotation makeSignature(CstString signature) {
    Annotation result = new Annotation(SIGNATURE_TYPE, SYSTEM);
    /*
         * Split the string into pieces that are likely to be common
         * across many signatures and the rest of the file.
         */
    String raw = signature.getString();
    int rawLength = raw.length();
    ArrayList<String> pieces = new ArrayList<String>(20);
    for (int at = 0; at < rawLength; ) /*at*/
    {
        char c = raw.charAt(at);
        int endAt = at + 1;
        if (c == 'L') {
            // Scan to ';' or '<'. Consume ';' but not '<'.
            while (endAt < rawLength) {
                c = raw.charAt(endAt);
                if (c == ';') {
                    endAt++;
                    break;
                } else if (c == '<') {
                    break;
                }
                endAt++;
            }
        } else {
            // Scan to 'L' without consuming it.
            while (endAt < rawLength) {
                c = raw.charAt(endAt);
                if (c == 'L') {
                    break;
                }
                endAt++;
            }
        }
        pieces.add(raw.substring(at, endAt));
        at = endAt;
    }
    int size = pieces.size();
    CstArray.List list = new CstArray.List(size);
    for (int i = 0; i < size; i++) {
        list.set(i, new CstString(pieces.get(i)));
    }
    list.setImmutable();
    result.put(new NameValuePair(VALUE_STRING, new CstArray(list)));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.taobao.android.dx.rop.annotation.NameValuePair) CstArray(com.taobao.android.dx.rop.cst.CstArray) ArrayList(java.util.ArrayList) CstString(com.taobao.android.dx.rop.cst.CstString) ArrayList(java.util.ArrayList) TypeList(com.taobao.android.dx.rop.type.TypeList) CstString(com.taobao.android.dx.rop.cst.CstString) Annotation(com.taobao.android.dx.rop.annotation.Annotation) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation)

Aggregations

Annotation (com.taobao.android.dx.rop.annotation.Annotation)16 CstAnnotation (com.taobao.android.dx.rop.cst.CstAnnotation)10 NameValuePair (com.taobao.android.dx.rop.annotation.NameValuePair)9 Annotations (com.taobao.android.dx.rop.annotation.Annotations)5 CstArray (com.taobao.android.dx.rop.cst.CstArray)4 CstString (com.taobao.android.dx.rop.cst.CstString)4 CstType (com.taobao.android.dx.rop.cst.CstType)4 AttRuntimeInvisibleAnnotations (com.taobao.android.dx.cf.attrib.AttRuntimeInvisibleAnnotations)3 AttRuntimeInvisibleParameterAnnotations (com.taobao.android.dx.cf.attrib.AttRuntimeInvisibleParameterAnnotations)3 AttRuntimeVisibleAnnotations (com.taobao.android.dx.cf.attrib.AttRuntimeVisibleAnnotations)3 AttRuntimeVisibleParameterAnnotations (com.taobao.android.dx.cf.attrib.AttRuntimeVisibleParameterAnnotations)3 AttributeList (com.taobao.android.dx.cf.iface.AttributeList)2 AnnotationsList (com.taobao.android.dx.rop.annotation.AnnotationsList)2 CstNat (com.taobao.android.dx.rop.cst.CstNat)2 TypeList (com.taobao.android.dx.rop.type.TypeList)2 AttAnnotationDefault (com.taobao.android.dx.cf.attrib.AttAnnotationDefault)1 AttEnclosingMethod (com.taobao.android.dx.cf.attrib.AttEnclosingMethod)1 Method (com.taobao.android.dx.cf.iface.Method)1 MethodList (com.taobao.android.dx.cf.iface.MethodList)1 ParseException (com.taobao.android.dx.cf.iface.ParseException)1