< prev index next >

src/java.base/share/classes/java/nicl/types/LayoutType.java

Print this page

        

*** 33,43 **** import java.nicl.layout.Group; import java.nicl.layout.Layout; import java.nicl.layout.Sequence; import java.lang.invoke.MethodHandle; ! import java.nicl.metadata.NativeType; /** * This class describes the relationship between a memory layout (usually described in bits) and a Java carrier * (e.g. {@code int}, {@code long}, or any Java reference type. A {@code LayoutType} defines operation for getting/setting * the layout contents using a given Java carrier (see {@link LayoutType#getter()} and {@link LayoutType#setter()}). --- 33,43 ---- import java.nicl.layout.Group; import java.nicl.layout.Layout; import java.nicl.layout.Sequence; import java.lang.invoke.MethodHandle; ! import java.nicl.metadata.NativeStruct; /** * This class describes the relationship between a memory layout (usually described in bits) and a Java carrier * (e.g. {@code int}, {@code long}, or any Java reference type. A {@code LayoutType} defines operation for getting/setting * the layout contents using a given Java carrier (see {@link LayoutType#getter()} and {@link LayoutType#setter()}).
*** 217,232 **** /** * Create a {@code LayoutType} from a {@link Struct} interface carrier. * @param <T> the struct type. * @param carrier the struct carrier. * @return the {@code LayoutType}. ! * @throws IllegalArgumentException if the given carrier is not annotated with the {@link java.nicl.metadata.NativeType} annotation. */ public static <T extends Struct<T>> LayoutType<T> ofStruct(Class<T> carrier) throws IllegalArgumentException { ! NativeType nativeStruct = carrier.getAnnotation(NativeType.class); if (nativeStruct == null) { throw new IllegalArgumentException("Not a struct type!"); } ! Group type = (Group) new DescriptorParser(nativeStruct.layout()).parseLayout().findFirst().get(); return new LayoutType<>(type, References.ofStruct(carrier)); } } --- 217,232 ---- /** * Create a {@code LayoutType} from a {@link Struct} interface carrier. * @param <T> the struct type. * @param carrier the struct carrier. * @return the {@code LayoutType}. ! * @throws IllegalArgumentException if the given carrier is not annotated with the {@link java.nicl.metadata.NativeStruct} annotation. */ public static <T extends Struct<T>> LayoutType<T> ofStruct(Class<T> carrier) throws IllegalArgumentException { ! NativeStruct nativeStruct = carrier.getAnnotation(NativeStruct.class); if (nativeStruct == null) { throw new IllegalArgumentException("Not a struct type!"); } ! Group type = (Group) new DescriptorParser(nativeStruct.value()).parseLayout().findFirst().get(); return new LayoutType<>(type, References.ofStruct(carrier)); } }
< prev index next >