Package com.jogamp.gluegen
Class JavaMethodBindingEmitter
- java.lang.Object
-
- com.jogamp.gluegen.FunctionEmitter
-
- com.jogamp.gluegen.JavaMethodBindingEmitter
-
- Direct Known Subclasses:
ProcAddressJavaMethodBindingEmitter
public class JavaMethodBindingEmitter extends FunctionEmitter
Emits the Java-side component (interface and.or implementation) of the Java<->C JNI binding to itsCodeUnit
, seeFunctionEmitter
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
JavaMethodBindingEmitter.DefaultCommentEmitter
Class that emits a generic comment for JavaMethodBindingEmitters; the comment includes the C signature of the native method that is being bound by the emitter java method.protected class
JavaMethodBindingEmitter.InterfaceCommentEmitter
-
Nested classes/interfaces inherited from class com.jogamp.gluegen.FunctionEmitter
FunctionEmitter.EmissionModifier
-
-
Field Summary
Fields Modifier and Type Field Description static FunctionEmitter.EmissionModifier
ABSTRACT
protected CommentEmitter
defaultInterfaceCommentEmitter
protected CommentEmitter
defaultJavaCommentEmitter
protected List<String>
epilogue
static FunctionEmitter.EmissionModifier
FINAL
static FunctionEmitter.EmissionModifier
NATIVE
static FunctionEmitter.EmissionModifier
PRIVATE
protected List<String>
prologue
static FunctionEmitter.EmissionModifier
PROTECTED
static FunctionEmitter.EmissionModifier
PUBLIC
static FunctionEmitter.EmissionModifier
SYNCHRONIZED
protected boolean
tagNativeBinding
protected boolean
useNIODirectOnly
-
Fields inherited from class com.jogamp.gluegen.FunctionEmitter
binding, cfg, STATIC, unit
-
-
Constructor Summary
Constructors Constructor Description JavaMethodBindingEmitter(JavaMethodBindingEmitter arg)
JavaMethodBindingEmitter(MethodBinding binding, CodeUnit unit, String runtimeExceptionType, String unsupportedExceptionType, boolean emitBody, boolean tagNativeBinding, boolean eraseBufferAndArrayTypes, boolean useNIOOnly, boolean useNIODirectOnly, boolean forDirectBufferImplementation, boolean forIndirectBufferAndArrayImplementation, boolean isUnimplemented, boolean isInterface, boolean isNativeMethod, boolean isPrivateNativeMethod, JavaConfiguration configuration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
appendArguments(StringBuilder buf)
Returns the number of arguments emitted.protected StringBuilder
appendName(StringBuilder buf)
protected StringBuilder
appendReturnType(StringBuilder buf)
protected String[]
argumentNameArray()
protected String
byteOffsetArgName(int i)
protected static String
byteOffsetArgName(String s)
protected String
byteOffsetArrayArgName(int i)
protected void
emitAdditionalCode()
protected void
emitArrayLengthAndNIOBufferChecks(MethodBinding binding)
protected void
emitBody()
protected void
emitCall(MethodBinding binding)
protected int
emitCallArguments(MethodBinding binding)
protected void
emitCallResultReturn(MethodBinding binding)
protected void
emitCompoundArrayCopies(MethodBinding binding)
protected void
emitPostCallCleanup(MethodBinding binding)
protected void
emitPreCallSetup(MethodBinding binding)
protected void
emitPrologueOrEpilogue(List<String> code)
protected void
emitReturnVariableSetupAndCall(MethodBinding binding)
protected String
erasedTypeString(JavaType type, boolean skipBuffers)
protected String
getArgumentName(int i)
protected String
getBaseIndentString()
protected String
getCommentEndString()
protected String
getCommentStartString()
FunctionSymbol
getCSymbol()
String
getImplName()
String
getInterfaceName()
protected String
getNativeImplMethodName()
String
getNativeName()
protected String
getReturnedArrayLengthComment()
protected String
getReturnedArrayLengthExpression()
protected String
getReturnTypeString(boolean skipArray)
String
getRuntimeExceptionType()
The type of exception (must subclassjava.lang.RuntimeException
) raised if runtime checks fail in the generated code.String
getUnsupportedExceptionType()
boolean
isForDirectBufferImplementation()
boolean
isForIndirectBufferAndArrayImplementation()
boolean
isNativeMethod()
protected String
isNIOArgName(int i)
protected String
isNIOArgName(String s)
boolean
isPrivateNativeMethod()
static String
javaThisArgumentName()
protected String
offsetArgName(int i)
void
setEmitBody(boolean emitBody)
Accessor for subclasses.void
setEpilogue(List<String> epilogue)
Sets the manually-generated epilogue code for this emitter.void
setEraseBufferAndArrayTypes(boolean erase)
Accessor for subclasses.void
setForDirectBufferImplementation(boolean direct)
Accessor for subclasses.void
setForIndirectBufferAndArrayImplementation(boolean indirect)
Accessor for subclasses.void
setPrivateNativeMethod(boolean v)
Accessor for subclasses.void
setPrologue(List<String> prologue)
Sets the manually-generated prologue code for this emitter.void
setReturnedArrayLengthExpression(String expr)
If the underlying function returns an array (currently only arrays of compound types are supported) as opposed to a pointer to an object, this method should be called to provide a MessageFormat string containing an expression that computes the number of elements of the returned array.protected void
setReturnedArrayLengthExpression(String expr, boolean onlyForComments)
boolean
signatureOnly()
Indicates whether this emitter will print only a signature, or whether it will emit Java code for the body of the method as well.-
Methods inherited from class com.jogamp.gluegen.FunctionEmitter
addModifier, addModifiers, appendModifiers, appendSignature, clearModifiers, emit, emitArguments, emitDocComment, emitModifiers, emitName, emitReturnType, emitSignature, getBinding, getCommentEmitter, getModifiers, getUnit, hasModifier, isInterface, removeModifier, setCommentEmitter, toString
-
-
-
-
Field Detail
-
PUBLIC
public static final FunctionEmitter.EmissionModifier PUBLIC
-
PROTECTED
public static final FunctionEmitter.EmissionModifier PROTECTED
-
PRIVATE
public static final FunctionEmitter.EmissionModifier PRIVATE
-
ABSTRACT
public static final FunctionEmitter.EmissionModifier ABSTRACT
-
FINAL
public static final FunctionEmitter.EmissionModifier FINAL
-
NATIVE
public static final FunctionEmitter.EmissionModifier NATIVE
-
SYNCHRONIZED
public static final FunctionEmitter.EmissionModifier SYNCHRONIZED
-
defaultJavaCommentEmitter
protected final CommentEmitter defaultJavaCommentEmitter
-
defaultInterfaceCommentEmitter
protected final CommentEmitter defaultInterfaceCommentEmitter
-
tagNativeBinding
protected final boolean tagNativeBinding
-
useNIODirectOnly
protected final boolean useNIODirectOnly
-
-
Constructor Detail
-
JavaMethodBindingEmitter
public JavaMethodBindingEmitter(MethodBinding binding, CodeUnit unit, String runtimeExceptionType, String unsupportedExceptionType, boolean emitBody, boolean tagNativeBinding, boolean eraseBufferAndArrayTypes, boolean useNIOOnly, boolean useNIODirectOnly, boolean forDirectBufferImplementation, boolean forIndirectBufferAndArrayImplementation, boolean isUnimplemented, boolean isInterface, boolean isNativeMethod, boolean isPrivateNativeMethod, JavaConfiguration configuration)
-
JavaMethodBindingEmitter
public JavaMethodBindingEmitter(JavaMethodBindingEmitter arg)
-
-
Method Detail
-
isNativeMethod
public boolean isNativeMethod()
-
isPrivateNativeMethod
public boolean isPrivateNativeMethod()
-
isForDirectBufferImplementation
public boolean isForDirectBufferImplementation()
-
isForIndirectBufferAndArrayImplementation
public boolean isForIndirectBufferAndArrayImplementation()
-
getInterfaceName
public String getInterfaceName()
- Specified by:
getInterfaceName
in classFunctionEmitter
-
getImplName
public String getImplName()
- Specified by:
getImplName
in classFunctionEmitter
-
getNativeName
public String getNativeName()
- Specified by:
getNativeName
in classFunctionEmitter
-
getCSymbol
public FunctionSymbol getCSymbol()
- Specified by:
getCSymbol
in classFunctionEmitter
-
getArgumentName
protected String getArgumentName(int i)
-
getRuntimeExceptionType
public String getRuntimeExceptionType()
The type of exception (must subclassjava.lang.RuntimeException
) raised if runtime checks fail in the generated code.
-
getUnsupportedExceptionType
public String getUnsupportedExceptionType()
-
setReturnedArrayLengthExpression
public void setReturnedArrayLengthExpression(String expr)
If the underlying function returns an array (currently only arrays of compound types are supported) as opposed to a pointer to an object, this method should be called to provide a MessageFormat string containing an expression that computes the number of elements of the returned array. The parameters to the MessageFormat expression are the names of the incoming Java arguments.
-
setReturnedArrayLengthExpression
protected void setReturnedArrayLengthExpression(String expr, boolean onlyForComments)
-
getReturnedArrayLengthExpression
protected String getReturnedArrayLengthExpression()
-
getReturnedArrayLengthComment
protected String getReturnedArrayLengthComment()
-
setPrologue
public void setPrologue(List<String> prologue)
Sets the manually-generated prologue code for this emitter.
-
setEpilogue
public void setEpilogue(List<String> epilogue)
Sets the manually-generated epilogue code for this emitter.
-
signatureOnly
public boolean signatureOnly()
Indicates whether this emitter will print only a signature, or whether it will emit Java code for the body of the method as well.
-
setEmitBody
public void setEmitBody(boolean emitBody)
Accessor for subclasses.
-
setEraseBufferAndArrayTypes
public void setEraseBufferAndArrayTypes(boolean erase)
Accessor for subclasses.
-
setPrivateNativeMethod
public void setPrivateNativeMethod(boolean v)
Accessor for subclasses.
-
setForDirectBufferImplementation
public void setForDirectBufferImplementation(boolean direct)
Accessor for subclasses.
-
setForIndirectBufferAndArrayImplementation
public void setForIndirectBufferAndArrayImplementation(boolean indirect)
Accessor for subclasses.
-
appendReturnType
protected StringBuilder appendReturnType(StringBuilder buf)
- Specified by:
appendReturnType
in classFunctionEmitter
-
getReturnTypeString
protected String getReturnTypeString(boolean skipArray)
-
appendName
protected StringBuilder appendName(StringBuilder buf)
- Specified by:
appendName
in classFunctionEmitter
-
appendArguments
protected int appendArguments(StringBuilder buf)
Description copied from class:FunctionEmitter
Returns the number of arguments emitted.- Specified by:
appendArguments
in classFunctionEmitter
-
getNativeImplMethodName
protected String getNativeImplMethodName()
-
byteOffsetArgName
protected String byteOffsetArgName(int i)
-
isNIOArgName
protected String isNIOArgName(int i)
-
byteOffsetArrayArgName
protected String byteOffsetArrayArgName(int i)
-
offsetArgName
protected String offsetArgName(int i)
-
emitAdditionalCode
protected void emitAdditionalCode()
- Overrides:
emitAdditionalCode
in classFunctionEmitter
-
emitBody
protected void emitBody()
- Specified by:
emitBody
in classFunctionEmitter
-
emitPreCallSetup
protected void emitPreCallSetup(MethodBinding binding)
-
emitArrayLengthAndNIOBufferChecks
protected void emitArrayLengthAndNIOBufferChecks(MethodBinding binding)
-
emitCompoundArrayCopies
protected void emitCompoundArrayCopies(MethodBinding binding)
-
emitCall
protected void emitCall(MethodBinding binding)
-
emitReturnVariableSetupAndCall
protected void emitReturnVariableSetupAndCall(MethodBinding binding)
-
emitCallArguments
protected int emitCallArguments(MethodBinding binding)
-
emitPostCallCleanup
protected void emitPostCallCleanup(MethodBinding binding)
-
emitCallResultReturn
protected void emitCallResultReturn(MethodBinding binding)
-
argumentNameArray
protected String[] argumentNameArray()
-
javaThisArgumentName
public static String javaThisArgumentName()
-
getCommentStartString
protected String getCommentStartString()
- Overrides:
getCommentStartString
in classFunctionEmitter
-
getCommentEndString
protected String getCommentEndString()
- Overrides:
getCommentEndString
in classFunctionEmitter
-
getBaseIndentString
protected String getBaseIndentString()
- Overrides:
getBaseIndentString
in classFunctionEmitter
-
-