Remove struct #ordered

This commit is contained in:
gingerBill
2017-12-17 14:53:40 +00:00
parent 436928d06a
commit 30530d058c
15 changed files with 83 additions and 396 deletions
+28 -28
View File
@@ -23,12 +23,12 @@ import "core:raw.odin"
// NOTE(bill): This must match the compiler's
Calling_Convention :: enum {
Invalid = 0,
Odin = 1,
Contextless = 2,
C = 3,
Std = 4,
Fast = 5,
Invalid = 0,
Odin = 1,
Contextless = 2,
C = 3,
Std = 4,
Fast = 5,
}
// IMPORTANT NOTE(bill): Do not change the order of any of this data
// The compiler relies upon this _exact_ order
@@ -42,67 +42,66 @@ Type_Info_Enum_Value :: union {
};
// Variant Types
Type_Info_Named :: struct #ordered {name: string, base: ^Type_Info};
Type_Info_Integer :: struct #ordered {signed: bool};
Type_Info_Named :: struct {name: string, base: ^Type_Info};
Type_Info_Integer :: struct {signed: bool};
Type_Info_Rune :: struct{};
Type_Info_Float :: struct{};
Type_Info_Complex :: struct{};
Type_Info_String :: struct{};
Type_Info_Boolean :: struct{};
Type_Info_Any :: struct{};
Type_Info_Pointer :: struct #ordered {
Type_Info_Pointer :: struct {
elem: ^Type_Info // nil -> rawptr
};
Type_Info_Procedure :: struct #ordered {
Type_Info_Procedure :: struct {
params: ^Type_Info, // Type_Info_Tuple
results: ^Type_Info, // Type_Info_Tuple
variadic: bool,
convention: Calling_Convention,
};
Type_Info_Array :: struct #ordered {
Type_Info_Array :: struct {
elem: ^Type_Info,
elem_size: int,
count: int,
};
Type_Info_Dynamic_Array :: struct #ordered {elem: ^Type_Info, elem_size: int};
Type_Info_Slice :: struct #ordered {elem: ^Type_Info, elem_size: int};
Type_Info_Tuple :: struct #ordered { // Only really used for procedures
Type_Info_Dynamic_Array :: struct {elem: ^Type_Info, elem_size: int};
Type_Info_Slice :: struct {elem: ^Type_Info, elem_size: int};
Type_Info_Tuple :: struct { // Only really used for procedures
types: []^Type_Info,
names: []string,
};
Type_Info_Struct :: struct #ordered {
Type_Info_Struct :: struct {
types: []^Type_Info,
names: []string,
offsets: []uintptr, // offsets may not be used in tuples
usings: []bool, // usings may not be used in tuples
is_packed: bool,
is_ordered: bool,
is_raw_union: bool,
custom_align: bool,
};
Type_Info_Union :: struct #ordered {
Type_Info_Union :: struct {
variants: []^Type_Info,
tag_offset: uintptr,
tag_type: ^Type_Info,
};
Type_Info_Enum :: struct #ordered {
Type_Info_Enum :: struct {
base: ^Type_Info,
names: []string,
values: []Type_Info_Enum_Value,
};
Type_Info_Map :: struct #ordered {
Type_Info_Map :: struct {
key: ^Type_Info,
value: ^Type_Info,
generated_struct: ^Type_Info,
};
Type_Info_Bit_Field :: struct #ordered {
Type_Info_Bit_Field :: struct {
names: []string,
bits: []i32,
offsets: []i32,
};
Type_Info :: struct #ordered {
Type_Info :: struct {
size: int,
align: int,
@@ -139,7 +138,7 @@ __argv__: ^^byte;
// IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it)
Source_Code_Location :: struct #ordered {
Source_Code_Location :: struct {
file_path: string,
line, column: int,
procedure: string,
@@ -160,19 +159,20 @@ Allocator_Proc :: #type proc(allocator_data: rawptr, mode: Allocator_Mode,
old_memory: rawptr, old_size: int, flags: u64 = 0, location := #caller_location) -> rawptr;
Allocator :: struct #ordered {
Allocator :: struct {
procedure: Allocator_Proc,
data: rawptr,
}
Context :: struct #ordered {
Context :: struct {
allocator: Allocator,
thread_id: int,
user_data: any,
user_index: int,
parent: ^Context,
derived: any, // May be used for derived data types
}
@@ -180,18 +180,18 @@ DEFAULT_ALIGNMENT :: 2*align_of(rawptr);
__INITIAL_MAP_CAP :: 16;
__Map_Key :: struct #ordered {
__Map_Key :: struct {
hash: u128,
str: string,
}
__Map_Find_Result :: struct #ordered {
__Map_Find_Result :: struct {
hash_index: int,
entry_prev: int,
entry_index: int,
}
__Map_Entry_Header :: struct #ordered {
__Map_Entry_Header :: struct {
key: __Map_Key,
next: int,
/*
@@ -199,7 +199,7 @@ __Map_Entry_Header :: struct #ordered {
*/
}
__Map_Header :: struct #ordered {
__Map_Header :: struct {
m: ^raw.Map,
is_key_string: bool,
entry_size: int,
-1
View File
@@ -253,7 +253,6 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) {
case Type_Info_Struct:
write_string(buf, "struct ");
if info.is_packed do write_string(buf, "#packed ");
if info.is_ordered do write_string(buf, "#ordered ");
if info.is_raw_union do write_string(buf, "#raw_union ");
if info.custom_align {
write_string(buf, "#align ");
+1 -1
View File
@@ -13,7 +13,7 @@ OS_Node_Type :: enum i32 {
Directory = 1,
}
OS_Node_Information :: struct #ordered {
OS_Node_Information :: struct {
handle: Handle,
id: [16]byte,
ntype: OS_Node_Type,
+2 -2
View File
@@ -40,7 +40,7 @@ RTLD_GLOBAL :: 0x100;
// "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments();
_File_Time :: struct #ordered {
_File_Time :: struct {
seconds: i64,
nanoseconds: i32,
reserved: i32,
@@ -50,7 +50,7 @@ _File_Time :: struct #ordered {
// https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/+/jb-dev/sysroot/usr/include/bits/stat.h
// Validity is not guaranteed.
Stat :: struct #ordered {
Stat :: struct {
device_id: u64, // ID of device containing file
serial: u64, // File serial number
nlink: u32, // Number of hard links
+2 -2
View File
@@ -46,12 +46,12 @@ RTLD_FIRST :: 0x100;
// "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments();
_File_Time :: struct #ordered {
_File_Time :: struct {
seconds: i64,
nanoseconds: i64,
}
Stat :: struct #ordered {
Stat :: struct {
device_id: i32, // ID of device containing file
mode: u16, // Mode of the file
nlink: u16, // Number of hard links
+5 -5
View File
@@ -1,26 +1,26 @@
Any :: struct #ordered {
Any :: struct {
data: rawptr,
type_info: ^Type_Info,
}
String :: struct #ordered {
String :: struct {
data: ^byte,
len: int,
}
Slice :: struct #ordered {
Slice :: struct {
data: rawptr,
len: int,
}
Dynamic_Array :: struct #ordered {
Dynamic_Array :: struct {
data: rawptr,
len: int,
cap: int,
allocator: Allocator,
}
Map :: struct #ordered {
Map :: struct {
hashes: [dynamic]int,
entries: Dynamic_Array,
}
+27 -27
View File
@@ -30,11 +30,11 @@ Bool :: i32;
FALSE: Bool : 0;
TRUE: Bool : 1;
Point :: struct #ordered {
Point :: struct {
x, y: i32,
}
Wnd_Class_Ex_A :: struct #ordered {
Wnd_Class_Ex_A :: struct {
size, style: u32,
wnd_proc: Wnd_Proc,
cls_extra, wnd_extra: i32,
@@ -46,7 +46,7 @@ Wnd_Class_Ex_A :: struct #ordered {
sm: Hicon,
}
Wnd_Class_Ex_W :: struct #ordered {
Wnd_Class_Ex_W :: struct {
size, style: u32,
wnd_proc: Wnd_Proc,
cls_extra, wnd_extra: i32,
@@ -59,7 +59,7 @@ Wnd_Class_Ex_W :: struct #ordered {
}
Msg :: struct #ordered {
Msg :: struct {
hwnd: Hwnd,
message: u32,
wparam: Wparam,
@@ -68,24 +68,24 @@ Msg :: struct #ordered {
pt: Point,
}
Rect :: struct #ordered {
Rect :: struct {
left: i32,
top: i32,
right: i32,
bottom: i32,
}
Filetime :: struct #ordered {
Filetime :: struct {
lo, hi: u32,
}
Systemtime :: struct #ordered {
Systemtime :: struct {
year, month: u16,
day_of_week, day: u16,
hour, minute, second, millisecond: u16,
}
By_Handle_File_Information :: struct #ordered {
By_Handle_File_Information :: struct {
file_attributes: u32,
creation_time,
last_access_time,
@@ -98,7 +98,7 @@ By_Handle_File_Information :: struct #ordered {
file_index_low: u32,
}
File_Attribute_Data :: struct #ordered {
File_Attribute_Data :: struct {
file_attributes: u32,
creation_time,
last_access_time,
@@ -107,7 +107,7 @@ File_Attribute_Data :: struct #ordered {
file_size_low: u32,
}
Find_Data :: struct #ordered{
Find_Data :: struct{
file_attributes: u32,
creation_time: Filetime,
last_access_time: Filetime,
@@ -120,7 +120,7 @@ Find_Data :: struct #ordered{
alternate_file_name: [14]byte,
}
Security_Attributes :: struct #ordered {
Security_Attributes :: struct {
length: u32,
security_descriptor: rawptr,
inherit_handle: Bool,
@@ -128,7 +128,7 @@ Security_Attributes :: struct #ordered {
Pixel_Format_Descriptor :: struct #ordered {
Pixel_Format_Descriptor :: struct {
size,
version,
flags: u32,
@@ -159,7 +159,7 @@ Pixel_Format_Descriptor :: struct #ordered {
damage_mask: u32,
}
Critical_Section :: struct #ordered {
Critical_Section :: struct {
debug_info: ^Critical_Section_Debug,
lock_count: i32,
@@ -169,7 +169,7 @@ Critical_Section :: struct #ordered {
spin_count: ^u32,
}
Critical_Section_Debug :: struct #ordered {
Critical_Section_Debug :: struct {
typ: u16,
creator_back_trace_index: u16,
critical_section: ^Critical_Section,
@@ -181,30 +181,30 @@ Critical_Section_Debug :: struct #ordered {
spare_word: u16,
}
List_Entry :: struct #ordered {flink, blink: ^List_Entry};
List_Entry :: struct {flink, blink: ^List_Entry};
Raw_Input_Device :: struct #ordered {
Raw_Input_Device :: struct {
usage_page: u16,
usage: u16,
flags: u32,
wnd_target: Hwnd,
}
Raw_Input_Header :: struct #ordered {
Raw_Input_Header :: struct {
kind: u32,
size: u32,
device: Handle,
wparam: Wparam,
}
Raw_HID :: struct #ordered {
Raw_HID :: struct {
size_hid: u32,
count: u32,
raw_data: [1]byte,
}
Raw_Keyboard :: struct #ordered {
Raw_Keyboard :: struct {
make_code: u16,
flags: u16,
reserved: u16,
@@ -213,11 +213,11 @@ Raw_Keyboard :: struct #ordered {
extra_information: u32,
}
Raw_Mouse :: struct #ordered {
Raw_Mouse :: struct {
flags: u16,
using data: struct #raw_union {
buttons: u32,
using _: struct #ordered {
using _: struct {
button_flags: u16,
button_data: u16,
},
@@ -228,7 +228,7 @@ Raw_Mouse :: struct #ordered {
extra_information: u32,
}
Raw_Input :: struct #ordered {
Raw_Input :: struct {
using header: Raw_Input_Header,
data: struct #raw_union {
mouse: Raw_Mouse,
@@ -724,14 +724,14 @@ FILE_TYPE_CHAR :: 0x0002;
FILE_TYPE_PIPE :: 0x0003;
Monitor_Info :: struct #ordered {
Monitor_Info :: struct {
size: u32,
monitor: Rect,
work: Rect,
flags: u32,
}
Window_Placement :: struct #ordered {
Window_Placement :: struct {
length: u32,
flags: u32,
show_cmd: u32,
@@ -740,7 +740,7 @@ Window_Placement :: struct #ordered {
normal_pos: Rect,
}
Bitmap_Info_Header :: struct #ordered {
Bitmap_Info_Header :: struct {
size: u32,
width, height: i32,
planes, bit_count: i16,
@@ -751,13 +751,13 @@ Bitmap_Info_Header :: struct #ordered {
clr_used: u32,
clr_important: u32,
}
Bitmap_Info :: struct #ordered {
Bitmap_Info :: struct {
using header: Bitmap_Info_Header,
colors: [1]Rgb_Quad,
}
Rgb_Quad :: struct #ordered {blue, green, red, reserved: byte}
Rgb_Quad :: struct {blue, green, red, reserved: byte}
Key_Code :: enum i32 {
-1
View File
@@ -97,7 +97,6 @@ are_types_identical :: proc(a, b: ^Type_Info) -> bool {
switch {
case len(x.types) != len(y.types),
x.is_packed != y.is_packed,
x.is_ordered != y.is_ordered,
x.is_raw_union != y.is_raw_union,
x.custom_align != y.custom_align:
return false;