diff --git a/core/_preload.odin b/core/_preload.odin index 90ebcde56..80f8453fe 100644 --- a/core/_preload.odin +++ b/core/_preload.odin @@ -5,6 +5,17 @@ #import "utf8.odin"; #import "raw.odin"; +// Naming Conventions: +// In general, PascalCase for types and snake_case for values +// +// Import Name: snake_case (but prefer single word) +// Types: PascalCase +// Union Variants: PascalCase +// Enum Values: PascalCase +// Procedures: snake_case +// Local Variables: snake_case +// Constant Variables: SCREAMING_SNAKE_CASE + // IMPORTANT NOTE(bill): `type_info` & `type_info_val` cannot be used within a // #shared_global_scope due to the internals of the compiler. // This could change at a later date if the all these data structures are @@ -13,20 +24,20 @@ // IMPORTANT NOTE(bill): Do not change the order of any of this data // The compiler relies upon this _exact_ order -Type_Info_Enum_Value :: raw_union { +TypeInfoEnumValue :: raw_union { f: f64, i: i64, } // NOTE(bill): This must match the compiler's -Calling_Convention :: enum { +CallingConvention :: enum { ODIN = 0, C = 1, STD = 2, FAST = 3, } -Type_Info_Record :: struct #ordered { - types: []^Type_Info, +TypeInfoRecord :: struct #ordered { + types: []^TypeInfo, names: []string, offsets: []int, // offsets may not be used in tuples usings: []bool, // usings may not be used in tuples @@ -35,11 +46,11 @@ Type_Info_Record :: struct #ordered { custom_align: bool, } -Type_Info :: union { +TypeInfo :: union { size: int, align: int, - Named{name: string, base: ^Type_Info}, + Named{name: string, base: ^TypeInfo}, Integer{signed: bool}, Float{}, Complex{}, @@ -48,44 +59,44 @@ Type_Info :: union { Boolean{}, Any{}, Pointer{ - elem: ^Type_Info, // nil -> rawptr + elem: ^TypeInfo, // nil -> rawptr }, - Atomic{elem: ^Type_Info}, + Atomic{elem: ^TypeInfo}, Procedure{ - params: ^Type_Info, // Type_Info.Tuple - results: ^Type_Info, // Type_Info.Tuple + params: ^TypeInfo, // TypeInfo.Tuple + results: ^TypeInfo, // TypeInfo.Tuple variadic: bool, - convention: Calling_Convention, + convention: CallingConvention, }, Array{ - elem: ^Type_Info, + elem: ^TypeInfo, elem_size: int, count: int, }, - Dynamic_Array{elem: ^Type_Info, elem_size: int}, - Slice {elem: ^Type_Info, elem_size: int}, - Vector {elem: ^Type_Info, elem_size, count: int}, - Tuple {using record: Type_Info_Record}, // Only really used for procedures - Struct {using record: Type_Info_Record}, - Raw_Union {using record: Type_Info_Record}, + DynamicArray{elem: ^TypeInfo, elem_size: int}, + Slice {elem: ^TypeInfo, elem_size: int}, + Vector {elem: ^TypeInfo, elem_size, count: int}, + Tuple {using record: TypeInfoRecord}, // Only really used for procedures + Struct {using record: TypeInfoRecord}, + RawUnion {using record: TypeInfoRecord}, Union{ common_fields: struct { - types: []^Type_Info, + types: []^TypeInfo, names: []string, offsets: []int, // offsets may not be used in tuples }, variant_names: []string, - variant_types: []^Type_Info, + variant_types: []^TypeInfo, }, Enum{ - base: ^Type_Info, + base: ^TypeInfo, names: []string, - values: []Type_Info_Enum_Value, + values: []TypeInfoEnumValue, }, Map{ - key: ^Type_Info, - value: ^Type_Info, - generated_struct: ^Type_Info, + key: ^TypeInfo, + value: ^TypeInfo, + generated_struct: ^TypeInfo, count: int, // == 0 if dynamic }, } @@ -93,33 +104,33 @@ Type_Info :: union { // NOTE(bill): only the ones that are needed (not all types) // This will be set by the compiler -__type_table: []Type_Info; +__type_table: []TypeInfo; __argv__: ^^byte; __argc__: i32; -type_info_base :: proc(info: ^Type_Info) -> ^Type_Info { +type_info_base :: proc(info: ^TypeInfo) -> ^TypeInfo { if info == nil { return nil; } base := info; match i in base { - case Type_Info.Named: + case TypeInfo.Named: base = i.base; } return base; } -type_info_base_without_enum :: proc(info: ^Type_Info) -> ^Type_Info { +type_info_base_without_enum :: proc(info: ^TypeInfo) -> ^TypeInfo { if info == nil { return nil; } base := info; match i in base { - case Type_Info.Named: + case TypeInfo.Named: base = i.base; - case Type_Info.Enum: + case TypeInfo.Enum: base = i.base; } return base; @@ -135,17 +146,17 @@ read_cycle_counter :: proc() -> u64 #foreign __llvm_core "llvm.readcyclecounter" // IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it) -Allocator_Mode :: enum u8 { - ALLOC, - FREE, - FREE_ALL, - RESIZE, +AllocatorMode :: enum u8 { + Alloc, + Free, + FreeAll, + Resize, } -Allocator_Proc :: #type proc(allocator_data: rawptr, mode: Allocator_Mode, +AllocatorProc :: #type proc(allocator_data: rawptr, mode: AllocatorMode, size, alignment: int, old_memory: rawptr, old_size: int, flags: u64) -> rawptr; Allocator :: struct #ordered { - procedure: Allocator_Proc, + procedure: AllocatorProc, data: rawptr, } @@ -181,7 +192,7 @@ alloc :: proc(size: int) -> rawptr #inline { return alloc_align(size, DEFAULT_AL alloc_align :: proc(size, alignment: int) -> rawptr #inline { __check_context(); a := context.allocator; - return a.procedure(a.data, Allocator_Mode.ALLOC, size, alignment, nil, 0, 0); + return a.procedure(a.data, AllocatorMode.Alloc, size, alignment, nil, 0, 0); } free_ptr_with_allocator :: proc(a: Allocator, ptr: rawptr) #inline { @@ -191,7 +202,7 @@ free_ptr_with_allocator :: proc(a: Allocator, ptr: rawptr) #inline { if a.procedure == nil { return; } - a.procedure(a.data, Allocator_Mode.FREE, 0, 0, ptr, 0, 0); + a.procedure(a.data, AllocatorMode.Free, 0, 0, ptr, 0, 0); } free_ptr :: proc(ptr: rawptr) #inline { @@ -202,7 +213,7 @@ free_ptr :: proc(ptr: rawptr) #inline { free_all :: proc() #inline { __check_context(); a := context.allocator; - a.procedure(a.data, Allocator_Mode.FREE_ALL, 0, 0, nil, 0, 0); + a.procedure(a.data, AllocatorMode.FreeAll, 0, 0, nil, 0, 0); } @@ -210,7 +221,7 @@ resize :: proc(ptr: rawptr, old_size, new_size: int) -> rawptr #inline { r resize_align :: proc(ptr: rawptr, old_size, new_size, alignment: int) -> rawptr #inline { __check_context(); a := context.allocator; - return a.procedure(a.data, Allocator_Mode.RESIZE, new_size, alignment, ptr, old_size, 0); + return a.procedure(a.data, AllocatorMode.Resize, new_size, alignment, ptr, old_size, 0); } @@ -240,23 +251,23 @@ default_resize_align :: proc(old_memory: rawptr, old_size, new_size, alignment: } -default_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, +default_allocator_proc :: proc(allocator_data: rawptr, mode: AllocatorMode, size, alignment: int, old_memory: rawptr, old_size: int, flags: u64) -> rawptr { - using Allocator_Mode; + using AllocatorMode; match mode { - case ALLOC: + case Alloc: return os.heap_alloc(size); - case FREE: + case Free: os.heap_free(old_memory); return nil; - case FREE_ALL: + case FreeAll: // NOTE(bill): Does nothing - case RESIZE: + case Resize: ptr := os.heap_resize(old_memory, size); assert(ptr != nil); return ptr; @@ -360,7 +371,7 @@ __substring_expr_error :: proc(file: string, line, column: int, low, high: int) file, line, column, low, high); __debug_trap(); } -__type_assertion_check :: proc(ok: bool, file: string, line, column: int, from, to: ^Type_Info) { +__type_assertion_check :: proc(ok: bool, file: string, line, column: int, from, to: ^TypeInfo) { if !ok { fmt.fprintf(os.stderr, "%s(%d:%d) Invalid type_assertion from %T to %T\n", file, line, column, from, to); @@ -429,7 +440,7 @@ __abs_quaternion256 :: proc(x: quaternion256) -> f64 #inline { __dynamic_array_make :: proc(array_: rawptr, elem_size, elem_align: int, len, cap: int) { - array := ^raw.Dynamic_Array(array_); + array := ^raw.DynamicArray(array_); __check_context(); array.allocator = context.allocator; assert(array.allocator.procedure != nil); @@ -441,7 +452,7 @@ __dynamic_array_make :: proc(array_: rawptr, elem_size, elem_align: int, len, ca } __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap: int) -> bool { - array := ^raw.Dynamic_Array(array_); + array := ^raw.DynamicArray(array_); if cap <= array.cap { return true; @@ -457,7 +468,7 @@ __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap: new_size := cap * elem_size; allocator := array.allocator; - new_data := allocator.procedure(allocator.data, Allocator_Mode.RESIZE, new_size, elem_align, array.data, old_size, 0); + new_data := allocator.procedure(allocator.data, AllocatorMode.Resize, new_size, elem_align, array.data, old_size, 0); if new_data == nil { return false; } @@ -468,7 +479,7 @@ __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap: } __dynamic_array_resize :: proc(array_: rawptr, elem_size, elem_align: int, len: int) -> bool { - array := ^raw.Dynamic_Array(array_); + array := ^raw.DynamicArray(array_); ok := __dynamic_array_reserve(array_, elem_size, elem_align, len); if ok { @@ -480,7 +491,7 @@ __dynamic_array_resize :: proc(array_: rawptr, elem_size, elem_align: int, len: __dynamic_array_append :: proc(array_: rawptr, elem_size, elem_align: int, items: rawptr, item_count: int) -> int { - array := ^raw.Dynamic_Array(array_); + array := ^raw.DynamicArray(array_); if item_count <= 0 || items == nil { return array.len; @@ -504,7 +515,7 @@ __dynamic_array_append :: proc(array_: rawptr, elem_size, elem_align: int, } __dynamic_array_append_nothing :: proc(array_: rawptr, elem_size, elem_align: int) -> int { - array := ^raw.Dynamic_Array(array_); + array := ^raw.DynamicArray(array_); ok := true; if array.cap <= array.len+1 { @@ -559,27 +570,27 @@ __default_hash_string :: proc(s: string) -> u64 { __INITIAL_MAP_CAP :: 16; -__Map_Key :: struct #ordered { +__MapKey :: struct #ordered { hash: u64, str: string, } -__Map_Find_Result :: struct #ordered { +__MapFindResult :: struct #ordered { hash_index: int, entry_prev: int, entry_index: int, } -__Map_Entry_Header :: struct #ordered { - key: __Map_Key, +__MapEntryHeader :: struct #ordered { + key: __MapKey, next: int, /* value: Value_Type, */ } -__Map_Header :: struct #ordered { - m: ^raw.Dynamic_Map, +__MapHeader :: struct #ordered { + m: ^raw.DynamicMap, is_key_string: bool, entry_size: int, entry_align: int, @@ -587,18 +598,18 @@ __Map_Header :: struct #ordered { value_size: int, } -__dynamic_map_reserve :: proc(using header: __Map_Header, cap: int) { +__dynamic_map_reserve :: proc(using header: __MapHeader, cap: int) { __dynamic_array_reserve(&m.hashes, size_of(int), align_of(int), cap); __dynamic_array_reserve(&m.entries, entry_size, entry_align, cap); } -__dynamic_map_rehash :: proc(using header: __Map_Header, new_count: int) { - new_header: __Map_Header = header; - nm: raw.Dynamic_Map; +__dynamic_map_rehash :: proc(using header: __MapHeader, new_count: int) { + new_header: __MapHeader = header; + nm: raw.DynamicMap; new_header.m = &nm; - header_hashes := ^raw.Dynamic_Array(&header.m.hashes); - nm_hashes := ^raw.Dynamic_Array(&nm.hashes); + header_hashes := ^raw.DynamicArray(&header.m.hashes); + nm_hashes := ^raw.DynamicArray(&nm.hashes); __dynamic_array_resize(nm_hashes, size_of(int), align_of(int), new_count); __dynamic_array_reserve(&nm.entries, entry_size, entry_align, m.entries.len); @@ -637,7 +648,7 @@ __dynamic_map_rehash :: proc(using header: __Map_Header, new_count: int) { header.m^ = nm; } -__dynamic_map_get :: proc(h: __Map_Header, key: __Map_Key) -> rawptr { +__dynamic_map_get :: proc(h: __MapHeader, key: __MapKey) -> rawptr { index := __dynamic_map_find(h, key).entry_index; if index >= 0 { data := ^byte(__dynamic_map_get_entry(h, index)); @@ -647,7 +658,7 @@ __dynamic_map_get :: proc(h: __Map_Header, key: __Map_Key) -> rawptr { return nil; } -__dynamic_map_set :: proc(using h: __Map_Header, key: __Map_Key, value: rawptr) { +__dynamic_map_set :: proc(using h: __MapHeader, key: __MapKey, value: rawptr) { index: int; assert(value != nil); @@ -682,17 +693,17 @@ __dynamic_map_set :: proc(using h: __Map_Header, key: __Map_Key, value: rawptr) } -__dynamic_map_grow :: proc(using h: __Map_Header) { +__dynamic_map_grow :: proc(using h: __MapHeader) { new_count := max(2*m.entries.cap + 8, __INITIAL_MAP_CAP); __dynamic_map_rehash(h, new_count); } -__dynamic_map_full :: proc(using h: __Map_Header) -> bool { +__dynamic_map_full :: proc(using h: __MapHeader) -> bool { return int(0.75 * f64(len(m.hashes))) <= m.entries.cap; } -__dynamic_map_hash_equal :: proc(h: __Map_Header, a, b: __Map_Key) -> bool { +__dynamic_map_hash_equal :: proc(h: __MapHeader, a, b: __MapKey) -> bool { if a.hash == b.hash { if h.is_key_string { return a.str == b.str; @@ -702,8 +713,8 @@ __dynamic_map_hash_equal :: proc(h: __Map_Header, a, b: __Map_Key) -> bool { return false; } -__dynamic_map_find :: proc(using h: __Map_Header, key: __Map_Key) -> __Map_Find_Result { - fr := __Map_Find_Result{-1, -1, -1}; +__dynamic_map_find :: proc(using h: __MapHeader, key: __MapKey) -> __MapFindResult { + fr := __MapFindResult{-1, -1, -1}; if len(m.hashes) > 0 { fr.hash_index = int(key.hash % u64(len(m.hashes))); fr.entry_index = m.hashes[fr.hash_index]; @@ -719,7 +730,7 @@ __dynamic_map_find :: proc(using h: __Map_Header, key: __Map_Key) -> __Map_Find_ return fr; } -__dynamic_map_add_entry :: proc(using h: __Map_Header, key: __Map_Key) -> int { +__dynamic_map_add_entry :: proc(using h: __MapHeader, key: __MapKey) -> int { prev := m.entries.len; c := __dynamic_array_append_nothing(&m.entries, entry_size, entry_align); if c != prev { @@ -731,19 +742,19 @@ __dynamic_map_add_entry :: proc(using h: __Map_Header, key: __Map_Key) -> int { } -__dynamic_map_delete :: proc(using h: __Map_Header, key: __Map_Key) { +__dynamic_map_delete :: proc(using h: __MapHeader, key: __MapKey) { fr := __dynamic_map_find(h, key); if fr.entry_index >= 0 { __dynamic_map_erase(h, fr); } } -__dynamic_map_get_entry :: proc(using h: __Map_Header, index: int) -> ^__Map_Entry_Header { +__dynamic_map_get_entry :: proc(using h: __MapHeader, index: int) -> ^__MapEntryHeader { data := ^byte(m.entries.data) + index*entry_size; - return ^__Map_Entry_Header(data); + return ^__MapEntryHeader(data); } -__dynamic_map_erase :: proc(using h: __Map_Header, fr: __Map_Find_Result) { +__dynamic_map_erase :: proc(using h: __MapHeader, fr: __MapFindResult) { if fr.entry_prev < 0 { m.hashes[fr.hash_index] = __dynamic_map_get_entry(h, fr.entry_index).next; } else { diff --git a/core/fmt.odin b/core/fmt.odin index b2242d087..c1e3886ff 100644 --- a/core/fmt.odin +++ b/core/fmt.odin @@ -8,57 +8,58 @@ _BUFFER_SIZE :: 1<<12; -String_Buffer :: struct { +// TODO(bill): Make this a union +StringBuffer :: struct { is_dynamic: bool, sa: []byte, da: [dynamic]byte, }; -make_string_buffer_from_slice :: proc(b: []byte) -> String_Buffer { - return String_Buffer{ +make_string_buffer_from_slice :: proc(b: []byte) -> StringBuffer { + return StringBuffer{ is_dynamic = false, sa = b, }; } -make_string_dynamic_buffer :: proc() -> String_Buffer { - return String_Buffer{ +make_string_dynamic_buffer :: proc() -> StringBuffer { + return StringBuffer{ is_dynamic = true, da = make([dynamic]byte), }; } -string_buffer_data :: proc(buf: ^String_Buffer) -> []byte { +string_buffer_data :: proc(buf: ^StringBuffer) -> []byte { return string_buffer_data(buf^); } -string_buffer_data :: proc(buf: String_Buffer) -> []byte { +string_buffer_data :: proc(buf: StringBuffer) -> []byte { if buf.is_dynamic { return buf.da[..]; } return buf.sa[..]; } -to_string :: proc(buf: String_Buffer) -> string { +to_string :: proc(buf: StringBuffer) -> string { return string(string_buffer_data(buf)); } -write_string :: proc(buf: ^String_Buffer, s: string) { +write_string :: proc(buf: ^StringBuffer, s: string) { write_bytes(buf, []byte(s)); } -write_bytes :: proc(buf: ^String_Buffer, b: []byte) { +write_bytes :: proc(buf: ^StringBuffer, b: []byte) { if buf.is_dynamic { append(buf.da, ..b); } else { append(buf.sa, ..b); } } -write_byte :: proc(buf: ^String_Buffer, b: byte) { +write_byte :: proc(buf: ^StringBuffer, b: byte) { if buf.is_dynamic { append(buf.da, b); } else { append(buf.sa, b); } } -write_rune :: proc(buf: ^String_Buffer, r: rune) { +write_rune :: proc(buf: ^StringBuffer, r: rune) { if r < utf8.RUNE_SELF { write_byte(buf, byte(r)); return; @@ -68,7 +69,7 @@ write_rune :: proc(buf: ^String_Buffer, r: rune) { write_bytes(buf, b[0.. string { -fprint_type :: proc(fd: os.Handle, info: ^Type_Info) { +fprint_type :: proc(fd: os.Handle, info: ^TypeInfo) { data: [_BUFFER_SIZE]byte; buf := make_string_buffer_from_slice(data[0..<0]); write_type(&buf, info); os.write(fd, string_buffer_data(buf)); } -write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) { +write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) { if ti == nil { return; } - using Type_Info; + using TypeInfo; match info in ti { case Named: write_string(buf, info.name); @@ -191,7 +192,7 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) { case ti == type_info(uint): write_string(buf, "uint"); case: write_string(buf, info.signed ? "i" : "u"); - fi := Fmt_Info{buf = buf}; + fi := FmtInfo{buf = buf}; fmt_int(&fi, u64(8*info.size), false, 64, 'd'); } case Float: @@ -259,11 +260,11 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) { case Array: write_string(buf, "["); - fi := Fmt_Info{buf = buf}; + fi := FmtInfo{buf = buf}; fmt_int(&fi, u64(info.count), false, 64, 'd'); write_string(buf, "]"); write_type(buf, info.elem); - case Dynamic_Array: + case DynamicArray: write_string(buf, "[dynamic]"); write_type(buf, info.elem); case Slice: @@ -271,7 +272,7 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) { write_type(buf, info.elem); case Vector: write_string(buf, "[vector "); - fi := Fmt_Info{buf = buf}; + fi := FmtInfo{buf = buf}; fmt_int(&fi, u64(info.count), false, 64, 'd'); write_string(buf, "]"); write_type(buf, info.elem); @@ -288,7 +289,7 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) { if info.ordered { write_string(buf, "#ordered "); } if info.custom_align { write_string(buf, "#align "); - fi := Fmt_Info{buf = buf}; + fi := FmtInfo{buf = buf}; fmt_int(&fi, u64(info.align), false, 64, 'd'); write_byte(buf, ' '); } @@ -340,7 +341,7 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) { } write_string(buf, "}"); - case Raw_Union: + case RawUnion: write_string(buf, "raw_union {"); for name, i in info.names { if i > 0 { @@ -391,7 +392,7 @@ _parse_int :: proc(s: string, offset: int) -> (result: int, offset: int, ok: boo return result, offset+i, i != 0; } -_arg_number :: proc(fi: ^Fmt_Info, arg_index: int, format: string, offset, arg_count: int) -> (index, offset: int, ok: bool) { +_arg_number :: proc(fi: ^FmtInfo, arg_index: int, format: string, offset, arg_count: int) -> (index, offset: int, ok: bool) { parse_arg_number :: proc(format: string) -> (int, int, bool) { if len(format) < 3 { return 0, 1, false; @@ -449,7 +450,7 @@ int_from_arg :: proc(args: []any, arg_index: int) -> (int, int, bool) { } -fmt_bad_verb :: proc(using fi: ^Fmt_Info, verb: rune) { +fmt_bad_verb :: proc(using fi: ^FmtInfo, verb: rune) { assert(verb != 'v'); write_string(buf, "%!"); write_rune(buf, verb); @@ -464,7 +465,7 @@ fmt_bad_verb :: proc(using fi: ^Fmt_Info, verb: rune) { write_byte(buf, ')'); } -fmt_bool :: proc(using fi: ^Fmt_Info, b: bool, verb: rune) { +fmt_bool :: proc(using fi: ^FmtInfo, b: bool, verb: rune) { match verb { case 't', 'v': write_string(buf, b ? "true" : "false"); @@ -474,7 +475,7 @@ fmt_bool :: proc(using fi: ^Fmt_Info, b: bool, verb: rune) { } -fmt_write_padding :: proc(fi: ^Fmt_Info, width: int) { +fmt_write_padding :: proc(fi: ^FmtInfo, width: int) { if width <= 0 { return; } @@ -522,7 +523,7 @@ is_integer_negative :: proc(u: u64, is_signed: bool, bit_size: int) -> (unsigned return u, neg; } -_write_int :: proc(fi: ^Fmt_Info, u: u64, base: int, is_signed: bool, bit_size: int, digits: string) { +_write_int :: proc(fi: ^FmtInfo, u: u64, base: int, is_signed: bool, bit_size: int, digits: string) { _, neg := is_integer_negative(u, is_signed, bit_size); BUF_SIZE :: 256; @@ -575,11 +576,11 @@ _write_int :: proc(fi: ^Fmt_Info, u: u64, base: int, is_signed: bool, bit_size: immutable __DIGITS_LOWER := "0123456789abcdefx"; immutable __DIGITS_UPPER := "0123456789ABCDEFX"; -fmt_rune :: proc(fi: ^Fmt_Info, r: rune) { +fmt_rune :: proc(fi: ^FmtInfo, r: rune) { write_rune(fi.buf, r); } -fmt_int :: proc(fi: ^Fmt_Info, u: u64, is_signed: bool, bit_size: int, verb: rune) { +fmt_int :: proc(fi: ^FmtInfo, u: u64, is_signed: bool, bit_size: int, verb: rune) { match verb { case 'v': _write_int(fi, u, 10, is_signed, bit_size, __DIGITS_LOWER); case 'b': _write_int(fi, u, 2, is_signed, bit_size, __DIGITS_LOWER); @@ -603,7 +604,7 @@ fmt_int :: proc(fi: ^Fmt_Info, u: u64, is_signed: bool, bit_size: int, verb: run } } -_pad :: proc(fi: ^Fmt_Info, s: string) { +_pad :: proc(fi: ^FmtInfo, s: string) { if !fi.width_set { write_string(fi.buf, s); return; @@ -618,7 +619,7 @@ _pad :: proc(fi: ^Fmt_Info, s: string) { } } -fmt_float :: proc(fi: ^Fmt_Info, v: f64, bit_size: int, verb: rune) { +fmt_float :: proc(fi: ^FmtInfo, v: f64, bit_size: int, verb: rune) { match verb { // case 'e', 'E', 'f', 'F', 'g', 'G', 'v': // case 'f', 'F', 'v': @@ -664,7 +665,7 @@ fmt_float :: proc(fi: ^Fmt_Info, v: f64, bit_size: int, verb: rune) { return; } } -fmt_string :: proc(fi: ^Fmt_Info, s: string, verb: rune) { +fmt_string :: proc(fi: ^FmtInfo, s: string, verb: rune) { match verb { case 's', 'v': write_string(fi.buf, s); @@ -686,7 +687,7 @@ fmt_string :: proc(fi: ^Fmt_Info, s: string, verb: rune) { } } -fmt_pointer :: proc(fi: ^Fmt_Info, p: rawptr, verb: rune) { +fmt_pointer :: proc(fi: ^FmtInfo, p: rawptr, verb: rune) { match verb { case 'p', 'v': // Okay @@ -701,13 +702,13 @@ fmt_pointer :: proc(fi: ^Fmt_Info, p: rawptr, verb: rune) { _write_int(fi, u, 16, false, 8*size_of(rawptr), __DIGITS_UPPER); } -fmt_enum :: proc(fi: ^Fmt_Info, v: any, verb: rune) { +fmt_enum :: proc(fi: ^FmtInfo, v: any, verb: rune) { if v.type_info == nil || v.data == nil { write_string(fi.buf, ""); return; } - using Type_Info; + using TypeInfo; match e in v.type_info { case: fmt_bad_verb(fi, verb); @@ -768,13 +769,13 @@ fmt_enum :: proc(fi: ^Fmt_Info, v: any, verb: rune) { } -fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) { +fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) { if v.data == nil || v.type_info == nil { write_string(fi.buf, ""); return; } - using Type_Info; + using TypeInfo; match info in v.type_info { case Named: match b in info.base { @@ -808,8 +809,8 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) { case String: fmt_arg(fi, v, verb); case Pointer: - if v.type_info == type_info(^Type_Info) { - write_type(fi.buf, (^^Type_Info)(v.data)^); + if v.type_info == type_info(^TypeInfo) { + write_type(fi.buf, (^^TypeInfo)(v.data)^); } else { fmt_pointer(fi, (^rawptr)(v.data)^, verb); } @@ -828,10 +829,10 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) { fmt_arg(fi, any{rawptr(data), info.elem}, verb); } - case Dynamic_Array: + case DynamicArray: write_byte(fi.buf, '['); defer write_byte(fi.buf, ']'); - array := (^raw.Dynamic_Array)(v.data); + array := (^raw.DynamicArray)(v.data); for i in 0.. 0 { write_string(fi.buf, ", "); @@ -873,9 +874,9 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) { write_string(fi.buf, "map["); defer write_byte(fi.buf, ']'); - entries := &(^raw.Dynamic_Map(v.data).entries); + entries := &(^raw.DynamicMap(v.data).entries); gs := type_info_base(info.generated_struct).(^Struct); - ed := type_info_base(gs.types[1]).(^Dynamic_Array); + ed := type_info_base(gs.types[1]).(^DynamicArray); entry_type := ed.elem.(^Struct); entry_size := ed.elem_size; @@ -885,11 +886,11 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) { } data := ^byte(entries.data) + i*entry_size; - header := ^__Map_Entry_Header(data); + header := ^__MapEntryHeader(data); if types.is_string(info.key) { write_string(fi.buf, header.key.str); } else { - fi := Fmt_Info{buf = fi.buf}; + fi := FmtInfo{buf = fi.buf}; fmt_arg(&fi, any{rawptr(&header.key.hash), info.key}, 'v'); } @@ -931,7 +932,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) { fmt_value(fi, any{rawptr(data), cf.types[i]}, 'v'); } - case Raw_Union: + case RawUnion: write_string(fi.buf, "(raw_union)"); case Enum: @@ -944,7 +945,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) { } } -fmt_complex :: proc(fi: ^Fmt_Info, c: complex128, bits: int, verb: rune) { +fmt_complex :: proc(fi: ^FmtInfo, c: complex128, bits: int, verb: rune) { match verb { case 'f', 'F', 'v': r := real(c); @@ -962,7 +963,7 @@ fmt_complex :: proc(fi: ^Fmt_Info, c: complex128, bits: int, verb: rune) { } } -fmt_quaternion :: proc(fi: ^Fmt_Info, c: quaternion256, bits: int, verb: rune) { +fmt_quaternion :: proc(fi: ^FmtInfo, c: quaternion256, bits: int, verb: rune) { match verb { case 'f', 'F', 'v': r := real(c); @@ -989,7 +990,7 @@ fmt_quaternion :: proc(fi: ^Fmt_Info, c: quaternion256, bits: int, verb: rune) { } } -fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) { +fmt_arg :: proc(fi: ^FmtInfo, arg: any, verb: rune) { if arg == nil { write_string(fi.buf, ""); return; @@ -999,7 +1000,7 @@ fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) { if verb == 'T' { ti := arg.type_info; match a in arg { - case ^Type_Info: ti = a; + case ^TypeInfo: ti = a; } write_type(fi.buf, ti); return; @@ -1036,8 +1037,8 @@ fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) { -sbprint :: proc(buf: ^String_Buffer, args: ..any) -> string { - fi: Fmt_Info; +sbprint :: proc(buf: ^StringBuffer, args: ..any) -> string { + fi: FmtInfo; fi.buf = buf; prev_string := false; @@ -1052,8 +1053,8 @@ sbprint :: proc(buf: ^String_Buffer, args: ..any) -> string { return to_string(buf^); } -sbprintln :: proc(buf: ^String_Buffer, args: ..any) -> string { - fi: Fmt_Info; +sbprintln :: proc(buf: ^StringBuffer, args: ..any) -> string { + fi: FmtInfo; fi.buf = buf; for arg, i in args { @@ -1066,13 +1067,13 @@ sbprintln :: proc(buf: ^String_Buffer, args: ..any) -> string { return to_string(buf^); } -sbprintf :: proc(b: ^String_Buffer, fmt: string, args: ..any) -> string { - fi := Fmt_Info{}; +sbprintf :: proc(b: ^StringBuffer, fmt: string, args: ..any) -> string { + fi := FmtInfo{}; end := len(fmt); arg_index := 0; was_prev_index := false; for i := 0; i < end; { - fi = Fmt_Info{buf = b, good_arg_index = true}; + fi = FmtInfo{buf = b, good_arg_index = true}; prev_i := i; for i < end && fmt[i] != '%' { diff --git a/core/mem.odin b/core/mem.odin index ff7ab8367..fc4a72d07 100644 --- a/core/mem.odin +++ b/core/mem.odin @@ -50,11 +50,11 @@ align_forward :: proc(ptr: rawptr, align: int) -> rawptr { -Allocation_Header :: struct { +AllocationHeader :: struct { size: int, } -allocation_header_fill :: proc(header: ^Allocation_Header, data: rawptr, size: int) { +allocation_header_fill :: proc(header: ^AllocationHeader, data: rawptr, size: int) { header.size = size; ptr := ^int(header+1); @@ -62,7 +62,7 @@ allocation_header_fill :: proc(header: ^Allocation_Header, data: rawptr, size: i (ptr+i)^ = -1; } } -allocation_header :: proc(data: rawptr) -> ^Allocation_Header { +allocation_header :: proc(data: rawptr) -> ^AllocationHeader { if data == nil { return nil; } @@ -70,7 +70,7 @@ allocation_header :: proc(data: rawptr) -> ^Allocation_Header { for (p-1)^ == -1 { p = (p-1); } - return ^Allocation_Header(p-1); + return ^AllocationHeader(p-1); } @@ -85,7 +85,7 @@ Arena :: struct { temp_count: int, } -Arena_Temp_Memory :: struct { +ArenaTempMemory :: struct { arena: ^Arena, original_count: int, } @@ -123,14 +123,14 @@ arena_allocator :: proc(arena: ^Arena) -> Allocator { }; } -arena_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, +arena_allocator_proc :: proc(allocator_data: rawptr, mode: AllocatorMode, size, alignment: int, old_memory: rawptr, old_size: int, flags: u64) -> rawptr { - using Allocator_Mode; + using AllocatorMode; arena := ^Arena(allocator_data); match mode { - case ALLOC: + case Alloc: total_size := size + alignment; if arena.offset + total_size > len(arena.memory) { @@ -144,29 +144,29 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, arena.offset += total_size; return zero(ptr, size); - case FREE: + case Free: // NOTE(bill): Free all at once - // Use Arena_Temp_Memory if you want to free a block + // Use ArenaTempMemory if you want to free a block - case FREE_ALL: + case FreeAll: arena.offset = 0; - case RESIZE: + case Resize: return default_resize_align(old_memory, old_size, size, alignment); } return nil; } -begin_arena_temp_memory :: proc(a: ^Arena) -> Arena_Temp_Memory { - tmp: Arena_Temp_Memory; +begin_arena_temp_memory :: proc(a: ^Arena) -> ArenaTempMemory { + tmp: ArenaTempMemory; tmp.arena = a; tmp.original_count = len(a.memory); a.temp_count++; return tmp; } -end_arena_temp_memory :: proc(using tmp: Arena_Temp_Memory) { +end_arena_temp_memory :: proc(using tmp: ArenaTempMemory) { assert(len(arena.memory) >= original_count); assert(arena.temp_count > 0); arena.memory = arena.memory[0.. int { +align_of_type_info :: proc(type_info: ^TypeInfo) -> int { prev_pow2 :: proc(n: i64) -> i64 { if n <= 0 { return 0; @@ -195,7 +195,7 @@ align_of_type_info :: proc(type_info: ^Type_Info) -> int { WORD_SIZE :: size_of(int); MAX_ALIGN :: size_of([vector 64]f64); // TODO(bill): Should these constants be builtin constants? - using Type_Info; + using TypeInfo; match info in type_info { case Named: return align_of_type_info(info.base); @@ -215,7 +215,7 @@ align_of_type_info :: proc(type_info: ^Type_Info) -> int { return WORD_SIZE; case Array: return align_of_type_info(info.elem); - case Dynamic_Array: + case DynamicArray: return WORD_SIZE; case Slice: return WORD_SIZE; @@ -230,7 +230,7 @@ align_of_type_info :: proc(type_info: ^Type_Info) -> int { return info.align; case Union: return info.align; - case Raw_Union: + case RawUnion: return info.align; case Enum: return align_of_type_info(info.base); @@ -246,9 +246,9 @@ align_formula :: proc(size, align: int) -> int { return result - result%align; } -size_of_type_info :: proc(type_info: ^Type_Info) -> int { +size_of_type_info :: proc(type_info: ^TypeInfo) -> int { WORD_SIZE :: size_of(int); - using Type_Info; + using TypeInfo; match info in type_info { case Named: return size_of_type_info(info.base); @@ -275,7 +275,7 @@ size_of_type_info :: proc(type_info: ^Type_Info) -> int { align := align_of_type_info(info.elem); alignment := align_formula(size, align); return alignment*(count-1) + size; - case Dynamic_Array: + case DynamicArray: return size_of(rawptr) + 2*size_of(int) + size_of(Allocator); case Slice: return 2*WORD_SIZE; @@ -292,7 +292,7 @@ size_of_type_info :: proc(type_info: ^Type_Info) -> int { return info.size; case Union: return info.size; - case Raw_Union: + case RawUnion: return info.size; case Enum: return size_of_type_info(info.base); diff --git a/core/os_linux.odin b/core/os_linux.odin index 99eea1a47..22d31fe9c 100644 --- a/core/os_linux.odin +++ b/core/os_linux.odin @@ -2,7 +2,7 @@ #import "strings.odin"; Handle :: i32; -File_Time :: u64; +FileTime :: u64; Errno :: i32; // INVALID_HANDLE: Handle : -1; @@ -36,7 +36,7 @@ RTLD_GLOBAL :: 0x100; // "Argv" arguments converted to Odin strings immutable args := _alloc_command_line_arguments(); -_File_Time :: struct #ordered { +_FileTime :: struct #ordered { seconds: i64, nanoseconds: i32, reserved: i32, @@ -59,9 +59,9 @@ Stat :: struct #ordered { block_size: i64, // Optimal bllocksize for I/O blocks: i64, // Number of 512-byte blocks allocated - last_access: _File_Time, // Time of last access - modified: _File_Time, // Time of last modification - status_change: _File_Time, // Time of last status change + last_access: _FileTime, // Time of last access + modified: _FileTime, // Time of last modification + status_change: _FileTime, // Time of last status change _reserve1, _reserve2, @@ -193,8 +193,8 @@ stdout: Handle = 1; stderr: Handle = 2; /* TODO(zangent): Implement these! -last_write_time :: proc(fd: Handle) -> File_Time {} -last_write_time_by_name :: proc(name: string) -> File_Time {} +last_write_time :: proc(fd: Handle) -> FileTime {} +last_write_time_by_name :: proc(name: string) -> FileTime {} */ stat :: proc(path: string) -> (Stat, int) #inline { diff --git a/core/os_windows.odin b/core/os_windows.odin index 7de7807b6..40cbdc880 100644 --- a/core/os_windows.odin +++ b/core/os_windows.odin @@ -1,7 +1,7 @@ #import win32 "sys/windows.odin"; Handle :: int; -File_Time :: u64; +FileTime :: u64; Errno :: int; INVALID_HANDLE: Handle : -1; @@ -214,17 +214,17 @@ get_std_handle :: proc(h: int) -> Handle { -last_write_time :: proc(fd: Handle) -> File_Time { - file_info: win32.By_Handle_File_Information; +last_write_time :: proc(fd: Handle) -> FileTime { + file_info: win32.ByHandleFileInformation; win32.GetFileInformationByHandle(win32.Handle(fd), &file_info); - lo := File_Time(file_info.last_write_time.lo); - hi := File_Time(file_info.last_write_time.hi); + lo := FileTime(file_info.last_write_time.lo); + hi := FileTime(file_info.last_write_time.hi); return lo | hi << 32; } -last_write_time_by_name :: proc(name: string) -> File_Time { +last_write_time_by_name :: proc(name: string) -> FileTime { last_write_time: win32.Filetime; - data: win32.File_Attribute_Data; + data: win32.FileAttributeData; buf: [1024]byte; assert(len(buf) > len(name)); @@ -235,8 +235,8 @@ last_write_time_by_name :: proc(name: string) -> File_Time { last_write_time = data.last_write_time; } - l := File_Time(last_write_time.lo); - h := File_Time(last_write_time.hi); + l := FileTime(last_write_time.lo); + h := FileTime(last_write_time.hi); return l | h << 32; } diff --git a/core/os_x.odin b/core/os_x.odin index fcc39c218..16f2814ae 100644 --- a/core/os_x.odin +++ b/core/os_x.odin @@ -2,7 +2,7 @@ #import "strings.odin"; Handle :: i32; -File_Time :: u64; +FileTime :: u64; Errno :: int; // TODO(zangent): Find out how to make this work on x64 and x32. @@ -211,8 +211,8 @@ stdout: Handle = 1; // get_std_handle(win32.STD_OUTPUT_HANDLE); stderr: Handle = 2; // get_std_handle(win32.STD_ERROR_HANDLE); /* TODO(zangent): Implement these! -last_write_time :: proc(fd: Handle) -> File_Time {} -last_write_time_by_name :: proc(name: string) -> File_Time {} +last_write_time :: proc(fd: Handle) -> FileTime {} +last_write_time_by_name :: proc(name: string) -> FileTime {} */ stat :: proc(path: string) -> (Stat, bool) #inline { diff --git a/core/raw.odin b/core/raw.odin index 0ad7af7b8..2f105f886 100644 --- a/core/raw.odin +++ b/core/raw.odin @@ -1,6 +1,6 @@ Any :: struct #ordered { data: rawptr, - type_info: ^Type_Info, + type_info: ^TypeInfo, } String :: struct #ordered { @@ -14,14 +14,14 @@ Slice :: struct #ordered { cap: int, }; -Dynamic_Array :: struct #ordered { +DynamicArray :: struct #ordered { data: rawptr, len: int, cap: int, allocator: Allocator, }; -Dynamic_Map :: struct #ordered { +DynamicMap :: struct #ordered { hashes: [dynamic]int, - entries: Dynamic_Array, + entries: DynamicArray, }; diff --git a/core/strconv.odin b/core/strconv.odin index 7232acf1b..d6163a3fa 100644 --- a/core/strconv.odin +++ b/core/strconv.odin @@ -1,6 +1,6 @@ #import . "decimal.odin"; -Int_Flag :: enum { +IntFlag :: enum { PREFIX = 1<<0, PLUS = 1<<1, SPACE = 1<<2, @@ -320,7 +320,7 @@ is_integer_negative :: proc(u: u64, is_signed: bool, bit_size: int) -> (unsigned } -append_bits :: proc(buf: []byte, u: u64, base: int, is_signed: bool, bit_size: int, digits: string, flags: Int_Flag) -> string { +append_bits :: proc(buf: []byte, u: u64, base: int, is_signed: bool, bit_size: int, digits: string, flags: IntFlag) -> string { is_pow2 :: proc(x: i64) -> bool { if (x <= 0) { return false; @@ -348,7 +348,7 @@ append_bits :: proc(buf: []byte, u: u64, base: int, is_signed: bool, bit_size: i i--; a[i] = digits[uint(u)]; - if flags&Int_Flag.PREFIX != 0 { + if flags&IntFlag.PREFIX != 0 { ok := true; match base { case 2: i--; a[i] = 'b'; @@ -366,9 +366,9 @@ append_bits :: proc(buf: []byte, u: u64, base: int, is_signed: bool, bit_size: i if neg { i--; a[i] = '-'; - } else if flags&Int_Flag.PLUS != 0 { + } else if flags&IntFlag.PLUS != 0 { i--; a[i] = '+'; - } else if flags&Int_Flag.SPACE != 0 { + } else if flags&IntFlag.SPACE != 0 { i--; a[i] = ' '; } diff --git a/core/sys/wgl.odin b/core/sys/wgl.odin index 0d8dce7fe..664b65dd4 100644 --- a/core/sys/wgl.odin +++ b/core/sys/wgl.odin @@ -12,7 +12,7 @@ CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x00000002; Hglrc :: Handle; Color_Ref :: u32; -Layer_Plane_Descriptor :: struct { +LayerPlaneDescriptor :: struct { size: u16, version: u16, flags: u32, @@ -39,28 +39,28 @@ Layer_Plane_Descriptor :: struct { transparent: Color_Ref, } -Point_Float :: struct { +PointFloat :: struct { x, y: f32, } -Glyph_Metrics_Float :: struct { +Glyph_MetricsFloat :: struct { black_box_x: f32, black_box_y: f32, - glyph_origin: Point_Float, + glyph_origin: PointFloat, cell_inc_x: f32, cell_inc_y: f32, } -CreateContextAttribsARB_Type :: #type proc(hdc: Hdc, h_share_context: rawptr, attribList: ^i32) -> Hglrc; -ChoosePixelFormatARB_Type :: #type proc(hdc: Hdc, attrib_i_list: ^i32, attrib_f_list: ^f32, max_formats: u32, formats: ^i32, num_formats : ^u32) -> Bool #cc_c; -SwapIntervalEXT_Type :: #type proc(interval : i32) -> bool #cc_c; -GetExtensionsStringARB_Type :: #type proc(Hdc) -> ^byte #cc_c; +CreateContextAttribsARBType :: #type proc(hdc: Hdc, h_share_context: rawptr, attribList: ^i32) -> Hglrc; +ChoosePixelFormatARBType :: #type proc(hdc: Hdc, attrib_i_list: ^i32, attrib_f_list: ^f32, max_formats: u32, formats: ^i32, num_formats : ^u32) -> Bool #cc_c; +SwapIntervalEXTType :: #type proc(interval : i32) -> bool #cc_c; +GetExtensionsStringARBType :: #type proc(Hdc) -> ^byte #cc_c; -CreateContextAttribsARB: CreateContextAttribsARB_Type; -ChoosePixelFormatARB: ChoosePixelFormatARB_Type; -SwapIntervalEXT: SwapIntervalEXT_Type; -GetExtensionsStringARB: GetExtensionsStringARB_Type; +CreateContextAttribsARB: CreateContextAttribsARBType; +ChoosePixelFormatARB: ChoosePixelFormatARBType; +SwapIntervalEXT: SwapIntervalEXTType; +GetExtensionsStringARB: GetExtensionsStringARBType; @@ -70,7 +70,7 @@ GetProcAddress :: proc(c_str: ^u8) -> Proc DeleteContext :: proc(hglrc: Hglrc) -> Bool #foreign opengl32 "wglDeleteContext"; CopyContext :: proc(src, dst: Hglrc, mask: u32) -> Bool #foreign opengl32 "wglCopyContext"; CreateLayerContext :: proc(hdc: Hdc, layer_plane: i32) -> Hglrc #foreign opengl32 "wglCreateLayerContext"; -DescribeLayerPlane :: proc(hdc: Hdc, pixel_format, layer_plane: i32, bytes: u32, pd: ^Layer_Plane_Descriptor) -> Bool #foreign opengl32 "wglDescribeLayerPlane"; +DescribeLayerPlane :: proc(hdc: Hdc, pixel_format, layer_plane: i32, bytes: u32, pd: ^LayerPlaneDescriptor) -> Bool #foreign opengl32 "wglDescribeLayerPlane"; GetCurrentContext :: proc() -> Hglrc #foreign opengl32 "wglGetCurrentContext"; GetCurrentDC :: proc() -> Hdc #foreign opengl32 "wglGetCurrentDC"; GetLayerPaletteEntries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^Color_Ref) -> i32 #foreign opengl32 "wglGetLayerPaletteEntries"; @@ -79,4 +79,4 @@ SetLayerPaletteEntries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ShareLists :: proc(hglrc1, hglrc2: Hglrc) -> Bool #foreign opengl32 "wglShareLists"; SwapLayerBuffers :: proc(hdc: Hdc, planes: u32) -> Bool #foreign opengl32 "wglSwapLayerBuffers"; UseFontBitmaps :: proc(hdc: Hdc, first, count, list_base: u32) -> Bool #foreign opengl32 "wglUseFontBitmaps"; -UseFontOutlines :: proc(hdc: Hdc, first, count, list_base: u32, deviation, extrusion: f32, format: i32, gmf: ^Glyph_Metrics_Float) -> Bool #foreign opengl32 "wglUseFontOutlines"; +UseFontOutlines :: proc(hdc: Hdc, first, count, list_base: u32, deviation, extrusion: f32, format: i32, gmf: ^Glyph_MetricsFloat) -> Bool #foreign opengl32 "wglUseFontOutlines"; diff --git a/core/sys/windows.odin b/core/sys/windows.odin index 7ea62bb4c..91837b190 100644 --- a/core/sys/windows.odin +++ b/core/sys/windows.odin @@ -18,7 +18,7 @@ Wparam :: uint; Lparam :: int; Lresult :: int; Bool :: i32; -Wnd_Proc :: #type proc(Hwnd, u32, Wparam, Lparam) -> Lresult #cc_c; +WndProc :: #type proc(Hwnd, u32, Wparam, Lparam) -> Lresult #cc_c; INVALID_HANDLE :: Handle(~int(0)); @@ -71,7 +71,7 @@ Point :: struct #ordered { WndClassExA :: struct #ordered { size, style: u32, - wnd_proc: Wnd_Proc, + wndproc: WndProc, cls_extra, wnd_extra: i32, instance: Hinstance, icon: Hicon, @@ -107,7 +107,7 @@ Systemtime :: struct #ordered { hour, minute, second, millisecond: u16, } -By_Handle_File_Information :: struct #ordered { +ByHandleFileInformation :: struct #ordered { file_attributes: u32, creation_time, last_access_time, @@ -120,7 +120,7 @@ By_Handle_File_Information :: struct #ordered { file_index_low: u32, } -File_Attribute_Data :: struct #ordered { +FileAttributeData :: struct #ordered { file_attributes: u32, creation_time, last_access_time, @@ -129,7 +129,7 @@ File_Attribute_Data :: struct #ordered { file_size_low: u32, } -Find_Data :: struct #ordered { +FindData :: struct #ordered { file_attributes : u32, creation_time : Filetime, last_access_time : Filetime, @@ -188,7 +188,7 @@ AdjustWindowRect :: proc(rect: ^Rect, style: u32, menu: Bool) -> Bool #foreign u GetActiveWindow :: proc() -> Hwnd #foreign user32; DestroyWindow :: proc(wnd: Hwnd) -> Bool #foreign user32; -DescribePixelFormat :: proc(dc: Hdc, pixel_format: i32, bytes : u32, pfd: ^PIXELFORMATDESCRIPTOR) -> i32 #foreign user32; +DescribePixelFormat :: proc(dc: Hdc, pixel_format: i32, bytes : u32, pfd: ^PixelFormatDescriptor) -> i32 #foreign user32; GetQueryPerformanceFrequency :: proc() -> i64 { @@ -222,15 +222,15 @@ WriteFile :: proc(h: Handle, buf: rawptr, len: i32, written_result: ^i32, overla GetFileSizeEx :: proc(file_handle: Handle, file_size: ^i64) -> Bool #foreign kernel32; GetFileAttributesA :: proc(filename : ^byte) -> u32 #foreign kernel32; GetFileAttributesExA :: proc(filename: ^u8, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: rawptr) -> Bool #foreign kernel32; -GetFileInformationByHandle :: proc(file_handle: Handle, file_info: ^By_Handle_File_Information) -> Bool #foreign kernel32; +GetFileInformationByHandle :: proc(file_handle: Handle, file_info: ^ByHandleFileInformation) -> Bool #foreign kernel32; GetFileType :: proc(file_handle: Handle) -> u32 #foreign kernel32; SetFilePointer :: proc(file_handle: Handle, distance_to_move: i32, distance_to_move_high: ^i32, move_method: u32) -> u32 #foreign kernel32; SetHandleInformation :: proc(obj: Handle, mask, flags: u32) -> Bool #foreign kernel32; -FindFirstFileA :: proc(file_name : ^byte, data : ^Find_Data) -> Handle #foreign kernel32; -FindNextFileA :: proc(file : Handle, data : ^Find_Data) -> Bool #foreign kernel32; +FindFirstFileA :: proc(file_name : ^byte, data : ^FindData) -> Handle #foreign kernel32; +FindNextFileA :: proc(file : Handle, data : ^FindData) -> Bool #foreign kernel32; FindClose :: proc(file : Handle) -> Bool #foreign kernel32; MAX_PATH :: 0x00000104; @@ -350,14 +350,14 @@ SWP_NOSIZE :: 0x0001; SWP_NOMOVE :: 0x0002; -Monitor_Info :: struct #ordered { +MonitorInfo :: struct #ordered { size: u32, monitor: Rect, work: Rect, flags: u32, } -Window_Placement :: struct #ordered { +WindowPlacement :: struct #ordered { length: u32, flags: u32, show_cmd: u32, @@ -366,13 +366,13 @@ Window_Placement :: struct #ordered { normal_pos: Rect, } -GetMonitorInfoA :: proc(monitor: Hmonitor, mi: ^Monitor_Info) -> Bool #foreign user32; +GetMonitorInfoA :: proc(monitor: Hmonitor, mi: ^MonitorInfo) -> Bool #foreign user32; MonitorFromWindow :: proc(wnd: Hwnd, flags : u32) -> Hmonitor #foreign user32; SetWindowPos :: proc(wnd: Hwnd, wndInsertAfter: Hwnd, x, y, width, height: i32, flags: u32) #foreign user32 "SetWindowPos"; -GetWindowPlacement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool #foreign user32; -SetWindowPlacement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool #foreign user32; +GetWindowPlacement :: proc(wnd: Hwnd, wndpl: ^WindowPlacement) -> Bool #foreign user32; +SetWindowPlacement :: proc(wnd: Hwnd, wndpl: ^WindowPlacement) -> Bool #foreign user32; GetWindowRect :: proc(wnd: Hwnd, rect: ^Rect) -> Bool #foreign user32; GetWindowLongPtrA :: proc(wnd: Hwnd, index: i32) -> i64 #foreign user32; @@ -394,7 +394,7 @@ LOWORD :: proc(lParam: Lparam) -> u16 { return u16(lParam); } -Bitmap_Info_Header :: struct #ordered { +BitmapInfoHeader :: struct #ordered { size: u32, width, height: i32, planes, bit_count: i16, @@ -405,13 +405,13 @@ Bitmap_Info_Header :: struct #ordered { clr_used: u32, clr_important: u32, } -Bitmap_Info :: struct #ordered { - using header: Bitmap_Info_Header, - colors: [1]Rgb_Quad, +BitmapInfo :: struct #ordered { + using header: BitmapInfoHeader, + colors: [1]RgbQuad, } -Rgb_Quad :: struct #ordered { blue, green, red, reserved: byte } +RgbQuad :: struct #ordered { blue, green, red, reserved: byte } BI_RGB :: 0; DIB_RGB_COLORS :: 0x00; @@ -421,7 +421,7 @@ SRCCOPY: u32 : 0x00cc0020; StretchDIBits :: proc (hdc: Hdc, x_dst, y_dst, width_dst, height_dst: i32, x_src, y_src, width_src, header_src: i32, - bits: rawptr, bits_info: ^Bitmap_Info, + bits: rawptr, bits_info: ^BitmapInfo, usage: u32, rop: u32) -> i32 #foreign gdi32; @@ -457,7 +457,7 @@ PFD_DOUBLEBUFFER_DONTCARE :: 0x40000000; PFD_STEREO_DONTCARE :: 0x80000000; -PIXELFORMATDESCRIPTOR :: struct #ordered { +PixelFormatDescriptor :: struct #ordered { size, version, flags: u32, @@ -489,8 +489,8 @@ PIXELFORMATDESCRIPTOR :: struct #ordered { } GetDC :: proc(h: Hwnd) -> Hdc #foreign user32; -SetPixelFormat :: proc(hdc: Hdc, pixel_format: i32, pfd: ^PIXELFORMATDESCRIPTOR) -> Bool #foreign gdi32; -ChoosePixelFormat :: proc(hdc: Hdc, pfd: ^PIXELFORMATDESCRIPTOR) -> i32 #foreign gdi32; +SetPixelFormat :: proc(hdc: Hdc, pixel_format: i32, pfd: ^PixelFormatDescriptor) -> Bool #foreign gdi32; +ChoosePixelFormat :: proc(hdc: Hdc, pfd: ^PixelFormatDescriptor) -> i32 #foreign gdi32; SwapBuffers :: proc(hdc: Hdc) -> Bool #foreign gdi32; ReleaseDC :: proc(wnd: Hwnd, hdc: Hdc) -> i32 #foreign user32; @@ -501,62 +501,62 @@ Proc :: #type proc() #cc_c; GetKeyState :: proc(v_key: i32) -> i16 #foreign user32; GetAsyncKeyState :: proc(v_key: i32) -> i16 #foreign user32; -is_key_down :: proc(key: Key_Code) -> bool #inline { return GetAsyncKeyState(i32(key)) < 0; } +is_key_down :: proc(key: KeyCode) -> bool #inline { return GetAsyncKeyState(i32(key)) < 0; } -Key_Code :: enum i32 { - LBUTTON = 0x01, - RBUTTON = 0x02, - CANCEL = 0x03, - MBUTTON = 0x04, - BACK = 0x08, - TAB = 0x09, - CLEAR = 0x0C, - RETURN = 0x0D, +KeyCode :: enum i32 { + Lbutton = 0x01, + Rbutton = 0x02, + Cancel = 0x03, + Mbutton = 0x04, + Back = 0x08, + Tab = 0x09, + Clear = 0x0C, + Return = 0x0D, - SHIFT = 0x10, - CONTROL = 0x11, - MENU = 0x12, - PAUSE = 0x13, - CAPITAL = 0x14, - KANA = 0x15, - HANGEUL = 0x15, - HANGUL = 0x15, - JUNJA = 0x17, - FINAL = 0x18, - HANJA = 0x19, - KANJI = 0x19, - ESCAPE = 0x1B, - CONVERT = 0x1C, - NONCONVERT = 0x1D, - ACCEPT = 0x1E, - MODECHANGE = 0x1F, - SPACE = 0x20, - PRIOR = 0x21, - NEXT = 0x22, - END = 0x23, - HOME = 0x24, - LEFT = 0x25, - UP = 0x26, - RIGHT = 0x27, - DOWN = 0x28, - SELECT = 0x29, - PRINT = 0x2A, - EXECUTE = 0x2B, - SNAPSHOT = 0x2C, - INSERT = 0x2D, - DELETE = 0x2E, - HELP = 0x2F, + Shift = 0x10, + Control = 0x11, + Menu = 0x12, + Pause = 0x13, + Capital = 0x14, + Kana = 0x15, + Hangeul = 0x15, + Hangul = 0x15, + Junja = 0x17, + Final = 0x18, + Hanja = 0x19, + Kanji = 0x19, + Escape = 0x1B, + Convert = 0x1C, + NonConvert = 0x1D, + Accept = 0x1E, + ModeChange = 0x1F, + Space = 0x20, + Prior = 0x21, + Next = 0x22, + End = 0x23, + Home = 0x24, + Left = 0x25, + Up = 0x26, + Right = 0x27, + Down = 0x28, + Select = 0x29, + Print = 0x2A, + Execute = 0x2B, + Snapshot = 0x2C, + Insert = 0x2D, + Delete = 0x2E, + Help = 0x2F, - NUM0 = '0', - NUM1 = '1', - NUM2 = '2', - NUM3 = '3', - NUM4 = '4', - NUM5 = '5', - NUM6 = '6', - NUM7 = '7', - NUM8 = '8', - NUM9 = '9', + Num0 = '0', + Num1 = '1', + Num2 = '2', + Num3 = '3', + Num4 = '4', + Num5 = '5', + Num6 = '6', + Num7 = '7', + Num8 = '8', + Num9 = '9', A = 'A', B = 'B', C = 'C', @@ -584,26 +584,26 @@ Key_Code :: enum i32 { Y = 'Y', Z = 'Z', - LWIN = 0x5B, - RWIN = 0x5C, - APPS = 0x5D, + Lwin = 0x5B, + Rwin = 0x5C, + Apps = 0x5D, - NUMPAD0 = 0x60, - NUMPAD1 = 0x61, - NUMPAD2 = 0x62, - NUMPAD3 = 0x63, - NUMPAD4 = 0x64, - NUMPAD5 = 0x65, - NUMPAD6 = 0x66, - NUMPAD7 = 0x67, - NUMPAD8 = 0x68, - NUMPAD9 = 0x69, - MULTIPLY = 0x6A, - ADD = 0x6B, - SEPARATOR = 0x6C, - SUBTRACT = 0x6D, - DECIMAL = 0x6E, - DIVIDE = 0x6F, + Numpad0 = 0x60, + Numpad1 = 0x61, + Numpad2 = 0x62, + Numpad3 = 0x63, + Numpad4 = 0x64, + Numpad5 = 0x65, + Numpad6 = 0x66, + Numpad7 = 0x67, + Numpad8 = 0x68, + Numpad9 = 0x69, + Multiply = 0x6A, + Add = 0x6B, + Separator = 0x6C, + Subtract = 0x6D, + Decimal = 0x6E, + Divide = 0x6F, F1 = 0x70, F2 = 0x71, @@ -630,22 +630,22 @@ Key_Code :: enum i32 { F23 = 0x86, F24 = 0x87, - NUMLOCK = 0x90, - SCROLL = 0x91, - LSHIFT = 0xA0, - RSHIFT = 0xA1, - LCONTROL = 0xA2, - RCONTROL = 0xA3, - LMENU = 0xA4, - RMENU = 0xA5, - ProcESSKEY = 0xE5, - ATTN = 0xF6, - CRSEL = 0xF7, - EXSEL = 0xF8, - EREOF = 0xF9, - PLAY = 0xFA, - ZOOM = 0xFB, - NONAME = 0xFC, - PA1 = 0xFD, - OEM_CLEAR = 0xFE, + Numlock = 0x90, + Scroll = 0x91, + Lshift = 0xA0, + Rshift = 0xA1, + Lcontrol = 0xA2, + Rcontrol = 0xA3, + Lmenu = 0xA4, + Rmenu = 0xA5, + ProcessKey = 0xE5, + Attn = 0xF6, + Crsel = 0xF7, + Exsel = 0xF8, + Ereof = 0xF9, + Play = 0xFA, + Zoom = 0xFB, + Noname = 0xFC, + Pa1 = 0xFD, + OemClear = 0xFE, } diff --git a/core/types.odin b/core/types.odin index 63cec2243..73ecd3a1e 100644 --- a/core/types.odin +++ b/core/types.odin @@ -1,98 +1,98 @@ -is_signed :: proc(info: ^Type_Info) -> bool { +is_signed :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } match i in type_info_base(info) { - case Type_Info.Integer: return i.signed; - case Type_Info.Float: return true; + case TypeInfo.Integer: return i.signed; + case TypeInfo.Float: return true; } return false; } -is_integer :: proc(info: ^Type_Info) -> bool { +is_integer :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Integer); + _, ok := type_info_base(info).(^TypeInfo.Integer); return ok; } -is_float :: proc(info: ^Type_Info) -> bool { +is_float :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Float); + _, ok := type_info_base(info).(^TypeInfo.Float); return ok; } -is_complex :: proc(info: ^Type_Info) -> bool { +is_complex :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Complex); + _, ok := type_info_base(info).(^TypeInfo.Complex); return ok; } -is_any :: proc(info: ^Type_Info) -> bool { +is_any :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Any); + _, ok := type_info_base(info).(^TypeInfo.Any); return ok; } -is_string :: proc(info: ^Type_Info) -> bool { +is_string :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.String); + _, ok := type_info_base(info).(^TypeInfo.String); return ok; } -is_boolean :: proc(info: ^Type_Info) -> bool { +is_boolean :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Boolean); + _, ok := type_info_base(info).(^TypeInfo.Boolean); return ok; } -is_pointer :: proc(info: ^Type_Info) -> bool { +is_pointer :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Pointer); + _, ok := type_info_base(info).(^TypeInfo.Pointer); return ok; } -is_procedure :: proc(info: ^Type_Info) -> bool { +is_procedure :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Procedure); + _, ok := type_info_base(info).(^TypeInfo.Procedure); return ok; } -is_array :: proc(info: ^Type_Info) -> bool { +is_array :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Array); + _, ok := type_info_base(info).(^TypeInfo.Array); return ok; } -is_dynamic_array :: proc(info: ^Type_Info) -> bool { +is_dynamic_array :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Dynamic_Array); + _, ok := type_info_base(info).(^TypeInfo.DynamicArray); return ok; } -is_dynamic_map :: proc(info: ^Type_Info) -> bool { +is_dynamic_map :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Map); + _, ok := type_info_base(info).(^TypeInfo.Map); return ok; } -is_slice :: proc(info: ^Type_Info) -> bool { +is_slice :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Slice); + _, ok := type_info_base(info).(^TypeInfo.Slice); return ok; } -is_vector :: proc(info: ^Type_Info) -> bool { +is_vector :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Vector); + _, ok := type_info_base(info).(^TypeInfo.Vector); return ok; } -is_tuple :: proc(info: ^Type_Info) -> bool { +is_tuple :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Tuple); + _, ok := type_info_base(info).(^TypeInfo.Tuple); return ok; } -is_struct :: proc(info: ^Type_Info) -> bool { +is_struct :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Struct); + _, ok := type_info_base(info).(^TypeInfo.Struct); return ok; } -is_union :: proc(info: ^Type_Info) -> bool { +is_union :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Union); + _, ok := type_info_base(info).(^TypeInfo.Union); return ok; } -is_raw_union :: proc(info: ^Type_Info) -> bool { +is_raw_union :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Raw_Union); + _, ok := type_info_base(info).(^TypeInfo.RawUnion); return ok; } -is_enum :: proc(info: ^Type_Info) -> bool { +is_enum :: proc(info: ^TypeInfo) -> bool { if info == nil { return false; } - _, ok := type_info_base(info).(^Type_Info.Enum); + _, ok := type_info_base(info).(^TypeInfo.Enum); return ok; } diff --git a/core/utf8.odin b/core/utf8.odin index 40338f432..9f932e9c4 100644 --- a/core/utf8.odin +++ b/core/utf8.odin @@ -28,9 +28,9 @@ RUNE3_MAX :: 1<<16 - 1; LOCB :: 0b1000_0000; HICB :: 0b1011_1111; -Accept_Range :: struct { lo, hi: u8 } +AcceptRange :: struct { lo, hi: u8 } -immutable accept_ranges := [5]Accept_Range{ +immutable accept_ranges := [5]AcceptRange{ {0x80, 0xbf}, {0xa0, 0xbf}, {0x80, 0x9f}, diff --git a/src/checker.c b/src/checker.c index 9ca8dc371..709a5ce29 100644 --- a/src/checker.c +++ b/src/checker.c @@ -1201,22 +1201,22 @@ void init_preload(Checker *c) { } if (t_type_info == NULL) { - Entity *type_info_entity = find_core_entity(c, str_lit("Type_Info")); + Entity *type_info_entity = find_core_entity(c, str_lit("TypeInfo")); t_type_info = type_info_entity->type; t_type_info_ptr = make_type_pointer(c->allocator, t_type_info); GB_ASSERT(is_type_union(type_info_entity->type)); TypeRecord *record = &base_type(type_info_entity->type)->Record; - t_type_info_record = find_core_entity(c, str_lit("Type_Info_Record"))->type; + t_type_info_record = find_core_entity(c, str_lit("TypeInfoRecord"))->type; t_type_info_record_ptr = make_type_pointer(c->allocator, t_type_info_record); - t_type_info_enum_value = find_core_entity(c, str_lit("Type_Info_Enum_Value"))->type; + t_type_info_enum_value = find_core_entity(c, str_lit("TypeInfoEnumValue"))->type; t_type_info_enum_value_ptr = make_type_pointer(c->allocator, t_type_info_enum_value); if (record->variant_count != 22) { - compiler_error("Invalid `Type_Info` layout"); + compiler_error("Invalid `TypeInfo` layout"); } t_type_info_named = record->variants[ 1]->type; t_type_info_integer = record->variants[ 2]->type; @@ -1277,12 +1277,12 @@ void init_preload(Checker *c) { } if (t_map_key == NULL) { - Entity *e = find_core_entity(c, str_lit("__Map_Key")); + Entity *e = find_core_entity(c, str_lit("__MapKey")); t_map_key = e->type; } if (t_map_header == NULL) { - Entity *e = find_core_entity(c, str_lit("__Map_Header")); + Entity *e = find_core_entity(c, str_lit("__MapHeader")); t_map_header = e->type; }