struct*. When used as a field within another
Structure, it corresponds to struct. The
tagging interfaces ByReference and ByValue may be used
to alter the default behavior.
See the overview for supported type mappings.
Structure alignment and type mappings are derived by default from the
enclosing interface definition (if any) by using
Native#getStructureAlignment and Native#getTypeMapper.
Note
Strings are used to represent native C strings because usage of
char * is generally more common than wchar_t *.
Note
This class assumes that fields are returned in Class#getFields
in the same or reverse order as declared. If your VM returns them in
no particular order, you're out of luck.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Structure.ByReference
Tagging interface to indicate the address of an instance of the
Structure type is to be used within a |
| public static interface | Structure.ByValue
Tagging interface to indicate the value of an instance of the
|
| private static class | Structure.FFIType
This class auto-generates an ffi_type structure appropriate for a given structure for use by libffi. |
| private static class | |
| pack-priv class |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | ALIGN_DEFAULT
Use the platform default alignment. |
| public static final int | ALIGN_GNUC
validated for 32-bit x86 linux/gcc; align field size, max 4 bytes |
| public static final int | ALIGN_MSVC
validated for w32/msvc; align on field size |
| public static final int | ALIGN_NONE
No alignment, place all fields on nearest 1-byte boundary |
| private int | |
| protected static final int | |
| pack-priv static final boolean | |
| pack-priv static final boolean | |
| private static final int | |
| private Pointer | |
| private Map | |
| private static Set | |
| private static final boolean | |
| private int | |
| private int | |
| private Map | |
| private long | |
| private TypeMapper |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| protected void | |
| pack-priv int | |
| pack-priv int | |
| public void | |
| public boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
| pack-priv Map | |
| private String | |
| pack-priv Object | |
| protected int | |
| private static int | |
| public Pointer | |
| protected int | |
| pack-priv Pointer | |
| pack-priv static Pointer | |
| public int | hashCode()
Overrides java. equals depends on the native address, use that
as the hash code.
|
| public static Structure | Returns: the new instanceCreate a new Structure instance of the given type |
| public void | |
| public Object | |
| pack-priv Object | |
| protected void | |
| private void | |
| protected void | |
| public int | |
| public Structure[] | |
| public Structure[] | |
| public String | |
| private String | |
| pack-priv static Structure | Returns: UpdatedStructure.ByReference objectStructure subclass type, Structure Original Structure object s, Pointer the native address)struct *Only keep the original structure if its address is unchanged. |
| protected void | |
| protected void | |
| public void | |
| public void | |
| pack-priv void |
| ALIGN_DEFAULT | back to summary |
|---|---|
| public static final int ALIGN_DEFAULT Use the platform default alignment. | |
| ALIGN_GNUC | back to summary |
|---|---|
| public static final int ALIGN_GNUC validated for 32-bit x86 linux/gcc; align field size, max 4 bytes | |
| ALIGN_MSVC | back to summary |
|---|---|
| public static final int ALIGN_MSVC validated for w32/msvc; align on field size | |
| ALIGN_NONE | back to summary |
|---|---|
| public static final int ALIGN_NONE No alignment, place all fields on nearest 1-byte boundary | |
| alignType | back to summary |
|---|---|
| private int alignType | |
| CALCULATE_SIZE | back to summary |
|---|---|
| protected static final int CALCULATE_SIZE | |
| isPPC | back to summary |
|---|---|
| pack-priv static final boolean isPPC | |
| isSPARC | back to summary |
|---|---|
| pack-priv static final boolean isSPARC | |
| MAX_GNUC_ALIGNMENT | back to summary |
|---|---|
| private static final int MAX_GNUC_ALIGNMENT | |
| memory | back to summary |
|---|---|
| private Pointer memory | |
| nativeStrings | back to summary |
|---|---|
| private Map<K, V> nativeStrings | |
| reading | back to summary |
|---|---|
| private static Set<E> reading | |
| REVERSE_FIELDS | back to summary |
|---|---|
| private static final boolean REVERSE_FIELDS | |
| size | back to summary |
|---|---|
| private int size | |
| structAlignment | back to summary |
|---|---|
| private int structAlignment | |
| structFields | back to summary |
|---|---|
| private Map<K, V> structFields | |
| typeInfo | back to summary |
|---|---|
| private long typeInfo | |
| typeMapper | back to summary |
|---|---|
| private TypeMapper typeMapper | |
| Structure | back to summary |
|---|---|
| protected Structure() | |
| Structure | back to summary |
|---|---|
| protected Structure(int size) | |
| Structure | back to summary |
|---|---|
| protected Structure(int size, int alignment) | |
| allocateMemory | back to summary |
|---|---|
| protected void allocateMemory() Attempt to allocate memory if sufficient information is available. Returns whether the operation was successful. | |
| allocateMemory | back to summary |
|---|---|
| protected void allocateMemory(int size) Provided for derived classes to indicate a different size than the default. Returns whether the operation was successful. | |
| calculateAlignedSize | back to summary |
|---|---|
| pack-priv int calculateAlignedSize(int calculatedSize) | |
| calculateSize | back to summary |
|---|---|
| pack-priv int calculateSize(boolean force) Calculate the amount of native memory required for this structure.
May return
If the
| |
| clear | back to summary |
|---|---|
| public void clear() | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. This structure is only equal to another based on the same native memory address and data type.
| |
| fields | back to summary |
|---|---|
| pack-priv Map Return all fields in this structure (ordered). | |
| format | back to summary |
|---|---|
| private String format(Class<T> type) | |
| getField | back to summary |
|---|---|
| pack-priv Object getField(Structure. Obtain the value currently in the Java field. Does not read from memory. | |
| getNativeAlignment | back to summary |
|---|---|
| protected int getNativeAlignment(Class<T> type, Object value, boolean isFirstElement) Overridable in subclasses. | |
| getNativeSize | back to summary |
|---|---|
| private static int getNativeSize(Class<T> type, Object value) Returns the native size of the given class, in bytes. | |
| getPointer | back to summary |
|---|---|
| public Pointer getPointer() Return a | |
| getStructAlignment | back to summary |
|---|---|
| protected int getStructAlignment() | |
| getTypeInfo | back to summary |
|---|---|
| pack-priv Pointer getTypeInfo() Obtain native type information for this structure. | |
| getTypeInfo | back to summary |
|---|---|
| pack-priv static Pointer getTypeInfo(Object obj) Exposed for testing purposes only. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Since
| |
| newInstance | back to summary |
|---|---|
| public static Structure newInstance(Class<T> type) throws IllegalArgumentException Create a new Structure instance of the given type
| |
| read | back to summary |
|---|---|
| public void read() Reads the fields of the struct from native memory | |
| readField | back to summary |
|---|---|
| public Object readField(String name) Force a read of the given field from native memory.
| |
| readField | back to summary |
|---|---|
| pack-priv Object readField(Structure. Read the given field and return its value. | |
| setAlignType | back to summary |
|---|---|
| protected void setAlignType(int alignType) Change the alignment of this structure. Re-allocates memory if
necessary. If alignment is | |
| setField | back to summary |
|---|---|
| private void setField(Structure. | |
| setTypeMapper | back to summary |
|---|---|
| protected void setTypeMapper(TypeMapper mapper) Change the type mapping for this structure. May cause the structure
to be resized and any existing memory to be reallocated.
If | |
| size | back to summary |
|---|---|
| public int size() | |
| toArray | back to summary |
|---|---|
| public Structure[] toArray(Structure[] array) Returns a view of this structure's memory as an array of structures.
Note that this | |
| toArray | back to summary |
|---|---|
| public Structure[] toArray(int size) Returns a view of this structure's memory as an array of structures.
Note that this | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
| |
| toString | back to summary |
|---|---|
| private String toString(int indent) | |
| updateStructureByReference | back to summary |
|---|---|
| pack-priv static Structure updateStructureByReference(Class<T> type, Structure s, Pointer address) Only keep the original structure if its address is unchanged. Otherwise replace it with a new object. | |
| useMemory | back to summary |
|---|---|
| protected void useMemory(Pointer m) Set the memory used by this structure. This method is used to indicate the given structure is nested within another or otherwise overlaid on some other memory block and thus does not own its own memory. | |
| useMemory | back to summary |
|---|---|
| protected void useMemory(Pointer m, int offset) Set the memory used by this structure. This method is used to indicate the given structure is nested within another or otherwise overlaid on some other memory block and thus does not own its own memory. | |
| write | back to summary |
|---|---|
| public void write() Writes the fields of the struct to native memory | |
| writeField | back to summary |
|---|---|
| public void writeField(String name) Write the given field to native memory. | |
| writeField | back to summary |
|---|---|
| pack-priv void writeField(Structure. | |
Structure definition
rather than nesting the full Structure contents. The default behavior
is to inline Structure fields.
Structure type is to be used in function invocations rather
than its address. The default behavior is to treat
Structure function parameters and return values as by
reference, meaning the address of the structure is used.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| public short | |
| public Pointer | |
| private static final int | |
| public Structure. | |
| public short | |
| private static Map |
| Access | Constructor and Description |
|---|---|
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static Pointer | |
| private static Pointer | |
| private void |
| alignment | back to summary |
|---|---|
| public short alignment | |
| elements | back to summary |
|---|---|
| public Pointer elements | |
| FFI_TYPE_STRUCT | back to summary |
|---|---|
| private static final int FFI_TYPE_STRUCT | |
| size | back to summary |
|---|---|
| public Structure. Hides com. | |
| type | back to summary |
|---|---|
| public short type | |
| typeInfoMap | back to summary |
|---|---|
| private static Map<K, V> typeInfoMap | |
| FFIType | back to summary |
|---|---|
| private FFIType(Structure ref) | |
| FFIType | back to summary |
|---|---|
| private FFIType(Object array, Class<T> type) | |
| get | back to summary |
|---|---|
| pack-priv static Pointer get(Object obj) | |
| get | back to summary |
|---|---|
| private static Pointer get(Object obj, Class<T> cls) | |
| init | back to summary |
|---|---|
| private void init(Pointer[] els) | |
| Modifier and Type | Field and Description |
|---|---|
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer | |
| private static Pointer |
| Access | Constructor and Description |
|---|---|
| private |
| ffi_type_double | back to summary |
|---|---|
| private static Pointer ffi_type_double | |
| ffi_type_float | back to summary |
|---|---|
| private static Pointer ffi_type_float | |
| ffi_type_longdouble | back to summary |
|---|---|
| private static Pointer ffi_type_longdouble | |
| ffi_type_pointer | back to summary |
|---|---|
| private static Pointer ffi_type_pointer | |
| ffi_type_sint16 | back to summary |
|---|---|
| private static Pointer ffi_type_sint16 | |
| ffi_type_sint32 | back to summary |
|---|---|
| private static Pointer ffi_type_sint32 | |
| ffi_type_sint64 | back to summary |
|---|---|
| private static Pointer ffi_type_sint64 | |
| ffi_type_sint8 | back to summary |
|---|---|
| private static Pointer ffi_type_sint8 | |
| ffi_type_uint16 | back to summary |
|---|---|
| private static Pointer ffi_type_uint16 | |
| ffi_type_uint32 | back to summary |
|---|---|
| private static Pointer ffi_type_uint32 | |
| ffi_type_uint64 | back to summary |
|---|---|
| private static Pointer ffi_type_uint64 | |
| ffi_type_uint8 | back to summary |
|---|---|
| private static Pointer ffi_type_uint8 | |
| ffi_type_void | back to summary |
|---|---|
| private static Pointer ffi_type_void | |
| FFITypes | back to summary |
|---|---|
| private FFITypes() | |
| size_t | back to summary |
|---|---|
| public size_t() | |
| size_t | back to summary |
|---|---|
| public size_t(long value) | |
| Modifier and Type | Field and Description |
|---|---|
| public int | |
| public int | |
| public int |
| Access | Constructor and Description |
|---|---|
| private |
| first | back to summary |
|---|---|
| public int first | |
| last | back to summary |
|---|---|
| public int last | |
| middle | back to summary |
|---|---|
| public int middle | |
| MemberOrder | back to summary |
|---|---|
| private MemberOrder() | |
| Modifier and Type | Field and Description |
|---|---|
| public FromNativeContext | |
| public Field | |
| public boolean | |
| public String | |
| public int | |
| public FromNativeConverter | |
| public int | |
| public Class | |
| public ToNativeConverter |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| context | back to summary |
|---|---|
| public FromNativeContext context | |
| field | back to summary |
|---|---|
| public Field field | |
| isVolatile | back to summary |
|---|---|
| public boolean isVolatile | |
| name | back to summary |
|---|---|
| public String name | |
| offset | back to summary |
|---|---|
| public int offset | |
| readConverter | back to summary |
|---|---|
| public FromNativeConverter readConverter | |
| size | back to summary |
|---|---|
| public int size | |
| type | back to summary |
|---|---|
| public Class<T> type | |
| writeConverter | back to summary |
|---|---|
| public ToNativeConverter writeConverter | |
| StructField | back to summary |
|---|---|
| pack-priv StructField() | |