Skip to content

Commit

Permalink
v0.6.2; Use Ada_Case for types
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed Aug 3, 2017
1 parent 2940929 commit 49d337c
Show file tree
Hide file tree
Showing 19 changed files with 354 additions and 319 deletions.
174 changes: 87 additions & 87 deletions core/_preload.odin

Large diffs are not rendered by default.

138 changes: 69 additions & 69 deletions core/fmt.odin

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions core/mem.odin
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ end_arena_temp_memory :: proc(using tmp: ArenaTempMemory) {



align_of_type_info :: proc(type_info: ^TypeInfo) -> int {
align_of_type_info :: proc(type_info: ^Type_Info) -> int {
prev_pow2 :: proc(n: i64) -> i64 {
if n <= 0 do return 0;
n |= n >> 1;
Expand All @@ -208,7 +208,7 @@ align_of_type_info :: proc(type_info: ^TypeInfo) -> int {

WORD_SIZE :: size_of(int);
MAX_ALIGN :: size_of([vector 64]f64); // TODO(bill): Should these constants be builtin constants?
using TypeInfo;
using Type_Info;
match info in type_info.variant {
case Named:
return align_of_type_info(info.base);
Expand All @@ -230,7 +230,7 @@ align_of_type_info :: proc(type_info: ^TypeInfo) -> int {
return WORD_SIZE;
case Array:
return align_of_type_info(info.elem);
case DynamicArray:
case Dynamic_Array:
return WORD_SIZE;
case Slice:
return WORD_SIZE;
Expand Down Expand Up @@ -259,9 +259,9 @@ align_formula :: proc(size, align: int) -> int {
return result - result%align;
}

size_of_type_info :: proc(type_info: ^TypeInfo) -> int {
size_of_type_info :: proc(type_info: ^Type_Info) -> int {
WORD_SIZE :: size_of(int);
using TypeInfo;
using Type_Info;
match info in type_info.variant {
case Named:
return size_of_type_info(info.base);
Expand All @@ -288,7 +288,7 @@ size_of_type_info :: proc(type_info: ^TypeInfo) -> int {
align := align_of_type_info(info.elem);
alignment := align_formula(size, align);
return alignment*(count-1) + size;
case DynamicArray:
case Dynamic_Array:
return size_of(rawptr) + 2*size_of(int) + size_of(Allocator);
case Slice:
return 2*WORD_SIZE;
Expand Down
14 changes: 7 additions & 7 deletions core/os_linux.odin
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ foreign_system_library (
import "strings.odin";

Handle :: i32;
FileTime :: u64;
File_Time :: u64;
Errno :: i32;


Expand Down Expand Up @@ -40,7 +40,7 @@ RTLD_GLOBAL :: 0x100;
// "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments();

_FileTime :: struct #ordered {
_File_Time :: struct #ordered {
seconds: i64;
nanoseconds: i32;
reserved: i32;
Expand All @@ -63,9 +63,9 @@ Stat :: struct #ordered {
block_size: i64; // Optimal bllocksize for I/O
blocks: i64; // Number of 512-byte blocks allocated

last_access: _FileTime; // Time of last access
modified: _FileTime; // Time of last modification
status_change: _FileTime; // Time of last status change
last_access: _File_Time; // Time of last access
modified: _File_Time; // Time of last modification
status_change: _File_Time; // Time of last status change

_reserve1,
_reserve2,
Expand Down Expand Up @@ -195,8 +195,8 @@ stdout: Handle = 1;
stderr: Handle = 2;

/* TODO(zangent): Implement these!
last_write_time :: proc(fd: Handle) -> FileTime {}
last_write_time_by_name :: proc(name: string) -> FileTime {}
last_write_time :: proc(fd: Handle) -> File_Time {}
last_write_time_by_name :: proc(name: string) -> File_Time {}
*/

stat :: proc(path: string) -> (Stat, int) #inline {
Expand Down
24 changes: 12 additions & 12 deletions core/os_windows.odin
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import win32 "sys/windows.odin";
import "mem.odin";

Handle :: int;
FileTime :: u64;
File_Time :: u64;


INVALID_HANDLE: Handle : -1;
Expand Down Expand Up @@ -75,8 +75,8 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: u32 = 0) -> (Handle, Errn
}

share_mode := u32(win32.FILE_SHARE_READ|win32.FILE_SHARE_WRITE);
sa: ^win32.SecurityAttributes = nil;
sa_inherit := win32.SecurityAttributes{length = size_of(win32.SecurityAttributes), inherit_handle = 1};
sa: ^win32.Security_Attributes = nil;
sa_inherit := win32.Security_Attributes{length = size_of(win32.Security_Attributes), inherit_handle = 1};
if mode&O_CLOEXEC == 0 {
sa = &sa_inherit;
}
Expand Down Expand Up @@ -202,17 +202,17 @@ get_std_handle :: proc(h: int) -> Handle {



last_write_time :: proc(fd: Handle) -> FileTime {
file_info: win32.ByHandleFileInformation;
last_write_time :: proc(fd: Handle) -> File_Time {
file_info: win32.By_Handle_File_Information;
win32.get_file_information_by_handle(win32.Handle(fd), &file_info);
lo := FileTime(file_info.last_write_time.lo);
hi := FileTime(file_info.last_write_time.hi);
lo := File_Time(file_info.last_write_time.lo);
hi := File_Time(file_info.last_write_time.hi);
return lo | hi << 32;
}

last_write_time_by_name :: proc(name: string) -> FileTime {
last_write_time_by_name :: proc(name: string) -> File_Time {
last_write_time: win32.Filetime;
data: win32.FileAttributeData;
data: win32.File_Attribute_Data;
buf: [1024]u8;

assert(len(buf) > len(name));
Expand All @@ -223,8 +223,8 @@ last_write_time_by_name :: proc(name: string) -> FileTime {
last_write_time = data.last_write_time;
}

l := FileTime(last_write_time.lo);
h := FileTime(last_write_time.hi);
l := File_Time(last_write_time.lo);
h := File_Time(last_write_time.hi);
return l | h << 32;
}

Expand Down Expand Up @@ -284,7 +284,7 @@ _alloc_command_line_arguments :: proc() -> []string {
j += 1;
case 0xd800 <= str[j] && str[j] < 0xdc00:
if i+4 > len do return "";
c := rune((str[j] - 0xd800) << 10) + rune((str[j+1]) - 0xdc00) + 0x10000;
c := rune((str[j] - 0xd800) << 10) + rune((str[j+1]) - 0xdc00) + 0x10000;
buf[i] = u8(0xf0 + (c >> 18)); i += 1;
buf[i] = u8(0x80 + ((c >> 12) & 0x3f)); i += 1;
buf[i] = u8(0x80 + ((c >> 6) & 0x3f)); i += 1;
Expand Down
16 changes: 8 additions & 8 deletions core/os_x.odin
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ foreign_system_library (
import "strings.odin";

Handle :: i32;
FileTime :: u64;
File_Time :: u64;
Errno :: int;


Expand Down Expand Up @@ -46,7 +46,7 @@ RTLD_FIRST :: 0x100;

args: [dynamic]string;

_FileTime :: struct #ordered {
_File_Time :: struct #ordered {
seconds: i64;
nanoseconds: i64;
}
Expand All @@ -60,10 +60,10 @@ Stat :: struct #ordered {
gid: u32; // Group ID of the file's group
rdev: i32; // Device ID, if device

last_access: FileTime; // Time of last access
modified: FileTime; // Time of last modification
status_change: FileTime; // Time of last status change
created: FileTime; // Time of creation
last_access: File_Time; // Time of last access
modified: File_Time; // Time of last modification
status_change: File_Time; // Time of last status change
created: File_Time; // Time of creation

size: i64; // Size of the file, in bytes
blocks: i64; // Number of blocks allocated for the file
Expand Down Expand Up @@ -212,8 +212,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) -> FileTime {}
last_write_time_by_name :: proc(name: string) -> FileTime {}
last_write_time :: proc(fd: Handle) -> File_Time {}
last_write_time_by_name :: proc(name: string) -> File_Time {}
*/

stat :: proc(path: string) -> (Stat, bool) #inline {
Expand Down
8 changes: 4 additions & 4 deletions core/raw.odin
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Any :: struct #ordered {
data: rawptr;
type_info: ^TypeInfo;
type_info: ^Type_Info;
};

String :: struct #ordered {
Expand All @@ -14,15 +14,15 @@ Slice :: struct #ordered {
cap: int;
};

DynamicArray :: struct #ordered {
Dynamic_Array :: struct #ordered {
data: rawptr;
len: int;
cap: int;
allocator: Allocator;
};

DynamicMap :: struct #ordered {
Map :: struct #ordered {
hashes: [dynamic]int;
entries: DynamicArray;
entries: Dynamic_Array;
};

10 changes: 5 additions & 5 deletions core/strconv.odin
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import . "decimal.odin";

IntFlag :: enum {
Int_Flag :: enum {
Prefix = 1<<0,
Plus = 1<<1,
Space = 1<<2,
Expand Down Expand Up @@ -445,7 +445,7 @@ is_integer_negative :: proc(u: u128, is_signed: bool, bit_size: int) -> (unsigne
return u, neg;
}

append_bits :: proc(buf: []u8, u: u128, base: int, is_signed: bool, bit_size: int, digits: string, flags: IntFlag) -> string {
append_bits :: proc(buf: []u8, u: u128, base: int, is_signed: bool, bit_size: int, digits: string, flags: Int_Flag) -> string {
if base < 2 || base > MAX_BASE {
panic("strconv: illegal base passed to append_bits");
}
Expand All @@ -461,7 +461,7 @@ append_bits :: proc(buf: []u8, u: u128, base: int, is_signed: bool, bit_size: in
}
i-=1; a[i] = digits[uint(u % b)];

if flags&IntFlag.Prefix != 0 {
if flags&Int_Flag.Prefix != 0 {
ok := true;
match base {
case 2: i-=1; a[i] = 'b';
Expand All @@ -478,9 +478,9 @@ append_bits :: proc(buf: []u8, u: u128, base: int, is_signed: bool, bit_size: in

if neg {
i-=1; a[i] = '-';
} else if flags&IntFlag.Plus != 0 {
} else if flags&Int_Flag.Plus != 0 {
i-=1; a[i] = '+';
} else if flags&IntFlag.Space != 0 {
} else if flags&Int_Flag.Space != 0 {
i-=1; a[i] = ' ';
}

Expand Down
2 changes: 1 addition & 1 deletion core/sync_windows.odin
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Mutex :: struct {
*/

Mutex :: struct {
_critical_section: win32.CriticalSection;
_critical_section: win32.Critical_Section;
}

current_thread_id :: proc() -> i32 {
Expand Down
36 changes: 18 additions & 18 deletions core/sys/wgl.odin
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ CONTEXT_CORE_PROFILE_BIT_ARB :: 0x00000001;
CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x00000002;

Hglrc :: Handle;
ColorRef :: u32;
Color_Ref :: u32;

LayerPlaneDescriptor :: struct {
Layer_Plane_Descriptor :: struct {
size: u16;
version: u16;
flags: u32;
Expand All @@ -37,29 +37,29 @@ LayerPlaneDescriptor :: struct {
aux_buffers: u8;
layer_type: u8;
reserved: u8;
transparent: ColorRef;
transparent: Color_Ref;
}

PointFloat :: struct {x, y: f32};
Point_Float :: struct {x, y: f32};

Glyph_MetricsFloat :: struct {
Glyph_Metrics_Float :: struct {
black_box_x: f32;
black_box_y: f32;
glyph_origin: PointFloat;
glyph_origin: Point_Float;
cell_inc_x: f32;
cell_inc_y: f32;
}

CreateContextAttribsARBType :: proc(hdc: Hdc, h_share_context: rawptr, attribList: ^i32) -> Hglrc;
ChoosePixelFormatARBType :: proc(hdc: Hdc, attrib_i_list: ^i32, attrib_f_list: ^f32, max_formats: u32, formats: ^i32, num_formats : ^u32) -> Bool #cc_c;
SwapIntervalEXTType :: proc(interval: i32) -> bool #cc_c;
GetExtensionsStringARBType :: proc(Hdc) -> ^u8 #cc_c;
Create_Context_Attribs_ARB_Type :: #type proc(hdc: Hdc, h_share_context: rawptr, attribList: ^i32) -> Hglrc;
Choose_Pixel_Format_ARB_Type :: #type proc(hdc: Hdc, attrib_i_list: ^i32, attrib_f_list: ^f32, max_formats: u32, formats: ^i32, num_formats : ^u32) -> Bool #cc_c;
Swap_Interval_EXT_Type :: #type proc(interval: i32) -> bool #cc_c;
Get_Extensions_String_ARB_Type :: #type proc(Hdc) -> ^u8 #cc_c;

// Procedures
create_context_attribs_arb: CreateContextAttribsARBType;
choose_pixel_format_arb: ChoosePixelFormatARBType;
swap_interval_ext: SwapIntervalEXTType;
get_extensions_string_arb: GetExtensionsStringARBType;
create_context_attribs_arb: Create_Context_Attribs_ARB_Type;
choose_pixel_format_arb: Choose_Pixel_Format_ARB_Type;
swap_interval_ext: Swap_Interval_EXT_Type;
get_extensions_string_arb: Get_Extensions_String_ARB_Type;



Expand All @@ -70,14 +70,14 @@ foreign opengl32 {
delete_context :: proc(hglrc: Hglrc) -> Bool #link_name "wglDeleteContext" ---;
copy_context :: proc(src, dst: Hglrc, mask: u32) -> Bool #link_name "wglCopyContext" ---;
create_layer_context :: proc(hdc: Hdc, layer_plane: i32) -> Hglrc #link_name "wglCreateLayerContext" ---;
describe_layer_plane :: proc(hdc: Hdc, pixel_format, layer_plane: i32, bytes: u32, pd: ^LayerPlaneDescriptor) -> Bool #link_name "wglDescribeLayerPlane" ---;
describe_layer_plane :: proc(hdc: Hdc, pixel_format, layer_plane: i32, bytes: u32, pd: ^Layer_Plane_Descriptor) -> Bool #link_name "wglDescribeLayerPlane" ---;
get_current_context :: proc() -> Hglrc #link_name "wglGetCurrentContext" ---;
get_current_dc :: proc() -> Hdc #link_name "wglGetCurrentDC" ---;
get_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^ColorRef) -> i32 #link_name "wglGetLayerPaletteEntries" ---;
get_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^Color_Ref) -> i32 #link_name "wglGetLayerPaletteEntries" ---;
realize_layer_palette :: proc(hdc: Hdc, layer_plane: i32, realize: Bool) -> Bool #link_name "wglRealizeLayerPalette" ---;
set_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^ColorRef) -> i32 #link_name "wglSetLayerPaletteEntries" ---;
set_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^Color_Ref) -> i32 #link_name "wglSetLayerPaletteEntries" ---;
share_lists :: proc(hglrc1, hglrc2: Hglrc) -> Bool #link_name "wglShareLists" ---;
swap_layer_buffers :: proc(hdc: Hdc, planes: u32) -> Bool #link_name "wglSwapLayerBuffers" ---;
use_font_bitmaps :: proc(hdc: Hdc, first, count, list_base: u32) -> Bool #link_name "wglUseFontBitmaps" ---;
use_font_outlines :: proc(hdc: Hdc, first, count, list_base: u32, deviation, extrusion: f32, format: i32, gmf: ^Glyph_MetricsFloat) -> Bool #link_name "wglUseFontOutlines" ---;
use_font_outlines :: proc(hdc: Hdc, first, count, list_base: u32, deviation, extrusion: f32, format: i32, gmf: ^Glyph_Metrics_Float) -> Bool #link_name "wglUseFontOutlines" ---;
}
Loading

0 comments on commit 49d337c

Please sign in to comment.