|
|||||||
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.Structure
The Structure
class represents structures in tems of C language.
Structure
is a superclass for classes representing specific structures.
Example of usage:
final public class RECT extends Structure{ public UInt32 left; public UInt32 top; public UInt32 right; public UInt32 bottom; public RECT(){ left = new UInt32(); top = new UInt32(); right = new UInt32(); bottom = new UInt32(); initialize(new Argument[]{left, top, right, bottom}); } }You are not forced to derive another class from Struct. A needed structure can be constructed using constructor taking array of
Argument
s.
Field Summary |
Fields inherited from class com.smardec.j2native.Argument |
JAVA_SIDE, NATIVE_SIDE |
Constructor Summary | |
Structure()
Constructs a new structure. |
|
Structure(Argument[] members)
Constructs a new structure that consists of a given set of members with default alignment. |
|
Structure(Argument[] members,
int align)
Constructs a new structure that consists of a given set of members with specified alignment. |
Method Summary | |
void |
free()
To avoid memory leaks in native memory should be used this method. |
void |
fromBytesValue(byte[] bytes,
int offset)
Restores itself from provided array of bytes. |
int |
getLength()
Returns length in bytes. |
Argument[] |
getMembers()
Returns structure members. |
protected void |
initialize(Argument[] members)
Initializes the Structure instance with specified
structure 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. |
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, getAlignedLength, getResultFlags, readFromRAM, restoreFromRAM, storeToRAM, writeToRAM |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Structure()
initialize()
method to define structure members
and alignment
public Structure(Argument[] members)
members
- structure members as appear in structure definitionpublic Structure(Argument[] members, int align)
members
- structure members as appear in structure definitionalign
- alignment in bytesMethod Detail |
protected void initialize(Argument[] members)
Structure
instance with specified
structure members.
members
- members of structure. Order of members in array
is order of members in native structure.public Argument[] getMembers()
public int getLength()
Argument
getLength
in class Argument
protected void writeToStack(byte[] stack, int offset)
Argument
writeToStack
in class Argument
stack
- it's byte array, where Argument
will be writtenoffset
- offset in stackprotected void readFromStack(byte[] stack, int offset)
Argument
readFromStack
in class Argument
stack
- it's byte array, from which Argument
will be restoredoffset
- offset in stackpublic byte[] toBytesValue()
Argument
toBytesValue
in class Argument
Argument
protected void toBytesValue(byte[] bytes, int offset)
Argument
toBytesValue
in class Argument
bytes
- array of bytes to which Argument
will be writtenoffset
- offset in arraypublic void fromBytesValue(byte[] bytes, int offset)
Argument
fromBytesValue
in class Argument
bytes
- array of bytes from which Argument
will be restoredoffset
- offset in arrayprotected void write(long handle, int offset)
Argument
write
in class Argument
handle
- identifies location in memory where Argument
will be writtenoffset
- memory address offsetprotected void read(long handle, int offset)
Argument
read
in class Argument
handle
- identifies location in memory from which Argument
will be readoffset
- memory address offsetprotected void update(byte side)
Argument
update
in class Argument
side
- identifies part that should be updatedprotected boolean isFixedLength()
Argument
Argument
is a fixed length variable.
isFixedLength
in class Argument
true
if it is so, and false
otherwisepublic void free()
Argument
free
in class Argument
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |