org.purejava.appindicator.GEqualFunc Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libayatana-appindicator-java-full Show documentation
Show all versions of libayatana-appindicator-java-full Show documentation
Java bindings for libayatana-appindicator in 100% pure Java
// Generated by jextract
package org.purejava.appindicator;
import java.lang.foreign.Arena;
import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.Linker;
import java.lang.foreign.MemorySegment;
import java.lang.invoke.MethodHandle;
/**
* {@snippet lang=c :
* typedef gboolean (*GEqualFunc)(gconstpointer, gconstpointer)
* }
*/
public class GEqualFunc {
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
int apply(MemorySegment a, MemorySegment b);
}
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(GEqualFunc.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(GEqualFunc.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 a, MemorySegment b) {
try {
return (int) DOWN$MH.invokeExact(funcPtr, a, b);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}