Skip to content

Commit

Permalink
chore: zig 0.14.0-dev.2989+bf6ee7cb3
Browse files Browse the repository at this point in the history
fix: `callconv(.c)` was missing everywhere
  • Loading branch information
giann committed Jan 31, 2025
1 parent c8c93d7 commit 5b69603
Show file tree
Hide file tree
Showing 30 changed files with 530 additions and 532 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ A small/lightweight statically typed scripting language written in Zig

## How to build and install

_Latest zig version supported: 0.14.0-dev.2643+fb43e91b2_
_Latest zig version supported: 0.14.0-dev.2989+bf6ee7cb3_

### Requirements
- Since this is built with Zig, you should be able to build buzz on a wide variety of architectures even though this has only been tested on x86/M1.
Expand Down
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn build(b: *Build) !void {

// Check minimum zig version
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse("0.14.0-dev.2851+b074fb7dd") catch return;
const min_zig = std.SemanticVersion.parse("0.14.0-dev.2989+bf6ee7cb3") catch return;
if (current_zig.order(min_zig).compare(.lt)) {
@panic(b.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig }));
}
Expand Down
7 changes: 2 additions & 5 deletions src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ else

const Self = @This();

extern fn dlerror() [*:0]u8;
extern fn dlerror() callconv(.c) [*:0]u8;

