|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jniwrapper.Parameter
com.jniwrapper.Union
public class Union
Represents a C union
type. Function parameters of this type are
initialized with several parameters representing the union members. The
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.
Field Summary |
---|
Fields inherited from class com.jniwrapper.Parameter |
---|
LICENSE_TYPE, V |
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)
Implementation of a Visitor pattern for parameter IO. |
java.lang.Object |
clone()
This method is not supported and throws exception to designate that. |
Parameter |
getActiveMember()
|
int |
getAlignmentRequirement()
|
protected boolean |
getCheckMembers()
|
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[] |
getMembers()
|
protected void |
init(Parameter[] members)
Sets union members. |
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 |
readPerformed()
|
void |
setActiveMember(int index)
Selects a new active member of the union by its index in the array passed on the initialization. |
void |
setActiveMember(int index,
boolean read)
Selects a 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 |
setCheckMembers(boolean value)
|
protected void |
setDataBuffer(DataBuffer newStorage,
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. |
Methods inherited from class com.jniwrapper.Parameter |
---|
asReturnValue, dataBufferAssigned, equals, getAlignedLength, getDataBuffer, getDataBufferOffset, hashCode, indent, read, read, toByteArray, write |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, 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 - the order does not matter.Method Detail |
---|
protected void init(Parameter[] members)
members
- union memberspublic Parameter[] getMembers()
protected void setDataBuffer(DataBuffer newStorage, int newOffset, boolean shouldRead)
Parameter
setDataBuffer
in class Parameter
public Parameter getActiveMember()
public void setActiveMember(Parameter active)
active
- a new active memberpublic void setActiveMember(Parameter active, boolean read)
read
parameter is true
, this member is read
from the last value of this union. This is for the case when an active
member can be determined only after the function call is completed.
If the union contains pointers, it is recommended to set an 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
- a 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
- the index of a new active member.read
- if true
, a 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
protected void readPerformed()
protected boolean getCheckMembers()
protected void setCheckMembers(boolean value)
public void write(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
write
in class Parameter
MemoryAccessViolationException
public void push(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
push
in class Parameter
MemoryAccessViolationException
public void pop(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
pop
in class Parameter
MemoryAccessViolationException
protected void acceptIOPerformer(IOPerformer performer, DataBuffer buffer, int initialOffset, boolean isReadOperation, boolean invokedByCallback)
Parameter
performer
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 Parameter
performer
- a visitor responsible for I/Oing the parameter.buffer
- data buffer for I/O operation.initialOffset
- I/O operation offset of this parameter in the
buffer.public int getAlignmentRequirement()
getAlignmentRequirement
in class Parameter
public java.lang.String getDebugInfo()
Parameter
getDebugInfo
in class Parameter
public int getFirstMemberSize()
AlignmentAwareParameter
getFirstMemberSize
in interface AlignmentAwareParameter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |