## Summary Standardize naming conventions across the entire wizapp-stdlib codebase by replacing inconsistent prefixes and snake_case with a unified `wp` prefix + CamelCase scheme. ## Changes ### Naming convention applied | Pattern | Before | After | |---|---|---| | Public functions | `wapp_module_function` | `wpModuleFunction` | | Public types | `GenericXxx`, bare `Xxx` | `WpXxx` | | Constants / enum values | `WAPP_XXX`, `SHELL_XXX` | `WP_XXX`, `WP_SHELL_XXX` | | Internal functions | `_module_function` | `_moduleFunction` | | Storage-class macros | `wapp_extern`, `wapp_intern` | `wp_extern`, `wp_intern` | ### Modules affected All 20 modules were renamed: `arena`, `array`, `dbl_list`, `queue`, `str8`, `mem_allocator`, `mem_utils`, `mem_os`, `file`, `cpath`, `log`, `shell_commander`, `shell_termcolour`, `shell_utils`, `prng/xorshift`, `uuid`, `tester`, `aliases`, `assert`, `misc_utils`, `platform` — plus their test files. ### Backward compatibility Added `src/oldnames.h` with `#define OLD_NAME NEW_NAME` for every renamed symbol, organized by module under Constants → Types → Functions sections. Existing code that includes this file will compile without changes. Reviewed-on: #12 Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com> Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
This commit was merged in pull request #12.
This commit is contained in:
@@ -12,13 +12,13 @@ struct SplitMix64State {
|
||||
u64 seed;
|
||||
};
|
||||
|
||||
wapp_intern u64 rol64(u64 x, u64 bits);
|
||||
wapp_intern u64 split_mix_64(SplitMix64State *state);
|
||||
wapp_intern void seed_os_generator(void);
|
||||
wapp_intern u64 generate_random_number(void);
|
||||
wp_intern u64 rol64(u64 x, u64 bits);
|
||||
wp_intern u64 split_mix_64(SplitMix64State *state);
|
||||
wp_intern void seed_os_generator(void);
|
||||
wp_intern u64 generate_random_number(void);
|
||||
|
||||
XOR256State wapp_prng_xorshift_init_state(void) {
|
||||
wapp_persist b8 seeded = false;
|
||||
WpXor256State wpPrngXorshiftInit(void) {
|
||||
wp_persist b8 seeded = false;
|
||||
if (!seeded) {
|
||||
seeded = true;
|
||||
seed_os_generator();
|
||||
@@ -26,7 +26,7 @@ XOR256State wapp_prng_xorshift_init_state(void) {
|
||||
|
||||
SplitMix64State sm64 = {.seed = generate_random_number()};
|
||||
|
||||
return (XOR256State){
|
||||
return (WpXor256State){
|
||||
.x = split_mix_64(&sm64),
|
||||
.y = split_mix_64(&sm64),
|
||||
.z = split_mix_64(&sm64),
|
||||
@@ -34,7 +34,7 @@ XOR256State wapp_prng_xorshift_init_state(void) {
|
||||
};
|
||||
}
|
||||
|
||||
u64 wapp_prng_xorshift_256(XOR256State *state) {
|
||||
u64 wpPrngXorshift256(WpXor256State *state) {
|
||||
u64 t = state->x ^ (state->x << 11);
|
||||
|
||||
state->x = state->y;
|
||||
@@ -45,7 +45,7 @@ u64 wapp_prng_xorshift_256(XOR256State *state) {
|
||||
return state->w;
|
||||
}
|
||||
|
||||
u64 wapp_prng_xorshift_256ss(XOR256State *state) {
|
||||
u64 wpPrngXorshift256ss(WpXor256State *state) {
|
||||
const u64 result = rol64(state->z * 5, 7) * 9;
|
||||
const u64 t = state->z << 17;
|
||||
|
||||
@@ -60,7 +60,7 @@ u64 wapp_prng_xorshift_256ss(XOR256State *state) {
|
||||
return result;
|
||||
}
|
||||
|
||||
u64 wapp_prng_xorshift_256p(XOR256State *state) {
|
||||
u64 wpPrngXorshift256p(WpXor256State *state) {
|
||||
const u64 result = state->w + state->x;
|
||||
const u64 t = state->z << 17;
|
||||
|
||||
@@ -75,11 +75,11 @@ u64 wapp_prng_xorshift_256p(XOR256State *state) {
|
||||
return result;
|
||||
}
|
||||
|
||||
wapp_intern u64 rol64(u64 x, u64 bits) {
|
||||
wp_intern u64 rol64(u64 x, u64 bits) {
|
||||
return (x << bits) | (x >> (64 - bits));
|
||||
}
|
||||
|
||||
wapp_intern u64 split_mix_64(SplitMix64State *state) {
|
||||
wp_intern u64 split_mix_64(SplitMix64State *state) {
|
||||
state->seed += 0x9E3779B97f4A7C15;
|
||||
|
||||
u64 result = state->seed;
|
||||
@@ -89,47 +89,47 @@ wapp_intern u64 split_mix_64(SplitMix64State *state) {
|
||||
return result ^ (result >> 31);
|
||||
}
|
||||
|
||||
#if defined(WAPP_PLATFORM_C) && WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C11_VERSION
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
wapp_intern void seed_os_generator(void) {
|
||||
#if defined(WP_PLATFORM_C) && WP_PLATFORM_C_VERSION >= WP_PLATFORM_C11_VERSION
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
wp_intern void seed_os_generator(void) {
|
||||
struct timespec ts = {0};
|
||||
int result = clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
|
||||
wapp_runtime_assert(result == 0, "Invalid seed value");
|
||||
wpRuntimeAssert(result == 0, "Invalid seed value");
|
||||
|
||||
srand48(ts.tv_nsec);
|
||||
}
|
||||
|
||||
wapp_intern u64 generate_random_number(void) {
|
||||
wp_intern u64 generate_random_number(void) {
|
||||
return lrand48();
|
||||
}
|
||||
#else
|
||||
wapp_intern void seed_os_generator(void) {
|
||||
wp_intern void seed_os_generator(void) {
|
||||
struct timespec ts = {0};
|
||||
int result = timespec_get(&ts, TIME_UTC);
|
||||
wapp_runtime_assert(result != 0, "Invalid seed value");
|
||||
wpRuntimeAssert(result != 0, "Invalid seed value");
|
||||
|
||||
srand(ts.tv_nsec);
|
||||
}
|
||||
|
||||
wapp_intern u64 generate_random_number(void) {
|
||||
wp_intern u64 generate_random_number(void) {
|
||||
i32 n1 = rand();
|
||||
i32 n2 = rand();
|
||||
|
||||
return (((u64)n1) << 32 | (u64)n2);
|
||||
}
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
#else
|
||||
wapp_intern void seed_os_generator(void) {
|
||||
wp_intern void seed_os_generator(void) {
|
||||
time_t result = time(NULL);
|
||||
wapp_runtime_assert(result != (time_t)(-1), "Invalid seed value");
|
||||
wpRuntimeAssert(result != (time_t)(-1), "Invalid seed value");
|
||||
|
||||
srand(result);
|
||||
}
|
||||
|
||||
wapp_intern u64 generate_random_number(void) {
|
||||
wp_intern u64 generate_random_number(void) {
|
||||
i32 n1 = rand();
|
||||
i32 n2 = rand();
|
||||
|
||||
return (((u64)n1) << 32 | (u64)n2);
|
||||
}
|
||||
#endif // !WAPP_PLATFORM_C
|
||||
#endif // !WP_PLATFORM_C
|
||||
|
||||
Reference in New Issue
Block a user