001 package org.bridj.ann;
002
003 import java.lang.annotation.ElementType;
004 import java.lang.annotation.Retention;
005 import java.lang.annotation.RetentionPolicy;
006 import java.lang.annotation.Target;
007
008 /**
009 * Indicate the index of a structure field (in Java, the order of methods and fields is unspecified so you need to order them explicitely).<br>
010 * For C++ structs, the index is absolute : it must take into account the fields in parent classes (unlike {@link Virtual}, which virtual table offset is relative to the declared class).
011 * @author ochafik
012 */
013 @Retention(RetentionPolicy.RUNTIME)
014 @Target({ElementType.FIELD, ElementType.METHOD})
015 public @interface Field {
016 /**
017 * Index of the field in a struct (first field has index 0).<br>
018 * Fields of parent structures must be taken into account (if parent struct has 2 fields, first field of sub-struct has index 2).<br>
019 * If more than one field are given the same index, this will produce an union at that index.
020 */
021 int value();
022
023 /**
024 * Absolute index of the field from the start of the struct
025 */
026 //int offset() default Integer.MIN_VALUE;
027
028 /**
029 * Declare that this field shares its space with another (the two or more fields are in an union).<br>
030 * The unionWith index must be the index of the first field of the union.
031 */
032 int unionWith() default -1;
033 }