com.jogamp.gluegen
Class JavaMethodBindingEmitter

java.lang.Object
  extended by com.jogamp.gluegen.FunctionEmitter
      extended by com.jogamp.gluegen.JavaMethodBindingEmitter
Direct Known Subclasses:
ProcAddressJavaMethodBindingEmitter

public class JavaMethodBindingEmitter
extends FunctionEmitter

An emitter that emits only the interface for a Java<->C JNI binding.


Nested Class Summary
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
static FunctionEmitter.EmissionModifier ABSTRACT
           
protected  MethodBinding binding
           
protected  CommentEmitter defaultInterfaceCommentEmitter
           
protected  CommentEmitter defaultJavaCommentEmitter
           
protected  boolean directNIOOnly
           
protected  boolean emitBody
           
protected  List<String> epilogue
           
protected  boolean eraseBufferAndArrayTypes
           
static FunctionEmitter.EmissionModifier FINAL
           
protected  boolean forDirectBufferImplementation
           
protected  boolean forImplementingMethodCall
           
protected  boolean forIndirectBufferAndArrayImplementation
           
protected  boolean isUnimplemented
           
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
           
 
Fields inherited from class com.jogamp.gluegen.FunctionEmitter
STATIC
 
Constructor Summary
JavaMethodBindingEmitter(JavaMethodBindingEmitter arg)
           
JavaMethodBindingEmitter(MethodBinding binding, PrintWriter output, String runtimeExceptionType, String unsupportedExceptionType, boolean emitBody, boolean tagNativeBinding, boolean eraseBufferAndArrayTypes, boolean directNIOOnly, boolean forImplementingMethodCall, boolean forDirectBufferImplementation, boolean forIndirectBufferAndArrayImplementation, boolean isUnimplemented, boolean isInterface, JavaConfiguration configuration)
           
 
Method Summary
protected  String[] argumentNameArray()
           
protected  String byteOffsetArgName(int i)
           
protected  String byteOffsetArgName(String s)
           
protected  String byteOffsetArrayArgName(int i)
           
protected  int emitArguments(PrintWriter writer)
          Returns the number of arguments emitted.
protected  void emitArrayLengthAndNIOBufferChecks(MethodBinding binding, PrintWriter writer)
           
protected  void emitBody(PrintWriter writer)
           
protected  void emitCall(MethodBinding binding, PrintWriter writer)
           
protected  int emitCallArguments(MethodBinding binding, PrintWriter writer)
           
protected  void emitCallResultReturn(MethodBinding binding, PrintWriter writer)
           
protected  void emitCompoundArrayCopies(MethodBinding binding, PrintWriter writer)
           
protected  void emitName(PrintWriter writer)
           
protected  void emitPostCallCleanup(MethodBinding binding, PrintWriter writer)
           
protected  void emitPreCallSetup(MethodBinding binding, PrintWriter writer)
           
protected  void emitPrologueOrEpilogue(List<String> code, PrintWriter writer)
           
protected  void emitReturnType(PrintWriter writer)
           
protected  void emitReturnVariableSetupAndCall(MethodBinding binding, PrintWriter writer)
           
protected  String erasedTypeString(JavaType type, boolean skipBuffers)
           
protected  String getArgumentName(int i)
           
protected  String getBaseIndentString()
           
 MethodBinding getBinding()
           
protected  String getCommentStartString()
           
protected  String getImplMethodName()
           
 String getName()
           
protected  String getReturnedArrayLengthExpression()
           
protected  String getReturnTypeString(boolean skipArray)
           
 String getRuntimeExceptionType()
          The type of exception (must subclass java.lang.RuntimeException) raised if runtime checks fail in the generated code.
 String getUnsupportedExceptionType()
           
 boolean isForDirectBufferImplementation()
           
 boolean isForImplementingMethodCall()
           
 boolean isForIndirectBufferAndArrayImplementation()
           
protected  String isNIOArgName(int i)
           
protected  String isNIOArgName(String s)
           
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 setForImplementingMethodCall(boolean impl)
          Accessor for subclasses.
 void setForIndirectBufferAndArrayImplementation(boolean indirect)
          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.
 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, clearModifiers, emit, emit, emitDocComment, emitModifiers, emitSignature, getCommentEmitter, getCommentEndString, getDefaultOutput, getModifiers, hasModifier, isInterface, removeModifier, setCommentEmitter, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

emitBody

protected boolean emitBody

eraseBufferAndArrayTypes

protected boolean eraseBufferAndArrayTypes

directNIOOnly

protected boolean directNIOOnly

forImplementingMethodCall

protected boolean forImplementingMethodCall

forDirectBufferImplementation

protected boolean forDirectBufferImplementation

