1 // Generated by jextract
2
3 package oracle.code.onnx.foreign;
4
5 import java.lang.invoke.*;
6 import java.lang.foreign.*;
7 import java.nio.ByteOrder;
8 import java.util.*;
9 import java.util.function.*;
10 import java.util.stream.*;
11
12 import static java.lang.foreign.ValueLayout.*;
13 import static java.lang.foreign.MemoryLayout.PathElement.*;
14
15 /**
16 * {@snippet lang=c :
17 * typedef OrtStatus *(*OrtGetInitializerLocationFunc)(void *, const char *, const OrtValue *, const OrtExternalInitializerInfo *, OrtExternalInitializerInfo **)
18 * }
19 */
20 public class OrtGetInitializerLocationFunc {
21
22 OrtGetInitializerLocationFunc() {
23 // Should not be called directly
24 }
25
26 /**
27 * The function pointer signature, expressed as a functional interface
28 */
29 public interface Function {
30 MemorySegment apply(MemorySegment state, MemorySegment initializer_name, MemorySegment initializer_value, MemorySegment external_info, MemorySegment new_external_info);
31 }
32
33 private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
34 onnxruntime_c_api_h.C_POINTER,
35 onnxruntime_c_api_h.C_POINTER,
36 onnxruntime_c_api_h.C_POINTER,
37 onnxruntime_c_api_h.C_POINTER,
38 onnxruntime_c_api_h.C_POINTER,
39 onnxruntime_c_api_h.C_POINTER
40 );
41
42 /**
43 * The descriptor of this function pointer
44 */
45 public static FunctionDescriptor descriptor() {
46 return $DESC;
47 }
48
49 private static final MethodHandle UP$MH = onnxruntime_c_api_h.upcallHandle(OrtGetInitializerLocationFunc.Function.class, "apply", $DESC);
50
51 /**
52 * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
53 * The lifetime of the returned segment is managed by {@code arena}
54 */
55 public static MemorySegment allocate(OrtGetInitializerLocationFunc.Function fi, Arena arena) {
56 return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
57 }
58
59 private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
60
61 /**
62 * Invoke the upcall stub {@code funcPtr}, with given parameters
63 */
64 public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment state, MemorySegment initializer_name, MemorySegment initializer_value, MemorySegment external_info, MemorySegment new_external_info) {
65 try {
66 return (MemorySegment) DOWN$MH.invokeExact(funcPtr, state, initializer_name, initializer_value, external_info, new_external_info);
67 } catch (Throwable ex$) {
68 throw new AssertionError("should not reach here", ex$);
69 }
70 }
71 }
72