correct case for zig naming

This commit is contained in:
Brendan Hansknecht 2023-03-11 17:33:07 -08:00
parent 401f525846
commit f96a63c1d4
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
2 changed files with 17 additions and 17 deletions

View file

@ -18,7 +18,7 @@ const HasTagId = fn (u16, ?[*]u8) callconv(.C) extern struct { matched: bool, da
pub const RocList = extern struct {
bytes: ?[*]u8,
length: usize,
capacityOrRefPtr: usize,
capacity_or_ref_ptr: usize,
pub inline fn len(self: RocList) usize {
return self.length;
@ -26,13 +26,13 @@ pub const RocList = extern struct {
pub fn getCapacity(self: RocList) usize {
if (!self.isSeamlessSlice()) {
return self.capacityOrRefPtr;
return self.capacity_or_ref_ptr;
}
return self.length;
}
pub fn isSeamlessSlice(self: RocList) bool {
return @bitCast(isize, self.capacityOrRefPtr) < 0;
return @bitCast(isize, self.capacity_or_ref_ptr) < 0;
}
pub fn isEmpty(self: RocList) bool {
@ -40,7 +40,7 @@ pub const RocList = extern struct {
}
pub fn empty() RocList {
return RocList{ .bytes = null, .length = 0, .capacityOrRefPtr = 0 };
return RocList{ .bytes = null, .length = 0, .capacity_or_ref_ptr = 0 };
}
pub fn eql(self: RocList, other: RocList) bool {
@ -88,7 +88,7 @@ pub const RocList = extern struct {
pub fn decref(self: RocList, alignment: u32) void {
if (self.isSeamlessSlice()) {
const ref_ptr = @intToPtr([*]isize, self.capacityOrRefPtr << 1);
const ref_ptr = @intToPtr([*]isize, self.capacity_or_ref_ptr << 1);
utils.decref_ptr_to_refcount(ref_ptr, alignment);
} else {
utils.decref(self.bytes, self.getCapacity(), alignment);
@ -163,7 +163,7 @@ pub const RocList = extern struct {
return RocList{
.bytes = utils.allocateWithRefcount(data_bytes, alignment),
.length = length,
.capacityOrRefPtr = capacity,
.capacity_or_ref_ptr = capacity,
};
}
@ -177,11 +177,11 @@ pub const RocList = extern struct {
if (self.isUnique() and !self.isSeamlessSlice()) {
const capacity = self.getCapacity();
if (capacity >= new_length) {
return RocList{ .bytes = self.bytes, .length = new_length, .capacityOrRefPtr = capacity };
return RocList{ .bytes = self.bytes, .length = new_length, .capacity_or_ref_ptr = capacity };
} else {
const new_capacity = utils.calculateCapacity(capacity, new_length, element_width);
const new_source = utils.unsafeReallocate(source_ptr, alignment, capacity, new_capacity, element_width);
return RocList{ .bytes = new_source, .length = new_length, .capacityOrRefPtr = new_capacity };
return RocList{ .bytes = new_source, .length = new_length, .capacity_or_ref_ptr = new_capacity };
}
}
return self.reallocateFresh(alignment, new_length, element_width);
@ -585,7 +585,7 @@ pub fn listSublist(
return RocList{
.bytes = source_ptr + start * element_width,
.length = keep_len,
.capacityOrRefPtr = list.capacityOrRefPtr,
.capacity_or_ref_ptr = list.capacity_or_ref_ptr,
};
}
@ -596,7 +596,7 @@ pub fn listSublist(
return RocList{
.bytes = source_ptr + start * element_width,
.length = keep_len,
.capacityOrRefPtr = (@ptrToInt(ref_ptr) >> 1) | seamless_slice_bit,
.capacity_or_ref_ptr = (@ptrToInt(ref_ptr) >> 1) | seamless_slice_bit,
};
}
}

View file

@ -66,7 +66,7 @@ pub const RocStr = extern struct {
return RocStr{
.str_bytes = list.bytes,
.str_len = list.length,
.str_capacity = list.capacityOrRefPtr, // This is guaranteed to be a proper capcity.
.str_capacity = list.capacity_or_ref_ptr, // This is guaranteed to be a proper capcity.
};
}
@ -1678,7 +1678,7 @@ test "RocStr.concat: small concat small" {
pub const RocListStr = extern struct {
list_elements: ?[*]RocStr,
list_length: usize,
list_capacityOrRefPtr: usize,
list_capacity_or_ref_ptr: usize,
};
// Str.joinWith
@ -1686,7 +1686,7 @@ pub fn strJoinWithC(list: RocList, separator: RocStr) callconv(.C) RocStr {
const roc_list_str = RocListStr{
.list_elements = @ptrCast(?[*]RocStr, @alignCast(@alignOf(usize), list.bytes)),
.list_length = list.length,
.list_capacityOrRefPtr = list.capacityOrRefPtr,
.list_capacity_or_ref_ptr = list.capacity_or_ref_ptr,
};
return @call(.{ .modifier = always_inline }, strJoinWith, .{ roc_list_str, separator });
@ -1748,7 +1748,7 @@ test "RocStr.joinWith: result is big" {
var elements: [3]RocStr = .{ roc_elem, roc_elem, roc_elem };
const list = RocListStr{
.list_length = 3,
.list_capacityOrRefPtr = 3,
.list_capacity_or_ref_ptr = 3,
.list_elements = @ptrCast([*]RocStr, &elements),
};
@ -1779,9 +1779,9 @@ inline fn strToBytes(arg: RocStr) RocList {
@memcpy(ptr, arg.asU8ptr(), length);
return RocList{ .length = length, .bytes = ptr, .capacityOrRefPtr = length };
return RocList{ .length = length, .bytes = ptr, .capacity_or_ref_ptr = length };
} else {
return RocList{ .length = length, .bytes = arg.str_bytes, .capacityOrRefPtr = arg.str_capacity };
return RocList{ .length = length, .bytes = arg.str_bytes, .capacity_or_ref_ptr = arg.str_capacity };
}
}
@ -1915,7 +1915,7 @@ pub const Utf8ByteProblem = enum(u8) {
};
fn validateUtf8Bytes(bytes: [*]u8, length: usize) FromUtf8Result {
return fromUtf8Range(RocList{ .bytes = bytes, .length = length, .capacityOrRefPtr = length }, 0, length, .Immutable);
return fromUtf8Range(RocList{ .bytes = bytes, .length = length, .capacity_or_ref_ptr = length }, 0, length, .Immutable);
}
fn validateUtf8BytesX(str: RocList) FromUtf8Result {