Add $T: typeid/[]$E; Deprecate T: type/[]$E

`type` as a keyword will soon be removed in favour of polymorphic names (identifiers) in procedures
This commit is contained in:
gingerBill
2018-09-02 16:33:54 +01:00
parent 220485a2d2
commit 11f5236434
6 changed files with 101 additions and 27 deletions
+1 -1
View File
@@ -767,7 +767,7 @@ enum_value_to_string :: proc(v: any) -> (string, bool) {
return "", false;
}
string_to_enum_value :: proc(T: type, s: string) -> (T, bool) {
string_to_enum_value :: proc($T: typeid, s: string) -> (T, bool) {
ti := type_info_base(type_info_of(T));
if e, ok := ti.variant.(Type_Info_Enum); ok {
for str, idx in e.names {
+1 -1
View File
@@ -192,7 +192,7 @@ norm0 :: proc(v: $T/[$N]$E) -> T {
identity :: proc(T: type/[$N][N]$E) -> T {
identity :: proc($T: typeid/[$N][N]$E) -> T {
m: T;
for i in 0..N-1 do m[i][i] = E(1);
return m;
+6 -6
View File
@@ -78,7 +78,7 @@ delete :: proc[
];
new :: inline proc(T: type, allocator := context.allocator, loc := #caller_location) -> ^T {
new :: inline proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> ^T {
ptr := (^T)(alloc(size_of(T), align_of(T), allocator, loc));
if ptr != nil do ptr^ = T{};
return ptr;
@@ -90,25 +90,25 @@ new_clone :: inline proc(data: $T, allocator := context.allocator, loc := #calle
}
make_slice :: proc(T: type/[]$E, auto_cast len: int, allocator := context.allocator, loc := #caller_location) -> T {
make_slice :: proc($T: typeid/[]$E, auto_cast len: int, allocator := context.allocator, loc := #caller_location) -> T {
runtime.make_slice_error_loc(loc, len);
data := alloc(size_of(E)*len, align_of(E), allocator, loc);
s := Raw_Slice{data, len};
return transmute(T)s;
}
make_dynamic_array :: proc(T: type/[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> T {
make_dynamic_array :: proc($T: typeid/[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> T {
return make_dynamic_array_len_cap(T, 0, 16, allocator, loc);
}
make_dynamic_array_len :: proc(T: type/[dynamic]$E, auto_cast len: int, allocator := context.allocator, loc := #caller_location) -> T {
make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, auto_cast len: int, allocator := context.allocator, loc := #caller_location) -> T {
return make_dynamic_array_len_cap(T, len, len, allocator, loc);
}
make_dynamic_array_len_cap :: proc(T: type/[dynamic]$E, auto_cast len: int, auto_cast cap: int, allocator := context.allocator, loc := #caller_location) -> T {
make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, auto_cast len: int, auto_cast cap: int, allocator := context.allocator, loc := #caller_location) -> T {
runtime.make_dynamic_array_error_loc(loc, len, cap);
data := alloc(size_of(E)*cap, align_of(E), allocator, loc);
s := Raw_Dynamic_Array{data, len, cap, allocator};
return transmute(T)s;
}
make_map :: proc(T: type/map[$K]$E, auto_cast cap: int = 16, allocator := context.allocator, loc := #caller_location) -> T {
make_map :: proc($T: typeid/map[$K]$E, auto_cast cap: int = 16, allocator := context.allocator, loc := #caller_location) -> T {
runtime.make_map_expr_error_loc(loc, cap);
c := context;