odinfmt: Switch to Stroustrup braces, run fmt on project

This commit is contained in:
Riyyi
2026-11-15 13:15:37 +01:00
parent 235ff0a41d
commit 916a40611c
10 changed files with 73 additions and 47 deletions
+21 -10
View File
@@ -14,17 +14,20 @@ import "../vendor/brokkr"
when ODIN_OS == .Windows {
LIB_EXT :: ".dll"
OS_NAME :: "windows"
} else when ODIN_OS == .Darwin {
}
else when ODIN_OS == .Darwin {
LIB_EXT :: ".dylib"
OS_NAME :: "macos"
} else {
}
else {
LIB_EXT :: ".so"
OS_NAME :: "linux"
}
when ODIN_ARCH == .amd64 {
ARCH_NAME :: "x86_64"
} else when ODIN_ARCH == .arm64 {
}
else when ODIN_ARCH == .arm64 {
ARCH_NAME :: "aarch64"
}
@@ -192,7 +195,8 @@ hot_reload :: proc(debug: bool, extra_args: []string) {
if !ok {
die("hot reload: failed to terminate running %s", process)
}
} else {
}
else {
_, ok, _ := exec([]string{"pkill", "-TERM", "-x", process})
if !ok {
die(
@@ -219,7 +223,8 @@ wgpu_init :: proc(version_override := "") {
when ODIN_OS == .Windows {
target_name :=
"wgpu-" + OS_NAME + "-" + ARCH_NAME + "-msvc" + "-release"
} else {
}
else {
target_name := "wgpu-" + OS_NAME + "-" + ARCH_NAME + "-release"
}
@@ -315,7 +320,8 @@ wgpu_init :: proc(version_override := "") {
); dl_err != nil {
die("wgpu setup: failed to download wgpu-native release")
}
} else {
}
else {
if dl_err := brokkr.execute_command(
[]string{"curl", "-fL", "--retry", "3", "-o", zip_path, url},
); dl_err != nil {
@@ -339,7 +345,8 @@ wgpu_init :: proc(version_override := "") {
); ex_err != nil {
die("wgpu setup: failed to extract wgpu-native release")
}
} else {
}
else {
// Matches scripts/wgpu-init.sh.
if ex_err := brokkr.execute_command(
[]string{"unzip", "-o", "-q", zip_path, "-d", target},
@@ -384,7 +391,8 @@ bindings_version_from_file :: proc(
chmod_recursively :: proc(path: string) {
when ODIN_OS == .Windows {
return
} else {
}
else {
info, err := os.stat(path, context.temp_allocator)
if err != nil {
die(
@@ -520,7 +528,9 @@ pre_commit :: proc() {
// Pop additional changes
cleanup :: proc() {
err := brokkr.execute_command([]string{"git", "stash", "pop", "--quiet"})
err := brokkr.execute_command(
[]string{"git", "stash", "pop", "--quiet"},
)
if err != nil do os.exit(1)
}
@@ -588,7 +598,8 @@ engine_is_running :: proc() -> bool {
)
if !ok do return false
return strings.contains(string(out), PROJECT_NAME + ".exe")
} else {
}
else {
_, ok, code := exec([]string{"pgrep", "-x", PROJECT_NAME}, false)
if !ok do return false
return code == 0
+1
View File
@@ -3,6 +3,7 @@
"align_comments": true,
"align_struct_fields": true,
"align_struct_values": true,
"brace_style": "Stroustrup",
"character_width": 80,
"indent_cases": true,
"newline_limit": 1,
+9 -5
View File
@@ -92,7 +92,7 @@ hot_reload_init :: proc(
region_count = 0,
},
region_headers = make(map[string]Region_Header, 1, allocator), // initial capacity for nil checks
regions = make(map[string]Memory_Region, 1, allocator), // initial capacity for nil checks
regions = make(map[string]Memory_Region, 1, allocator), // initial capacity for nil checks
write_full_snapshot = true,
}
@@ -241,7 +241,8 @@ write_snapshot :: proc() -> os.Error {
snapshot: ^os.File
if hr.write_full_snapshot || !os.exists(hr.snapshot_path) {
snapshot = os.create(hr.snapshot_path) or_return
} else {
}
else {
snapshot = os.open(hr.snapshot_path, {.Read, .Write}) or_return
}
defer os.close(snapshot)
@@ -284,11 +285,13 @@ write_snapshot :: proc() -> os.Error {
delete(region.digest, hr.allocator)
region.digest = digest
os.write_at(snapshot, data_bytes, offset) or_return
} else if mem.compare(digest, region.digest) != 0 {
}
else if mem.compare(digest, region.digest) != 0 {
delete(region.digest, hr.allocator)
region.digest = digest
write_diff_at(snapshot, data_bytes, offset) or_return
} else {
}
else {
delete(digest, hr.allocator)
}
offset += cast(i64)header.data_size
@@ -321,7 +324,8 @@ write_diff_at :: proc(
) or_return
diff_idx = -1
}
} else if diff_idx < 0 {
}
else if diff_idx < 0 {
diff_idx = i
}
}
+11 -11
View File
@@ -24,17 +24,17 @@ Key :: enum i16 {
// Named printable keys
Key_Space = 32,
Key_Apostrophe = 39, // '
Key_Comma = 44, // ,
Key_Minus = 45, // -
Key_Period = 46, // .
Key_Slash = 47, // /
Key_Semicolon = 59, // ;
Key_Equal = 61, // =
Key_Left_Bracket = 91, // [
Key_Backslash = 92, // \
Key_Right_Bracket = 93, // ]
Key_Grave_Accent = 96, // `
Key_Apostrophe = 39, // '
Key_Comma = 44, // ,
Key_Minus = 45, // -
Key_Period = 46, // .
Key_Slash = 47, // /
Key_Semicolon = 59, // ;
Key_Equal = 61, // =
Key_Left_Bracket = 91, // [
Key_Backslash = 92, // \
Key_Right_Bracket = 93, // ]
Key_Grave_Accent = 96, // `
Key_World_1 = 161, // non-US #1
Key_World_2 = 162, // non-US #2
+4 -2
View File
@@ -87,7 +87,8 @@ load_obj_model :: proc(
slash2 := strings.index_byte(token[slash + 1:], '/')
if slash2 != -1 {
vti_str = token[slash + 1:slash + 1 + slash2]
} else {
}
else {
vti_str = token[slash + 1:]
}
}
@@ -103,7 +104,8 @@ load_obj_model :: proc(
if vti >= 0 && vti < len(uvs) {
uv = uvs[vti]
}
} else if vi < len(uvs) {
}
else if vi < len(uvs) {
uv = uvs[vi]
}
+2 -1
View File
@@ -71,7 +71,8 @@ add :: proc(t: ^Things) -> Thing_Ref {
slot = t.next_free
t.next_free = t.free_list[t.next_free]
t.free_list[slot] = THING_NIL // clean up the pop'ed free-slot
} else if (t.next_unused < THINGS_MAX) {
}
else if (t.next_unused < THINGS_MAX) {
if t.next_unused == THING_NIL do t.next_unused = 1 // first ever add()
slot = t.next_unused
t.next_unused += 1
+1 -1
View File
@@ -30,7 +30,7 @@ main :: proc() {
defer api.destroy()
settings := api.settings()
// Event system
// Event systems
base.event_bus_init()
defer base.event_bus_destroy()
+2 -1
View File
@@ -290,7 +290,8 @@ joystick_callback :: proc "c" (id, connected: i32) {
context = state.ctx
if connected == glfw.CONNECTED {
base.on_event(base.Joystick_Connect_Event{id = id})
} else {
}
else {
base.on_event(base.Joystick_Disconnect_Event{id = id})
}
} // GLFWjoystickfun
+14 -12
View File
@@ -61,10 +61,10 @@ state: struct {
os: OS,
// ----------------------------------------
instance: wgpu.Instance, // entry point: creates Adapter, Device and Surface
surface: wgpu.Surface, // handle to a presentable surface (e.g. a window)
adapter: wgpu.Adapter, // handle to physical GPU
device: wgpu.Device, // open connection to a GPU
queue: wgpu.Queue, // handle to command queue on a Device
surface: wgpu.Surface, // handle to a presentable surface (e.g. a window)
adapter: wgpu.Adapter, // handle to physical GPU
device: wgpu.Device, // open connection to a GPU
queue: wgpu.Queue, // handle to command queue on a Device
config: wgpu.SurfaceConfiguration,
module: wgpu.ShaderModule,
pipeline_layout: wgpu.PipelineLayout,
@@ -297,15 +297,15 @@ frame :: proc "c" () {
render_pass_encoder,
slot = 0,
buffer = m.vertex_buffer,
offset = 0, // offset into buffer to start from
offset = 0, // offset into buffer to start from
size = wgpu.WHOLE_SIZE, // x bytes of the buffer to use
)
wgpu.RenderPassEncoderSetIndexBuffer(
render_pass_encoder,
buffer = m.index_buffer,
format = .Uint16, // type of each element in the buffer
offset = 0, // offset into buffer to start from
format = .Uint16, // type of each element in the buffer
offset = 0, // offset into buffer to start from
size = wgpu.WHOLE_SIZE, // x bytes of the buffer to use
)
@@ -313,8 +313,8 @@ frame :: proc "c" () {
render_pass_encoder,
m.index_count,
instanceCount = 1, // draw x instance(s) of the mesh
firstIndex = 0, // offset into buffer to start from, useful for drawing sub-mesh
baseVertex = 0, // value added to index before vertex fetch, useful for multi-mesh vertex buffers
firstIndex = 0, // offset into buffer to start from, useful for drawing sub-mesh
baseVertex = 0, // value added to index before vertex fetch, useful for multi-mesh vertex buffers
firstInstance = 0, // number to start instance index from
)
}
@@ -808,7 +808,8 @@ pick_present_mode :: proc(vsync: bool) -> wgpu.PresentMode {
if slice.contains(present_modes, wgpu.PresentMode.FifoRelaxed) {
return .FifoRelaxed // Adaptive Vsync
}
} else {
}
else {
if slice.contains(present_modes, wgpu.PresentMode.Immediate) {
return .Immediate // Vsync Off
}
@@ -913,7 +914,8 @@ create_diffuse_texture :: proc(
pixels[idx + 1] = 240
pixels[idx + 2] = 240
pixels[idx + 3] = 255
} else {
}
else {
pixels[idx + 0] = 64
pixels[idx + 1] = 64
pixels[idx + 2] = 64
@@ -942,7 +944,7 @@ create_diffuse_texture :: proc(
raw_data(pixels),
len(pixels),
&{offset = 0, bytesPerRow = width * 4, rowsPerImage = height}, // data layout
&{width = width, height = height, depthOrArrayLayers = 1}, // 3D extent
&{width = width, height = height, depthOrArrayLayers = 1}, // 3D extent
)
view := wgpu.TextureCreateView(texture, nil)
+8 -4
View File
@@ -52,7 +52,8 @@ to_wgsl_struct :: proc(
names[i],
wgsl_type,
)
} else {
}
else {
fmt.sbprintf(&b, "\t%s: %s,\n", names[i], wgsl_type)
}
}
@@ -188,7 +189,8 @@ to_vertex_format :: proc(
case 4:
return .Sint32, true
}
} else {
}
else {
switch ti.size {
case 1:
return .Uint8, true
@@ -210,7 +212,8 @@ to_vertex_format :: proc(
case 4:
return .Float16x4, true
}
} else if elem.size == 4 {
}
else if elem.size == 4 {
switch v.count {
case 2:
return .Float32x2, true
@@ -248,7 +251,8 @@ to_vertex_format :: proc(
return .Sint32x4, true
}
}
} else {
}
else {
switch elem.size {
case 1:
switch v.count {