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

org.purejava.appindicator._GIOFuncs Maven / Gradle / Ivy

There is a newer version: 1.4.1
Show newest version
// Generated by jextract

package org.purejava.appindicator;

import java.lang.foreign.*;
import java.lang.invoke.MethodHandle;
import java.util.function.Consumer;

import static java.lang.foreign.MemoryLayout.PathElement.groupElement;

/**
 * {@snippet lang=c :
 * struct _GIOFuncs {
 *     GIOStatus (*io_read)(GIOChannel *, gchar *, gsize, gsize *, GError **);
 *     GIOStatus (*io_write)(GIOChannel *, const gchar *, gsize, gsize *, GError **);
 *     GIOStatus (*io_seek)(GIOChannel *, gint64, GSeekType, GError **);
 *     GIOStatus (*io_close)(GIOChannel *, GError **);
 *     GSource *(*io_create_watch)(GIOChannel *, GIOCondition);
 *     void (*io_free)(GIOChannel *);
 *     GIOStatus (*io_set_flags)(GIOChannel *, GIOFlags, GError **);
 *     GIOFlags (*io_get_flags)(GIOChannel *);
 * }
 * }
 */
public class _GIOFuncs {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        app_indicator_h.C_POINTER.withName("io_read"),
        app_indicator_h.C_POINTER.withName("io_write"),
        app_indicator_h.C_POINTER.withName("io_seek"),
        app_indicator_h.C_POINTER.withName("io_close"),
        app_indicator_h.C_POINTER.withName("io_create_watch"),
        app_indicator_h.C_POINTER.withName("io_free"),
        app_indicator_h.C_POINTER.withName("io_set_flags"),
        app_indicator_h.C_POINTER.withName("io_get_flags")
    ).withName("_GIOFuncs");

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

    /**
     * {@snippet lang=c :
     * GIOStatus (*io_read)(GIOChannel *, gchar *, gsize, gsize *, GError **)
     * }
     */
    public class io_read {

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            int apply(MemorySegment _x0, MemorySegment _x1, long _x2, MemorySegment _x3, MemorySegment _x4);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            app_indicator_h.C_INT,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_LONG,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(io_read.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(io_read.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static int invoke(MemorySegment funcPtr,MemorySegment _x0, MemorySegment _x1, long _x2, MemorySegment _x3, MemorySegment _x4) {
            try {
                return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2, _x3, _x4);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

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

    /**
     * Layout for field:
     * {@snippet lang=c :
     * GIOStatus (*io_read)(GIOChannel *, gchar *, gsize, gsize *, GError **)
     * }
     */
    public static final AddressLayout io_read$layout() {
        return io_read$LAYOUT;
    }

    private static final long io_read$OFFSET = 0;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * GIOStatus (*io_read)(GIOChannel *, gchar *, gsize, gsize *, GError **)
     * }
     */
    public static final long io_read$offset() {
        return io_read$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * GIOStatus (*io_read)(GIOChannel *, gchar *, gsize, gsize *, GError **)
     * }
     */
    public static MemorySegment io_read(MemorySegment struct) {
        return struct.get(io_read$LAYOUT, io_read$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * GIOStatus (*io_read)(GIOChannel *, gchar *, gsize, gsize *, GError **)
     * }
     */
    public static void io_read(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(io_read$LAYOUT, io_read$OFFSET, fieldValue);
    }

    /**
     * {@snippet lang=c :
     * GIOStatus (*io_write)(GIOChannel *, const gchar *, gsize, gsize *, GError **)
     * }
     */
    public class io_write {

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            int apply(MemorySegment _x0, MemorySegment _x1, long _x2, MemorySegment _x3, MemorySegment _x4);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            app_indicator_h.C_INT,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_LONG,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(io_write.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(io_write.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static int invoke(MemorySegment funcPtr,MemorySegment _x0, MemorySegment _x1, long _x2, MemorySegment _x3, MemorySegment _x4) {
            try {
                return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2, _x3, _x4);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

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

    /**
     * Layout for field:
     * {@snippet lang=c :
     * GIOStatus (*io_write)(GIOChannel *, const gchar *, gsize, gsize *, GError **)
     * }
     */
    public static final AddressLayout io_write$layout() {
        return io_write$LAYOUT;
    }

    private static final long io_write$OFFSET = 8;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * GIOStatus (*io_write)(GIOChannel *, const gchar *, gsize, gsize *, GError **)
     * }
     */
    public static final long io_write$offset() {
        return io_write$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * GIOStatus (*io_write)(GIOChannel *, const gchar *, gsize, gsize *, GError **)
     * }
     */
    public static MemorySegment io_write(MemorySegment struct) {
        return struct.get(io_write$LAYOUT, io_write$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * GIOStatus (*io_write)(GIOChannel *, const gchar *, gsize, gsize *, GError **)
     * }
     */
    public static void io_write(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(io_write$LAYOUT, io_write$OFFSET, fieldValue);
    }

    /**
     * {@snippet lang=c :
     * GIOStatus (*io_seek)(GIOChannel *, gint64, GSeekType, GError **)
     * }
     */
    public class io_seek {

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            int apply(MemorySegment _x0, long _x1, int _x2, MemorySegment _x3);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            app_indicator_h.C_INT,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_LONG,
            app_indicator_h.C_INT,
            app_indicator_h.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(io_seek.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(io_seek.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static int invoke(MemorySegment funcPtr,MemorySegment _x0, long _x1, int _x2, MemorySegment _x3) {
            try {
                return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2, _x3);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

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

    /**
     * Layout for field:
     * {@snippet lang=c :
     * GIOStatus (*io_seek)(GIOChannel *, gint64, GSeekType, GError **)
     * }
     */
    public static final AddressLayout io_seek$layout() {
        return io_seek$LAYOUT;
    }

    private static final long io_seek$OFFSET = 16;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * GIOStatus (*io_seek)(GIOChannel *, gint64, GSeekType, GError **)
     * }
     */
    public static final long io_seek$offset() {
        return io_seek$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * GIOStatus (*io_seek)(GIOChannel *, gint64, GSeekType, GError **)
     * }
     */
    public static MemorySegment io_seek(MemorySegment struct) {
        return struct.get(io_seek$LAYOUT, io_seek$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * GIOStatus (*io_seek)(GIOChannel *, gint64, GSeekType, GError **)
     * }
     */
    public static void io_seek(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(io_seek$LAYOUT, io_seek$OFFSET, fieldValue);
    }

    /**
     * {@snippet lang=c :
     * GIOStatus (*io_close)(GIOChannel *, GError **)
     * }
     */
    public class io_close {

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            int apply(MemorySegment _x0, MemorySegment _x1);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            app_indicator_h.C_INT,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(io_close.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(io_close.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static int invoke(MemorySegment funcPtr,MemorySegment _x0, MemorySegment _x1) {
            try {
                return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

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

    /**
     * Layout for field:
     * {@snippet lang=c :
     * GIOStatus (*io_close)(GIOChannel *, GError **)
     * }
     */
    public static final AddressLayout io_close$layout() {
        return io_close$LAYOUT;
    }

    private static final long io_close$OFFSET = 24;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * GIOStatus (*io_close)(GIOChannel *, GError **)
     * }
     */
    public static final long io_close$offset() {
        return io_close$OFFSET;
    }

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

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

    /**
     * {@snippet lang=c :
     * GSource *(*io_create_watch)(GIOChannel *, GIOCondition)
     * }
     */
    public class io_create_watch {

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            MemorySegment apply(MemorySegment _x0, int _x1);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            app_indicator_h.C_POINTER,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_INT
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(io_create_watch.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(io_create_watch.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0, int _x1) {
            try {
                return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0, _x1);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

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

    /**
     * Layout for field:
     * {@snippet lang=c :
     * GSource *(*io_create_watch)(GIOChannel *, GIOCondition)
     * }
     */
    public static final AddressLayout io_create_watch$layout() {
        return io_create_watch$LAYOUT;
    }

    private static final long io_create_watch$OFFSET = 32;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * GSource *(*io_create_watch)(GIOChannel *, GIOCondition)
     * }
     */
    public static final long io_create_watch$offset() {
        return io_create_watch$OFFSET;
    }

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

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

    /**
     * {@snippet lang=c :
     * void (*io_free)(GIOChannel *)
     * }
     */
    public class io_free {

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            void apply(MemorySegment _x0);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid(
            app_indicator_h.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(io_free.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(io_free.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static void invoke(MemorySegment funcPtr,MemorySegment _x0) {
            try {
                 DOWN$MH.invokeExact(funcPtr, _x0);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

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

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

    private static final long io_free$OFFSET = 40;

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

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

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

    /**
     * {@snippet lang=c :
     * GIOStatus (*io_set_flags)(GIOChannel *, GIOFlags, GError **)
     * }
     */
    public class io_set_flags {

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            int apply(MemorySegment _x0, int _x1, MemorySegment _x2);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            app_indicator_h.C_INT,
            app_indicator_h.C_POINTER,
            app_indicator_h.C_INT,
            app_indicator_h.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(io_set_flags.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(io_set_flags.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static int invoke(MemorySegment funcPtr,MemorySegment _x0, int _x1, MemorySegment _x2) {
            try {
                return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

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

    /**
     * Layout for field:
     * {@snippet lang=c :
     * GIOStatus (*io_set_flags)(GIOChannel *, GIOFlags, GError **)
     * }
     */
    public static final AddressLayout io_set_flags$layout() {
        return io_set_flags$LAYOUT;
    }

    private static final long io_set_flags$OFFSET = 48;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * GIOStatus (*io_set_flags)(GIOChannel *, GIOFlags, GError **)
     * }
     */
    public static final long io_set_flags$offset() {
        return io_set_flags$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * GIOStatus (*io_set_flags)(GIOChannel *, GIOFlags, GError **)
     * }
     */
    public static MemorySegment io_set_flags(MemorySegment struct) {
        return struct.get(io_set_flags$LAYOUT, io_set_flags$OFFSET);
    }

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

    /**
     * {@snippet lang=c :
     * GIOFlags (*io_get_flags)(GIOChannel *)
     * }
     */
    public class io_get_flags {

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            int apply(MemorySegment _x0);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            app_indicator_h.C_INT,
            app_indicator_h.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(io_get_flags.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(io_get_flags.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static int invoke(MemorySegment funcPtr,MemorySegment _x0) {
            try {
                return (int) DOWN$MH.invokeExact(funcPtr, _x0);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

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

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

    private static final long io_get_flags$OFFSET = 56;

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

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

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