All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dds.contractType Maven / Gradle / Ivy

The newest version!
// Generated by jextract

package dds;

import java.lang.invoke.*;
import java.lang.foreign.*;
import java.nio.ByteOrder;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

import static java.lang.foreign.ValueLayout.*;
import static java.lang.foreign.MemoryLayout.PathElement.*;

/**
 * {@snippet lang=c :
 * struct contractType {
 *     int underTricks;
 *     int overTricks;
 *     int level;
 *     int denom;
 *     int seats;
 * }
 * }
 */
public class contractType {

    contractType() {
        // Should not be called directly
    }

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Dds.C_INT.withName("underTricks"),
        Dds.C_INT.withName("overTricks"),
        Dds.C_INT.withName("level"),
        Dds.C_INT.withName("denom"),
        Dds.C_INT.withName("seats")
    ).withName("contractType");

    /**
     * The layout of this struct
     */
    public static final GroupLayout layout() {
        return $LAYOUT;
    }

    private static final OfInt underTricks$LAYOUT = (OfInt)$LAYOUT.select(groupElement("underTricks"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int underTricks
     * }
     */
    public static final OfInt underTricks$layout() {
        return underTricks$LAYOUT;
    }

    private static final long underTricks$OFFSET = 0;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int underTricks
     * }
     */
    public static final long underTricks$offset() {
        return underTricks$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int underTricks
     * }
     */
    public static int underTricks(MemorySegment struct) {
        return struct.get(underTricks$LAYOUT, underTricks$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int underTricks
     * }
     */
    public static void underTricks(MemorySegment struct, int fieldValue) {
        struct.set(underTricks$LAYOUT, underTricks$OFFSET, fieldValue);
    }

    private static final OfInt overTricks$LAYOUT = (OfInt)$LAYOUT.select(groupElement("overTricks"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int overTricks
     * }
     */
    public static final OfInt overTricks$layout() {
        return overTricks$LAYOUT;
    }

    private static final long overTricks$OFFSET = 4;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int overTricks
     * }
     */
    public static final long overTricks$offset() {
        return overTricks$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int overTricks
     * }
     */
    public static int overTricks(MemorySegment struct) {
        return struct.get(overTricks$LAYOUT, overTricks$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int overTricks
     * }
     */
    public static void overTricks(MemorySegment struct, int fieldValue) {
        struct.set(overTricks$LAYOUT, overTricks$OFFSET, fieldValue);
    }

    private static final OfInt level$LAYOUT = (OfInt)$LAYOUT.select(groupElement("level"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int level
     * }
     */
    public static final OfInt level$layout() {
        return level$LAYOUT;
    }

    private static final long level$OFFSET = 8;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int level
     * }
     */
    public static final long level$offset() {
        return level$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int level
     * }
     */
    public static int level(MemorySegment struct) {
        return struct.get(level$LAYOUT, level$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int level
     * }
     */
    public static void level(MemorySegment struct, int fieldValue) {
        struct.set(level$LAYOUT, level$OFFSET, fieldValue);
    }

    private static final OfInt denom$LAYOUT = (OfInt)$LAYOUT.select(groupElement("denom"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int denom
     * }
     */
    public static final OfInt denom$layout() {
        return denom$LAYOUT;
    }

    private static final long denom$OFFSET = 12;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int denom
     * }
     */
    public static final long denom$offset() {
        return denom$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int denom
     * }
     */
    public static int denom(MemorySegment struct) {
        return struct.get(denom$LAYOUT, denom$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int denom
     * }
     */
    public static void denom(MemorySegment struct, int fieldValue) {
        struct.set(denom$LAYOUT, denom$OFFSET, fieldValue);
    }

    private static final OfInt seats$LAYOUT = (OfInt)$LAYOUT.select(groupElement("seats"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int seats
     * }
     */
    public static final OfInt seats$layout() {
        return seats$LAYOUT;
    }

    private static final long seats$OFFSET = 16;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int seats
     * }
     */
    public static final long seats$offset() {
        return seats$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int seats
     * }
     */
    public static int seats(MemorySegment struct) {
        return struct.get(seats$LAYOUT, seats$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int seats
     * }
     */
    public static void seats(MemorySegment struct, int fieldValue) {
        struct.set(seats$LAYOUT, seats$OFFSET, fieldValue);
    }

    /**
     * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}.
     * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()}
     */
    public static MemorySegment asSlice(MemorySegment array, long index) {
        return array.asSlice(layout().byteSize() * index);
    }

    /**
     * The size (in bytes) of this struct
     */
    public static long sizeof() { return layout().byteSize(); }

    /**
     * Allocate a segment of size {@code layout().byteSize()} using {@code allocator}
     */
    public static MemorySegment allocate(SegmentAllocator allocator) {
        return allocator.allocate(layout());
    }

    /**
     * Allocate an array of size {@code elementCount} using {@code allocator}.
     * The returned segment has size {@code elementCount * layout().byteSize()}.
     */
    public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) {
        return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout()));
    }

    /**
     * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction) (if any).
     * The returned segment has size {@code layout().byteSize()}
     */
    public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) {
        return reinterpret(addr, 1, arena, cleanup);
    }

    /**
     * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction) (if any).
     * The returned segment has size {@code elementCount * layout().byteSize()}
     */
    public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) {
        return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy