Change procedure group syntax from proc[] to proc{}; deprecate proc[] (raises warning currently)

This commit is contained in:
gingerBill
2018-12-02 18:01:03 +00:00
parent b2df48dadb
commit 28583bfff8
9 changed files with 85 additions and 68 deletions
+10 -10
View File
@@ -66,7 +66,7 @@ byte_swap_int :: proc(i: int) -> int {
}
}
byte_swap :: proc[
byte_swap :: proc{
byte_swap_u16,
byte_swap_u32,
byte_swap_u64,
@@ -75,7 +75,7 @@ byte_swap :: proc[
byte_swap_i64,
byte_swap_uint,
byte_swap_int,
];
};
count_zeros8 :: proc(i: u8) -> u8 { return 8 - count_ones8(i); }
count_zeros16 :: proc(i: u16) -> u16 { return 16 - count_ones16(i); }
@@ -150,13 +150,13 @@ overflowing_add_int :: proc(lhs, rhs: int) -> (int, bool) {
}
}
overflowing_add :: proc[
overflowing_add :: proc{
overflowing_add_u8, overflowing_add_i8,
overflowing_add_u16, overflowing_add_i16,
overflowing_add_u32, overflowing_add_i32,
overflowing_add_u64, overflowing_add_i64,
overflowing_add_uint, overflowing_add_int,
];
};
foreign {
@(link_name="llvm.usub.with.overflow.i8") overflowing_sub_u8 :: proc(lhs, rhs: u8) -> (u8, bool) ---
@@ -187,13 +187,13 @@ overflowing_sub_int :: proc(lhs, rhs: int) -> (int, bool) {
}
}
overflowing_sub :: proc[
overflowing_sub :: proc{
overflowing_sub_u8, overflowing_sub_i8,
overflowing_sub_u16, overflowing_sub_i16,
overflowing_sub_u32, overflowing_sub_i32,
overflowing_sub_u64, overflowing_sub_i64,
overflowing_sub_uint, overflowing_sub_int,
];
};
foreign {
@@ -225,13 +225,13 @@ overflowing_mul_int :: proc(lhs, rhs: int) -> (int, bool) {
}
}
overflowing_mul :: proc[
overflowing_mul :: proc{
overflowing_mul_u8, overflowing_mul_i8,
overflowing_mul_u16, overflowing_mul_i16,
overflowing_mul_u32, overflowing_mul_i32,
overflowing_mul_u64, overflowing_mul_i64,
overflowing_mul_uint, overflowing_mul_int,
];
};
is_power_of_two_u8 :: proc(i: u8) -> bool { return i > 0 && (i & (i-1)) == 0; }
is_power_of_two_i8 :: proc(i: i8) -> bool { return i > 0 && (i & (i-1)) == 0; }
@@ -244,10 +244,10 @@ is_power_of_two_i64 :: proc(i: i64) -> bool { return i > 0 && (i & (i-1)) == 0
is_power_of_two_uint :: proc(i: uint) -> bool { return i > 0 && (i & (i-1)) == 0; }
is_power_of_two_int :: proc(i: int) -> bool { return i > 0 && (i & (i-1)) == 0; }
is_power_of_two :: proc[
is_power_of_two :: proc{
is_power_of_two_u8, is_power_of_two_i8,
is_power_of_two_u16, is_power_of_two_i16,
is_power_of_two_u32, is_power_of_two_i32,
is_power_of_two_u64, is_power_of_two_i64,
is_power_of_two_uint, is_power_of_two_int,
]
};
+21 -23
View File
@@ -63,7 +63,7 @@ foreign _ {
log_f64 :: proc(x: f64) -> f64 ---;
}
log :: proc[log_f32, log_f64];
log :: proc{log_f32, log_f64};
tan_f32 :: proc "c" (θ: f32) -> f32 { return sin(θ)/cos(θ); }
tan_f64 :: proc "c" (θ: f64) -> f64 { return sin(θ)/cos(θ); }
@@ -94,31 +94,31 @@ copy_sign_f64 :: proc(x, y: f64) -> f64 {
}
sqrt :: proc[sqrt_f32, sqrt_f64];
sin :: proc[sin_f32, sin_f64];
cos :: proc[cos_f32, cos_f64];
tan :: proc[tan_f32, tan_f64];
pow :: proc[pow_f32, pow_f64];
fmuladd :: proc[fmuladd_f32, fmuladd_f64];
sign :: proc[sign_f32, sign_f64];
copy_sign :: proc[copy_sign_f32, copy_sign_f64];
sqrt :: proc{sqrt_f32, sqrt_f64};
sin :: proc{sin_f32, sin_f64};
cos :: proc{cos_f32, cos_f64};
tan :: proc{tan_f32, tan_f64};
pow :: proc{pow_f32, pow_f64};
fmuladd :: proc{fmuladd_f32, fmuladd_f64};
sign :: proc{sign_f32, sign_f64};
copy_sign :: proc{copy_sign_f32, copy_sign_f64};
round_f32 :: proc(x: f32) -> f32 { return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5); }
round_f64 :: proc(x: f64) -> f64 { return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5); }
round :: proc[round_f32, round_f64];
round :: proc{round_f32, round_f64};
floor_f32 :: proc(x: f32) -> f32 { return x >= 0 ? f32(i64(x)) : f32(i64(x-0.5)); } // TODO: Get accurate versions
floor_f64 :: proc(x: f64) -> f64 { return x >= 0 ? f64(i64(x)) : f64(i64(x-0.5)); } // TODO: Get accurate versions
floor :: proc[floor_f32, floor_f64];
floor :: proc{floor_f32, floor_f64};
ceil_f32 :: proc(x: f32) -> f32 { return x < 0 ? f32(i64(x)) : f32(i64(x+1)); }// TODO: Get accurate versions
ceil_f64 :: proc(x: f64) -> f64 { return x < 0 ? f64(i64(x)) : f64(i64(x+1)); }// TODO: Get accurate versions
ceil :: proc[ceil_f32, ceil_f64];
ceil :: proc{ceil_f32, ceil_f64};
remainder_f32 :: proc(x, y: f32) -> f32 { return x - round(x/y) * y; }
remainder_f64 :: proc(x, y: f64) -> f64 { return x - round(x/y) * y; }
remainder :: proc[remainder_f32, remainder_f64];
remainder :: proc{remainder_f32, remainder_f64};
mod_f32 :: proc(x, y: f32) -> f32 {
result: f32;
@@ -138,7 +138,7 @@ mod_f64 :: proc(x, y: f64) -> f64 {
}
return copy_sign(result, x);
}
mod :: proc[mod_f32, mod_f64];
mod :: proc{mod_f32, mod_f64};
@@ -148,19 +148,17 @@ to_degrees :: proc(radians: f32) -> f32 { return radians * 360 / TAU; }
mul :: proc[
mul :: proc{
mat3_mul,
mat4_mul, mat4_mul_vec4,
quat_mul, quat_mulf,
];
};
div :: proc[
quat_div, quat_divf,
];
div :: proc{quat_div, quat_divf};
inverse :: proc[mat4_inverse, quat_inverse];
dot :: proc[vec_dot, quat_dot];
cross :: proc[cross2, cross3];
inverse :: proc{mat4_inverse, quat_inverse};
dot :: proc{vec_dot, quat_dot};
cross :: proc{cross2, cross3};
vec_dot :: proc(a, b: $T/[$N]$E) -> E {
res: E;
@@ -361,7 +359,7 @@ scale_f32 :: proc(m: Mat4, s: f32) -> Mat4 {
return m;
}
scale :: proc[scale_vec3, scale_f32];
scale :: proc{scale_vec3, scale_f32};
look_at :: proc(eye, centre, up: Vec3) -> Mat4 {
+4 -4
View File
@@ -74,13 +74,13 @@ delete_map :: proc(m: $T/map[$K]$V, loc := #caller_location) {
}
delete :: proc[
delete :: proc{
delete_string,
delete_cstring,
delete_dynamic_array,
delete_slice,
delete_map,
];
};
new :: inline proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> ^T {
@@ -122,13 +122,13 @@ make_map :: proc($T: typeid/map[$K]$E, auto_cast cap: int = 16, allocator := con
return m;
}
make :: proc[
make :: proc{
make_slice,
make_dynamic_array,
make_dynamic_array_len,
make_dynamic_array_len_cap,
make_map,
];
};
+1 -1
View File
@@ -5,7 +5,7 @@ foreign _ {
@(link_name = "llvm.bswap.i32") swap32 :: proc(b: u32) -> u32 ---;
@(link_name = "llvm.bswap.i64") swap64 :: proc(b: u64) -> u64 ---;
}
swap :: proc[swap16, swap32, swap64];
swap :: proc{swap16, swap32, swap64};
+1 -1
View File
@@ -46,6 +46,6 @@ raw_dynamic_array_data :: inline proc(a: $T/[dynamic]$E) -> ^E {
return cast(^E)(^Raw_Dynamic_Array)(&a).data;
}
raw_data :: proc[raw_string_data, raw_slice_data, raw_dynamic_array_data];
raw_data :: proc{raw_string_data, raw_slice_data, raw_dynamic_array_data};
+14 -14
View File
@@ -401,44 +401,44 @@ ordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_locati
@(builtin)
clear :: proc[clear_dynamic_array, clear_map];
clear :: proc{clear_dynamic_array, clear_map};
@(builtin)
reserve :: proc[reserve_dynamic_array, reserve_map];
reserve :: proc{reserve_dynamic_array, reserve_map};
@(builtin)
resize :: proc[resize_dynamic_array];
resize :: proc{resize_dynamic_array};
@(builtin)
new :: proc[mem.new];
new :: proc{mem.new};
@(builtin)
new_clone :: proc[mem.new_clone];
new_clone :: proc{mem.new_clone};
@(builtin)
free :: proc[mem.free];
free :: proc{mem.free};
@(builtin)
free_all :: proc[mem.free_all];
free_all :: proc{mem.free_all};
@(builtin)
delete :: proc[
delete :: proc{
mem.delete_string,
mem.delete_cstring,
mem.delete_dynamic_array,
mem.delete_slice,
mem.delete_map,
];
};
@(builtin)
make :: proc[
make :: proc{
mem.make_slice,
mem.make_dynamic_array,
mem.make_dynamic_array_len,
mem.make_dynamic_array_len_cap,
mem.make_map,
];
};
@@ -508,7 +508,7 @@ append_elems :: proc(array: ^$T/[dynamic]$E, args: ..E, loc := #caller_location)
}
return len(array);
}
@(builtin) append :: proc[append_elem, append_elems];
@(builtin) append :: proc{append_elem, append_elems};
@@ -616,8 +616,8 @@ excl_bit_set :: inline proc(s: ^$S/bit_set[$E; $U], other: S) -> S {
return s^;
}
@(builtin) incl :: proc[incl_elem, incl_elems, incl_bit_set];
@(builtin) excl :: proc[excl_elem, excl_elems, excl_bit_set];
@(builtin) incl :: proc{incl_elem, incl_elems, incl_bit_set};
@(builtin) excl :: proc{excl_elem, excl_elems, excl_bit_set};