All Packages  This Package  Class Hierarchy  Class Search  Index

Inner Class posix.CPtr.Struct
java.lang.Object
   |
   +----posix.CPtr.Struct

  Summary

public static class  CPtr.Struct
     extends java.lang.Object
{
          // Constructors 1
     public Struct(int);

          // Methods 5
     public final int addMember(int, int);
     public final int offsetOf(int);
     public final int offsetOf(int, int);
     public final int offsetOf(CPtr.Struct, int);
     public final int size();
}

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.




  Constructors

· Struct

Summary  |  Top

   public Struct(int offset) 

Initialize with the offset (within a CPtr) of the C struct.



  Methods

· offsetOf

Summary  |  Top
   public final int offsetOf(int type) 

Return the offset of the next member.



· offsetOf

Summary  |  Top
   public final int offsetOf(int type, 
                             int len) 

Return the offset of the next array member.



· addMember

Summary  |  Top
   public final int addMember(int size, 
                              int mask) 

Add a member by size and alignment mask. Return the member offset.



· offsetOf

Summary  |  Top
   public final int offsetOf(CPtr.Struct s, 
                             int cnt) 

Return the offset of a nested struct. The members must have already been added to the nested struct so that it will have the proper size and alignment.



· size

Summary  |  Top
   public final int size() 

Return total struct size including padding to reflect maximum alignment.



All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7