diff --git a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/DisposeCallback.java b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/DisposeCallback.java index ee0c5d6..957611a 100644 --- a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/DisposeCallback.java +++ b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/DisposeCallback.java @@ -1,14 +1,10 @@ package io.gitlab.jfronny.inceptum.gtk.callback; -import io.github.jwharm.javagi.CallbackGenerator; import io.github.jwharm.javagi.Interop; import org.jetbrains.annotations.ApiStatus; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryAddress; +import java.lang.foreign.*; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; public interface DisposeCallback { void upcall(MemoryAddress pointer); @@ -16,7 +12,7 @@ public interface DisposeCallback { @ApiStatus.Internal FunctionDescriptor DESCRIPTOR = FunctionDescriptor.ofVoid(Interop.valueLayout.ADDRESS); @ApiStatus.Internal - MethodHandle HANDLE = CallbackGenerator.getHandle(MethodHandles.lookup(), DisposeCallback.class, DESCRIPTOR); + MethodHandle HANDLE = Interop.getHandle(DisposeCallback.class, DESCRIPTOR); default MemoryAddress toCallback() { return Linker.nativeLinker().upcallStub(HANDLE.bindTo(this), DESCRIPTOR, Interop.getScope()).address(); diff --git a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetItemCallback.java b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetItemCallback.java index c839cb1..6997de3 100644 --- a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetItemCallback.java +++ b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetItemCallback.java @@ -1,22 +1,17 @@ package io.gitlab.jfronny.inceptum.gtk.callback; -import io.github.jwharm.javagi.CallbackGenerator; import io.github.jwharm.javagi.Interop; import org.jetbrains.annotations.ApiStatus; -import java.lang.foreign.Addressable; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryAddress; +import java.lang.foreign.*; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; @FunctionalInterface public interface GetItemCallback { Addressable upcall(MemoryAddress inst, int position); @ApiStatus.Internal FunctionDescriptor DESCRIPTOR = FunctionDescriptor.of(Interop.valueLayout.ADDRESS, Interop.valueLayout.ADDRESS, Interop.valueLayout.C_INT); - @ApiStatus.Internal MethodHandle HANDLE = CallbackGenerator.getHandle(MethodHandles.lookup(), GetItemCallback.class, DESCRIPTOR); + @ApiStatus.Internal MethodHandle HANDLE = Interop.getHandle(GetItemCallback.class, DESCRIPTOR); default MemoryAddress toCallback() { return Linker.nativeLinker().upcallStub(HANDLE.bindTo(this), DESCRIPTOR, Interop.getScope()).address(); diff --git a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetItemTypeCallback.java b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetItemTypeCallback.java index d8be6fc..80d8fd4 100644 --- a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetItemTypeCallback.java +++ b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetItemTypeCallback.java @@ -1,14 +1,10 @@ package io.gitlab.jfronny.inceptum.gtk.callback; -import io.github.jwharm.javagi.CallbackGenerator; import io.github.jwharm.javagi.Interop; import org.jetbrains.annotations.ApiStatus; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryAddress; +import java.lang.foreign.*; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; public interface GetItemTypeCallback { long upcall(MemoryAddress address); @@ -16,7 +12,7 @@ public interface GetItemTypeCallback { @ApiStatus.Internal FunctionDescriptor DESCRIPTOR = FunctionDescriptor.of(Interop.valueLayout.C_LONG, Interop.valueLayout.ADDRESS); @ApiStatus.Internal - MethodHandle HANDLE = CallbackGenerator.getHandle(MethodHandles.lookup(), GetItemTypeCallback.class, DESCRIPTOR); + MethodHandle HANDLE = Interop.getHandle(GetItemTypeCallback.class, DESCRIPTOR); default MemoryAddress toCallback() { return Linker.nativeLinker().upcallStub(HANDLE.bindTo(this), DESCRIPTOR, Interop.getScope()).address(); diff --git a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetNItemsCallback.java b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetNItemsCallback.java index 39b1dcc..9c05680 100644 --- a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetNItemsCallback.java +++ b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetNItemsCallback.java @@ -1,14 +1,10 @@ package io.gitlab.jfronny.inceptum.gtk.callback; -import io.github.jwharm.javagi.CallbackGenerator; import io.github.jwharm.javagi.Interop; import org.jetbrains.annotations.ApiStatus; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryAddress; +import java.lang.foreign.*; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; public interface GetNItemsCallback { int upcall(MemoryAddress inst); @@ -16,7 +12,7 @@ public interface GetNItemsCallback { @ApiStatus.Internal FunctionDescriptor DESCRIPTOR = FunctionDescriptor.of(Interop.valueLayout.C_INT, Interop.valueLayout.ADDRESS); @ApiStatus.Internal - MethodHandle HANDLE = CallbackGenerator.getHandle(MethodHandles.lookup(), GetNItemsCallback.class, DESCRIPTOR); + MethodHandle HANDLE = Interop.getHandle(GetNItemsCallback.class, DESCRIPTOR); default MemoryAddress toCallback() { return Linker.nativeLinker().upcallStub(HANDLE.bindTo(this), DESCRIPTOR, Interop.getScope()).address(); diff --git a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetPropertyCallback.java b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetPropertyCallback.java index 16445a2..55bd34d 100644 --- a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetPropertyCallback.java +++ b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/GetPropertyCallback.java @@ -1,25 +1,18 @@ package io.gitlab.jfronny.inceptum.gtk.callback; -import io.github.jwharm.javagi.CallbackGenerator; import io.github.jwharm.javagi.Interop; -import io.github.jwharm.javagi.Marshal; import io.github.jwharm.javagi.Ownership; -import org.gtk.gobject.GiObject; -import org.gtk.gobject.ParamSpec; -import org.gtk.gobject.Value; +import org.gtk.gobject.*; import org.jetbrains.annotations.ApiStatus; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryAddress; +import java.lang.foreign.*; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; public interface GetPropertyCallback { - void invoke(GiObject object, int propertyId, Value value, ParamSpec paramSpec); + void invoke(GObject object, int propertyId, Value value, ParamSpec paramSpec); default void upcall(MemoryAddress object, int propertyId, MemoryAddress value, MemoryAddress pspec) { - invoke(GiObject.fromAddress.marshal(object, Ownership.NONE), + invoke(GObject.fromAddress.marshal(object, Ownership.NONE), propertyId, Value.fromAddress.marshal(value, Ownership.NONE), ParamSpec.fromAddress.marshal(pspec, Ownership.NONE)); @@ -28,7 +21,7 @@ public interface GetPropertyCallback { @ApiStatus.Internal FunctionDescriptor DESCRIPTOR = FunctionDescriptor.ofVoid(Interop.valueLayout.ADDRESS, Interop.valueLayout.C_INT, Interop.valueLayout.ADDRESS, Interop.valueLayout.ADDRESS); @ApiStatus.Internal - MethodHandle HANDLE = CallbackGenerator.getHandle(MethodHandles.lookup(), GetPropertyCallback.class, DESCRIPTOR); + MethodHandle HANDLE = Interop.getHandle(GetPropertyCallback.class, DESCRIPTOR); default MemoryAddress toCallback() { return Linker.nativeLinker().upcallStub(HANDLE.bindTo(this), DESCRIPTOR, Interop.getScope()).address(); diff --git a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/SetPropertyCallback.java b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/SetPropertyCallback.java index 39e1e7a..310c5ac 100644 --- a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/SetPropertyCallback.java +++ b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/callback/SetPropertyCallback.java @@ -1,25 +1,18 @@ package io.gitlab.jfronny.inceptum.gtk.callback; -import io.github.jwharm.javagi.CallbackGenerator; import io.github.jwharm.javagi.Interop; -import io.github.jwharm.javagi.Marshal; import io.github.jwharm.javagi.Ownership; -import org.gtk.gobject.GiObject; -import org.gtk.gobject.ParamSpec; -import org.gtk.gobject.Value; +import org.gtk.gobject.*; import org.jetbrains.annotations.ApiStatus; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.Linker; -import java.lang.foreign.MemoryAddress; +import java.lang.foreign.*; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; public interface SetPropertyCallback { - void invoke(GiObject object, int propertyId, Value value, ParamSpec paramSpec); + void invoke(GObject object, int propertyId, Value value, ParamSpec paramSpec); default void upcall(MemoryAddress object, int propertyId, MemoryAddress value, MemoryAddress pspec) { - invoke(GiObject.fromAddress.marshal(object, Ownership.NONE), + invoke(GObject.fromAddress.marshal(object, Ownership.NONE), propertyId, Value.fromAddress.marshal(value, Ownership.NONE), ParamSpec.fromAddress.marshal(pspec, Ownership.NONE)); @@ -28,7 +21,7 @@ public interface SetPropertyCallback { @ApiStatus.Internal FunctionDescriptor DESCRIPTOR = FunctionDescriptor.ofVoid(Interop.valueLayout.ADDRESS, Interop.valueLayout.C_INT, Interop.valueLayout.ADDRESS, Interop.valueLayout.ADDRESS); @ApiStatus.Internal - MethodHandle HANDLE = CallbackGenerator.getHandle(MethodHandles.lookup(), SetPropertyCallback.class, DESCRIPTOR); + MethodHandle HANDLE = Interop.getHandle(SetPropertyCallback.class, DESCRIPTOR); default MemoryAddress toCallback() { return Linker.nativeLinker().upcallStub(HANDLE.bindTo(this), DESCRIPTOR, Interop.getScope()).address(); diff --git a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/control/InstanceThumbnail.java b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/control/InstanceThumbnail.java index 455351b..514695c 100644 --- a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/control/InstanceThumbnail.java +++ b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/control/InstanceThumbnail.java @@ -2,8 +2,7 @@ package io.gitlab.jfronny.inceptum.gtk.control; import io.github.jwharm.javagi.Ownership; import io.gitlab.jfronny.inceptum.launcher.system.instance.Instance; -import org.gtk.gobject.GObject; -import org.gtk.gobject.TypeInstance; +import org.gtk.gobject.*; import org.gtk.gtk.Image; import org.gtk.gtk.Spinner; import org.gtk.gtk.Stack; @@ -19,8 +18,8 @@ public class InstanceThumbnail extends Stack { super(address, ownership); } - public static InstanceThumbnail castFrom(org.gtk.gobject.GiObject gobject) { - if (GObject.typeCheckInstanceIsA(TypeInstance.fromAddress.marshal(gobject.handle(), Ownership.NONE), Stack.getType())) { + public static InstanceThumbnail castFrom(org.gtk.gobject.GObject gobject) { + if (GObjects.typeCheckInstanceIsA(TypeInstance.fromAddress.marshal(gobject.handle(), Ownership.NONE), Stack.getType())) { return new InstanceThumbnail(gobject.handle(), gobject.yieldOwnership()); } else { throw new ClassCastException("Object type is not an instance of GtkStack"); diff --git a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/util/ListIndex.java b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/util/ListIndex.java index e93acca..e2547e3 100644 --- a/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/util/ListIndex.java +++ b/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/util/ListIndex.java @@ -12,14 +12,14 @@ import org.gtk.gtk.*; import java.lang.foreign.*; import java.lang.invoke.VarHandle; -public class ListIndex extends GiObject { +public class ListIndex extends GObject { private static final int PROP_ITEM_TYPE = 1; private static final String PROP_NAME = "item-type"; private static final String TYPE_NAME = "ListIndex"; - private static final Type PARENT_TYPE = GiObject.getType(); + private static final Type PARENT_TYPE = GObject.getType(); private static final MemoryLayout memoryLayout = MemoryLayout.structLayout( - GiObject.getMemoryLayout().withName("parent_instance"), + GObject.getMemoryLayout().withName("parent_instance"), Interop.valueLayout.C_INT.withName("index"), Interop.valueLayout.C_INT.withName("size") ).withName(TYPE_NAME); @@ -28,7 +28,7 @@ public class ListIndex extends GiObject { public static Type getType() { if (type == null) { // Register the new gtype - type = GObject.typeRegisterStaticSimple( + type = GObjects.typeRegisterStaticSimple( PARENT_TYPE, TYPE_NAME, (short) ObjectClass.getMemoryLayout().byteSize(), @@ -37,7 +37,7 @@ public class ListIndex extends GiObject { instanceInit, TypeFlags.NONE ); - GObject.typeAddInterfaceStatic(type, ListModel.getType(), InterfaceInfo.builder() + GObjects.typeAddInterfaceStatic(type, ListModel.getType(), InterfaceInfo.builder() .setInterfaceInit(interfaceInit) .setInterfaceData(null) .setInterfaceFinalize(null) @@ -49,8 +49,8 @@ public class ListIndex extends GiObject { private static final VarHandle index = memoryLayout.varHandle(MemoryLayout.PathElement.groupElement("index")); private static final VarHandle size = memoryLayout.varHandle(MemoryLayout.PathElement.groupElement("size")); - public static ListIndex castFrom(GiObject gobject) { - if (GObject.typeCheckInstanceIsA(TypeInstance.fromAddress.marshal(gobject.handle(), Ownership.NONE), getType())) { + public static ListIndex castFrom(GObject gobject) { + if (GObjects.typeCheckInstanceIsA(TypeInstance.fromAddress.marshal(gobject.handle(), Ownership.NONE), getType())) { return new ListIndex(gobject.handle(), gobject.yieldOwnership()); } else { throw new ClassCastException("Object type is not an instance of ListIndex"); @@ -68,7 +68,7 @@ public class ListIndex extends GiObject { } public ListIndex() { - super(new GiObject(getType(), PROP_NAME, getType()).handle(), + super(new GObject(getType(), PROP_NAME, getType()).handle(), Ownership.FULL); } @@ -110,12 +110,12 @@ public class ListIndex extends GiObject { private static final ClassInitFunc classInit = (klass, data) -> { System.out.println("ListIndex::classInit"); parentClass = klass.peekParent(); - ObjectClass objectClass = ObjectClass.fromAddress.marshal(GObject.typeCheckClassCast(klass, PARENT_TYPE).handle(), Ownership.NONE); + ObjectClass objectClass = ObjectClass.fromAddress.marshal(GObjects.typeCheckClassCast(klass, PARENT_TYPE).handle(), Ownership.NONE); objectClass.setDispose(instanceDispose.toCallback()); objectClass.setGetProperty(getProperty.toCallback()); objectClass.setSetProperty(setProperty.toCallback()); - ParamSpec paramType = GObject.paramSpecGtype(PROP_NAME, "", "", PARENT_TYPE, + ParamSpec paramType = GObjects.paramSpecGtype(PROP_NAME, "", "", PARENT_TYPE, ParamFlags.CONSTRUCT .or(ParamFlags.READWRITE, ParamFlags.STATIC_NAME,