public class Structure extends Parameter implements CompositeParameter, AlignmentAwareParameter
Structure is a 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 Structure. A needed structure can be instanciated using constructor taking array of Parameters.
LICENSE_TYPE, V| Modifier | Constructor and Description |
|---|---|
protected |
Structure()
Preconstructs a new structure.
|
|
Structure(Parameter[] members)
Constructs a new structure that consists of a given set of members with default
alignment.
|
|
Structure(Parameter[] members,
short alignment)
Constructs a new structure that consists of a given set of members with given
alignment.
|
|
Structure(Structure t)
Deprecated.
This medhod does nothing. Use new
initFrom(Structure) method instead. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
acceptIOPerformer(IOPerformer performer,
DataBuffer source,
int initialOffset,
boolean isReadOperation,
boolean invokedByCallback)
Implementation of a Visitor pattern for parameter IO.
|
protected void |
addMembers(Parameter[] additionalMembers)
Adds structure members (for example, in the case of structure inheritance).
|
java.lang.Object |
clone() |
protected void |
computeLength()
Subclasses should call this method if any member changes its length.
|
boolean |
equals(java.lang.Object obj)
Compares this
Parameter object to a given object. |
int |
getAlignmentRequirement() |
java.lang.String |
getDebugInfo()
Return debug info for JNIWrapper parameter.
|
int |
getFirstMemberSize()
Should return first member size.
|
int |
getLength()
Returns the 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 int[] |
getOffsets()
Required for alignment tests
|
protected void |
init(Parameter[] members)
Initializes the instance with specified structure members and default alignment for current Platform.
|
protected void |
init(Parameter[] members,
short alignment)
Initializes the instance with specified structure members and alignment.
|
void |
initFrom(Structure source)
Copies data of source structure to this structure.
|
void |
pop(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Default implementation that does nothing because 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,
boolean shouldRead)
Sets the data buffer this parameter should use to store data and an
offset in bytes within that buffer.
|
void |
write(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Writes this parameter to a specified data source.
|
asReturnValue, dataBufferAssigned, getAlignedLength, getDataBuffer, getDataBufferOffset, hashCode, indent, read, read, toByteArray, writeprotected 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.
Note.Alignment should be 1 for Delphi packed record and 8 for non-packed.
public Structure(Structure t)
initFrom(Structure) method instead.public void initFrom(Structure source)
source - source structure which values will be copied to this structureprotected void init(Parameter[] members, short alignment)
members - members of structure. Order of members in array is order of members in native structure.alignment - alignment in bytes.
Note.Alignment should be 1 for Delphi packed record.
protected void init(Parameter[] members)
protected final void addMembers(Parameter[] additionalMembers)
public int getAlignmentRequirement()
getAlignmentRequirement in class Parameterprotected int[] getOffsets()
protected void computeLength()
setBuffer.public int getLength()
Parametersizeof() operator.public java.lang.String getDebugInfo()
ParametergetDebugInfo in class Parameterpublic Parameter[] getMembers()
public Parameter getMember(int i)
i. To get the actual member element, use
getMembers()[i]i - index of member to returnprotected void setDataBuffer(DataBuffer newSource, int newOffset, boolean shouldRead)
ParametersetDataBuffer in class Parameterprotected void acceptIOPerformer(IOPerformer performer, DataBuffer source, int initialOffset, boolean isReadOperation, boolean invokedByCallback)
Parameterperformer is responsible for reading and writing 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 - a visitor responsible for I/Oing the parameter.source - data buffer for I/O operation.initialOffset - I/O operation offset of this parameter in the
buffer.public void write(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameterwrite in class ParameterMemoryAccessViolationExceptionpublic void read(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameterread in class ParameterMemoryAccessViolationExceptionpublic void push(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameterpush in class ParameterMemoryAccessViolationExceptionpublic void pop(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameterpop in class ParameterMemoryAccessViolationExceptionpublic boolean equals(java.lang.Object obj)
ParameterParameter object to a given object. Two
Parameter objects are considered equal if their byte
representations are equal and they are of the same type. Subclasses may
override this method as appropriate.public int getFirstMemberSize()
AlignmentAwareParametergetFirstMemberSize in interface AlignmentAwareParameter