auto_cast prefix for procedure parameters

This commit is contained in:
gingerBill
2018-08-09 17:58:11 +01:00
parent 877a78d6ba
commit 70586b1cf8
6 changed files with 40 additions and 17 deletions
+4 -4
View File
@@ -104,22 +104,22 @@ new_clone_with_allocator :: inline proc(a: Allocator, data: $T, loc := #caller_l
}
make_slice :: proc(T: type/[]$E, len: int, loc := #caller_location) -> T {
make_slice :: proc(T: type/[]$E, auto_cast len: int, loc := #caller_location) -> T {
runtime.make_slice_error_loc(loc, len);
data := alloc(size_of(E)*len, align_of(E));
s := Raw_Slice{data, len};
return transmute(T)s;
}
make_dynamic_array_len :: proc(T: type/[dynamic]$E, len: int = 16, loc := #caller_location) -> T {
make_dynamic_array_len :: proc(T: type/[dynamic]$E, auto_cast len: int = 16, loc := #caller_location) -> T {
return make_dynamic_array(T, len, len, loc);
}
make_dynamic_array :: proc(T: type/[dynamic]$E, len, cap: int, loc := #caller_location) -> T {
make_dynamic_array :: proc(T: type/[dynamic]$E, auto_cast len: int, auto_cast cap: int, loc := #caller_location) -> T {
runtime.make_dynamic_array_error_loc(loc, len, cap);
data := alloc(size_of(E)*cap, align_of(E));
s := Raw_Dynamic_Array{data, len, cap, context.allocator};
return transmute(T)s;
}
make_map :: proc(T: type/map[$K]$E, cap: int = 16, loc := #caller_location) -> T {
make_map :: proc(T: type/map[$K]$E, auto_cast cap: int = 16, loc := #caller_location) -> T {
runtime.make_map_expr_error_loc(loc, cap);
m: T;
reserve_map(&m, cap);