aboutsummaryrefslogtreecommitdiff
path: root/src/zeroscript/Env/js.zig
blob: c1ff85de3869b2a1d74527df0d2d5c3d60d366fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const std = @import("std");
const Env = @import("root.zig");

pub extern "object_store" fn process(
    [*]const Env.Call,
    [*]const Env.Value,
    [*]*Env.Value,
    length: usize,
) void;

export fn valueAllocString(value: *Env.Value, len: usize) [*]u8 {
    const ptr: [*]u8 = @ptrCast(std.heap.wasm_allocator.alloc(u8, len) catch @panic("unable to allocate string"));
    value.kind = .string;
    value.value = .{
        .string = .{
            .ptr = ptr,
            .len = len,
        },
    };

    return @constCast(value.value.string.ptr);
}