Comma for all field separators; Overloaded procedures follow exportation rules

This commit is contained in:
Ginger Bill
2017-01-17 18:47:38 +00:00
parent 383f5b55ad
commit cb59c1cf08
14 changed files with 439 additions and 285 deletions
+56 -56
View File
@@ -14,20 +14,20 @@
// IMPORTANT NOTE(bill): Do not change the order of any of this data
// The compiler relies upon this _exact_ order
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_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_Info_Enum_Value :: raw_union {
f: f64;
i: i64;
f: f64,
i: i64,
}
// NOTE(bill): This much the same as the compiler's
@@ -40,55 +40,55 @@ Calling_Convention :: enum {
Type_Info :: union {
Named: struct #ordered {
name: string;
base: ^Type_Info; // This will _not_ be a Type_Info.Named
};
name: string,
base: ^Type_Info, // This will _not_ be a Type_Info.Named
},
Integer: struct #ordered {
size: int; // in bytes
signed: bool;
};
size: int, // in bytes
signed: bool,
},
Float: struct #ordered {
size: int; // in bytes
};
Any: struct #ordered {};
String: struct #ordered {};
Boolean: struct #ordered {};
size: int, // in bytes
},
Any: struct #ordered {},
String: struct #ordered {},
Boolean: struct #ordered {},
Pointer: struct #ordered {
elem: ^Type_Info; // nil -> rawptr
};
elem: ^Type_Info, // nil -> rawptr
},
Maybe: struct #ordered {
elem: ^Type_Info;
};
elem: ^Type_Info,
},
Procedure: struct #ordered {
params: ^Type_Info; // Type_Info.Tuple
results: ^Type_Info; // Type_Info.Tuple
variadic: bool;
convention: Calling_Convention;
};
params: ^Type_Info, // Type_Info.Tuple
results: ^Type_Info, // Type_Info.Tuple
variadic: bool,
convention: Calling_Convention,
},
Array: struct #ordered {
elem: ^Type_Info;
elem_size: int;
count: int;
};
elem: ^Type_Info,
elem_size: int,
count: int,
},
Slice: struct #ordered {
elem: ^Type_Info;
elem_size: int;
};
elem: ^Type_Info,
elem_size: 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;
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;
names: []string;
values: []Type_Info_Enum_Value;
};
base: ^Type_Info,
names: []string,
values: []Type_Info_Enum_Value,
},
}
type_info_base :: proc(info: ^Type_Info) -> ^Type_Info {
@@ -137,17 +137,17 @@ Allocator_Proc :: type proc(allocator_data: rawptr, mode: Allocator_Mode,
size, alignment: int,
old_memory: rawptr, old_size: int, flags: u64) -> rawptr;
Allocator :: struct #ordered {
procedure: Allocator_Proc;
data: rawptr;
procedure: Allocator_Proc,
data: rawptr,
}
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 __context: Context;
+18 -18
View File
@@ -5,8 +5,8 @@
DEFAULT_BUFFER_SIZE :: 1<<12;
Buffer :: struct {
data: []byte;
length: int;
data: []byte,
length: int,
}
buffer_write :: proc(buf: ^Buffer, b: []byte) {
@@ -38,22 +38,22 @@ buffer_write_rune :: proc(buf: ^Buffer, r: rune) {
}
Fmt_Info :: struct {
minus: bool;
plus: bool;
space: bool;
zero: bool;
hash: bool;
width_set: bool;
prec_set: bool;
minus: bool,
plus: bool,
space: bool,
zero: bool,
hash: bool,
width_set: bool,
prec_set: bool,
width: int;
prec: int;
width: int,
prec: int,
reordered: bool;
good_arg_index: bool;
reordered: bool,
good_arg_index: bool,
buf: ^Buffer;
arg: any; // Temporary
buf: ^Buffer,
arg: any, // Temporary
}
@@ -827,9 +827,9 @@ __real_to_string :: proc(start: ^string, out: []byte, decimal_pos: ^i32, val: f6
generic_ftoa :: proc(buf: []byte, val: f64, verb: rune, prec, bit_size: int) -> []byte {
Float_Info :: struct {
mantbits: uint;
expbits: uint;
bias: int;
mantbits: uint,
expbits: uint,
bias: int,
};
f32info := Float_Info{23, 8, -127};
f64info := Float_Info{52, 11, -1023};
+7 -7
View File
@@ -68,7 +68,7 @@ align_forward :: proc(ptr: rawptr, align: int) -> rawptr {
Allocation_Header :: struct {
size: int;
size: int,
}
allocation_header_fill :: proc(header: ^Allocation_Header, data: rawptr, size: int) {
@@ -94,15 +94,15 @@ allocation_header :: proc(data: rawptr) -> ^Allocation_Header {
// Custom allocators
Arena :: struct {
backing: Allocator;
offset: int;
memory: []byte;
temp_count: int;
backing: Allocator,
offset: int,
memory: []byte,
temp_count: int,
}
Arena_Temp_Memory :: struct {
arena: ^Arena;
original_count: int;
arena: ^Arena,
original_count: int,
}
+18 -18
View File
@@ -2,14 +2,14 @@
#import "atomic.odin";
Semaphore :: struct {
handle: win32.HANDLE;
handle: win32.HANDLE,
}
Mutex :: struct {
semaphore: Semaphore;
counter: i32;
owner: i32;
recursion: i32;
semaphore: Semaphore,
counter: i32,
owner: i32,
recursion: i32,
}
current_thread_id :: proc() -> i32 {
@@ -36,8 +36,8 @@ semaphore_wait :: proc(s: ^Semaphore) {
mutex_init :: proc(m: ^Mutex) {
atomic.store32(^m.counter, 0);
atomic.store32(^m.owner, current_thread_id());
atomic.store(^m.counter, 0);
atomic.store(^m.owner, current_thread_id());
semaphore_init(^m.semaphore);
m.recursion = 0;
}
@@ -46,27 +46,27 @@ mutex_destroy :: proc(m: ^Mutex) {
}
mutex_lock :: proc(m: ^Mutex) {
thread_id := current_thread_id();
if atomic.fetch_add32(^m.counter, 1) > 0 {
if thread_id != atomic.load32(^m.owner) {
if atomic.fetch_add(^m.counter, 1) > 0 {
if thread_id != atomic.load(^m.owner) {
semaphore_wait(^m.semaphore);
}
}
atomic.store32(^m.owner, thread_id);
atomic.store(^m.owner, thread_id);
m.recursion += 1;
}
mutex_try_lock :: proc(m: ^Mutex) -> bool {
thread_id := current_thread_id();
if atomic.load32(^m.owner) == thread_id {
atomic.fetch_add32(^m.counter, 1);
if atomic.load(^m.owner) == thread_id {
atomic.fetch_add(^m.counter, 1);
} else {
expected: i32 = 0;
if atomic.load32(^m.counter) != 0 {
if atomic.load(^m.counter) != 0 {
return false;
}
if atomic.compare_exchange32(^m.counter, expected, 1) == 0 {
if atomic.compare_exchange(^m.counter, expected, 1) == 0 {
return false;
}
atomic.store32(^m.owner, thread_id);
atomic.store(^m.owner, thread_id);
}
m.recursion += 1;
return true;
@@ -74,15 +74,15 @@ mutex_try_lock :: proc(m: ^Mutex) -> bool {
mutex_unlock :: proc(m: ^Mutex) {
recursion: i32;
thread_id := current_thread_id();
assert(thread_id == atomic.load32(^m.owner));
assert(thread_id == atomic.load(^m.owner));
m.recursion -= 1;
recursion = m.recursion;
if recursion == 0 {
atomic.store32(^m.owner, thread_id);
atomic.store(^m.owner, thread_id);
}
if atomic.fetch_add32(^m.counter, -1) > 1 {
if atomic.fetch_add(^m.counter, -1) > 1 {
if recursion == 0 {
semaphore_release(^m.semaphore);
}
+46 -48
View File
@@ -16,7 +16,7 @@ LPARAM :: int;
LRESULT :: int;
ATOM :: i16;
BOOL :: i32;
WNDPROC :: type proc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT;
WNDPROC :: type proc(HWND, u32, WPARAM, LPARAM) -> LRESULT #cc_c;
INVALID_HANDLE_VALUE :: (-1 as int) as HANDLE;
@@ -56,61 +56,61 @@ SW_SHOW :: 5;
POINT :: struct #ordered {
x, y: i32;
x, y: i32,
}
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,
}
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,
}
RECT :: struct #ordered {
left: i32;
top: i32;
right: i32;
bottom: i32;
left: i32,
top: i32,
right: i32,
bottom: i32,
}
FILETIME :: struct #ordered {
lo, hi: u32;
lo, hi: u32,
}
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,
}
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,
}
GET_FILEEX_INFO_LEVELS :: i32;
@@ -249,9 +249,9 @@ HEAP_ZERO_MEMORY :: 0x00000008;
// Synchronization
SECURITY_ATTRIBUTES :: struct #ordered {
length: u32;
security_descriptor: rawptr;
inherit_handle: BOOL;
length: u32,
security_descriptor: rawptr,
inherit_handle: BOOL,
}
INFINITE :: 0xffffffff;
@@ -281,25 +281,23 @@ ReadBarrier :: proc() #foreign
// GDI
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,
}
BITMAPINFO :: struct #ordered {
using header: BITMAPINFOHEADER;
colors: [1]RGBQUAD;
using header: BITMAPINFOHEADER,
colors: [1]RGBQUAD,
}
RGBQUAD :: struct #ordered {
blue, green, red, reserved: byte;
}
RGBQUAD :: struct #ordered { blue, green, red, reserved: byte }
BI_RGB :: 0;
DIB_RGB_COLORS :: 0x00;
@@ -354,7 +352,7 @@ wglCreateContextAttribsARBType :: proc(hdc: HDC, hshareContext: rawptr, attribLi
PIXELFORMATDESCRIPTOR :: struct #ordered {
size,
version,
flags: u32;
flags: u32,
pixel_type,
color_bits,
@@ -375,11 +373,11 @@ PIXELFORMATDESCRIPTOR :: struct #ordered {
stencil_bits,
aux_buffers,
layer_type,
reserved: byte;
reserved: byte,
layer_mask,
visible_mask,
damage_mask: u32;
damage_mask: u32,
}
GetDC :: proc(h: HANDLE) -> HDC #foreign
+1 -3
View File
@@ -8,9 +8,7 @@ UTF_MAX :: 4;
SURROGATE_MIN :: 0xd800;
SURROGATE_MAX :: 0xdfff;
Accept_Range :: struct {
lo, hi: u8;
}
Accept_Range :: struct { lo, hi: u8 }
accept_ranges := [5]Accept_Range{
{0x80, 0xbf},