Class CMethodBindingEmitter

    • Constructor Detail

      • CMethodBindingEmitter

        public CMethodBindingEmitter​(MethodBinding binding,
                                     PrintWriter output,
                                     String javaPackageName,
                                     String javaClassName,
                                     boolean isOverloadedBinding,
                                     boolean isJavaMethodStatic,
                                     boolean forImplementingMethodCall,
                                     boolean forIndirectBufferAndArrayImplementation,
                                     MachineDataInfo machDesc,
                                     JavaConfiguration configuration)
        Constructs an emitter for the specified binding, and sets a default comment emitter that will emit the signature of the C function that is being bound.
    • Method Detail

      • getReturnValueCapacityExpression

        public final MessageFormat getReturnValueCapacityExpression()
        Get the expression for the capacity of the returned java.nio.Buffer.
      • setReturnValueCapacityExpression

        public final void setReturnValueCapacityExpression​(MessageFormat expression)
        If this function returns a void* encapsulated in a java.nio.Buffer (or compound type wrapper), sets the expression for the capacity of the returned Buffer.
        Parameters:
        expression - a MessageFormat which, when applied to an array of type String[] that contains each of the arguments names of the Java-side binding, returns an expression that will (when compiled by a C compiler) evaluate to an integer-valued expression. The value of this expression is the capacity of the java.nio.Buffer returned from this method.
        Throws:
        IllegalArgumentException - if the binding.getJavaReturnType().isNIOBuffer() == false and binding.getJavaReturnType().isCompoundTypeWrapper() == false
      • getReturnValueLengthExpression

        public final MessageFormat getReturnValueLengthExpression()
        Get the expression for the length of the returned array
      • setReturnValueLengthExpression

        public final void setReturnValueLengthExpression​(MessageFormat expression)
        If this function returns an array, sets the expression for the length of the returned array.
        Parameters:
        expression - a MessageFormat which, when applied to an array of type String[] that contains each of the arguments names of the Java-side binding, returns an expression that will (when compiled by a C compiler) evaluate to an integer-valued expression. The value of this expression is the length of the array returned from this method.
        Throws:
        IllegalArgumentException - if the binding.getJavaReturnType().isNIOBuffer() == false
      • getTemporaryCVariableDeclarations

        public final List<String> getTemporaryCVariableDeclarations()
        Returns the List of Strings containing declarations for temporary C variables to be assigned to after the underlying function call.
      • setTemporaryCVariableDeclarations

        public final void setTemporaryCVariableDeclarations​(List<String> arg)
        Sets up a List of Strings containing declarations for temporary C variables to be assigned to after the underlying function call. A null argument indicates that no manual declarations are to be made.
      • getTemporaryCVariableAssignments

        public final List<String> getTemporaryCVariableAssignments()
        Returns the List of Strings containing assignments for temporary C variables which are made after the underlying function call. A null argument indicates that no manual assignments are to be made.
      • setTemporaryCVariableAssignments

        public final void setTemporaryCVariableAssignments​(List<String> arg)
        Sets up a List of Strings containing assignments for temporary C variables which are made after the underlying function call. A null argument indicates that no manual assignments are to be made.
      • getJavaPackageName

        public String getJavaPackageName()
        Get the name of the class in which the corresponding Java method resides.
      • getJavaClassName

        public String getJavaClassName()
        Get the name of the package in which the corresponding Java method resides.
      • getIsOverloadedBinding

        public final boolean getIsOverloadedBinding()
        Is the Java<->C JNI binding for this emitter's MethodBinding one of several overloaded methods with the same name?
      • getIsJavaMethodStatic

        public final boolean getIsJavaMethodStatic()
        Is the Java side of the Java<->C JNI binding for this emitter's MethodBinding a static method?.
      • forIndirectBufferAndArrayImplementation

        public final boolean forIndirectBufferAndArrayImplementation()
        Is this CMethodBindingEmitter implementing the case of an indirect buffer or array being passed down to C code?
      • getMachineDataInfo

        public final MachineDataInfo getMachineDataInfo()
        Used for certain internal type size computations
      • getImplSuffix

        protected String getImplSuffix()
      • emitBodyVariableDeclarations

        protected void emitBodyVariableDeclarations​(PrintWriter writer)
      • emitBodyUserVariableDeclarations

        protected void emitBodyUserVariableDeclarations​(PrintWriter writer)
        Emits the user-defined C variable declarations from the TemporaryCVariableDeclarations directive in the .cfg file.
      • isUTF8Type

        protected boolean isUTF8Type​(Type type)
        Checks a type to see whether it is for a UTF-8 pointer type (i.e., "const char *", "const char **"). False implies that this type is for a Unicode pointer type ("jchar *", "jchar **").
      • emitBodyVariablePreCallSetup

        protected void emitBodyVariablePreCallSetup​(PrintWriter writer)
        Code to init the variables that were declared in emitBodyVariableDeclarations(), PRIOR TO calling the actual C function.
      • emitBodyVariablePostCallCleanup

        protected void emitBodyVariablePostCallCleanup​(PrintWriter writer)
        Code to clean up any variables that were declared in emitBodyVariableDeclarations(), AFTER calling the actual C function.
      • emitBodyPassCArguments

        protected int emitBodyPassCArguments​(PrintWriter writer)
        Returns the number of arguments passed so calling code knows whether to print a comma
      • setIsCStructFunctionPointer

        protected void setIsCStructFunctionPointer​(boolean v)
        If method originates from a struct, see MethodBinding.hasContainingType(), it can either purposed to call a native static function (default) or a struct's function pointer.
      • emitBodyCallCFunction

        protected void emitBodyCallCFunction​(PrintWriter writer)
      • emitBodyUserVariableAssignments

        protected void emitBodyUserVariableAssignments​(PrintWriter writer)
        Emits the user-defined C variable assignments from the TemporaryCVariableAssignments directive in the .cfg file.
      • emitBodyReturnResult

        protected void emitBodyReturnResult​(PrintWriter writer)
      • cThisArgumentName

        protected static String cThisArgumentName()
      • jniMangle

        protected void jniMangle​(Class<?> c,
                                 StringBuilder res,
                                 boolean syntheticArgument)
      • byteOffsetArgName

        protected String byteOffsetArgName​(int i)
      • isNIOArgName

        protected String isNIOArgName​(int i)
      • isNIOArgName

        protected String isNIOArgName​(String s)
      • byteOffsetArrayArgName

        protected String byteOffsetArrayArgName​(int i)
      • argumentNameArray

        protected String[] argumentNameArray()
      • pointerConversionArgumentName

        protected String pointerConversionArgumentName​(String argName)
      • javaArgTypeNeedsDataCopy

        protected boolean javaArgTypeNeedsDataCopy​(JavaType javaArgType)