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

com.nextbreakpoint.freeimage4java.FreeImageIO Maven / Gradle / Ivy

// Generated by jextract

package com.nextbreakpoint.freeimage4java;

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 FreeImageIO {
 *     FI_ReadProc read_proc;
 *     FI_WriteProc write_proc;
 *     FI_SeekProc seek_proc;
 *     FI_TellProc tell_proc;
 * }
 * }
 */
public class FreeImageIO {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Libfreeimage.align(Libfreeimage.C_POINTER, 1).withName("read_proc"),
        Libfreeimage.align(Libfreeimage.C_POINTER, 1).withName("write_proc"),
        Libfreeimage.align(Libfreeimage.C_POINTER, 1).withName("seek_proc"),
        Libfreeimage.align(Libfreeimage.C_POINTER, 1).withName("tell_proc")
    ).withName("FreeImageIO");

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

    private static final AddressLayout read_proc$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("read_proc"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * FI_ReadProc read_proc
     * }
     */
    public static final AddressLayout read_proc$layout() {
        return read_proc$LAYOUT;
    }

    private static final long read_proc$OFFSET = 0;

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

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

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

    private static final AddressLayout write_proc$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("write_proc"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * FI_WriteProc write_proc
     * }
     */
    public static final AddressLayout write_proc$layout() {
        return write_proc$LAYOUT;
    }

    private static final long write_proc$OFFSET = 8;

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

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

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

    private static final AddressLayout seek_proc$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("seek_proc"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * FI_SeekProc seek_proc
     * }
     */
    public static final AddressLayout seek_proc$layout() {
        return seek_proc$LAYOUT;
    }

    private static final long seek_proc$OFFSET = 16;

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

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

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

    private static final AddressLayout tell_proc$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("tell_proc"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * FI_TellProc tell_proc
     * }
     */
    public static final AddressLayout tell_proc$layout() {
        return tell_proc$LAYOUT;
    }

    private static final long tell_proc$OFFSET = 24;

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

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

    /**
     * Setter for field:
     * {@snippet lang=c :
     * FI_TellProc tell_proc
     * }
     */
    public static void tell_proc(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(tell_proc$LAYOUT, tell_proc$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