Top Description Inners Fields Constructors Methods
jnr.ffi

public abstract Class Struct

extends Object
Class Inheritance
Known Direct Subclasses
jnr.ffi.Union
Imports
jnr.ffi.provider.ParameterFlags, jnr.ffi.provider.jffi.ArrayMemoryIO, jnr.ffi.util.EnumMapper, java.lang.reflect.Array, .Constructor, java.nio.charset.Charset

Representation of C structures in java

Note

This class is not threadsafe.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract class
Struct.AbstractBoolean

Base class for Boolean fields

protected abstract class
Struct.AbstractMember

Base implementation of Member

public class
Struct.Address

Represents a native memory address.

public static class
public class
public class
public class
public class
public class
public class
Struct.Boolean

A normal C boolean - 1 byte in size

public class
public class
public class
public class
public class
public class
public class
public class
Struct.Enum<T extends Enum<T>>

public class
Struct.Enum16<E extends Enum<E>>

public class
Struct.Enum32<E extends Enum<E>>

public class
Struct.Enum64<E extends Enum<E>>

public class
Struct.Enum8<
the java.lang.Enum to translate to/from.
E extends Enum<E>
>

An 8 bit enum field.

protected abstract class
Struct.EnumField<
the type of java.lang.Enum
E
>

Base for all the Enum fields.

public class
Struct.EnumLong<E extends Enum<E>>

public class
public class
public class
public class
public class
public class
public class
public class
pack-priv static class
public class
public class
public class
public class
public class
public class
public abstract class
public class
public class
public class
protected abstract class
Struct.Member

Interface all Struct members must implement.

public class
public abstract class
Struct.NumberField

Base class for all Number structure fields.

public class
public static class
protected class
Struct.Padding

Specialized padding fields for structs.

public class
public class
Struct.Pointer

Represents a native memory address.

public abstract class
public class
public class
public class
Struct.Signed16

A 16 bit signed integer field.

public class
Struct.Signed32

A 32 bit signed integer field.

public class
Struct.Signed64

A 64 bit signed integer field.

public class
Struct.Signed8

An 8 bit signed integer

public class
Struct.SignedLong

A native long integer field.

public class
public class
public class
public class
public abstract class
public class
Struct.StructRef<
- Struct type
T extends Struct
>

Represents a reference to a Struct or and array of Structs

public class
public class
public class
public class
public class
public class
public class
public class
public class
public class
Struct.Unsigned16

A 16 bit signed integer field.

public class
Struct.Unsigned32

A 32 bit signed integer field.

public class
Struct.Unsigned64

A 64 bit unsigned integer field.

public class
Struct.Unsigned8

An 8 bit unsigned integer

public class
Struct.UnsignedLong

A native long integer field.

public class
public class
public class
public class
public class
Struct.WBOOL

A Windows BOOL - 4 bytes

public class

Field Summary

Modifier and TypeField and Description
pack-priv final Struct.Info
pack-priv static final Charset
pack-priv static final Charset

Constructor Summary

AccessConstructor and Description
protected
Struct(Runtime
The current runtime.
runtime
)

Creates a new Struct.

protected
Struct(Runtime runtime, Struct.Alignment alignment)

protected
Struct(Runtime runtime, Struct enclosing)

protected
Struct(Runtime
the current jnr-ffi runtime
runtime
,
final boolean
if this Struct is a Union
isUnion
)

Creates a new Struct.

Method Summary

Modifier and TypeMethod and Description
private static int
align(int offset, int align)

public static int
alignment(Struct struct)

protected <
The type of the Member subclass to create.
T extends Struct.Member
>
T[]

Returns:

the array that was passed in
array
(T[]
the array to store the instances in
array
)

Creates an array of Member instances.

protected <
The type of the java.lang.Enum
T extends Enum<T>
>
Struct.Enum8<T>[]

Returns:

the array that was passed in
array
(Struct.Enum8<T>[]
the array to store the instances in
array
,
Class<T>
class of java.lang.Enum, these Enum8 instances will represent
enumClass
)

Creates an array of Enum8 instances.

protected <
The type of the java.lang.Enum
T extends Enum<T>
>
Struct.Enum16<T>[]

Returns:

the array that was passed in
array
(Struct.Enum16<T>[]
the array to store the instances in
array
,
Class<T>
class of java.lang.Enum, these Enum16 instances will represent
enumClass
)

Creates an array of Enum16 instances.

protected <
The type of the java.lang.Enum
T extends Enum<T>
>
Struct.Enum32<T>[]

Returns:

the array that was passed in
array
(Struct.Enum32<T>[]
the array to store the instances in
array
,
Class<T>
class of java.lang.Enum, these Enum32 instances will represent
enumClass
)

Creates an array of Enum32 instances.

protected <
The type of the java.lang.Enum
T extends Enum<T>
>
Struct.Enum64<T>[]

Returns:

the array that was passed in
array
(Struct.Enum64<T>[]
the array to store the instances in
array
,
Class<T>
class of java.lang.Enum, these Enum64 instances will represent
enumClass
)

