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

org.purejava.appindicator._GValue 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;
import static java.lang.foreign.MemoryLayout.PathElement.sequenceElement;
import static java.lang.foreign.ValueLayout.*;

/**
 * {@snippet lang=c :
 * struct _GValue {
 *     GType g_type;
 *     union {
 *         gint v_int;
 *         guint v_uint;
 *         glong v_long;
 *         gulong v_ulong;
 *         gint64 v_int64;
 *         guint64 v_uint64;
 *         gfloat v_float;
 *         gdouble v_double;
 *         gpointer v_pointer;
 *     } data[2];
 * }
 * }
 */
public class _GValue {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        app_indicator_h.C_LONG.withName("g_type"),
        MemoryLayout.sequenceLayout(2, _GValue.data.layout()).withName("data")
    ).withName("_GValue");

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

    private static final OfLong g_type$LAYOUT = (OfLong)$LAYOUT.select(groupElement("g_type"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * GType g_type
     * }
     */
    public static final OfLong g_type$layout() {
        return g_type$LAYOUT;
    }

    private static final long g_type$OFFSET = 0;

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

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

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

    /**
     * {@snippet lang=c :
     * union {
     *     gint v_int;
     *     guint v_uint;
     *     glong v_long;
     *     gulong v_ulong;
     *     gint64 v_int64;
     *     guint64 v_uint64;
     *     gfloat v_float;
     *     gdouble v_double;
     *     gpointer v_pointer;
     * }
     * }
     */
    public static class data {

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

        private static final GroupLayout $LAYOUT = MemoryLayout.unionLayout(
            app_indicator_h.C_INT.withName("v_int"),
            app_indicator_h.C_INT.withName("v_uint"),
            app_indicator_h.C_LONG.withName("v_long"),
            app_indicator_h.C_LONG.withName("v_ulong"),
            app_indicator_h.C_LONG.withName("v_int64"),
            app_indicator_h.C_LONG.withName("v_uint64"),
            app_indicator_h.C_FLOAT.withName("v_float"),
            app_indicator_h.C_DOUBLE.withName("v_double"),
            app_indicator_h.C_POINTER.withName("v_pointer")
        ).withName("$anon$119:3");

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

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

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

        private static final long v_int$OFFSET = 0;

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

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

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

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

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

        private static final long v_uint$OFFSET = 0;

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

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

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

        private static final OfLong v_long$LAYOUT = (OfLong)$LAYOUT.select(groupElement("v_long"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * glong v_long
         * }
         */
        public static final OfLong v_long$layout() {
            return v_long$LAYOUT;
        }

        private static final long v_long$OFFSET = 0;

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

        /**
         * Getter for field:
         * {@snippet lang=c :
         * glong v_long
         * }
         */
        public static long v_long(MemorySegment union) {
            return union.get(v_long$LAYOUT, v_long$OFFSET);
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * glong v_long
         * }
         */
        public static void v_long(MemorySegment union, long fieldValue) {
            union.set(v_long$LAYOUT, v_long$OFFSET, fieldValue);
        }

        private static final OfLong v_ulong$LAYOUT = (OfLong)$LAYOUT.select(groupElement("v_ulong"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * gulong v_ulong
         * }
         */
        public static final OfLong v_ulong$layout() {
            return v_ulong$LAYOUT;
        }

        private static final long v_ulong$OFFSET = 0;

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

        /**
         * Getter for field:
         * {@snippet lang=c :
         * gulong v_ulong
         * }
         */
        public static long v_ulong(MemorySegment union) {
            return union.get(v_ulong$LAYOUT, v_ulong$OFFSET);
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * gulong v_ulong
         * }
         */
        public static void v_ulong(MemorySegment union, long fieldValue) {
            union.set(v_ulong$LAYOUT, v_ulong$OFFSET, fieldValue);
        }

        private static final OfLong v_int64$LAYOUT = (OfLong)$LAYOUT.select(groupElement("v_int64"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * gint64 v_int64
         * }
         */
        public static final OfLong v_int64$layout() {
            return v_int64$LAYOUT;
        }

        private static final long v_int64$OFFSET = 0;

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

        /**
         * Getter for field:
         * {@snippet lang=c :
         * gint64 v_int64
         * }
         */
        public static long v_int64(MemorySegment union) {
            return union.get(v_int64$LAYOUT, v_int64$OFFSET);
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * gint64 v_int64
         * }
         */
        public static void v_int64(MemorySegment union, long fieldValue) {
            union.set(v_int64$LAYOUT, v_int64$OFFSET, fieldValue);
        }

        private static final OfLong v_uint64$LAYOUT = (OfLong)$LAYOUT.select(groupElement("v_uint64"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * guint64 v_uint64
         * }
         */
        public static final OfLong v_uint64$layout() {
            return v_uint64$LAYOUT;
        }

        private static final long v_uint64$OFFSET = 0;

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

        /**
         * Getter for field:
         * {@snippet lang=c :
         * guint64 v_uint64
         * }
         */
        public static long v_uint64(MemorySegment union) {
            return union.get(v_uint64$LAYOUT, v_uint64$OFFSET);
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * guint64 v_uint64
         * }
         */
        public static void v_uint64(MemorySegment union, long fieldValue) {
            union.set(v_uint64$LAYOUT, v_uint64$OFFSET, fieldValue);
        }

        private static final OfFloat v_float$LAYOUT = (OfFloat)$LAYOUT.select(groupElement("v_float"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * gfloat v_float
         * }
         */
        public static final OfFloat v_float$layout() {
            return v_float$LAYOUT;
        }

        private static final long v_float$OFFSET = 0;

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

        /**
         * Getter for field:
         * {@snippet lang=c :
         * gfloat v_float
         * }
         */
        public static float v_float(MemorySegment union) {
            return union.get(v_float$LAYOUT, v_float$OFFSET);
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * gfloat v_float
         * }
         */
        public static void v_float(MemorySegment union, float fieldValue) {
            union.set(v_float$LAYOUT, v_float$OFFSET, fieldValue);
        }

        private static final OfDouble v_double$LAYOUT = (OfDouble)$LAYOUT.select(groupElement("v_double"));

        /**
         * Layout for field:
         * {@snippet lang=c :
         * gdouble v_double
         * }
         */
        public static final OfDouble v_double$layout() {
            return v_double$LAYOUT;
        }

        private static final long v_double$OFFSET = 0;

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

        /**
         * Getter for field:
         * {@snippet lang=c :
         * gdouble v_double
         * }
         */
        public static double v_double(MemorySegment union) {
            return union.get(v_double$LAYOUT, v_double$OFFSET);
        }

        /**
         * Setter for field:
         * {@snippet lang=c :
         * gdouble v_double
         * }
         */
        public static void v_double(MemorySegment union, double fieldValue) {
            union.set(v_double$LAYOUT, v_double$OFFSET, fieldValue);
        }

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

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

        private static final long v_pointer$OFFSET = 0;

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

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

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

    private static final SequenceLayout data$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("data"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * union {
     *     gint v_int;
     *     guint v_uint;
     *     glong v_long;
     *     gulong v_ulong;
     *     gint64 v_int64;
     *     guint64 v_uint64;
     *     gfloat v_float;
     *     gdouble v_double;
     *     gpointer v_pointer;
     * } data[2]
     * }
     */
    public static final SequenceLayout data$layout() {
        return data$LAYOUT;
    }

    private static final long data$OFFSET = 8;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * union {
     *     gint v_int;
     *     guint v_uint;
     *     glong v_long;
     *     gulong v_ulong;
     *     gint64 v_int64;
     *     guint64 v_uint64;
     *     gfloat v_float;
     *     gdouble v_double;
     *     gpointer v_pointer;
     * } data[2]
     * }
     */
    public static final long data$offset() {
        return data$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * union {
     *     gint v_int;
     *     guint v_uint;
     *     glong v_long;
     *     gulong v_ulong;
     *     gint64 v_int64;
     *     guint64 v_uint64;
     *     gfloat v_float;
     *     gdouble v_double;
     *     gpointer v_pointer;
     * } data[2]
     * }
     */
    public static MemorySegment data(MemorySegment struct) {
        return struct.asSlice(data$OFFSET, data$LAYOUT.byteSize());
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * union {
     *     gint v_int;
     *     guint v_uint;
     *     glong v_long;
     *     gulong v_ulong;
     *     gint64 v_int64;
     *     guint64 v_uint64;
     *     gfloat v_float;
     *     gdouble v_double;
     *     gpointer v_pointer;
     * } data[2]
     * }
     */
    public static void data(MemorySegment struct, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, struct, data$OFFSET, data$LAYOUT.byteSize());
    }

    private static long[] data$DIMS = { 2 };

    /**
     * Dimensions for array field:
     * {@snippet lang=c :
     * union {
     *     gint v_int;
     *     guint v_uint;
     *     glong v_long;
     *     gulong v_ulong;
     *     gint64 v_int64;
     *     guint64 v_uint64;
     *     gfloat v_float;
     *     gdouble v_double;
     *     gpointer v_pointer;
     * } data[2]
     * }
     */
    public static long[] data$dimensions() {
        return data$DIMS;
    }
    private static final MethodHandle data$ELEM_HANDLE = data$LAYOUT.sliceHandle(sequenceElement());

    /**
     * Indexed getter for field:
     * {@snippet lang=c :
     * union {
     *     gint v_int;
     *     guint v_uint;
     *     glong v_long;
     *     gulong v_ulong;
     *     gint64 v_int64;
     *     guint64 v_uint64;
     *     gfloat v_float;
     *     gdouble v_double;
     *     gpointer v_pointer;
     * } data[2]
     * }
     */
    public static MemorySegment data(MemorySegment struct, long index0) {
        try {
            return (MemorySegment)data$ELEM_HANDLE.invokeExact(struct, 0L, index0);
        } catch (Throwable ex$) {
            throw new AssertionError("should not reach here", ex$);
        }
    }

    /**
     * Indexed setter for field:
     * {@snippet lang=c :
     * union {
     *     gint v_int;
     *     guint v_uint;
     *     glong v_long;
     *     gulong v_ulong;
     *     gint64 v_int64;
     *     guint64 v_uint64;
     *     gfloat v_float;
     *     gdouble v_double;
     *     gpointer v_pointer;
     * } data[2]
     * }
     */
    public static void data(MemorySegment struct, long index0, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, data(struct, index0), 0L, _GValue.data.layout().byteSize());
    }

    /**
     * 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