Standardize naming conventions (#12)
Release / release (push) Successful in 8s

## 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:
2026-06-26 17:17:27 +00:00
committed by Abdelrahman Said
parent ea689e7357
commit a998f6b981
89 changed files with 4081 additions and 3486 deletions
+62 -62
View File
@@ -11,115 +11,115 @@
#define MIN_LOG_MSG_LENGTH 32
#define TIME_BUF_CAPACITY 70
wapp_intern Str8RO L_BRACKET = wapp_str8_lit_ro("[");
wapp_intern Str8RO R_BRACKET_SPACE = wapp_str8_lit_ro("] ");
wapp_intern Str8RO R_BRACKET_NEWLINE = wapp_str8_lit_ro("]\n");
wp_intern WpStr8RO L_BRACKET = wpStr8LitRo("[");
wp_intern WpStr8RO R_BRACKET_SPACE = wpStr8LitRo("] ");
wp_intern WpStr8RO R_BRACKET_NEWLINE = wpStr8LitRo("]\n");
typedef struct {
WFile *outlog;
WFile *errlog;
LogLevel level;
WpFile *outlog;
WpFile *errlog;
WpLogLevel level;
wapp_misc_utils_reserve_padding(2 * sizeof(WFile *) + sizeof(LogLevel));
wpMiscUtilsReservePadding(2 * sizeof(WpFile *) + sizeof(WpLogLevel));
} LogConfig;
wapp_intern LogConfig LOG_CONFIG = {
.level = WAPP_LOG_DEBUG,
wp_intern LogConfig LOG_CONFIG = {
.level = WP_LOG_LEVEL_DEBUG,
};
wapp_intern Str8RO LOG_LEVEL_STRINGS[COUNT_LOG_LEVEL] = {
[WAPP_LOG_FATAL] = wapp_str8_lit_ro_initialiser_list("fatal "),
[WAPP_LOG_CRITICAL] = wapp_str8_lit_ro_initialiser_list("critical "),
[WAPP_LOG_ERROR] = wapp_str8_lit_ro_initialiser_list("error "),
[WAPP_LOG_WARNING] = wapp_str8_lit_ro_initialiser_list("warning "),
[WAPP_LOG_INFO] = wapp_str8_lit_ro_initialiser_list("info "),
[WAPP_LOG_DEBUG] = wapp_str8_lit_ro_initialiser_list("debug "),
wp_intern WpStr8RO LOG_LEVEL_STRINGS[COUNT_LOG_LEVEL] = {
[WP_LOG_LEVEL_FATAL] = wpStr8LitRoInitialiserList("fatal "),
[WP_LOG_LEVEL_CRITICAL] = wpStr8LitRoInitialiserList("critical "),
[WP_LOG_LEVEL_ERROR] = wpStr8LitRoInitialiserList("error "),
[WP_LOG_LEVEL_WARNING] = wpStr8LitRoInitialiserList("warning "),
[WP_LOG_LEVEL_INFO] = wpStr8LitRoInitialiserList("info "),
[WP_LOG_LEVEL_DEBUG] = wpStr8LitRoInitialiserList("debug "),
};
wapp_intern void _get_current_time_string(Str8 *dst);
wapp_intern void _write_log_line(WFile *fp, const Logger *logger, Str8 msg, LogLevel level);
wp_intern void _get_current_time_string(WpStr8 *dst);
wp_intern void _write_log_line(WpFile *fp, const WpLogger *logger, WpStr8 msg, WpLogLevel level);
void wapp_log_set_level(LogLevel level) {
void wpLogSetLevel(WpLogLevel level) {
LOG_CONFIG.level = level;
}
void wapp_log_configure(WFile *outlog, WFile *errlog, LogLevel level) {
void wpLogConfigure(WpFile *outlog, WpFile *errlog, WpLogLevel level) {
LOG_CONFIG.outlog = outlog;
LOG_CONFIG.errlog = errlog;
LOG_CONFIG.level = level;
}
Logger wapp_log_make_logger(Str8 name) {
return (Logger){ .name = name };
WpLogger wpLogMakeLogger(WpStr8 name) {
return (WpLogger){ .name = name };
}
void wapp_log_debug(const Logger *logger, Str8 msg) {
wapp_debug_assert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WAPP_LOG_DEBUG) { return; }
void wpLogDebug(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_DEBUG) { return; }
WFile *fp = LOG_CONFIG.outlog != NULL ? LOG_CONFIG.outlog : wapp_file_stdout();
_write_log_line(fp, logger, msg, WAPP_LOG_DEBUG);
WpFile *fp = LOG_CONFIG.outlog != NULL ? LOG_CONFIG.outlog : wpFileStdout();
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_DEBUG);
}
void wapp_log_info(const Logger *logger, Str8 msg) {
wapp_debug_assert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WAPP_LOG_INFO) { return; }
void wpLogInfo(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_INFO) { return; }
WFile *fp = LOG_CONFIG.outlog != NULL ? LOG_CONFIG.outlog : wapp_file_stdout();
_write_log_line(fp, logger, msg, WAPP_LOG_INFO);
WpFile *fp = LOG_CONFIG.outlog != NULL ? LOG_CONFIG.outlog : wpFileStdout();
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_INFO);
}
void wapp_log_warning(const Logger *logger, Str8 msg) {
wapp_debug_assert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WAPP_LOG_WARNING) { return; }
void wpLogWarning(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_WARNING) { return; }
WFile *fp = LOG_CONFIG.outlog != NULL ? LOG_CONFIG.outlog : wapp_file_stdout();
_write_log_line(fp, logger, msg, WAPP_LOG_WARNING);
WpFile *fp = LOG_CONFIG.outlog != NULL ? LOG_CONFIG.outlog : wpFileStdout();
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_WARNING);
}
void wapp_log_error(const Logger *logger, Str8 msg) {
wapp_debug_assert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WAPP_LOG_ERROR) { return; }
void wpLogError(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_ERROR) { return; }
WFile *fp = LOG_CONFIG.errlog != NULL ? LOG_CONFIG.errlog : wapp_file_stderr();
_write_log_line(fp, logger, msg, WAPP_LOG_ERROR);
WpFile *fp = LOG_CONFIG.errlog != NULL ? LOG_CONFIG.errlog : wpFileStderr();
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_ERROR);
}
void wapp_log_critical(const Logger *logger, Str8 msg) {
wapp_debug_assert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WAPP_LOG_CRITICAL) { return; }
void wpLogCritical(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_CRITICAL) { return; }
WFile *fp = LOG_CONFIG.errlog != NULL ? LOG_CONFIG.errlog : wapp_file_stderr();
_write_log_line(fp, logger, msg, WAPP_LOG_CRITICAL);
WpFile *fp = LOG_CONFIG.errlog != NULL ? LOG_CONFIG.errlog : wpFileStderr();
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_CRITICAL);
}
void wapp_log_fatal(const Logger *logger, Str8 msg) {
wapp_debug_assert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WAPP_LOG_FATAL) { return; }
void wpLogFatal(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_FATAL) { return; }
WFile *fp = LOG_CONFIG.errlog != NULL ? LOG_CONFIG.errlog : wapp_file_stderr();
_write_log_line(fp, logger, msg, WAPP_LOG_FATAL);
WpFile *fp = LOG_CONFIG.errlog != NULL ? LOG_CONFIG.errlog : wpFileStderr();
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_FATAL);
}
wapp_intern void _get_current_time_string(Str8 *dst) {
wp_intern void _get_current_time_string(WpStr8 *dst) {
// TODO (Abdelrahman): Replace with proper date/time utilities
char buf[TIME_BUF_CAPACITY];
time_t now = time(NULL);
struct tm utc;
gmtime_r(&now, &utc);
strftime(buf, sizeof(buf), "%FT%TZ ", &utc);
wapp_str8_copy_cstr_capped(dst, buf);
wpStr8CopyCstrCapped(dst, buf);
}
wapp_intern void _write_log_line(WFile *fp, const Logger *logger, Str8 msg, LogLevel level) {
Str8 padding = wapp_str8_buf(MIN_LOG_MSG_LENGTH);
wp_intern void _write_log_line(WpFile *fp, const WpLogger *logger, WpStr8 msg, WpLogLevel level) {
WpStr8 padding = wpStr8Buf(MIN_LOG_MSG_LENGTH);
u32 padding_size = msg.size < MIN_LOG_MSG_LENGTH ? MIN_LOG_MSG_LENGTH - msg.size + 1 : 0;
wapp_str8_format(&padding, "%-*s", padding_size, " ");
wpStr8Format(&padding, "%-*s", padding_size, " ");
Str8 time_str = wapp_str8_buf(TIME_BUF_CAPACITY);
WpStr8 time_str = wpStr8Buf(TIME_BUF_CAPACITY);
_get_current_time_string(&time_str);
Str8RO **strings = wapp_array(
Str8RO *,
WpStr8RO **strings = wpArray(
WpStr8RO *,
&time_str,
&L_BRACKET,
&LOG_LEVEL_STRINGS[level],
@@ -131,7 +131,7 @@ wapp_intern void _write_log_line(WFile *fp, const Logger *logger, Str8 msg, LogL
&R_BRACKET_NEWLINE
);
for (u64 i = 0; i < wapp_array_count(strings); ++i) {
wapp_file_write_str8(strings[i], fp);
for (u64 i = 0; i < wpArrayCount(strings); ++i) {
wpFileWriteStr8(strings[i], fp);
}
}