com.nextbreakpoint.freeimage4java.FI_ReadProc Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.nextbreakpoint.freeimage4java.macos Show documentation
Show all versions of com.nextbreakpoint.freeimage4java.macos Show documentation
FreeImage4Java provides a Java wrapper of FreeImage library
The newest version!
// Generated by jextract
package com.nextbreakpoint.freeimage4java;
import java.lang.invoke.*;
import java.lang.foreign.*;
import java.nio.ByteOrder;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import static java.lang.foreign.ValueLayout.*;
import static java.lang.foreign.MemoryLayout.PathElement.*;
/**
* {@snippet lang=c :
* typedef unsigned int (*FI_ReadProc)(void *, unsigned int, unsigned int, fi_handle)
* }
*/
public class FI_ReadProc {
FI_ReadProc() {
// Should not be called directly
}
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
int apply(MemorySegment buffer, int size, int count, MemorySegment handle);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
Libfreeimage.C_INT,
Libfreeimage.C_POINTER,
Libfreeimage.C_INT,
Libfreeimage.C_INT,
Libfreeimage.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = Libfreeimage.upcallHandle(FI_ReadProc.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(FI_ReadProc.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 buffer, int size, int count, MemorySegment handle) {
try {
return (int) DOWN$MH.invokeExact(funcPtr, buffer, size, count, handle);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}