Creates an array of Enum64 instances.

protected <
The type of the java.lang.Enum
T extends Enum<T>
>
Struct.Enum<T>[]

Returns:

the array that was passed in
array
(Struct.Enum<T>[]
the array to store the instances in
array
,
Class<T>
class of java.lang.Enum, these Enum instances will represent
enumClass
)

Creates an array of Enum instances.

protected <
the type of Struct
T extends Struct
>
T[]

Returns:

the array that was passed in
array
(T[]
the array to store the instances in
array
)

Creates an array of Struct instances.

protected final Struct.Signed8[]

Returns:

the array that was passed in
array
(Struct.Signed8[]
the array to store the instances in
array
)

Creates an array of Signed8 instances.

protected final Struct.Unsigned8[]

Returns:

the array that was passed in
array
(Struct.Unsigned8[]
the array to store the instances in
array
)

Creates an array of Unsigned8 instances.

protected final Struct.Signed16[]

Returns:

the array that was passed in
array
(Struct.Signed16[]
the array to store the instances in
array
)

Creates an array of Signed16 instances.

protected final Struct.Unsigned16[]

Returns:

the array that was passed in
array
(Struct.Unsigned16[]
the array to store the instances in
array
)

Creates an array of Unsigned16 instances.

protected final Struct.Signed32[]

Returns:

the array that was passed in
array
(Struct.Signed32[]
the array to store the instances in
array
)

Creates an array of Signed32 instances.

protected final Struct.Unsigned32[]

Returns:

the array that was passed in
array
(Struct.Unsigned32[]
the array to store the instances in
array
)

Creates an array of Unsigned32 instances.

protected final Struct.Signed64[]

Returns:

the array that was passed in
array
(Struct.Signed64[]
the array to store the instances in
array
)

Creates an array of Signed64 instances.

protected final Struct.Unsigned64[]

Returns:

the array that was passed in
array
(Struct.Unsigned64[]
the array to store the instances in
array
)

Creates an array of Unsigned64 instances.

protected final Struct.SignedLong[]

Returns:

the array that was passed in
array
(Struct.SignedLong[]
the array to store the instances in
array
)

Creates an array of SignedLong instances.

protected final Struct.UnsignedLong[]

Returns:

the array that was passed in
array
(Struct.UnsignedLong[]
the array to store the instances in
array
)

Creates an array of UnsignedLong instances.

protected final Struct.Float[]

Returns:

the array that was passed in
array
(Struct.Float[]
the array to store the instances in
array
)

Creates an array of Float instances.

protected final Struct.Double[]

Returns:

the array that was passed in
array
(Struct.Double[]
the array to store the instances in
array
)

Creates an array of Double instances.

protected final Struct.Address[]

Returns:

the array that was passed in
array
(Struct.Address[]
the array to store the instances in
array
)

Creates an array of Address instances.

protected final Struct.Pointer[]

Returns:

the array that was passed in
array
(Struct.Pointer[]
the array to store the instances in
array
)

Creates an array of Pointer instances.

protected Struct.UTF8String[]

Returns:

the array that was passed in
array
(Struct.UTF8String[]
the array to store the instances in
array
,
int
length of each string in array
stringLength
)

Creates an array of UTF8String instances.

protected final void
arrayBegin()

Starts an array construction session

protected final void
arrayEnd()

Ends an array construction session

public static <T extends Struct> T[]
arrayOf(Runtime runtime, Class<T> type, int length)

protected final <T> Struct.Function<T>
function(Class<T> closureClass)

public static Pointer
getMemory(Struct struct)

public static Pointer
getMemory(Struct struct, int flags)

public final Runtime
protected final <
the type of the inner Struct
T extends Struct
>
T

Returns:

the instance of the inner Struct of type T
inner
(T
an instance of the inner Struct
struct
)

Creates inner Structs in Struct definitions.

protected final <
the type of the inner Struct
T extends Struct
>
T

Returns:

the newly created inner Struct of type T
inner
(Class<T>
the Class of the inner Struct
structClass
)

Creates inner Structs in Struct definitions.

public static boolean
isDirect(Struct struct)

public static int

Returns:

the size of the Struct in bytes
size
(Struct
the Struct instance
struct
)

Gets the size of a Struct instance in bytes

public static <
the Struct type
T extends Struct
>
int

Returns:

the size of the Struct in bytes
size
(Class<T>
the Class of the Struct
structClass
,
Runtime
the Runtime that will be used to create an instance of the Struct
runtime
)

Gets the size of a Struct type in bytes

public static <
the Struct type
T extends Struct
>
int

Returns:

the size of the Struct in bytes
size
(Class<T>
the Class of the Struct
structClass
)

Gets the size of a Struct type in bytes

public String

Returns:

a String representation of this structure.
toString
()

Overrides java.lang.Object.toString.

Returns a human readable java.lang.String representation of the structure.
public final void
useMemory(Pointer
the native memory area.
address
)

Uses the specified memory address as the backing store for this structure.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait