diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-06 21:43:19 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-06 21:43:19 -0400 |
| commit | d8afa73368cdff38125fa1f7d17ad5ce54c84def (patch) | |
| tree | ac4e54673da6ac32df1e351b913b7c1ddd1118b9 /examples/commands/commands.tm | |
| parent | f4020db2f0d772481ba71edf78fbb65575badc00 (diff) | |
Improved inline C code: now uses `C_code` keyword and supports
interpolation with @
Diffstat (limited to 'examples/commands/commands.tm')
| -rw-r--r-- | examples/commands/commands.tm | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/commands/commands.tm b/examples/commands/commands.tm index 81c43692..ace7deb5 100644 --- a/examples/commands/commands.tm +++ b/examples/commands/commands.tm @@ -58,22 +58,22 @@ struct Command(command:Text, args:[Text]=[], env:{Text=Text}={}) stderr : [Byte] status := run_command(command.command, command.args, command.env, input_bytes, &stdout, &stderr) - if inline C : Bool { WIFEXITED(_$status) } - return ProgramResult(stdout, stderr, ExitType.Exited(inline C : Int32 { WEXITSTATUS(_$status) })) + if C_code:Bool(WIFEXITED(_$status)) + return ProgramResult(stdout, stderr, ExitType.Exited(C_code:Int32(WEXITSTATUS(_$status)))) - if inline C : Bool { WIFSIGNALED(_$status) } - return ProgramResult(stdout, stderr, ExitType.Signaled(inline C : Int32 { WTERMSIG(_$status) })) + if C_code:Bool(WIFSIGNALED(_$status)) + return ProgramResult(stdout, stderr, ExitType.Signaled(C_code:Int32(WTERMSIG(_$status)))) return ProgramResult(stdout, stderr, ExitType.Failed) func run(command:Command, -> ExitType) status := run_command(command.command, command.args, command.env, none, none, none) - if inline C : Bool { WIFEXITED(_$status) } - return ExitType.Exited(inline C : Int32 { WEXITSTATUS(_$status) }) + if C_code:Bool(WIFEXITED(_$status)) + return ExitType.Exited(C_code:Int32(WEXITSTATUS(_$status))) - if inline C : Bool { WIFSIGNALED(_$status) } - return ExitType.Signaled(inline C : Int32 { WTERMSIG(_$status) }) + if C_code:Bool(WIFSIGNALED(_$status)) + return ExitType.Signaled(C_code:Int32(WTERMSIG(_$status))) return ExitType.Failed |
