Package jnr.ffi
Class Struct
java.lang.Object
jnr.ffi.Struct
- Direct Known Subclasses:
Union
Representation of C structures in java.
Note: This class is not threadsafe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classBase class for Boolean fieldsprotected classBase implementation of MemberclassRepresents a native memory address.static final classclassclassfinal classfinal classfinal classfinal classA normal C boolean - 1 byte in sizefinal classfinal classfinal classfinal classfinal classfinal classfinal classclassStruct.Enum<T extends Enum<T>>classStruct.Enum16<E extends Enum<E>>classStruct.Enum32<E extends Enum<E>>classStruct.Enum64<E extends Enum<E>>classStruct.Enum8<E extends Enum<E>>An 8 bit enum field.protected classBase for all the Enum fields.classStruct.EnumLong<E extends Enum<E>>classfinal classfinal classfinal classfinal classfinal classfinal classfinal classfinal classfinal classfinal classfinal classfinal classfinal classclassfinal classfinal classfinal classprotected classInterface all Struct members must implement.final classfinal classclassBase class for all Number structure fields.final classstatic final classprotected final classSpecialized padding fields for structs.final classclassRepresents a native memory address.classfinal classfinal classclassA 16 bit signed integer field.classA 32 bit signed integer field.classA 64 bit signed integer field.classAn 8 bit signed integerclassA native long integer field.final classfinal classfinal classfinal classclassclassStruct.StructRef<T extends Struct>Represents a reference to a Struct or and array of Structsfinal classfinal classfinal classfinal classfinal classfinal classfinal classfinal classfinal classclassA 16 bit signed integer field.classA 32 bit signed integer field.classA 64 bit unsigned integer field.classAn 8 bit unsigned integerclassA native long integer field.classclassclassclassfinal classA Windows BOOL - 4 bytesfinal class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intprotected final Struct.Address[]array(Struct.Address[] array) Creates an array ofAddressinstances.protected final Struct.Double[]array(Struct.Double[] array) Creates an array ofDoubleinstances.protected <T extends Enum<T>>
Struct.Enum<T>[]array(Struct.Enum<T>[] array, Class<T> enumClass) Creates an array ofEnuminstances.protected <T extends Enum<T>>
Struct.Enum16<T>[]array(Struct.Enum16<T>[] array, Class<T> enumClass) Creates an array ofEnum16instances.protected <T extends Enum<T>>
Struct.Enum32<T>[]array(Struct.Enum32<T>[] array, Class<T> enumClass) Creates an array ofEnum32instances.protected <T extends Enum<T>>
Struct.Enum64<T>[]array(Struct.Enum64<T>[] array, Class<T> enumClass) Creates an array ofEnum64instances.protected <T extends Enum<T>>
Struct.Enum8<T>[]array(Struct.Enum8<T>[] array, Class<T> enumClass) Creates an array ofEnum8instances.protected final Struct.Float[]array(Struct.Float[] array) Creates an array ofFloatinstances.protected final Struct.Pointer[]array(Struct.Pointer[] array) Creates an array ofPointerinstances.protected final Struct.Signed16[]array(Struct.Signed16[] array) Creates an array ofSigned16instances.protected final Struct.Signed32[]array(Struct.Signed32[] array) Creates an array ofSigned32instances.protected final Struct.Signed64[]array(Struct.Signed64[] array) Creates an array ofSigned64instances.protected final Struct.Signed8[]array(Struct.Signed8[] array) Creates an array ofSigned8instances.protected final Struct.SignedLong[]array(Struct.SignedLong[] array) Creates an array ofSignedLonginstances.protected final Struct.Unsigned16[]array(Struct.Unsigned16[] array) Creates an array ofUnsigned16instances.protected final Struct.Unsigned32[]array(Struct.Unsigned32[] array) Creates an array ofUnsigned32instances.protected final Struct.Unsigned64[]array(Struct.Unsigned64[] array) Creates an array ofUnsigned64instances.protected final Struct.Unsigned8[]array(Struct.Unsigned8[] array) Creates an array ofUnsigned8instances.protected final Struct.UnsignedLong[]array(Struct.UnsignedLong[] array) Creates an array ofUnsignedLonginstances.protected Struct.UTF8String[]array(Struct.UTF8String[] array, int stringLength) Creates an array ofUTF8Stringinstances.protected <T extends Struct.Member>
T[]array(T[] array) Creates an array ofMemberinstances.protected final voidStarts an array construction sessionprotected final voidarrayEnd()Ends an array construction sessionstatic <T extends Struct>
T[]protected final <T> Struct.Function<T>static Pointerstatic Pointerfinal Runtimeprotected final <T extends Struct>
TCreates inner Structs in Struct definitions.protected final <T extends Struct>
Tinner(T struct) Creates inner Structs in Struct definitions.static booleanstatic <T extends Struct>
intGets the size of a Struct type in bytesstatic <T extends Struct>
intGets the size of a Struct type in bytesstatic intGets the size of a Struct instance in bytestoString()Returns a human readableStringrepresentation of the structure.final voidUses the specified memory address as the backing store for this structure.
-
Constructor Details
-
Struct
Creates a newStruct.- Parameters:
runtime- The current runtime.
-
Struct
-
Struct
-
Struct
Creates a newStruct.- Parameters:
runtime- the current jnr-ffi runtimeisUnion- if this Struct is a Union
-
-
Method Details
-
getRuntime
-
useMemory
Uses the specified memory address as the backing store for this structure.- Parameters:
address- the native memory area.
-
getMemory
-
getMemory
-
size
Gets the size of a Struct instance in bytes- Parameters:
struct- the Struct instance- Returns:
- the size of the Struct in bytes
-
size
Gets the size of a Struct type in bytes -
size
Gets the size of a Struct type in bytes- Type Parameters:
T- the Struct type- Parameters:
structClass- theClassof the Struct- Returns:
- the size of the Struct in bytes
-
alignment
-
isDirect
-
arrayOf
-
toString
Returns a human readableStringrepresentation of the structure. -
arrayBegin
protected final void arrayBegin()Starts an array construction session -
arrayEnd
protected final void arrayEnd()Ends an array construction session -
array
Creates an array ofMemberinstances.- Type Parameters:
T- The type of theMembersubclass to create.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofEnum8instances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnum8instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Enum<T>> Struct.Enum16<T>[] array(Struct.Enum16<T>[] array, Class<T> enumClass) Creates an array ofEnum16instances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnum16instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Enum<T>> Struct.Enum32<T>[] array(Struct.Enum32<T>[] array, Class<T> enumClass) Creates an array ofEnum32instances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnum32instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Enum<T>> Struct.Enum64<T>[] array(Struct.Enum64<T>[] array, Class<T> enumClass) Creates an array ofEnum64instances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnum64instances will represent- Returns:
- the array that was passed in
-
array
Creates an array ofEnuminstances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnuminstances will represent- Returns:
- the array that was passed in
-
array
Creates an array ofStructinstances.- Type Parameters:
T- the type of Struct- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofSigned8instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofUnsigned8instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofSigned16instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofUnsigned16instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofSigned32instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofUnsigned32instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofSigned64instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofUnsigned64instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofSignedLonginstances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofUnsignedLonginstances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofFloatinstances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofDoubleinstances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofAddressinstances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofPointerinstances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
Creates an array ofUTF8Stringinstances.- Parameters:
array- the array to store the instances instringLength- length of each string in array- Returns:
- the array that was passed in
-
inner
Creates inner Structs in Struct definitions. Example:public class InnerStruct extends Struct { public final Signed32 innerInt32 = new Signed32(); public final Double innerDouble = new Double(); public InnerStruct(Runtime runtime) {super(runtime);} } public class MyStruct extends Struct { public final Signed32 myInt32 = new Signed32(); public final InnerStruct myInnerStruct = inner(new InnerStruct()); public MyStruct(Runtime runtime) {super(runtime);} }- Type Parameters:
T- the type of the inner Struct- Parameters:
struct- an instance of the inner Struct- Returns:
- the instance of the inner Struct of type
Struct
-
inner
Creates inner Structs in Struct definitions. Example:public class InnerStruct extends Struct { public final Signed32 innerInt32 = new Signed32(); public final Double innerDouble = new Double(); public InnerStruct(Runtime runtime) {super(runtime);} } public class MyStruct extends Struct { public final Signed32 myInt32 = new Signed32(); public final InnerStruct myInnerStruct = inner(InnerStruct.class); public MyStruct(Runtime runtime) {super(runtime);} } -
function
-