Example usage for org.apache.commons.bcel6.generic Type VOID

List of usage examples for org.apache.commons.bcel6.generic Type VOID

Introduction

In this page you can find the example usage for org.apache.commons.bcel6.generic Type VOID.

Prototype

BasicType VOID

To view the source code for org.apache.commons.bcel6.generic Type VOID.

Click Source Link

Document

Predefined constants

Usage

From source file:ru.objective.jni.tasks.builders.ClassBuilder.java

private String getMethodImplementation(Method method, String declaration) {
    StringBuilder builder = new StringBuilder();

    String vars = generateArgumentString(method);

    builder.append(declaration).append(" {").append(System.lineSeparator());

    builder.append("OJNIEnv *__env = [OJNIEnv currentEnv];").append(System.lineSeparator());
    builder.append("jmethodID mid = [[OJNIMidManager sharedManager] methodIDFor");
    if (method.isStatic())
        builder.append("Static");
    builder.append("Method:@\"" + method.getName() + "\" ");
    builder.append("signature:@\"" + method.getSignature() + "\" inClass:self.class];");
    builder.append(System.lineSeparator());

    // todo remove [self.class OJNIClass];
    if (method.getReturnType().equals(Type.VOID)) {
        if (Utils.isConstructor(method)) {
            builder.append("jobject __obj = [__env newObject:[self.class OJNIClass] method:mid");
            builder.append(vars).append("];").append(System.lineSeparator());
            builder.append("return [super initWithJavaObject:__obj];");

        } else {//from   ww w . ja  v  a2s.  c om
            if (method.isStatic()) {
                builder.append("[__env callStaticVoidMethodOnClass:[self.class OJNIClass] method:mid");
            } else {
                builder.append("[__env callVoidMethodOnObject:[self javaObject] method:mid");
            }

            builder.append(vars).append("];");
        }
    } else {
        builder.append(generateCallMethod(method, vars));
        builder.append(generateReturnObject(method.getReturnType()));
    }

    builder.append(System.lineSeparator()).append("}");

    return builder.toString();
}