authorgravatar for hemisputnik@proton.mehemisputnik <hemisputnik@proton.me> 2026-08-05 06:50:26+03:00
committergravatar for hemisputnik@proton.mehemisputnik <hemisputnik@proton.me> 2026-08-05 21:46:56+03:00
log800fc5d25a5ed386910dc36c81ae200a19a1d01b
treeaa1e31ed6456c41e3abad13e8a6823aa96c2afc4
parent03ab50821418fac99578fd762ba1ef135671b545
signaturebadge-check Signed by SSH key SHA256:iUK/EffQPyeXTXChJNV0UrxsscinNLxnk+0pu4OGU7Q

std.Build.Configuration: use inline else to simplify long switches


1 files changed, 12 insertions(+), 311 deletions(-)

lib/std/Build/Configuration.zig+12-311
......@@ -2120,27 +2120,18 @@ pub const OptionalCSourceLanguage = enum(u3) {
21202120 objective_cpp,
21212121 assembly,
21222122 assembly_with_preprocessor,
2123
21232124 default,
21242125
21252126 pub fn init(x: ?std.Build.Module.CSourceLanguage) @This() {
21262127 return switch (x orelse return .default) {
2127 .c => .c,
2128 .cpp => .cpp,
2129 .objective_c => .objective_c,
2130 .objective_cpp => .objective_cpp,
2131 .assembly => .assembly,
2132 .assembly_with_preprocessor => .assembly_with_preprocessor,
2128 inline else => |tag| @field(@This(), @tagName(tag)),
21332129 };
21342130 }
21352131
21362132 pub fn get(this: @This()) ?std.Build.Module.CSourceLanguage {
21372133 return switch (this) {
2138 .c => .c,
2139 .cpp => .cpp,
2140 .objective_c => .objective_c,
2141 .objective_cpp => .objective_cpp,
2142 .assembly => .assembly,
2143 .assembly_with_preprocessor => .assembly_with_preprocessor,
2134 inline else => |tag| @field(std.Build.Module.CSourceLanguage, @tagName(tag)),
21442135 .default => null,
21452136 };
21462137 }
......@@ -2268,10 +2259,7 @@ pub const TargetQuery = struct {
22682259
22692260 pub fn init(x: std.Target.Query.CpuModel) @This() {
22702261 return switch (x) {
2271 .native => .native,
2272 .baseline => .baseline,
2273 .determined_by_arch_os => .determined_by_arch_os,
2274 .explicit => .explicit,
2262 inline else => |_, tag| @field(@This(), @tagName(tag)),
22752263 };
22762264 }
22772265 };
......@@ -2329,71 +2317,13 @@ pub const TargetQuery = struct {
23292317
23302318 pub fn init(x: ?std.Target.Abi) @This() {
23312319 return switch (x orelse return .default) {
2332 .none => .none,
2333 .gnu => .gnu,
2334 .gnuabin32 => .gnuabin32,
2335 .gnuabi64 => .gnuabi64,
2336 .gnueabi => .gnueabi,
2337 .gnueabihf => .gnueabihf,
2338 .gnuf32 => .gnuf32,
2339 .gnusf => .gnusf,
2340 .gnux32 => .gnux32,
2341 .eabi => .eabi,
2342 .eabihf => .eabihf,
2343 .abin32 => .abin32,
2344 .x32 => .x32,
2345 .ilp32 => .ilp32,
2346 .android => .android,
2347 .androideabi => .androideabi,
2348 .musl => .musl,
2349 .muslabin32 => .muslabin32,
2350 .muslabi64 => .muslabi64,
2351 .musleabi => .musleabi,
2352 .musleabihf => .musleabihf,
2353 .muslf32 => .muslf32,
2354 .muslsf => .muslsf,
2355 .muslx32 => .muslx32,
2356 .msvc => .msvc,
2357 .itanium => .itanium,
2358 .simulator => .simulator,
2359 .ohos => .ohos,
2360 .ohoseabi => .ohoseabi,
2361 .call0 => .call0,
2320 inline else => |tag| @field(@This(), @tagName(tag)),
23622321 };
23632322 }
23642323
23652324 pub fn unwrap(this: @This()) ?std.Target.Abi {
23662325 return switch (this) {
2367 .none => .none,
2368 .gnu => .gnu,
2369 .gnuabin32 => .gnuabin32,
2370 .gnuabi64 => .gnuabi64,
2371 .gnueabi => .gnueabi,
2372 .gnueabihf => .gnueabihf,
2373 .gnuf32 => .gnuf32,
2374 .gnusf => .gnusf,
2375 .gnux32 => .gnux32,
2376 .eabi => .eabi,
2377 .eabihf => .eabihf,
2378 .abin32 => .abin32,
2379 .x32 => .x32,
2380 .ilp32 => .ilp32,
2381 .android => .android,
2382 .androideabi => .androideabi,
2383 .musl => .musl,
2384 .muslabin32 => .muslabin32,
2385 .muslabi64 => .muslabi64,
2386 .musleabi => .musleabi,
2387 .musleabihf => .musleabihf,
2388 .muslf32 => .muslf32,
2389 .muslsf => .muslsf,
2390 .muslx32 => .muslx32,
2391 .msvc => .msvc,
2392 .itanium => .itanium,
2393 .simulator => .simulator,
2394 .ohos => .ohos,
2395 .ohoseabi => .ohoseabi,
2396 .call0 => .call0,
2326 inline else => |tag| @field(std.Target.Abi, @tagName(tag)),
23972327 .default => null,
23982328 };
23992329 }
......@@ -2465,132 +2395,13 @@ pub const TargetQuery = struct {
24652395
24662396 pub fn init(x: ?std.Target.Cpu.Arch) @This() {
24672397 return switch (x orelse return .default) {
2468 .aarch64 => .aarch64,
2469 .aarch64_be => .aarch64_be,
2470 .alpha => .alpha,
2471 .amdgcn => .amdgcn,
2472 .arc => .arc,
2473 .arceb => .arceb,
2474 .arm => .arm,
2475 .armeb => .armeb,
2476 .avr => .avr,
2477 .bpfeb => .bpfeb,
2478 .bpfel => .bpfel,
2479 .csky => .csky,
2480 .ez80 => .ez80,
2481 .hexagon => .hexagon,
2482 .hppa => .hppa,
2483 .hppa64 => .hppa64,
2484 .kalimba => .kalimba,
2485 .kvx => .kvx,
2486 .lanai => .lanai,
2487 .loongarch32 => .loongarch32,
2488 .loongarch64 => .loongarch64,
2489 .m68k => .m68k,
2490 .m88k => .m88k,
2491 .microblaze => .microblaze,
2492 .microblazeel => .microblazeel,
2493 .mips => .mips,
2494 .mipsel => .mipsel,
2495 .mips64 => .mips64,
2496 .mips64el => .mips64el,
2497 .msp430 => .msp430,
2498 .nvptx => .nvptx,
2499 .nvptx64 => .nvptx64,
2500 .or1k => .or1k,
2501 .powerpc => .powerpc,
2502 .powerpcle => .powerpcle,
2503 .powerpc64 => .powerpc64,
2504 .powerpc64le => .powerpc64le,
2505 .propeller => .propeller,
2506 .riscv32 => .riscv32,
2507 .riscv32be => .riscv32be,
2508 .riscv64 => .riscv64,
2509 .riscv64be => .riscv64be,
2510 .s390x => .s390x,
2511 .sh => .sh,
2512 .sheb => .sheb,
2513 .sparc => .sparc,
2514 .sparc64 => .sparc64,
2515 .spirv32 => .spirv32,
2516 .spirv64 => .spirv64,
2517 .thumb => .thumb,
2518 .thumbeb => .thumbeb,
2519 .ve => .ve,
2520 .wasm32 => .wasm32,
2521 .wasm64 => .wasm64,
2522 .x86_16 => .x86_16,
2523 .x86 => .x86,
2524 .x86_64 => .x86_64,
2525 .xcore => .xcore,
2526 .xtensa => .xtensa,
2527 .xtensaeb => .xtensaeb,
2398 inline else => |tag| @field(@This(), @tagName(tag)),
25282399 };
25292400 }
25302401
25312402 pub fn unwrap(this: @This()) ?std.Target.Cpu.Arch {
25322403 return switch (this) {
2533 .aarch64 => .aarch64,
2534 .aarch64_be => .aarch64_be,
2535 .alpha => .alpha,
2536 .amdgcn => .amdgcn,
2537 .arc => .arc,
2538 .arceb => .arceb,
2539 .arm => .arm,
2540 .armeb => .armeb,
2541 .avr => .avr,
2542 .bpfeb => .bpfeb,
2543 .bpfel => .bpfel,
2544 .csky => .csky,
2545 .ez80 => .ez80,
2546 .hexagon => .hexagon,
2547 .hppa => .hppa,
2548 .hppa64 => .hppa64,
2549 .kalimba => .kalimba,
2550 .kvx => .kvx,
2551 .lanai => .lanai,
2552 .loongarch32 => .loongarch32,
2553 .loongarch64 => .loongarch64,
2554 .m68k => .m68k,
2555 .m88k => .m88k,
2556 .microblaze => .microblaze,
2557 .microblazeel => .microblazeel,
2558 .mips => .mips,
2559 .mipsel => .mipsel,
2560 .mips64 => .mips64,
2561 .mips64el => .mips64el,
2562 .msp430 => .msp430,
2563 .nvptx => .nvptx,
2564 .nvptx64 => .nvptx64,
2565 .or1k => .or1k,
2566 .powerpc => .powerpc,
2567 .powerpcle => .powerpcle,
2568 .powerpc64 => .powerpc64,
2569 .powerpc64le => .powerpc64le,
2570 .propeller => .propeller,
2571 .riscv32 => .riscv32,
2572 .riscv32be => .riscv32be,
2573 .riscv64 => .riscv64,
2574 .riscv64be => .riscv64be,
2575 .s390x => .s390x,
2576 .sh => .sh,
2577 .sheb => .sheb,
2578 .sparc => .sparc,
2579 .sparc64 => .sparc64,
2580 .spirv32 => .spirv32,
2581 .spirv64 => .spirv64,
2582 .thumb => .thumb,
2583 .thumbeb => .thumbeb,
2584 .ve => .ve,
2585 .wasm32 => .wasm32,
2586 .wasm64 => .wasm64,
2587 .x86_16 => .x86_16,
2588 .x86 => .x86,
2589 .x86_64 => .x86_64,
2590 .xcore => .xcore,
2591 .xtensa => .xtensa,
2592 .xtensaeb => .xtensaeb,
2593
2404 inline else => |tag| @field(std.Target.Cpu.Arch, @tagName(tag)),
25942405 .default => null,
25952406 };
25962407 }
......@@ -2649,106 +2460,13 @@ pub const TargetQuery = struct {
26492460
26502461 pub fn init(x: ?std.Target.Os.Tag) @This() {
26512462 return switch (x orelse return .default) {
2652 .freestanding => .freestanding,
2653 .other => .other,
2654 .contiki => .contiki,
2655 .fuchsia => .fuchsia,
2656 .hermit => .hermit,
2657 .managarm => .managarm,
2658 .haiku => .haiku,
2659 .hurd => .hurd,
2660 .illumos => .illumos,
2661 .linux => .linux,
2662 .plan9 => .plan9,
2663 .rtems => .rtems,
2664 .serenity => .serenity,
2665 .dragonfly => .dragonfly,
2666 .freebsd => .freebsd,
2667 .netbsd => .netbsd,
2668 .openbsd => .openbsd,
2669 .driverkit => .driverkit,
2670 .ios => .ios,
2671 .maccatalyst => .maccatalyst,
2672 .macos => .macos,
2673 .tvos => .tvos,
2674 .visionos => .visionos,
2675 .watchos => .watchos,
2676 .windows => .windows,
2677 .uefi => .uefi,
2678 .@"3ds" => .@"3ds",
2679 .wiiu => .wiiu,
2680 .@"switch" => .@"switch",
2681 .psx => .psx,
2682 .ps3 => .ps3,
2683 .ps4 => .ps4,
2684 .ps5 => .ps5,
2685 .psp => .psp,
2686 .vita => .vita,
2687 .emscripten => .emscripten,
2688 .wasi => .wasi,
2689 .amdhsa => .amdhsa,
2690 .amdpal => .amdpal,
2691 .cuda => .cuda,
2692 .mesa3d => .mesa3d,
2693 .nvcl => .nvcl,
2694 .opencl => .opencl,
2695 .opengl => .opengl,
2696 .vulkan => .vulkan,
2697 .tios => .tios,
2698 .ashetos => .ashetos,
2463 inline else => |tag| @field(@This(), @tagName(tag)),
26992464 };
27002465 }
27012466
27022467 pub fn unwrap(this: @This()) ?std.Target.Os.Tag {
27032468 return switch (this) {
2704 .freestanding => .freestanding,
2705 .other => .other,
2706 .contiki => .contiki,
2707 .fuchsia => .fuchsia,
2708 .hermit => .hermit,
2709 .managarm => .managarm,
2710 .haiku => .haiku,
2711 .hurd => .hurd,
2712 .illumos => .illumos,
2713 .linux => .linux,
2714 .plan9 => .plan9,
2715 .rtems => .rtems,
2716 .serenity => .serenity,
2717 .dragonfly => .dragonfly,
2718 .freebsd => .freebsd,
2719 .netbsd => .netbsd,
2720 .openbsd => .openbsd,
2721 .driverkit => .driverkit,
2722 .ios => .ios,
2723 .maccatalyst => .maccatalyst,
2724 .macos => .macos,
2725 .tvos => .tvos,
2726 .visionos => .visionos,
2727 .watchos => .watchos,
2728 .windows => .windows,
2729 .uefi => .uefi,
2730 .@"3ds" => .@"3ds",
2731 .wiiu => .wiiu,
2732 .@"switch" => .@"switch",
2733 .psx => .psx,
2734 .ps3 => .ps3,
2735 .ps4 => .ps4,
2736 .ps5 => .ps5,
2737 .psp => .psp,
2738 .vita => .vita,
2739 .emscripten => .emscripten,
2740 .wasi => .wasi,
2741 .amdhsa => .amdhsa,
2742 .amdpal => .amdpal,
2743 .cuda => .cuda,
2744 .mesa3d => .mesa3d,
2745 .nvcl => .nvcl,
2746 .opencl => .opencl,
2747 .opengl => .opengl,
2748 .vulkan => .vulkan,
2749 .tios => .tios,
2750 .ashetos => .ashetos,
2751
2469 inline else => |tag| @field(std.Target.Os.Tag, @tagName(tag)),
27522470 .default => null,
27532471 };
27542472 }
......@@ -2769,30 +2487,13 @@ pub const TargetQuery = struct {
27692487
27702488 pub fn init(x: ?std.Target.ObjectFormat) @This() {
27712489 return switch (x orelse return .default) {
2772 .c => .c,
2773 .coff => .coff,
2774 .elf => .elf,
2775 .hex => .hex,
2776 .macho => .macho,
2777 .plan9 => .plan9,
2778 .raw => .raw,
2779 .spirv => .spirv,
2780 .wasm => .wasm,
2490 inline else => |tag| @field(@This(), @tagName(tag)),
27812491 };
27822492 }
27832493
27842494 pub fn unwrap(this: @This()) ?std.Target.ObjectFormat {
27852495 return switch (this) {
2786 .c => .c,
2787 .coff => .coff,
2788 .elf => .elf,
2789 .hex => .hex,
2790 .macho => .macho,
2791 .plan9 => .plan9,
2792 .raw => .raw,
2793 .spirv => .spirv,
2794 .wasm => .wasm,
2795
2496 inline else => |tag| @field(std.Target.ObjectFormat, @tagName(tag)),
27962497 .default => null,
27972498 };
27982499 }