|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--com.jniwrapper.Parameter
|
+--com.jniwrapper.Structure
The class represents structures in tems of C language.
Struct is superclass for classes representing specific structures.
Example of usage:
final public class CPoint extends Structure {
public Int x = new Int();
public Int y = new Int();
public CPoint() {
init(new Parameter[] {x, y});
}
}
Nevertheless you are not forced to derive another class from Struct. Needed structure can be constructed using constructor taking array of CParameters.
| Constructor Summary | |
protected |
Structure()
Preconstructs a new structure. |
|
Structure(Parameter[] members)
Construct a new structure that consists of given set of members with default alignment. |
|
Structure(Parameter[] members,
short alignment)
Construct a new structure that consists of given set of members with given alignment. |
| Method Summary | |
protected void |
acceptIOPerformer(IOPerformer performer,
DataBuffer source,
int initialOffset,
boolean isReadOperation,
boolean invokedByCallback)
Realization of a Visitor pattern for parameter IO. |
protected void |
addMembers(Parameter[] additionalMembers)
Adds structure members (for example, in a case of structure inheritance) |
java.lang.Object |
clone()
|
protected void |
computeLength()
Subclasses should call this method if any member changes its length. |
int |
getAlignmentRequirement()
|
int |
getLength()
Returns a length of the parameter in memory. |
Parameter |
getMember(int i)
Returns a copy (clone) of a member with index i. |
Parameter[] |
getMembers()
Returns structure members. |
protected void |
init(Parameter[] members)
Initializes the instance with specified structure members and default alignment. |
protected void |
init(Parameter[] members,
short alignment)
Initializes the instance with specified structure members and alignment. |
void |
pop(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Default implementation, which does nothing as most primitive types do nothing on pop. |
void |
push(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Writes a parameter to a function stacks |
void |
read(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Reads this parameter from a specified data source. |
protected void |
setDataBuffer(DataBuffer newSource,
int newOffset)
Sets the data buffer this parameter should use to store data and an offset in bytes within that buffer. |
java.lang.String |
toString()
|
void |
write(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Writes this parameter to a specified data source. |
| Methods inherited from class com.jniwrapper.Parameter |
asReturnValue, equals, getAlignedLength, getDataBuffer, getDataBufferOffset, indent, read, toByteArray, write |
| Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected Structure()
init() method to
define structure members and alignment.
public Structure(Parameter[] members)
members - structure members as appear in structure definition.
public Structure(Parameter[] members,
short alignment)
members - structure members as appear in structure definition.alignment - alignment in bytes.| Method Detail |
protected void init(Parameter[] members,
short alignment)
protected void init(Parameter[] members)
protected void addMembers(Parameter[] additionalMembers)
public int getAlignmentRequirement()
getAlignmentRequirement in class Parameterprotected void computeLength()
init.
public int getLength()
Parametersizeof() operator.
getLength in class Parameterpublic java.lang.Object clone()
clone in class Parameterpublic java.lang.String toString()
toString in class java.lang.Objectpublic Parameter[] getMembers()
public Parameter getMember(int i)
i. To get the actual member element use
getMembers()[i]
i - index of member to return
protected void setDataBuffer(DataBuffer newSource,
int newOffset)
Parameter
setDataBuffer in class Parameter
protected void acceptIOPerformer(IOPerformer performer,
DataBuffer source,
int initialOffset,
boolean isReadOperation,
boolean invokedByCallback)
Parameterperformer is responsible for I/Oing the
parameter. Users implementing a complex parameter from scratch (i.e. not by extending a pre-existing class
such as Structure or Pointer) may wish to override this method to make a performer
visit object internal parts.
acceptIOPerformer in class Parameterperformer - visitor responsible for I/Oing the parametersource - data buffer for I/O operationinitialOffset - I/O operation offset of this parameter in the buffer
public void write(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
throws MemoryAccessViolationException
Parameter
write in class ParameterMemoryAccessViolationException
public void read(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
throws MemoryAccessViolationException
Parameter
read in class ParameterMemoryAccessViolationException
public void push(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
throws MemoryAccessViolationException
Parameter
push in class ParameterMemoryAccessViolationException
public void pop(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
throws MemoryAccessViolationException
Parameter
pop in class ParameterMemoryAccessViolationException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||