|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jniwrapper.Parameter | +--com.jniwrapper.Union
Represents a C union
type.
Function parameters of this type are initialized with several parameters
representing union members.
A length of the union is equal to that of its longest member.
A union represents only one of its members at a time.
Users of this class should define which member the union represents
by calling one of the setActiveMember
methods.
Constructor Summary | |
protected |
Union()
Preconstructs a union. |
|
Union(Parameter[] members)
Constructs a union with a given set of members. |
protected |
Union(Union that)
|
Method Summary | |
protected void |
acceptIOPerformer(IOPerformer performer,
DataBuffer buffer,
int initialOffset,
boolean isReadOperation,
boolean invokedByCallback)
Realization of a Visitor pattern for parameter IO. |
java.lang.Object |
clone()
This method is not supported and throws exception to designate that. |
int |
getAlignmentRequirement()
|
int |
getLength()
Returns a length of the parameter in memory. |
Parameter[] |
getMembers()
|
protected void |
init(Parameter[] members)
Sets union members. |
void |
read(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Reads this parameter from a specified data source. |
void |
setActiveMember(int index)
Selects the new active member of the union by its index in the array passed on the initialization. |
void |
setActiveMember(int index,
boolean read)
Selects the new active member of the union by its index in the array passed on the initialization. |
void |
setActiveMember(Parameter active)
Defines the member of this union that is currently used. |
void |
setActiveMember(Parameter active,
boolean read)
Defines the member of this union that is currently used. |
protected void |
setDataBuffer(DataBuffer newStorage,
int newOffset)
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. |
Methods inherited from class com.jniwrapper.Parameter |
asReturnValue, equals, getAlignedLength, getDataBuffer, getDataBufferOffset, indent, pop, push, read, toByteArray, write |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected Union()
init()
method.
protected Union(Union that)
public Union(Parameter[] members)
setActiveMember()
method.
members
- union members - order does not matter.Method Detail |
protected void init(Parameter[] members)
members
- union memberspublic Parameter[] getMembers()
protected void setDataBuffer(DataBuffer newStorage, int newOffset)
Parameter
setDataBuffer
in class Parameter
public void setActiveMember(Parameter active)
public void setActiveMember(Parameter active, boolean read)
read
is true
this member is read
from the last value of this union. This is for the case when the active member
can be determined only after the function call is completed.
If the union contains pointers it is recommended to set active member
to null
before making such calls.
Because of performance considerations the method does not check that the
passed Parameter
instance actually belongs to the union.
active
- new active memberread
- if true
this member is read from the last value of this union.public void setActiveMember(int index)
index
- the index of the new active member.init(Parameter[])
public void setActiveMember(int index, boolean read)
index
- index the index of the new active member.read
- if true
the new active member is read from
the last value of the union.init(Parameter[])
public java.lang.Object clone()
clone
in class Parameter
java.lang.UnsupportedOperationException
- alwayspublic int getLength()
Parameter
sizeof()
operator.
getLength
in class Parameter
public void read(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
read
in class Parameter
MemoryAccessViolationException
public void write(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
write
in class Parameter
MemoryAccessViolationException
protected void acceptIOPerformer(IOPerformer performer, DataBuffer buffer, int initialOffset, boolean isReadOperation, boolean invokedByCallback)
Parameter
performer
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 Parameter
performer
- visitor responsible for I/Oing the parameterbuffer
- data buffer for I/O operationinitialOffset
- I/O operation offset of this parameter in the bufferpublic int getAlignmentRequirement()
getAlignmentRequirement
in class Parameter
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |