Package com.badlogic.gdx.jnigen.parsing.JavaMethodParser

Examples of com.badlogic.gdx.jnigen.parsing.JavaMethodParser.Argument


      buffer.append(cMethod.getArgumentTypes()[i + 2]);
      buffer.append(" ");
      // if this is not a POD or an object, we need to add a prefix
      // as we will output JNI code to get pointers to strings, arrays
      // and direct buffers.
      Argument javaArg = javaMethod.getArguments().get(i);
      if (!javaArg.getType().isPlainOldDataType() && !javaArg.getType().isObject() && appendPrefix) {
        buffer.append(JNI_ARG_PREFIX);
      }
      // output the name of the argument
      buffer.append(javaArg.getName());

      // comma, if this is not the last argument
      if (i < javaMethod.getArguments().size() - 1) buffer.append(", ");
    }
View Full Code Here


      wrapperArgs.append("env, object, ");
    }

    // arguments for wrapper method
    for (int i = 0; i < javaMethod.getArguments().size(); i++) {
      Argument arg = javaMethod.getArguments().get(i);
      if (!arg.getType().isPlainOldDataType() && !arg.getType().isObject()) {
        wrapperArgs.append(JNI_ARG_PREFIX);
      }
      // output the name of the argument
      wrapperArgs.append(arg.getName());
      if (i < javaMethod.getArguments().size() - 1) wrapperArgs.append(", ");
    }

    // direct buffer pointers
    for (Argument arg : javaMethod.getArguments()) {
      if (arg.getType().isBuffer()) {
        String type = arg.getType().getBufferCType();
        buffer.append("\t" + type + " " + arg.getName() + " = (" + type + ")(" + JNI_ARG_PREFIX
          + arg.getName() + "?env->GetDirectBufferAddress(" + JNI_ARG_PREFIX  + arg.getName() + "):0);\n");
        additionalArgs.append(", ");
        additionalArgs.append(type);
        additionalArgs.append(" ");
        additionalArgs.append(arg.getName());
        wrapperArgs.append(", ");
        wrapperArgs.append(arg.getName());
      }
    }

    // string pointers
    for (Argument arg : javaMethod.getArguments()) {
      if (arg.getType().isString()) {
        String type = "char*";
        buffer.append("\t" + type + " " + arg.getName() + " = (" + type + ")env->GetStringUTFChars(" + JNI_ARG_PREFIX
          + arg.getName() + ", 0);\n");
        additionalArgs.append(", ");
        additionalArgs.append(type);
        additionalArgs.append(" ");
        additionalArgs.append(arg.getName());
        wrapperArgs.append(", ");
        wrapperArgs.append(arg.getName());
      }
    }

    // Array pointers, we have to collect those last as GetPrimitiveArrayCritical
    // will explode into our face if we call another JNI method after that.
    for (Argument arg : javaMethod.getArguments()) {
      if (arg.getType().isPrimitiveArray()) {
        String type = arg.getType().getArrayCType();
        buffer.append("\t" + type + " " + arg.getName() + " = (" + type + ")env->GetPrimitiveArrayCritical(" + JNI_ARG_PREFIX
          + arg.getName() + ", 0);\n");
        additionalArgs.append(", ");
        additionalArgs.append(type);
        additionalArgs.append(" ");
        additionalArgs.append(arg.getName());
        wrapperArgs.append(", ");
        wrapperArgs.append(arg.getName());
      }
    }

    // new line for separation
    buffer.append("\n");
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.jnigen.parsing.JavaMethodParser.Argument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.