|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--com.jniwrapper.Parameter
|
+--com.jniwrapper.Callback
Callback is the superclass for all classes representing callback functions.
A class nested from Callback must override method callback().
Example of usage:
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: current implementation of callback is NOT thread-safe.
| 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. |
java.lang.Object |
clone()
Cloning is not supported by callbacks. |
void |
dispose()
Release resources associated with this callback. |
byte |
getCallingConvention()
Returns callback calling convention. |
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. |
void |
read(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Does nothing. |
void |
setCallingConvention(byte callingConvention)
Sets calling convention that is used to invoke this callback. |
java.lang.String |
toString()
|
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, equals, getAlignedLength, getAlignmentRequirement, getDataBuffer, getDataBufferOffset, indent, pop, push, read, setDataBuffer, toByteArray, write |
| Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, 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 value| Method Detail |
protected 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 function are stored in variables specified during callback initialization. Overriden method must store return value to the return value variable specified during initialization.
public int getLength()
getLength in class Parameterpublic java.lang.Object clone()
UnsupportedOperationException.
clone in class Parameterjava.lang.UnsupportedOperationException - alwayspublic java.lang.String toString()
toString in class java.lang.Objectpublic void dispose()
public void write(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
throws MemoryAccessViolationException
write in class ParameterMemoryAccessViolationException
public void read(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
throws MemoryAccessViolationException
read in class ParameterMemoryAccessViolationExceptionpublic void setCallingConvention(byte callingConvention)
public byte getCallingConvention()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||