try? / catch?

This commit is contained in:
Christoffer Lerno
2023-03-17 00:45:23 +01:00
committed by Christoffer Lerno
parent 1b667cbc93
commit 8b0df0ee11
33 changed files with 235 additions and 183 deletions

View File

@@ -7,7 +7,7 @@ macro usz _strlen(ptr) @private
return len;
}
macro int @main_to_err_main(#m, int, char**) => catch(#m()) ? 1 : 0;
macro int @main_to_err_main(#m, int, char**) => catch? #m() ? 1 : 0;
macro int @main_to_int_main(#m, int, char**) => #m();
macro int @main_to_void_main(#m, int, char**)
{
@@ -32,7 +32,7 @@ macro int @main_to_err_main_args(#m, int argc, char** argv)
{
String[] list = args_to_strings(argc, argv);
defer free(list.ptr);
return catch(#m(list)) ? 1 : 0;
return catch? #m(list) ? 1 : 0;
}
macro int @main_to_int_main_args(#m, int argc, char** argv)
@@ -79,7 +79,7 @@ macro void release_wargs(String[] list) @private
free(list.ptr);
}
macro int @win_to_err_main_noargs(#m, void* handle, Char16* cmd_line, int show_cmd) => catch(#m()) ? 1 : 0;
macro int @win_to_err_main_noargs(#m, void* handle, Char16* cmd_line, int show_cmd) => catch? #m() ? 1 : 0;
macro int @win_to_int_main_noargs(#m, void* handle, Char16* cmd_line, int show_cmd) => #m();
macro int @win_to_void_main_noargs(#m, void* handle, Char16* cmd_line, int show_cmd)
{
@@ -91,7 +91,7 @@ macro int @win_to_err_main_args(#m, void* handle, Char16* cmd_line, int show_cmd
{
String[] args = win_command_line_to_strings(cmd_line);
defer release_wargs(args);
return catch(#m(args)) ? 1 : 0;
return catch? #m(args) ? 1 : 0;
}
macro int @win_to_int_main_args(#m, void* handle, Char16* cmd_line, int show_cmd)
@@ -113,7 +113,7 @@ macro int @win_to_err_main(#m, void* handle, Char16* cmd_line, int show_cmd)
{
String[] args = win_command_line_to_strings(cmd_line);
defer release_wargs(args);
return catch(#m(handle, args, show_cmd)) ? 1 : 0;
return catch? #m(handle, args, show_cmd) ? 1 : 0;
}
macro int @win_to_int_main(#m, void* handle, Char16* cmd_line, int show_cmd)
@@ -135,7 +135,7 @@ macro int @wmain_to_err_main_args(#m, int argc, Char16** argv)
{
String[] args = wargs_strings(argc, argv);
defer release_wargs(args);
return catch(#m(args)) ? 1 : 0;
return catch? #m(args) ? 1 : 0;
}
macro int @wmain_to_int_main_args(#m, int argc, Char16** argv)