pub fn defaultBuzzPrefix() []const u8 {
return ".";
Expand Down Expand Up @@ -8231,10 +8231,7 @@ fn importLibSymbol(self: *Self, full_file_name: []const u8, symbol: []const u8)

var lib: ?std.DynLib = null;
for (paths.items) |path| {
lib = std.DynLib.open(path) catch |err| l: {
std.debug.print(">>> {s} => {}\n", .{ path, err });
break :l null;
};
lib = std.DynLib.open(path) catch null;
if (lib != null) {
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/builtin/fiber.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ const VM = @import("../vm.zig").VM;
const _value = @import("../value.zig");
const Value = _value.Value;

pub fn over(ctx: *NativeCtx) c_int {
pub fn over(ctx: *NativeCtx) callconv(.c) c_int {
const self = ObjFiber.cast(ctx.vm.peek(0).obj()).?;

ctx.vm.push(Value.fromBoolean(self.fiber.status == .Over));

return 1;
}

pub fn cancel(ctx: *NativeCtx) c_int {
pub fn cancel(ctx: *NativeCtx) callconv(.c) c_int {
const self = ObjFiber.cast(ctx.vm.peek(0).obj()).?;

// Main fiber can't be cancelled
Expand All @@ -27,7 +27,7 @@ pub fn cancel(ctx: *NativeCtx) c_int {
return 0;
}

pub fn isMain(ctx: *NativeCtx) c_int {
pub fn isMain(ctx: *NativeCtx) callconv(.c) c_int {
const self = ObjFiber.cast(ctx.vm.peek(0).obj()).?;

ctx.vm.push(Value.fromBoolean(self.fiber.parent_fiber == null));
Expand Down
36 changes: 18 additions & 18 deletions src/builtin/list.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const VM = @import("../vm.zig").VM;
const Value = @import("../value.zig").Value;
const buzz_api = @import("../buzz_api.zig");

pub fn append(ctx: *NativeCtx) c_int {
pub fn append(ctx: *NativeCtx) callconv(.c) c_int {
const list_value: Value = ctx.vm.peek(1);
const list: *ObjList = ObjList.cast(list_value.obj()).?;
const value: Value = ctx.vm.peek(0);
Expand All @@ -26,7 +26,7 @@ pub fn append(ctx: *NativeCtx) c_int {
return 0;
}

pub fn insert(ctx: *NativeCtx) c_int {
pub fn insert(ctx: *NativeCtx) callconv(.c) c_int {
const list_value: Value = ctx.vm.peek(2);
const list: *ObjList = ObjList.cast(list_value.obj()).?;
var index = ctx.vm.peek(1).integer();
Expand All @@ -52,15 +52,15 @@ pub fn insert(ctx: *NativeCtx) c_int {
return 1;
}

pub fn len(ctx: *NativeCtx) c_int {
pub fn len(ctx: *NativeCtx) callconv(.c) c_int {
const list: *ObjList = ObjList.cast(ctx.vm.peek(0).obj()).?;

ctx.vm.push(Value.fromInteger(@as(i32, @intCast(list.items.items.len))));

return 1;
}

pub fn reverse(ctx: *NativeCtx) c_int {
pub fn reverse(ctx: *NativeCtx) callconv(.c) c_int {
const list: *ObjList = ObjList.cast(ctx.vm.peek(0).obj()).?;

var new_list = ctx.vm.gc.allocateObject(
Expand All @@ -85,7 +85,7 @@ pub fn reverse(ctx: *NativeCtx) c_int {
return 1;
}

pub fn pop(ctx: *NativeCtx) c_int {
pub fn pop(ctx: *NativeCtx) callconv(.c) c_int {
const list: *ObjList = ObjList.cast(ctx.vm.peek(0).obj()).?;

if (list.items.items.len > 0) {
Expand All @@ -97,7 +97,7 @@ pub fn pop(ctx: *NativeCtx) c_int {
return 1;
}

pub fn remove(ctx: *NativeCtx) c_int {
pub fn remove(ctx: *NativeCtx) callconv(.c) c_int {
const list: *ObjList = ObjList.cast(ctx.vm.peek(1).obj()).?;
const list_index = ctx.vm.peek(0).integer();

Expand Down Expand Up @@ -135,7 +135,7 @@ fn lessThan(context: SortContext, lhs: Value, rhs: Value) bool {
return context.ctx.vm.pop().boolean();
}

pub fn sort(ctx: *NativeCtx) c_int {
pub fn sort(ctx: *NativeCtx) callconv(.c) c_int {
var self = ObjList.cast(ctx.vm.peek(1).obj()).?;
// fun compare(T lhs, T rhs) > bool
const sort_closure = ctx.vm.peek(0);
Expand All @@ -156,7 +156,7 @@ pub fn sort(ctx: *NativeCtx) c_int {
return 1;
}

pub fn indexOf(ctx: *NativeCtx) c_int {
pub fn indexOf(ctx: *NativeCtx) callconv(.c) c_int {
const self: *ObjList = ObjList.cast(ctx.vm.peek(1).obj()).?;
const needle: Value = ctx.vm.peek(0);

Expand Down Expand Up @@ -207,19 +207,19 @@ fn cloneRaw(ctx: *NativeCtx, mutable: bool) void {
ctx.vm.push(new_list.toValue());
}

pub fn cloneImmutable(ctx: *NativeCtx) c_int {
pub fn cloneImmutable(ctx: *NativeCtx) callconv(.c) c_int {
cloneRaw(ctx, false);

return 1;
}

pub fn cloneMutable(ctx: *NativeCtx) c_int {
pub fn cloneMutable(ctx: *NativeCtx) callconv(.c) c_int {
cloneRaw(ctx, true);

return 1;
}

pub fn join(ctx: *NativeCtx) c_int {
pub fn join(ctx: *NativeCtx) callconv(.c) c_int {
const self = ObjList.cast(ctx.vm.peek(1).obj()).?;
const separator = ObjString.cast(ctx.vm.peek(0).obj()).?;

Expand Down Expand Up @@ -250,7 +250,7 @@ pub fn join(ctx: *NativeCtx) c_int {
return 1;
}

pub fn sub(ctx: *NativeCtx) c_int {
pub fn sub(ctx: *NativeCtx) callconv(.c) c_int {
const self: *ObjList = ObjList.cast(ctx.vm.peek(2).obj()).?;
const start = @min(
@max(
Expand Down Expand Up @@ -302,7 +302,7 @@ pub fn sub(ctx: *NativeCtx) c_int {
return 1;
}

pub fn next(ctx: *NativeCtx) c_int {
pub fn next(ctx: *NativeCtx) callconv(.c) c_int {
const list_value: Value = ctx.vm.peek(1);
const list: *ObjList = ObjList.cast(list_value.obj()).?;
const list_index: Value = ctx.vm.peek(0);
Expand All @@ -325,7 +325,7 @@ pub fn next(ctx: *NativeCtx) c_int {
return 1;
}

pub fn forEach(ctx: *NativeCtx) c_int {
pub fn forEach(ctx: *NativeCtx) callconv(.c) c_int {
const list = ObjList.cast(ctx.vm.peek(1).obj()).?;
const closure = ctx.vm.peek(0);

Expand All @@ -346,7 +346,7 @@ pub fn forEach(ctx: *NativeCtx) c_int {
return 0;
}

pub fn reduce(ctx: *NativeCtx) c_int {
pub fn reduce(ctx: *NativeCtx) callconv(.c) c_int {
const list = ObjList.cast(ctx.vm.peek(2).obj()).?;
const closure = ctx.vm.peek(1);
var accumulator = ctx.vm.peek(0);
Expand Down Expand Up @@ -376,7 +376,7 @@ pub fn reduce(ctx: *NativeCtx) c_int {
return 1;
}

pub fn filter(ctx: *NativeCtx) c_int {
pub fn filter(ctx: *NativeCtx) callconv(.c) c_int {
const list = ObjList.cast(ctx.vm.peek(1).obj()).?;
const closure = ctx.vm.peek(0);

Expand Down Expand Up @@ -419,7 +419,7 @@ pub fn filter(ctx: *NativeCtx) c_int {
return 1;
}

pub fn map(ctx: *NativeCtx) c_int {
pub fn map(ctx: *NativeCtx) callconv(.c) c_int {
const list = ObjList.cast(ctx.vm.peek(1).obj()).?;
const closure = ctx.vm.peek(0);

Expand Down Expand Up @@ -478,7 +478,7 @@ pub fn map(ctx: *NativeCtx) c_int {
return 1;
}

pub fn fill(ctx: *NativeCtx) c_int {
pub fn fill(ctx: *NativeCtx) callconv(.c) c_int {
const self: *ObjList = ObjList.cast(ctx.vm.peek(3).obj()).?;
const value = ctx.vm.peek(2);
const start: usize = @intCast(
Expand Down
26 changes: 13 additions & 13 deletions src/builtin/map.zig
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ fn cloneRaw(ctx: *NativeCtx, mutable: bool) void {
ctx.vm.push(new_map.toValue());
}

pub fn cloneMutable(ctx: *NativeCtx) c_int {
pub fn cloneMutable(ctx: *NativeCtx) callconv(.c) c_int {
cloneRaw(ctx, true);

return 1;
}

pub fn cloneImmutable(ctx: *NativeCtx) c_int {
pub fn cloneImmutable(ctx: *NativeCtx) callconv(.c) c_int {
cloneRaw(ctx, false);

return 1;
}

pub fn reduce(ctx: *NativeCtx) c_int {
pub fn reduce(ctx: *NativeCtx) callconv(.c) c_int {
const self = ObjMap.cast(ctx.vm.peek(2).obj()).?;
const closure = ctx.vm.peek(1);
var accumulator = ctx.vm.peek(0);
Expand All @@ -80,7 +80,7 @@ pub fn reduce(ctx: *NativeCtx) c_int {
return 1;
}

pub fn filter(ctx: *NativeCtx) c_int {
pub fn filter(ctx: *NativeCtx) callconv(.c) c_int {
const self = ObjMap.cast(ctx.vm.peek(1).obj()).?;
const closure = ctx.vm.peek(0);

Expand Down Expand Up @@ -123,7 +123,7 @@ pub fn filter(ctx: *NativeCtx) c_int {
return 1;
}

pub fn forEach(ctx: *NativeCtx) c_int {
pub fn forEach(ctx: *NativeCtx) callconv(.c) c_int {
const self = ObjMap.cast(ctx.vm.peek(1).obj()).?;
const closure = ctx.vm.peek(0);

Expand All @@ -143,7 +143,7 @@ pub fn forEach(ctx: *NativeCtx) c_int {
return 0;
}

pub fn map(ctx: *NativeCtx) c_int {
pub fn map(ctx: *NativeCtx) callconv(.c) c_int {
const self = ObjMap.cast(ctx.vm.peek(1).obj()).?;
const closure = ctx.vm.peek(0);

Expand Down Expand Up @@ -235,7 +235,7 @@ const SortContext = struct {
}
};

pub fn sort(ctx: *NativeCtx) c_int {
pub fn sort(ctx: *NativeCtx) callconv(.c) c_int {
const self: *ObjMap = ObjMap.cast(ctx.vm.peek(1).obj()).?;
const sort_closure = ctx.vm.peek(0);

Expand All @@ -253,7 +253,7 @@ pub fn sort(ctx: *NativeCtx) c_int {
return 1;
}

pub fn diff(ctx: *NativeCtx) c_int {
pub fn diff(ctx: *NativeCtx) callconv(.c) c_int {
const lhs: *ObjMap = ObjMap.cast(ctx.vm.peek(1).obj()).?;
const rhs: *ObjMap = ObjMap.cast(ctx.vm.peek(0).obj()).?;

Expand Down Expand Up @@ -291,7 +291,7 @@ pub fn diff(ctx: *NativeCtx) c_int {
return 1;
}

pub fn intersect(ctx: *NativeCtx) c_int {
pub fn intersect(ctx: *NativeCtx) callconv(.c) c_int {
const lhs: *ObjMap = ObjMap.cast(ctx.vm.peek(1).obj()).?;
const rhs: *ObjMap = ObjMap.cast(ctx.vm.peek(0).obj()).?;

Expand Down Expand Up @@ -329,15 +329,15 @@ pub fn intersect(ctx: *NativeCtx) c_int {
return 1;
}

pub fn size(ctx: *NativeCtx) c_int {
pub fn size(ctx: *NativeCtx) callconv(.c) c_int {
const self: *ObjMap = ObjMap.cast(ctx.vm.peek(0).obj()).?;

ctx.vm.push(Value.fromInteger(@intCast(self.map.count())));

return 1;
}

pub fn remove(ctx: *NativeCtx) c_int {
pub fn remove(ctx: *NativeCtx) callconv(.c) c_int {
const self: *ObjMap = ObjMap.cast(ctx.vm.peek(1).obj()).?;
const map_key = ctx.vm.peek(0);

Expand All @@ -350,7 +350,7 @@ pub fn remove(ctx: *NativeCtx) c_int {
return 1;
}

pub fn keys(ctx: *NativeCtx) c_int {
pub fn keys(ctx: *NativeCtx) callconv(.c) c_int {
const self: *ObjMap = ObjMap.cast(ctx.vm.peek(0).obj()).?;

const map_keys = self.map.keys();
Expand Down Expand Up @@ -401,7 +401,7 @@ pub fn keys(ctx: *NativeCtx) c_int {
return 1;
}

pub fn values(ctx: *NativeCtx) c_int {
pub fn values(ctx: *NativeCtx) callconv(.c) c_int {
const self: *ObjMap = ObjMap.cast(ctx.vm.peek(0).obj()).?;

const map_values: []Value = self.map.values();
Expand Down
Loading

0 comments on commit 5b69603

Please sign in to comment.