|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jniwrapper.Parameter
com.jniwrapper.Callback
public abstract class Callback
Callback
is a superclass for all classes representing callback functions.
A class nested from Callback
must override the callback()
method.
Expected native code usage is:
final public class CMultiply extends Callback
{
public Int a = new Int();
public Int b = new Int();
public Int retVal = new Int();
public CMultiply()
{
init(new CParameter[] {a, b}, retVal);
}
public void callback()
{
retVal.setValue(a.getValue()*b.getValue());
}
}
void myMethod()
{
Function.call("userLib", "userFunc", null, new CMultiply());
}
typedef int CMultiply(int a, int b); void userFunc(CMultiply *func) { int val = func(2, 2); }NOTE:The current implementation of callback is NOT thread-safe.
Field Summary |
---|
Fields inherited from class com.jniwrapper.Parameter |
---|
LICENSE_TYPE, V |
Constructor Summary | |
---|---|
protected |
Callback()
Constructs a callback instance. |
|
Callback(Parameter[] params,
Parameter retVal)
Constructs a callback instance. |
Method Summary | |
---|---|
abstract void |
callback()
This method is called when callback function is called. |
protected void |
callback(Parameter[] parameters,
Parameter returnValue)
|
java.lang.Object |
clone()
Cloning is not supported by callbacks. |
protected Parameter |
createReturnValueByFields()
|
void |
dispose()
Releases resources associated with this callback. |
byte |
getCallingConvention()
Returns callback calling convention. |
java.lang.String |
getDebugInfo()
Return debug info for JNIWrapper parameter. |
int |
getLength()
Returns the length of native side parameter required to represent this callback. |
protected Parameter[] |
getParameters()
|
protected Parameter |
getReturnValue()
|
protected void |
init(Parameter[] params,
Parameter retVal)
Initializes callback parameters. |
boolean |
isNull()
Tests if this pointer is null. |
protected boolean |
isUseFieldsForCallbackParameters()
|
void |
read(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Does nothing. |
protected void |
restoreState()
|
protected void |
saveState()
|
void |
setCallingConvention(byte callingConvention)
Sets calling convention that is used to invoke this callback. |
protected void |
setUseFieldsForCallbackParameters(boolean useFieldsForCallbackParameters)
|
Pointer.Void |
toPointer()
Converts this callback to void pointer. |
void |
write(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Writes pointer to the native callback function that redirects to this callback object. |
Methods inherited from class com.jniwrapper.Parameter |
---|
acceptIOPerformer, asReturnValue, dataBufferAssigned, equals, getAlignedLength, getAlignmentRequirement, getDataBuffer, getDataBufferOffset, hashCode, indent, pop, push, read, read, setDataBuffer, toByteArray, write |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Callback()
init()
method to initialize callback arguments/return.
public Callback(Parameter[] params, Parameter retVal)
params
- callback function argumentsretVal
- callback function return valueMethod Detail |
---|
protected boolean isUseFieldsForCallbackParameters()
protected final void setUseFieldsForCallbackParameters(boolean useFieldsForCallbackParameters)
protected final void init(Parameter[] params, Parameter retVal)
params
- callback function argumentsretVal
- callback function return valueprotected Parameter[] getParameters()
protected Parameter getReturnValue()
public abstract void callback()
Parameters of the function are stored in variables specified during callback initialization. Overriden method must store return value to the return value variable specified during initialization.
protected void callback(Parameter[] parameters, Parameter returnValue)
protected Parameter createReturnValueByFields()
protected void saveState()
protected void restoreState()
public int getLength()
getLength
in class Parameter
public java.lang.Object clone()
UnsupportedOperationException
.
clone
in class Parameter
java.lang.UnsupportedOperationException
- alwayspublic void dispose()
public void write(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
write
in class Parameter
MemoryAccessViolationException
public void read(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
read
in class Parameter
MemoryAccessViolationException
public final void setCallingConvention(byte callingConvention)
public byte getCallingConvention()
public java.lang.String getDebugInfo()
Parameter
getDebugInfo
in class Parameter
public Pointer.Void toPointer()
public boolean isNull()
PointerParameter
isNull
in interface PointerParameter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |