Merge branch 'dev' into fix/free_hwnd

This commit is contained in:
曾奥然
2025-10-28 13:09:06 +08:00
committed by GitHub
62 changed files with 231 additions and 129 deletions

View File

@@ -9,7 +9,7 @@
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* |
* Created On : <2023-08-28>
* Last Modified : <2025-10-07>
* Last Modified : <2025-10-15>
*
*
* xy: 襄阳、咸阳
@@ -122,15 +122,24 @@ xy =
#define assert_str(a, b) assert (xy_streql ((a), (b)))
#define xy_panic(reason) assert(!reason)
#define xy_throw(reason) assert(!reason)
// @flavor Perl, PHP, Raku
#define die xy_panic
/**
* @depreacated 避免消极用语
*
* @flavor Perl, PHP, Raku
*/
// #define die xy_throw
#define xy_unsupported() xy_panic("Unsuppoted")
#define xy_unimplemented() xy_panic("Unimplemented temporarily")
#define xy_unreached() xy_panic("This code shouldn't be reached")
#define xy_cant_be_null(p) if(!p) xy_panic("This pointer can't be null")
/**
* @depreacated 避免消极用语
*/
// #define xy_panic xy_throw
#define xy_unsupported() xy_throw("Unsuppoted")
#define xy_unimplemented() xy_throw("Unimplemented temporarily")
#define xy_unreached() xy_throw("This code shouldn't be reached")
#define xy_cant_be_null(p) if(!p) xy_throw("This pointer can't be null")
@@ -164,7 +173,7 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);}
bool: _xy_print_bool, \
char *: _xy_print_str, \
const char *: _xy_print_const_str, \
default: xy_panic("Unsupported type for print()!") \
default: xy_throw("Unsupported type for print()!") \
)(x)
/**
@@ -179,7 +188,7 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);}
bool: _xy_println_bool, \
char *: _xy_println_str, \
const char *: _xy_println_const_str, \
default: xy_panic("Unsupported type for println()/say()!") \
default: xy_throw("Unsupported type for println()/say()!") \
)(x)
/* @flavor Raku, Perl */
#define say println
@@ -1332,18 +1341,21 @@ xy_detect_os ()
char buf[256] = {0};
fread (buf, 1, sizeof (buf) - 1, fp);
fclose (fp);
if (strstr (buf, "Android"))
{
xy.on_android = true;
return;
}
else if (strstr (buf, "Linux"))
if (strstr (buf, "Linux"))
{
xy.on_linux = true;
return;
}
}
// @consult https://android.googlesource.com/platform/system/core/+/refs/heads/main/rootdir/init.environ.rc.in
char *android_env = getenv ("ANDROID_ROOT");
if (xy_str_find (android_env, "/system").found)
{
xy.on_android = true;
return;
}
/* 判断 macOS */
DIR *d = opendir ("/System/Applications");
if (d)
@@ -1354,6 +1366,7 @@ xy_detect_os ()
{
xy.on_macos = true;
closedir (d);
return;
}
}
@@ -1376,10 +1389,11 @@ xy_detect_os ()
pclose (fp);
if (strstr (buf, "BSD") != NULL)
xy.on_bsd = true;
return;
}
if (!(xy.on_windows || xy.on_linux || xy.on_android || xy.on_macos || xy.on_bsd))
xy_panic ("Unknown operating system");
xy_throw ("Unknown operating system");
}
@@ -1488,7 +1502,7 @@ xy_seq_at (XySeq_t *seq, int n)
{
xy_cant_be_null (seq);
if (0 == n) xy_panic ("The index must begin from 1, not 0");
if (0 == n) xy_throw ("The index must begin from 1, not 0");
if (1 == n) return seq->first_item ? seq->first_item->data : NULL;