java.lang.Object
io.github.jwharm.cairobindings.Interop
The Interop class contains functionality for interoperability with native code.
-
Method Summary
Modifier and TypeMethodDescriptionstatic MemorySegmentallocateNativeString(String string, SegmentAllocator allocator) Allocate a native string using SegmentAllocator.allocateUtf8String(String).static MethodHandledowncallHandle(String name, FunctionDescriptor fdesc) Creates a method handle that is used to call the native function with the provided name and function descriptor.enumSetToInt(Set<T> set) Create a bitfield from the provided Set of enumsintToEnumSet(Class<T> cls, Function<Integer, T> make, int bitfield) Create an EnumSet of class `cls` from the provided bitfield
-
Method Details
-
downcallHandle
Creates a method handle that is used to call the native function with the provided name and function descriptor. The method handle is cached and reused in subsequent lookups.- Parameters:
name- Name of the native functionfdesc- Function descriptor of the native function- Returns:
- the MethodHandle
-
allocateNativeString
Allocate a native string using SegmentAllocator.allocateUtf8String(String).- Parameters:
string- the string to allocate as a native string (utf8 char*)allocator- the segment allocator to use- Returns:
- the allocated MemorySegment
-
intToEnumSet
public static <T extends Enum<T> & Flag> EnumSet<T> intToEnumSet(Class<T> cls, Function<Integer, T> make, int bitfield) Create an EnumSet of class `cls` from the provided bitfield- Type Parameters:
T- an enum implementing the Java-GI Enumeration interface- Parameters:
cls- the class of the enummake- function that will construct an enum from one flag valuebitfield- the integer containing the bitfield- Returns:
- an EnumSet containing the enum values as set in the bitfield
-
enumSetToInt
-