com.jinvoke
Annotation Type NativeStruct


@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface NativeStruct

Indicates that the annotated Java class represents a native structure (struct).

This annotation is applied to Java classes. The Java class representing a native struct must be declared as a public class (in it's own .java file) and contain public fields corresponding to the members of the native struct, declared in the same order.

A struct may contain fields of primitive types, Strings (including StringBuffer and StringBuilder) Callbacks(converted to function pointers), nested structs, embedded arrays, embedded Strings and arrays of primitives and structs.

Arrays of primitive types and structs are marshaled as pointers to the array allocated in native memory, unless the array is an embedded array (i.e. annotated with the @Embedded annotation.)

Example: The C declaration of the SYSTEMTIME struct is as follows

typedef struct _SYSTEMTIME {  
        WORD wYear;  
        WORD wMonth;  
        WORD wDayOfWeek;  
        WORD wDay;  
        WORD wHour;  
        WORD wMinute;  
        WORD wSecond;  
        WORD wMilliseconds;
} SYSTEMTIME,  *PSYSTEMTIME;

This struct can be represented in Java as shown below:

import com.jinvoke.NativeStruct;

@NativeStruct
public class SYSTEMTIME {
    public short wYear;
    public short wMonth;
    public short wDayOfWeek;
    public short wDay;
    public short wHour;
    public short wMinute;
    public short wSecond;
    public short wMilliseconds;
}


Optional Element Summary
 Charset charset
          Specifies the character set for String, StringBuffer and StringBuilder members of native structs.
 int packing
          Specifies the packing size used for packing and aligning structure fields.
 

packing

public abstract int packing
Specifies the packing size used for packing and aligning structure fields.

The default packing size is 8. It can be changed to 1, 2, 4, 8 or other values.

Default:
8

charset

public abstract Charset charset
Specifies the character set for String, StringBuffer and StringBuilder members of native structs.

If left unspecified, Strings members of structs are assumed to be Unicode(wide character) strings.

Default:
UNICODE