|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object posix.CPtr.Struct
public static class CPtr.Struct
Compute the offsets of a C struct one member at a time. This
is supposed to reflect what a C compiler would do. I can't think
of a better way to track C data structs with code that doesn't get
recompiled. A config file could do it, but would be even
more work. Some C compilers will do surprising things - like
padding structs that contain only 'char' members. They do this to
avoid cache misses at the beginning of the struct - or to make struct
pointers uniform on word addressable machines (e.g. PDP20).
You can work around this for now with the
addMember
method - provided you can figure out when
to do so. Please report any problems you encounter - we can add
additional native methods, e.g. 'structAlign' to return minimum
struct alignment.
Constructor Summary | |
---|---|
CPtr.Struct(int offset)
Initialize with the offset (within a CPtr) of the C struct. |
Method Summary | |
---|---|
int |
addMember(int size,
int mask)
Add a member by size and alignment mask. |
int |
offsetOf(CPtr.Struct s,
int cnt)
Return the offset of a nested struct. |
int |
offsetOf(int type)
Return the offset of the next member. |
int |
offsetOf(int type,
int len)
Return the offset of the next array member. |
int |
size()
Return total struct size including padding to reflect maximum alignment. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CPtr.Struct(int offset)
Method Detail |
---|
public final int offsetOf(int type)
public final int offsetOf(int type, int len)
public final int addMember(int size, int mask)
public final int offsetOf(CPtr.Struct s, int cnt)
public final int size()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |