20 lines
743 B
Java
20 lines
743 B
Java
package io.gitlab.jfronny.inceptum.gtk.callback;
|
|
|
|
import io.github.jwharm.javagi.Interop;
|
|
import org.jetbrains.annotations.ApiStatus;
|
|
|
|
import java.lang.foreign.*;
|
|
import java.lang.invoke.MethodHandle;
|
|
|
|
@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 = Interop.getHandle(GetItemCallback.class, DESCRIPTOR);
|
|
|
|
default MemoryAddress toCallback() {
|
|
return Linker.nativeLinker().upcallStub(HANDLE.bindTo(this), DESCRIPTOR, Interop.getScope()).address();
|
|
}
|
|
}
|