Class CallContext
java.lang.Object
com.kenai.jffi.CallContext
Native function call context
This class holds all the information that JFFI needs to correctly call a
native function, or to implement a callback from native code to java.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final longThe native address of the context(package private) int(package private) final int(package private) final intprivate final ForeignA handle to the foreign interface to keep it alive as long as this object is aliveprivate final intThe number of parameters this function takes(package private) final long[](package private) final Type[]The parameter types of this functionprivate final intThe size of buffer required when packing parameters(package private) final TypeThe return type of this function(package private) final AtomicIntegerFieldUpdater<CallContext> -
Constructor Summary
ConstructorsConstructorDescriptionCallContext(Type returnType, int fixedParamCount, Type[] parameterTypes, CallingConvention convention, boolean saveErrno, boolean faultProtect) Creates a new instance ofFunction.CallContext(Type returnType, Type... parameterTypes) Creates a new instance ofFunctionwith default calling convention.CallContext(Type returnType, Type[] parameterTypes, CallingConvention convention) Creates a new instance ofFunction.CallContext(Type returnType, Type[] parameterTypes, CallingConvention convention, boolean saveErrno) -
Method Summary
Modifier and TypeMethodDescriptionfinal voiddispose()Deprecated.boolean(package private) final longGets the address of the function context.static CallContextgetCallContext(Type returnType, int fixedParamCount, Type[] parameterTypes, CallingConvention convention, boolean saveErrno) static CallContextgetCallContext(Type returnType, Type[] parameterTypes, CallingConvention convention, boolean saveErrno) Returns aCallContextinstance.static CallContextgetCallContext(Type returnType, Type[] parameterTypes, CallingConvention convention, boolean saveErrno, boolean faultProtect) final intGets the number of parameters the native function accepts.final TypegetParameterType(int index) Gets the type of a parameter.final intGets the number of bytes required to pack all the parameters this function accepts, into a region of memory.final TypeGets the native return type of this function.inthashCode()
-
Field Details
-
contextAddress
final long contextAddressThe native address of the context -
parameterCount
private final int parameterCountThe number of parameters this function takes -
rawParameterSize
private final int rawParameterSizeThe size of buffer required when packing parameters -
returnType
The return type of this function -
parameterTypes
The parameter types of this function -
parameterTypeHandles
final long[] parameterTypeHandles -
fixedParamCount
final int fixedParamCount -
flags
final int flags -
disposed
volatile int disposed -
UPDATER
-
foreign
A handle to the foreign interface to keep it alive as long as this object is alive
-
-
Constructor Details
-
CallContext
-
CallContext
Creates a new instance ofFunction.Functioninstances created with this constructor will save the C errno contents after each call.- Parameters:
returnType- The return type of the native function.parameterTypes- The parameter types the function accepts.convention- The calling convention of the function.
-
CallContext
public CallContext(Type returnType, Type[] parameterTypes, CallingConvention convention, boolean saveErrno) -
CallContext
CallContext(Type returnType, int fixedParamCount, Type[] parameterTypes, CallingConvention convention, boolean saveErrno, boolean faultProtect) Creates a new instance ofFunction.- Parameters:
returnType- The return type of the native function.fixedParamCount- The number of parameters that are fixed, for varargs callsparameterTypes- The parameter types the function accepts.convention- The calling convention of the function.saveErrno- Whether the errno should be saved or not
-
-
Method Details
-
getCallContext
public static CallContext getCallContext(Type returnType, Type[] parameterTypes, CallingConvention convention, boolean saveErrno) Returns aCallContextinstance. This may return a previously cached instance that matches the signature requested, and should be used in preference to instantiating new instances.- Parameters:
returnType- The return type of the native function.parameterTypes- The parameter types the function accepts.convention- The calling convention of the function.saveErrno- Indicates that the errno should be saved- Returns:
- An instance of CallContext
-
getCallContext
public static CallContext getCallContext(Type returnType, int fixedParamCount, Type[] parameterTypes, CallingConvention convention, boolean saveErrno) -
getCallContext
public static CallContext getCallContext(Type returnType, Type[] parameterTypes, CallingConvention convention, boolean saveErrno, boolean faultProtect) -
getParameterCount
public final int getParameterCount()Gets the number of parameters the native function accepts.- Returns:
- The number of parameters the native function accepts.
-
getRawParameterSize
public final int getRawParameterSize()Gets the number of bytes required to pack all the parameters this function accepts, into a region of memory.- Returns:
- The number of bytes required to store all paraameters of this function.
-
getAddress
final long getAddress()Gets the address of the function context.- Returns:
- The address of the native function context struct.
-
getReturnType
Gets the native return type of this function.- Returns:
- The native return type of this function.
-
getParameterType
Gets the type of a parameter.- Parameters:
index- The index of the parameter in the function signature- Returns:
- The
Typeof the parameter.
-
equals
-
hashCode
-
dispose
Deprecated.
-