From d8afa73368cdff38125fa1f7d17ad5ce54c84def Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 6 Apr 2025 21:43:19 -0400 Subject: Improved inline C code: now uses `C_code` keyword and supports interpolation with @ --- examples/commands/commands.tm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'examples/commands') 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 -- cgit v1.2.3