Java Code Examples for com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod

The following examples show how to use com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 2
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 3
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 4
Source Project: TencentKona-8   Source File: RootJObjCClass.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 5
Source Project: jdk8u60   Source File: FunctionGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 6
Source Project: jdk8u60   Source File: RootJObjCClass.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 7
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 8
Source Project: openjdk-jdk8u   Source File: RootJObjCClass.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 9
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 10
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 11
Source Project: jdk8u-jdk   Source File: FunctionGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 12
Source Project: jdk8u-jdk   Source File: RootJObjCClass.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 13
Source Project: hottub   Source File: FunctionGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 14
Source Project: hottub   Source File: RootJObjCClass.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 15
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 16
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 17
Source Project: openjdk-8   Source File: FunctionGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 18
Source Project: openjdk-8   Source File: RootJObjCClass.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 19
Source Project: jdk8u_jdk   Source File: FunctionGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 20
Source Project: jdk8u_jdk   Source File: RootJObjCClass.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 21
Source Project: jdk8u-jdk   Source File: FunctionGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 22
Source Project: jdk8u-jdk   Source File: RootJObjCClass.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}
 
Example 23
private static String createFieldCache(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);

    JLField field = new JLField("private static", type.getCanonicalName(), identifier);
    // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance.
    JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier);

    JLCall createIt = new JLCall("new " + type.getCanonicalName());
    createIt.args.add(firstArg(fxn));
    createIt.args.add("\"" + fxn.name + "\"");
    createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName());
    for (final Arg arg : fxn.args)
        createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName());

    getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";");

    return field.toString() + getter.toString();
}
 
Example 24
Source Project: jdk8u-dev-jdk   Source File: RootJObjCClass.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override public void writeBeginning(final PrintStream out) {
    out.print(new JLField("private static", JOBJC_CLASSNAME, "instance"));
    out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime"));

    JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime");
    getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");");
    getInstR.body.add("if(instance == null) instance = new JObjC(runtime);");
    getInstR.body.add("return instance;");
    out.print(getInstR);

    JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance");
    getInst.body.add("return getInstance(JObjCRuntime.getInstance());");
    out.print(getInst);

    JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime");
    ctor.body.add("this.runtime = runtime;");
    for (final Framework f : frameworks)
        ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");");
    out.print(ctor);
}