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
parent ea689e7357
commit a998f6b981
89 changed files with 4081 additions and 3486 deletions
+37 -37
View File
@@ -17,85 +17,85 @@
#define CMD_BUF_LEN 8192
#define OUT_BUF_LEN 4096
wapp_intern CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf);
wapp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf);
wp_intern WpCmdResult executeCommand(WpStr8RO *cmd, WpCmdOutHandling out_handling, WpStr8 *out_buf);
wp_intern WpCmdError getCommandOutput(FILE *fp, WpCmdOutHandling out_handling, WpStr8 *out_buf);
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd) {
WpCmdResult wpShellCommanderExecute(WpCmdOutHandling out_handling, WpStr8 *out_buf, const WpStr8List *cmd) {
if (!cmd) {
return CMD_NO_EXIT(SHELL_ERR_INVALID_ARGS);
return wpCmdNoExit(WP_SHELL_ERR_INVALID_ARGS);
}
Allocator arena = wapp_mem_arena_allocator_init(KiB(500));
WpAllocator arena = wpMemArenaAllocatorInit(KiB(500));
Str8 *cmd_str = wapp_str8_join(&arena, cmd, &wapp_str8_lit_ro(" "));
WpStr8 *cmd_str = wpStr8Join(&arena, cmd, &wpStr8LitRo(" "));
if (!cmd_str) {
wapp_mem_arena_allocator_destroy(&arena);
return CMD_NO_EXIT(SHELL_ERR_ALLOCATION_FAIL);
wpMemArenaAllocatorDestroy(&arena);
return wpCmdNoExit(WP_SHELL_ERR_ALLOCATION_FAIL);
}
// Redirect output
cmd_str = wapp_str8_alloc_concat(&arena, cmd_str, &wapp_str8_lit_ro(" 2>&1"));
cmd_str = wpStr8AllocConcat(&arena, cmd_str, &wpStr8LitRo(" 2>&1"));
CMDResult output = execute_command(cmd_str, out_handling, out_buf);
WpCmdResult output = executeCommand(cmd_str, out_handling, out_buf);
wapp_mem_arena_allocator_destroy(&arena);
wpMemArenaAllocatorDestroy(&arena);
return output;
}
wapp_intern CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf) {
wp_intern WpCmdResult executeCommand(WpStr8RO *cmd, WpCmdOutHandling out_handling, WpStr8 *out_buf) {
char cmd_buf[CMD_BUF_LEN] = {0};
wapp_str8_copy_to_cstr(cmd_buf, cmd, CMD_BUF_LEN);
wpStr8CopyToCstr(cmd_buf, cmd, CMD_BUF_LEN);
FILE *fp = wapp_shell_utils_popen(cmd_buf, "r");
FILE *fp = wpShellUtilsPopen(cmd_buf, "r");
if (!fp) {
return CMD_NO_EXIT(SHELL_ERR_PROC_START_FAIL);
return wpCmdNoExit(WP_SHELL_ERR_PROC_START_FAIL);
}
CMDResult output;
WpCmdResult output;
CMDError err = get_command_output(fp, out_handling, out_buf);
if (err > SHELL_ERR_NO_ERROR) {
output = CMD_NO_EXIT(err);
goto EXECUTE_COMMAND_CLOSE;
WpCmdError err = getCommandOutput(fp, out_handling, out_buf);
if (err > WP_SHELL_ERR_NO_ERROR) {
output = wpCmdNoExit(err);
goto executeCommand_CLOSE;
}
i32 st = EXIT_SUCCESS;
err = get_output_status(fp, &st);
if (err > SHELL_ERR_NO_ERROR) {
output = CMD_NO_EXIT(err);
goto EXECUTE_COMMAND_CLOSE;
err = _getOutputStatus(fp, &st);
if (err > WP_SHELL_ERR_NO_ERROR) {
output = wpCmdNoExit(err);
goto executeCommand_CLOSE;
}
// Process is already closed in get_output_status
// Process is already closed in _getOutputStatus
fp = NULL;
output = (CMDResult){
output = (WpCmdResult){
.exited = true,
.exit_code = st,
.error = SHELL_ERR_NO_ERROR,
.error = WP_SHELL_ERR_NO_ERROR,
};
EXECUTE_COMMAND_CLOSE:
executeCommand_CLOSE:
if (fp) {
wapp_shell_utils_pclose(fp);
wpShellUtilsPclose(fp);
}
return output;
}
wapp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf) {
Str8 out = wapp_str8_buf(OUT_BUF_LEN);
wp_intern WpCmdError getCommandOutput(FILE *fp, WpCmdOutHandling out_handling, WpStr8 *out_buf) {
WpStr8 out = wpStr8Buf(OUT_BUF_LEN);
out.size = fread((void *)out.buf, sizeof(c8), out.capacity, fp);
if (out_handling == SHELL_OUTPUT_CAPTURE && out_buf != NULL) {
if (out_handling == WP_SHELL_OUTPUT_CAPTURE && out_buf != NULL) {
if (out.size >= out_buf->capacity) {
return SHELL_ERR_OUT_BUF_FULL;
return WP_SHELL_ERR_OUT_BUF_FULL;
}
wapp_str8_concat_capped(out_buf, &out);
} else if (out_handling == SHELL_OUTPUT_PRINT) {
printf(WAPP_STR8_SPEC, wapp_str8_varg(out));
wpStr8ConcatCapped(out_buf, &out);
} else if (out_handling == WP_SHELL_OUTPUT_PRINT) {
printf(WP_STR8_SPEC, wpStr8Varg(out));
}
return SHELL_ERR_NO_ERROR;
return WP_SHELL_ERR_NO_ERROR;
}
+7 -7
View File
@@ -12,18 +12,18 @@
// TODO (Abdelrahman): This module needs rethinking
#ifdef WAPP_PLATFORM_CPP
#ifdef WP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !WP_PLATFORM_CPP
#define CMD_NO_EXIT(ERR) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
#define wpCmdNoExit(ERR) ((WpCmdResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd);
WpCmdResult wpShellCommanderExecute(WpCmdOutHandling out_handling, WpStr8 *out_buf, const WpStr8List *cmd);
wapp_extern CMDError get_output_status(FILE *fp, i32 *status_out);
wp_extern WpCmdError _getOutputStatus(FILE *fp, i32 *status_out);
#ifdef WAPP_PLATFORM_CPP
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !WP_PLATFORM_CPP
#endif // !COMMANDER_H
+19 -19
View File
@@ -7,36 +7,36 @@
#include "../../../common/platform/platform.h"
#include "../../../common/misc/misc_utils.h"
#ifdef WAPP_PLATFORM_CPP
#ifdef WP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !WP_PLATFORM_CPP
typedef enum {
SHELL_OUTPUT_DISCARD,
SHELL_OUTPUT_PRINT,
SHELL_OUTPUT_CAPTURE,
} CMDOutHandling;
WP_SHELL_OUTPUT_DISCARD,
WP_SHELL_OUTPUT_PRINT,
WP_SHELL_OUTPUT_CAPTURE,
} WpCmdOutHandling;
typedef enum {
SHELL_ERR_NO_ERROR,
SHELL_ERR_INVALID_ARGS,
SHELL_ERR_ALLOCATION_FAIL,
SHELL_ERR_PROC_START_FAIL,
SHELL_ERR_OUT_BUF_FULL,
SHELL_ERR_PROC_EXIT_FAIL,
} CMDError;
WP_SHELL_ERR_NO_ERROR,
WP_SHELL_ERR_INVALID_ARGS,
WP_SHELL_ERR_ALLOCATION_FAIL,
WP_SHELL_ERR_PROC_START_FAIL,
WP_SHELL_ERR_OUT_BUF_FULL,
WP_SHELL_ERR_PROC_EXIT_FAIL,
} WpCmdError;
typedef struct CMDResult CMDResult;
struct CMDResult {
typedef struct WpCmdResult WpCmdResult;
struct WpCmdResult {
i32 exit_code;
CMDError error;
WpCmdError error;
b8 exited;
wapp_misc_utils_reserve_padding(sizeof(b8) + sizeof(i32) + sizeof(CMDError));
wpMiscUtilsReservePadding(sizeof(b8) + sizeof(i32) + sizeof(WpCmdError));
};
#ifdef WAPP_PLATFORM_CPP
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !WP_PLATFORM_CPP
#endif // !COMMANDER_OUTPUT_H
@@ -3,23 +3,23 @@
#include "../../../../common/aliases/aliases.h"
#include "../../../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_POSIX
#ifdef WP_PLATFORM_POSIX
#include "../commander_output.h"
#include "../../utils/shell_utils.h"
#include <stdio.h>
#include <stdlib.h>
CMDError get_output_status(FILE *fp, i32 *status_out) {
*status_out = wapp_shell_utils_pclose(fp);
WpCmdError _getOutputStatus(FILE *fp, i32 *status_out) {
*status_out = wpShellUtilsPclose(fp);
if (!WIFEXITED(*status_out)) {
return SHELL_ERR_PROC_EXIT_FAIL;
return WP_SHELL_ERR_PROC_EXIT_FAIL;
}
*status_out = WEXITSTATUS(*status_out);
return SHELL_ERR_NO_ERROR;
return WP_SHELL_ERR_NO_ERROR;
}
#endif // !WAPP_PLATFORM_POSIX
#endif // !WP_PLATFORM_POSIX
+7 -7
View File
@@ -3,22 +3,22 @@
#include "../../../../common/aliases/aliases.h"
#include "../../../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_WINDOWS
#ifdef WP_PLATFORM_WINDOWS
#include "../commander_output.h"
#include "../../utils/shell_utils.h"
#include <stdio.h>
CMDError get_output_status(FILE *fp, i32 *status_out) {
WpCmdError _getOutputStatus(FILE *fp, i32 *status_out) {
if (!feof(fp)) {
// Ensure process is closed on failure
wapp_shell_utils_pclose(fp);
return SHELL_ERR_PROC_EXIT_FAIL;
wpShellUtilsPclose(fp);
return WP_SHELL_ERR_PROC_EXIT_FAIL;
}
*status_out = wapp_shell_utils_pclose(fp);
*status_out = wpShellUtilsPclose(fp);
return SHELL_ERR_NO_ERROR;
return WP_SHELL_ERR_NO_ERROR;
}
#endif // !WAPP_PLATFORM_WINDOWS
#endif // !WP_PLATFORM_WINDOWS