Skip to content

Commit

Permalink
Fix web-lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
fubark committed Sep 2, 2024
1 parent 5b8dd64 commit bab51c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ export fn clUnwrapChoice(vm: *cy.VM, choice: cy.Value, name: c.Str) cy.Value {
// To enable logging for tests:
// c.setVerbose(true);
// c.setLog(printLogger);
pub fn printLogger(str: c.Str) callconv(.C) void {
fn printLogger(str: c.Str) callconv(.C) void {
std.debug.print("{s}\n", .{ c.fromStr(str) });
}

Expand Down
15 changes: 8 additions & 7 deletions src/web.zig
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ export fn clWebGetFuture(vm: *cy.VM, id: u32) cy.Value {
return futurev;
}

export fn clWebNewFuture(vm: *cy.VM) u32 {
const ctx = vm.getData(*WebContext, "web");
export fn clWebNewFuture(ivm: *cy.VM) u32 {
const vm: *C.ZVM = @ptrCast(ivm);
const ctx = ivm.getData(*WebContext, "web");

const any_t = C.newType(@ptrCast(vm), cy.types.BuiltinTypes.Any);
defer C.release(@ptrCast(vm), any_t);
const any_t = vm.newType(cy.types.BuiltinTypes.Any);
defer vm.release(any_t);
var FutureAnyT: cy.TypeId = undefined;
std.debug.assert(C.expandTemplateType(vm.sema.future_tmpl.head.toC(), &any_t, 1, &FutureAnyT));
const future = vm.allocFuture(FutureAnyT) catch @panic("error");
std.debug.assert(vm.expandTemplateType(ivm.sema.future_tmpl.head.toC(), &.{any_t}, &FutureAnyT));
const future = ivm.allocFuture(FutureAnyT) catch @panic("error");

const id = ctx.next_id;
ctx.futures.put(vm.alloc, id, future) catch @panic("error");
ctx.futures.put(ivm.alloc, id, future) catch @panic("error");
ctx.next_id += 1;
return id;
}

0 comments on commit bab51c1

Please sign in to comment.