forIndirectBufferAndArrayImplementation

protected boolean forIndirectBufferAndArrayImplementation

isUnimplemented

protected boolean isUnimplemented

tagNativeBinding

protected boolean tagNativeBinding

binding

protected MethodBinding binding

prologue

protected List<String> prologue

epilogue

protected List<String> epilogue
Constructor Detail

JavaMethodBindingEmitter

public JavaMethodBindingEmitter(MethodBinding binding,
                                PrintWriter output,
                                String runtimeExceptionType,
                                String unsupportedExceptionType,
                                boolean emitBody,
                                boolean tagNativeBinding,
                                boolean eraseBufferAndArrayTypes,
                                boolean directNIOOnly,
                                boolean forImplementingMethodCall,
                                boolean forDirectBufferImplementation,
                                boolean forIndirectBufferAndArrayImplementation,
                                boolean isUnimplemented,
                                boolean isInterface,
                                JavaConfiguration configuration)

JavaMethodBindingEmitter

public JavaMethodBindingEmitter(JavaMethodBindingEmitter arg)
Method Detail

getBinding

public final MethodBinding getBinding()

isForImplementingMethodCall

public boolean isForImplementingMethodCall()

isForDirectBufferImplementation

public boolean isForDirectBufferImplementation()

isForIndirectBufferAndArrayImplementation

public boolean isForIndirectBufferAndArrayImplementation()

getName

public String getName()
Specified by:
getName in class FunctionEmitter

getArgumentName

protected String getArgumentName(int i)

getRuntimeExceptionType

public String getRuntimeExceptionType()
The type of exception (must subclass java.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.


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.


setForImplementingMethodCall

public void setForImplementingMethodCall(boolean impl)
Accessor for subclasses.


setForDirectBufferImplementation

public void setForDirectBufferImplementation(boolean direct)
Accessor for subclasses.


setForIndirectBufferAndArrayImplementation

public void setForIndirectBufferAndArrayImplementation(boolean indirect)
Accessor for subclasses.


emitReturnType

protected void emitReturnType(PrintWriter writer)
Specified by:
emitReturnType in class FunctionEmitter

erasedTypeString

protected String erasedTypeString(JavaType type,
                                  boolean skipBuffers)

getReturnTypeString

protected String getReturnTypeString(boolean skipArray)

emitName

protected void emitName(PrintWriter writer)
Specified by:
emitName in class FunctionEmitter

emitArguments

protected int emitArguments(PrintWriter writer)
Description copied from class: FunctionEmitter
Returns the number of arguments emitted.

Specified by:
emitArguments in class FunctionEmitter

getImplMethodName

protected String getImplMethodName()

byteOffsetArgName

protected String byteOffsetArgName(int i)

byteOffsetArgName

protected String byteOffsetArgName(String s)

isNIOArgName

protected String isNIOArgName(int i)

isNIOArgName

protected String isNIOArgName(String s)

byteOffsetArrayArgName

protected String byteOffsetArrayArgName(int i)

offsetArgName

protected String offsetArgName(int i)

emitBody

protected void emitBody(PrintWriter writer)
Specified by:
emitBody in class FunctionEmitter

emitPrologueOrEpilogue

protected void emitPrologueOrEpilogue(List<String> code,
                                      PrintWriter writer)

emitPreCallSetup

protected void emitPreCallSetup(MethodBinding binding,
                                PrintWriter writer)

emitArrayLengthAndNIOBufferChecks

protected void emitArrayLengthAndNIOBufferChecks(MethodBinding binding,
                                                 PrintWriter writer)

emitCompoundArrayCopies

protected void emitCompoundArrayCopies(MethodBinding binding,
                                       PrintWriter writer)

emitCall

protected void emitCall(MethodBinding binding,
                        PrintWriter writer)

emitReturnVariableSetupAndCall

protected void emitReturnVariableSetupAndCall(MethodBinding binding,
                                              PrintWriter writer)

emitCallArguments

protected int emitCallArguments(MethodBinding binding,
                                PrintWriter writer)

emitPostCallCleanup

protected void emitPostCallCleanup(MethodBinding binding,
                                   PrintWriter writer)

emitCallResultReturn

protected void emitCallResultReturn(MethodBinding binding,
                                    PrintWriter writer)

argumentNameArray

protected String[] argumentNameArray()

javaThisArgumentName

public static String javaThisArgumentName()

getCommentStartString

protected String getCommentStartString()
Overrides:
getCommentStartString in class FunctionEmitter

getBaseIndentString

protected String getBaseIndentString()
Overrides:
getBaseIndentString in class FunctionEmitter

getReturnedArrayLengthExpression

protected String getReturnedArrayLengthExpression()