-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlua_LibraryMemberConstantCallback.java
More file actions
71 lines (58 loc) · 2.19 KB
/
lua_LibraryMemberConstantCallback.java
File metadata and controls
71 lines (58 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Generated by jextract
package net.hollowcube.luau.internal.compiler;
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 void (*lua_LibraryMemberConstantCallback)(const char *, const char *, lua_CompileConstant *)
* }
*/
public final class lua_LibraryMemberConstantCallback {
private lua_LibraryMemberConstantCallback() {
// Should not be called directly
}
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
void apply(MemorySegment library, MemorySegment member, MemorySegment constant);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid(
luacode_h.C_POINTER,
luacode_h.C_POINTER,
luacode_h.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = luacode_h.upcallHandle(lua_LibraryMemberConstantCallback.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(lua_LibraryMemberConstantCallback.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 void invoke(MemorySegment funcPtr, MemorySegment library, MemorySegment member, MemorySegment constant) {
try {
DOWN$MH.invokeExact(funcPtr, library, member, constant);
} catch (Error | RuntimeException ex) {
throw ex;
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}