public class CMethodBindingEmitter extends FunctionEmitter
Modifier and Type | Class and Description |
---|---|
protected static class |
CMethodBindingEmitter.DefaultCommentEmitter
Class 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.
|
FunctionEmitter.EmissionModifier
Modifier and Type | Field and Description |
---|---|
protected static String |
arrayIdx |
protected static String |
arrayRes |
protected static String |
arrayResLength |
protected MethodBinding |
binding |
protected static CommentEmitter |
defaultCommentEmitter |
protected boolean |
forImplementingMethodCall |
protected boolean |
forIndirectBufferAndArrayImplementation |
protected static Logger |
LOG |
protected MachineDescription |
machDesc |
protected static String |
STRING_CHARS_PREFIX |
STATIC
Constructor and Description |
---|
CMethodBindingEmitter(MethodBinding binding,
PrintWriter output,
String javaPackageName,
String javaClassName,
boolean isOverloadedBinding,
boolean isJavaMethodStatic,
boolean forImplementingMethodCall,
boolean forIndirectBufferAndArrayImplementation,
MachineDescription machDesc)
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.
|
Modifier and Type | Method and Description |
---|---|
protected String[] |
argumentNameArray() |
protected String |
byteOffsetArgName(int i) |
protected String |
byteOffsetArgName(String s) |
protected String |
byteOffsetArrayArgName(int i) |
protected static String |
cThisArgumentName() |
protected int |
emitArguments(PrintWriter writer)
Returns the number of arguments emitted.
|
protected void |
emitBody(PrintWriter writer) |
protected void |
emitBodyCallCFunction(PrintWriter writer) |
protected int |
emitBodyPassCArguments(PrintWriter writer)
Returns the number of arguments passed so calling code knows
whether to print a comma
|
protected void |
emitBodyReturnResult(PrintWriter writer) |
protected void |
emitBodyUserVariableAssignments(PrintWriter writer)
Emits the user-defined C variable assignments from the
TemporaryCVariableAssignments directive in the .cfg file.
|
protected void |
emitBodyUserVariableDeclarations(PrintWriter writer)
Emits the user-defined C variable declarations from the
TemporaryCVariableDeclarations directive in the .cfg file.
|
protected void |
emitBodyVariableDeclarations(PrintWriter writer) |
protected void |
emitBodyVariablePostCallCleanup(PrintWriter writer)
Code to clean up any variables that were declared in
emitBodyVariableDeclarations(), AFTER calling the actual C function.
|
protected void |
emitBodyVariablePreCallSetup(PrintWriter writer)
Code to init the variables that were declared in
emitBodyVariableDeclarations(), PRIOR TO calling the actual C
function.
|
protected void |
emitName(PrintWriter writer) |
protected void |
emitReturnType(PrintWriter writer) |
boolean |
forIndirectBufferAndArrayImplementation()
Is this CMethodBindingEmitter implementing the case of an
indirect buffer or array being passed down to C code?
|
MethodBinding |
getBinding() |
protected String |
getImplSuffix() |
boolean |
getIsJavaMethodStatic()
Is the Java side of the Java<->C JNI binding for this emitter's
MethodBinding a static method?.
|
boolean |
getIsOverloadedBinding()
Is the Java<->C JNI binding for this emitter's MethodBinding one of
several overloaded methods with the same name?
|
String |
getJavaClassName()
Get the name of the package in which the corresponding Java method
resides.
|
String |
getJavaPackageName()
Get the name of the class in which the corresponding Java method
resides.
|
MachineDescription |
getMachineDescription()
Used for certain internal type size computations
|
String |
getName() |
MessageFormat |
getReturnValueCapacityExpression()
Get the expression for the capacity of the returned java.nio.Buffer.
|
MessageFormat |
getReturnValueLengthExpression()
Get the expression for the length of the returned array
|
List<String> |
getTemporaryCVariableAssignments()
Returns the List of Strings containing assignments for temporary
C variables which are made after the underlying function call.
|
List<String> |
getTemporaryCVariableDeclarations()
Returns the List of Strings containing declarations for temporary
C variables to be assigned to after the underlying function call.
|
protected boolean |
isConstPtr(Type type)
Checks a type (expected to be pointer) for const-ness
|
protected boolean |
isConstPtrPtr(Type type)
Checks a type (expected to be pointer-to-pointer) for const-ness
|
protected String |
isNIOArgName(int i) |
protected String |
isNIOArgName(String s) |
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 **").
|
protected boolean |
javaArgTypeNeedsDataCopy(JavaType javaArgType) |
protected void |
jniMangle(Class<?> c,
StringBuilder res,
boolean syntheticArgument) |
protected String |
jniMangle(MethodBinding binding) |
protected String |
jniMangle(String name) |
protected String |
pointerConversionArgumentName(String argName) |
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.
|
void |
setReturnValueLengthExpression(MessageFormat expression)
If this function returns an array, sets the expression for the
length of the returned array.
|
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.
|
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.
|
addModifier, addModifiers, clearModifiers, emit, emit, emitDocComment, emitModifiers, emitSignature, getBaseIndentString, getCommentEmitter, getCommentEndString, getCommentStartString, getDefaultOutput, getModifiers, hasModifier, isInterface, removeModifier, setCommentEmitter, toString
protected static final Logger LOG
protected static final CommentEmitter defaultCommentEmitter
protected static final String arrayResLength
protected static final String arrayRes
protected static final String arrayIdx
protected MethodBinding binding
protected boolean forImplementingMethodCall
protected boolean forIndirectBufferAndArrayImplementation
protected static final String STRING_CHARS_PREFIX
protected MachineDescription machDesc
public CMethodBindingEmitter(MethodBinding binding, PrintWriter output, String javaPackageName, String javaClassName, boolean isOverloadedBinding, boolean isJavaMethodStatic, boolean forImplementingMethodCall, boolean forIndirectBufferAndArrayImplementation, MachineDescription machDesc)
public final MethodBinding getBinding()
public String getName()
getName
in class FunctionEmitter
public final MessageFormat getReturnValueCapacityExpression()
public final void setReturnValueCapacityExpression(MessageFormat expression)
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.IllegalArgumentException
- if the
binding.getJavaReturnType().isNIOBuffer() == false and
binding.getJavaReturnType().isCompoundTypeWrapper() == false
public final MessageFormat getReturnValueLengthExpression()
public final void setReturnValueLengthExpression(MessageFormat expression)
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.IllegalArgumentException
- if the
binding.getJavaReturnType().isNIOBuffer() == false
public final List<String> getTemporaryCVariableDeclarations()
public final void setTemporaryCVariableDeclarations(List<String> arg)
public final List<String> getTemporaryCVariableAssignments()
public final void setTemporaryCVariableAssignments(List<String> arg)
public String getJavaPackageName()
public String getJavaClassName()
public final boolean getIsOverloadedBinding()
public final boolean getIsJavaMethodStatic()
public final boolean forIndirectBufferAndArrayImplementation()
public final MachineDescription getMachineDescription()
protected void emitReturnType(PrintWriter writer)
emitReturnType
in class FunctionEmitter
protected void emitName(PrintWriter writer)
emitName
in class FunctionEmitter
protected String getImplSuffix()
protected int emitArguments(PrintWriter writer)
FunctionEmitter
emitArguments
in class FunctionEmitter
protected void emitBody(PrintWriter writer)
emitBody
in class FunctionEmitter
protected void emitBodyVariableDeclarations(PrintWriter writer)
protected void emitBodyUserVariableDeclarations(PrintWriter writer)
protected boolean isUTF8Type(Type type)
protected boolean isConstPtr(Type type)
protected boolean isConstPtrPtr(Type type)
protected void emitBodyVariablePreCallSetup(PrintWriter writer)
protected void emitBodyVariablePostCallCleanup(PrintWriter writer)
protected int emitBodyPassCArguments(PrintWriter writer)
protected void emitBodyCallCFunction(PrintWriter writer)
protected void emitBodyUserVariableAssignments(PrintWriter writer)
protected void emitBodyReturnResult(PrintWriter writer)
protected static String cThisArgumentName()
protected String jniMangle(MethodBinding binding)
protected void jniMangle(Class<?> c, StringBuilder res, boolean syntheticArgument)
protected String byteOffsetArgName(int i)
protected String isNIOArgName(int i)
protected String byteOffsetArrayArgName(int i)
protected String[] argumentNameArray()
protected boolean javaArgTypeNeedsDataCopy(JavaType javaArgType)