|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object
|
+--com.smardec.j2native.Argument
|
+--com.smardec.j2native.Union
The Union class represents a C union type. Function arguments 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.smardec.j2native.Argument |
JAVA_SIDE, NATIVE_SIDE |
| Constructor Summary | |
protected |
Union()
Preconstructs a union. |
protected |
Union(Argument[] members)
Constructs a union with a given set of members. |
| Method Summary | |
void |
fromBytesValue(byte[] bytes,
int offset)
Restores itself from provided array of bytes. |
Argument |
getActiveMember()
Returns currently active member. |
int |
getLength()
Returns length in bytes. |
Argument[] |
getMembers()
Returns union members. |
protected void |
initialize(Argument[] members)
Initialize union and sets union members. |
protected boolean |
isFixedLength()
Identify if Argument is a fixed length variable. |
protected void |
read(long handle,
int offset)
Reads itself from the memory. |
protected void |
readFromStack(byte[] stack,
int offset)
Read itself from stack. |
void |
setActiveMember(Argument active)
Defines the member of this union that is currently used. |
void |
setActiveMember(Argument active,
boolean update)
Defines the member of this union that is currently used. |
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 update)
Selects a new active member of the union by its index in the array passed on the initialization. |
byte[] |
toBytesValue()
Encodes itself and returns it's representation as array of bytes. |
protected void |
toBytesValue(byte[] bytes,
int offset)
Encodes itself to the provided array of bytes. |
protected void |
update(byte side)
This method is used to synchronize Java side and native part. |
protected void |
write(long handle,
int offset)
Writes itself to the memory. |
protected void |
writeToStack(byte[] stack,
int offset)
Writes itself to stack. |
| Methods inherited from class com.smardec.j2native.Argument |
clone, finalize, free, getAlignedLength, getResultFlags, readFromRAM, restoreFromRAM, storeToRAM, writeToRAM |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected Union()
initialize() method
protected Union(Argument[] members)
| Method Detail |
protected void initialize(Argument[] members)
members - union memberspublic Argument[] getMembers()
public void setActiveMember(Argument active)
active - a new active member
public void setActiveMember(Argument active,
boolean update)
throws java.lang.IllegalStateException
update
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.
active - a new active memberupdate - if true, this member is read from the last value of this union
java.lang.IllegalStateException - if internal structure is wrongpublic void setActiveMember(int index)
index - the index of the new active member.
public void setActiveMember(int index,
boolean update)
update 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.
index - the index of the new active member.update - if true, this member is read from the last value of this union
java.lang.IllegalStateException - if internal structure is wrongpublic Argument getActiveMember()
protected void update(byte side)
Argument
update in class Argumentside - identifies part that should be updated
protected void write(long handle,
int offset)
Argument
write in class Argumenthandle - identifies location in memory where Argument
will be writtenoffset - memory address offset
protected void read(long handle,
int offset)
Argument
read in class Argumenthandle - identifies location in memory from which Argument
will be readoffset - memory address offset
protected void writeToStack(byte[] stack,
int offset)
Argument
writeToStack in class Argumentstack - it's byte array, where Argument will be writtenoffset - offset in stack
protected void readFromStack(byte[] stack,
int offset)
Argument
readFromStack in class Argumentstack - it's byte array, from which Argument will be restoredoffset - offset in stackprotected boolean isFixedLength()
ArgumentArgument is a fixed length variable.
isFixedLength in class Argumenttrue if it is so, and false otherwisepublic byte[] toBytesValue()
Argument
toBytesValue in class ArgumentArgument
protected void toBytesValue(byte[] bytes,
int offset)
Argument
toBytesValue in class Argumentbytes - array of bytes to which Argument will be writtenoffset - offset in array
public void fromBytesValue(byte[] bytes,
int offset)
Argument
fromBytesValue in class Argumentbytes - array of bytes from which Argument will be restoredoffset - offset in arraypublic int getLength()
Argument
getLength in class Argument
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||