alef 0.25.37

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    private int {{ callback_name }}(IntPtr userData, out IntPtr outError) {
        try {
            lock ({{ trait_pascal }}Bridge._registryLock) {
                if (!{{ trait_pascal }}Bridge._bridgeRegistry.TryGetValue(userData, out var bridge)) {
                    outError = IntPtr.Zero;
                    return 1;
                }
                bridge._impl.{{ method_name }}();
            }
            outError = IntPtr.Zero;
            return 0;
        } catch (Exception ex) {
            outError = global::System.Runtime.InteropServices.Marshal.StringToCoTaskMemUTF8(ex.Message ?? ex.GetType().Name);
            return 1;
        }
    }