Package com.jogamp.gluegen
Class CMethodBindingEmitter
java.lang.Object
com.jogamp.gluegen.FunctionEmitter
com.jogamp.gluegen.CMethodBindingEmitter
- Direct Known Subclasses:
ProcAddressCMethodBindingEmitter
Emits the C-side component of the Java<->C JNI binding.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classClass that emits a generic comment for CMethodBindingEmitters; the comment includes the C signature of the native method that is being bound by the emitter java method.Nested classes/interfaces inherited from class com.jogamp.gluegen.FunctionEmitter
FunctionEmitter.EmissionModifier -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected MethodBindingprotected static final CommentEmitterprotected booleanprotected booleanprotected final Logging.LoggerIfprotected MachineDataInfoprotected static final StringFields inherited from class com.jogamp.gluegen.FunctionEmitter
cfg, STATIC -
Constructor Summary
ConstructorsConstructorDescriptionCMethodBindingEmitter(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 Summary
Modifier and TypeMethodDescriptionprotected String[]protected StringbyteOffsetArgName(int i) protected StringbyteOffsetArrayArgName(int i) protected static Stringprotected intemitArguments(PrintWriter writer) Returns the number of arguments emitted.protected voidemitBody(PrintWriter writer) protected voidemitBodyCallCFunction(PrintWriter writer) protected intemitBodyPassCArguments(PrintWriter writer) Returns the number of arguments passed so calling code knows whether to print a commaprotected voidemitBodyReturnResult(PrintWriter writer) protected voidEmits the user-defined C variable assignments from the TemporaryCVariableAssignments directive in the .cfg file.protected voidEmits the user-defined C variable declarations from the TemporaryCVariableDeclarations directive in the .cfg file.protected voidprotected voidCode to clean up any variables that were declared in emitBodyVariableDeclarations(), AFTER calling the actual C function.protected voidCode to init the variables that were declared in emitBodyVariableDeclarations(), PRIOR TO calling the actual C function.protected voidemitName(PrintWriter writer) protected voidemitReturnType(PrintWriter writer) final booleanIs this CMethodBindingEmitter implementing the case of an indirect buffer or array being passed down to C code?final MethodBindingprotected Stringfinal booleanIs the Java side of the Java<->C JNI binding for this emitter's MethodBinding a static method?.final booleanIs the Java<->C JNI binding for this emitter's MethodBinding one of several overloaded methods with the same name?Get the name of the package in which the corresponding Java method resides.Get the name of the class in which the corresponding Java method resides.final MachineDataInfoUsed for certain internal type size computationsfinal MessageFormatGet the expression for the capacity of the returned java.nio.Buffer.final MessageFormatGet the expression for the length of the returned arrayReturns the List of Strings containing assignments for temporary C variables which are made after the underlying function call.Returns the List of Strings containing declarations for temporary C variables to be assigned to after the underlying function call.protected StringisNIOArgName(int i) protected Stringprotected booleanisUTF8Type(Type type) Checks a type to see whether it is for a UTF-8 pointer type (i.e., "const char *", "const char **").protected booleanjavaArgTypeNeedsDataCopy(JavaType javaArgType) protected StringjniMangle(MethodBinding binding) protected voidjniMangle(Class<?> c, StringBuilder res, boolean syntheticArgument) protected StringpointerConversionArgumentName(String argName) protected voidsetIsCStructFunctionPointer(boolean v) If method originates from a struct, seeMethodBinding.hasContainingType(), it can either purposed to call a native static function (default) or a struct's function pointer.final voidsetReturnValueCapacityExpression(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.final voidsetReturnValueLengthExpression(MessageFormat expression) If this function returns an array, sets the expression for the length of the returned array.final voidSets up a List of Strings containing assignments for temporary C variables which are made after the underlying function call.final voidSets up a List of Strings containing declarations for temporary C variables to be assigned to after the underlying function call.Methods inherited from class com.jogamp.gluegen.FunctionEmitter
addModifier, addModifiers, clearModifiers, emit, emit, emitDocComment, emitModifiers, emitSignature, getBaseIndentString, getCommentEmitter, getCommentEndString, getCommentStartString, getDefaultOutput, getModifiers, hasModifier, isInterface, removeModifier, setCommentEmitter, toString
-
Field Details
-
defaultCommentEmitter
-
arrayResLength
- See Also:
-
arrayRes
- See Also:
-
arrayIdx
- See Also:
-
LOG
-
binding
-
forImplementingMethodCall
protected boolean forImplementingMethodCall -
forIndirectBufferAndArrayImplementation
protected boolean forIndirectBufferAndArrayImplementation -
STRING_CHARS_PREFIX
- See Also:
-
machDesc
-
-
Constructor Details
-
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 Details
-
getBinding
-
getInterfaceName
- Specified by:
getInterfaceNamein classFunctionEmitter
-
getImplName
- Specified by:
getImplNamein classFunctionEmitter
-
getNativeName
- Specified by:
getNativeNamein classFunctionEmitter
-
getCSymbol
- Specified by:
getCSymbolin classFunctionEmitter
-
getReturnValueCapacityExpression
Get the expression for the capacity of the returned java.nio.Buffer. -
setReturnValueCapacityExpression
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 thebinding.getJavaReturnType().isNIOBuffer() == false and binding.getJavaReturnType().isCompoundTypeWrapper() == false
-
getReturnValueLengthExpression
Get the expression for the length of the returned array -
setReturnValueLengthExpression
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 thebinding.getJavaReturnType().isNIOBuffer() == false
-
getTemporaryCVariableDeclarations
Returns the List of Strings containing declarations for temporary C variables to be assigned to after the underlying function call. -
setTemporaryCVariableDeclarations
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
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
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
Get the name of the class in which the corresponding Java method resides. -
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
Used for certain internal type size computations -
emitReturnType
- Specified by:
emitReturnTypein classFunctionEmitter
-
emitName
- Specified by:
emitNamein classFunctionEmitter
-
getImplSuffix
-
emitArguments
Description copied from class:FunctionEmitterReturns the number of arguments emitted.- Specified by:
emitArgumentsin classFunctionEmitter
-
emitBody
- Specified by:
emitBodyin classFunctionEmitter
-
emitBodyVariableDeclarations
-
emitBodyUserVariableDeclarations
Emits the user-defined C variable declarations from the TemporaryCVariableDeclarations directive in the .cfg file. -
isUTF8Type
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
Code to init the variables that were declared in emitBodyVariableDeclarations(), PRIOR TO calling the actual C function. -
emitBodyVariablePostCallCleanup
Code to clean up any variables that were declared in emitBodyVariableDeclarations(), AFTER calling the actual C function. -
emitBodyPassCArguments
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, seeMethodBinding.hasContainingType(), it can either purposed to call a native static function (default) or a struct's function pointer. -
emitBodyCallCFunction
-
emitBodyUserVariableAssignments
Emits the user-defined C variable assignments from the TemporaryCVariableAssignments directive in the .cfg file. -
emitBodyReturnResult
-
cThisArgumentName
-
jniMangle
-
jniMangle
-
byteOffsetArgName
-
isNIOArgName
-
isNIOArgName
-
byteOffsetArrayArgName
-
argumentNameArray
-
pointerConversionArgumentName
-
javaArgTypeNeedsDataCopy
-