emul/src/main/java/java/lang/AnnotationImpl.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 02 Dec 2012 12:26:14 +0100
branchreflection
changeset 235 bf0a77f029c4
child 236 d97770281580
permissions -rw-r--r--
Initial support for runtime annotations
jaroslav@235
     1
/*
jaroslav@235
     2
 * To change this template, choose Tools | Templates
jaroslav@235
     3
 * and open the template in the editor.
jaroslav@235
     4
 */
jaroslav@235
     5
package java.lang;
jaroslav@235
     6
jaroslav@235
     7
import java.lang.annotation.Annotation;
jaroslav@235
     8
import org.apidesign.bck2brwsr.core.JavaScriptBody;
jaroslav@235
     9
jaroslav@235
    10
/**
jaroslav@235
    11
 *
jaroslav@235
    12
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@235
    13
 */
jaroslav@235
    14
final class AnnotationImpl implements Annotation {
jaroslav@235
    15
    public Class<? extends Annotation> annotationType() {
jaroslav@235
    16
        return getClass();
jaroslav@235
    17
    }
jaroslav@235
    18
jaroslav@235
    19
    @JavaScriptBody(args = { "a", "n", "values" }, body =
jaroslav@235
    20
          "var v = values;"
jaroslav@235
    21
        + "for (p in values) {"
jaroslav@235
    22
        + "  a[p + 'I'] = function() { return v[p]; }"
jaroslav@235
    23
        + "}"
jaroslav@235
    24
        + "a['$instOf_' + n] = true;"
jaroslav@235
    25
        + "return a;"
jaroslav@235
    26
    )
jaroslav@235
    27
    private static <T extends Annotation> T create(AnnotationImpl a, String n, Object values) {
jaroslav@235
    28
        return null;
jaroslav@235
    29
    }
jaroslav@235
    30
    static <T extends Annotation> T create(Class<T> annoClass, Object values) {
jaroslav@235
    31
        return create(new AnnotationImpl(), annoClass.getName().replace('.', '_'), values);
jaroslav@235
    32
    }
jaroslav@235
    33
}