alef 0.32.5

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
                    // Complex return type: serialize the host value to JSON and hand back a
                    // NUL-terminated C string. The caller owns the returned pointer and must
                    // free it via the C API.
                    const _json_slice = std.fmt.allocPrint(std.heap.c_allocator, "{f}", .{ std.json.fmt({{ ok_binding }}, .{}) }) catch {
                        if (out_error) |ptr| ptr.* = null;
                        return 1;
                    };
                    defer std.heap.c_allocator.free(_json_slice);
                    const _json_cstr = std.heap.c_allocator.dupeZ(u8, _json_slice) catch {
                        if (out_error) |ptr| ptr.* = null;
                        return 1;
                    };
                    if (out_result) |ptr| ptr.* = @ptrCast(_json_cstr.ptr);
                    return 0;