Change record field syntax

This commit is contained in:
Ginger Bill
2016-12-18 22:23:34 +00:00
parent e370337f97
commit 4c10fbdcd4
11 changed files with 193 additions and 304 deletions
+55 -55
View File
@@ -13,67 +13,67 @@
// IMPORTANT NOTE(bill): Do not change the order of any of this data
// The compiler relies upon this _exact_ order
type Type_Info_Member struct #ordered {
name: string; // can be empty if tuple
type_info: ^Type_Info;
offset: int; // offsets are not used in tuples
};
name string; // can be empty if tuple
type_info ^Type_Info;
offset int; // offsets are not used in tuples
}
type Type_Info_Record struct #ordered {
fields: []Type_Info_Member;
size: int; // in bytes
align: int; // in bytes
packed: bool;
ordered: bool;
};
fields []Type_Info_Member;
size int; // in bytes
align int; // in bytes
packed bool;
ordered bool;
}
type Type_Info union {
Named: struct #ordered {
name: string;
base: ^Type_Info; // This will _not_ be a Type_Info.Named
Named struct #ordered {
name string;
base ^Type_Info; // This will _not_ be a Type_Info.Named
};
Integer: struct #ordered {
size: int; // in bytes
signed: bool;
Integer struct #ordered {
size int; // in bytes
signed bool;
};
Float: struct #ordered {
size: int; // in bytes
Float struct #ordered {
size int; // in bytes
};
Any: struct #ordered {};
String: struct #ordered {};
Boolean: struct #ordered {};
Pointer: struct #ordered {
elem: ^Type_Info; // nil -> rawptr
Any struct #ordered {};
String struct #ordered {};
Boolean struct #ordered {};
Pointer struct #ordered {
elem ^Type_Info; // nil -> rawptr
};
Maybe: struct #ordered {
elem: ^Type_Info;
Maybe struct #ordered {
elem ^Type_Info;
};
Procedure: struct #ordered {
params: ^Type_Info; // Type_Info.Tuple
results: ^Type_Info; // Type_Info.Tuple
variadic: bool;
Procedure struct #ordered {
params ^Type_Info; // Type_Info.Tuple
results ^Type_Info; // Type_Info.Tuple
variadic bool;
};
Array: struct #ordered {
elem: ^Type_Info;
elem_size: int;
count: int;
Array struct #ordered {
elem ^Type_Info;
elem_size int;
count int;
};
Slice: struct #ordered {
elem: ^Type_Info;
elem_size: int;
Slice struct #ordered {
elem ^Type_Info;
elem_size int;
};
Vector: struct #ordered {
elem: ^Type_Info;
elem_size: int;
count: int;
align: int;
Vector struct #ordered {
elem ^Type_Info;
elem_size int;
count int;
align int;
};
Tuple: Type_Info_Record;
Struct: Type_Info_Record;
Union: Type_Info_Record;
Raw_Union: Type_Info_Record;
Enum: struct #ordered {
base: ^Type_Info;
values: []i64;
names: []string;
Tuple Type_Info_Record;
Struct Type_Info_Record;
Union Type_Info_Record;
Raw_Union Type_Info_Record;
Enum struct #ordered {
base ^Type_Info;
values []i64;
names []string;
};
};
@@ -126,18 +126,18 @@ type Allocator_Proc proc(allocator_data rawptr, mode Allocator_Mode,
type Allocator struct #ordered {
procedure: Allocator_Proc;
data: rawptr;
procedure Allocator_Proc;
data rawptr;
}
type Context struct #ordered {
thread_id: int;
thread_id int;
allocator: Allocator;
allocator Allocator;
user_data: rawptr;
user_index: int;
user_data rawptr;
user_index int;
}
#thread_local var __context Context;
+6 -6
View File
@@ -90,7 +90,7 @@ proc align_forward(ptr rawptr, align int) -> rawptr {
type Allocation_Header struct {
size: int;
size int;
}
proc allocation_header_fill(header ^Allocation_Header, data rawptr, size int) {
header.size = size;
@@ -115,14 +115,14 @@ proc allocation_header(data rawptr) -> ^Allocation_Header {
// Custom allocators
type Arena struct {
backing: Allocator;
memory: []byte;
temp_count: int;
backing Allocator;
memory []byte;
temp_count int;
}
type Arena_Temp_Memory struct {
arena: ^Arena;
original_count: int;
arena ^Arena;
original_count int;
}
+4 -4
View File
@@ -4,13 +4,13 @@
type File_Time u64;
type File_Handle raw_union {
p: rawptr;
i: int;
p rawptr;
i int;
}
type File struct {
handle: File_Handle;
last_write_time: File_Time;
handle File_Handle;
last_write_time File_Time;
}
proc open(name string) -> (File, bool) {
+5 -5
View File
@@ -2,14 +2,14 @@
#import "atomic.odin";
type Semaphore struct {
handle: win32.HANDLE;
handle win32.HANDLE;
}
type Mutex struct {
semaphore: Semaphore;
counter: i32;
owner: i32;
recursion: i32;
semaphore Semaphore;
counter i32;
owner i32;
recursion i32;
}
+45 -45
View File
@@ -51,62 +51,62 @@ const SM_CYSCREEN = 1;
const SW_SHOW = 5;
type POINT struct #ordered {
x, y: i32;
x, y i32;
}
type WNDCLASSEXA struct #ordered {
size, style: u32;
wnd_proc: WNDPROC;
cls_extra, wnd_extra: i32;
instance: HINSTANCE;
icon: HICON;
cursor: HCURSOR;
background: HBRUSH;
menu_name, class_name: ^u8;
sm: HICON;
size, style u32;
wnd_proc WNDPROC;
cls_extra, wnd_extra i32;
instance HINSTANCE;
icon HICON;
cursor HCURSOR;
background HBRUSH;
menu_name, class_name ^u8;
sm HICON;
}
type MSG struct #ordered {
hwnd: HWND;
message: u32;
wparam: WPARAM;
lparam: LPARAM;
time: u32;
pt: POINT;
hwnd HWND;
message u32;
wparam WPARAM;
lparam LPARAM;
time u32;
pt POINT;
}
type RECT struct #ordered {
left: i32;
top: i32;
right: i32;
bottom: i32;
left i32;
top i32;
right i32;
bottom i32;
}
type FILETIME struct #ordered {
low_date_time, high_date_time: u32;
low_date_time, high_date_time u32;
}
type BY_HANDLE_FILE_INFORMATION struct #ordered {
file_attributes: u32;
file_attributes u32;
creation_time,
last_access_time,
last_write_time: FILETIME;
last_write_time FILETIME;
volume_serial_number,
file_size_high,
file_size_low,
number_of_links,
file_index_high,
file_index_low: u32;
file_index_low u32;
}
type WIN32_FILE_ATTRIBUTE_DATA struct #ordered {
file_attributes: u32;
file_attributes u32;
creation_time,
last_access_time,
last_write_time: FILETIME;
last_write_time FILETIME;
file_size_high,
file_size_low: u32;
file_size_low u32;
}
type GET_FILEEX_INFO_LEVELS i32;
@@ -209,9 +209,9 @@ const HEAP_ZERO_MEMORY = 0x00000008;
// Synchronization
type SECURITY_ATTRIBUTES struct #ordered {
length: u32;
security_descriptor: rawptr;
inherit_handle: BOOL;
length u32;
security_descriptor rawptr;
inherit_handle BOOL;
}
const INFINITE = 0xffffffff;
@@ -242,24 +242,24 @@ proc ReadBarrier () #foreign
// GDI
type BITMAPINFOHEADER struct #ordered {
size: u32;
width, height: i32;
planes, bit_count: i16;
compression: u32;
size_image: u32;
x_pels_per_meter: i32;
y_pels_per_meter: i32;
clr_used: u32;
clr_important: u32;
size u32;
width, height i32;
planes, bit_count i16;
compression u32;
size_image u32;
x_pels_per_meter i32;
y_pels_per_meter i32;
clr_used u32;
clr_important u32;
}
type BITMAPINFO struct #ordered {
using header: BITMAPINFOHEADER;
colors: [1]RGBQUAD;
using header BITMAPINFOHEADER;
colors [1]RGBQUAD;
}
type RGBQUAD struct #ordered {
blue, green, red, reserved: byte;
blue, green, red, reserved byte;
}
const BI_RGB = 0;
@@ -315,7 +315,7 @@ type wglCreateContextAttribsARBType proc(hdc HDC, hshareContext rawptr, attribLi
type PIXELFORMATDESCRIPTOR struct #ordered {
size,
version,
flags: u32;
flags u32;
pixel_type,
color_bits,
@@ -336,11 +336,11 @@ type PIXELFORMATDESCRIPTOR struct #ordered {
stencil_bits,
aux_buffers,
layer_type,
reserved: byte;
reserved byte;
layer_mask,
visible_mask,
damage_mask: u32;
damage_mask u32;
}
proc GetDC (h HANDLE) -> HDC #foreign
+1 -1
View File
@@ -11,7 +11,7 @@ const SURROGATE_MAX = 0xdfff;
type Accept_Range struct {
lo, hi: u8;
lo, hi u8;
};
accept_ranges := [5]Accept_Range{