Skip to content

Commit

Permalink
sili v0.2.0-dev-4
Browse files Browse the repository at this point in the history
Documentation:
- 'siMemory' section is moved above the 'siAllocator' section.
- `si_utf<8/16>ToUtf<16/8>Str` functions now first take the input as an argument rather than the output to make it consistent with other sili functions.
- Path & file functions have had their documentation reworked.
- `siIOType` -> `siIoType`.
- `SI_IO_TYPE_<NAME>` -> `siIoType_<Name>`.
- Directory functions have been given documentation.
- `si_numLeadingBit` function has been split into `si_numLeadingZeros` and `si_numLeadingOnes`.
- `si_cpuProcessorCount` has been given documentation.
- Print functions have had their documentation reworked.
- `siPrintColorAnsi` -> `siPrintColor3bit`

Additions:
- New memory alignment functions: `si_isPowerOfTwo` and `si_alignForward`.
- New memory pointer functions: `si_pointerAdd`, `si_pointerSub`, `si_pointerAddConst`, `si_pointerSubConst` and `si_pointerDiff`.
- `SI_ERROR_CHECK_EX` is changed to take an action instead of a return value, making it more versatile.
- New siArray macro: `SI_BUF_STACK`.
- `tests/bit.c` now has a test for `si_numLeadingZeros`/`si_numLeadingOnes`.
- `si_directoryClose` function has been added.
- A few specific warnings were fixed.

Bug fixes:
- `si_utf16Decode` returns the correct UTF-8 length.
- `si_numLeadingZeros` and `si_numLeadingOnes` functions now return correct results.
- `si_directoryPollEntryEx` is less bug-prone now.

Removals:
- String function `si_stringMakeFmt`.
- Every `siFilePermissions` enumerators and functions, including `si_pathCreateFolderEx`.
- `SI_IO_TYPE_ANY`, `SI_IO_TYPE_BITS` and `SI_IO_TYPE_BITS_ALL`.
- `si_timeStampPrintSinceEx` function declaration.
- `si_alignCeilEx` has been removed for `si_alignForward`.
  • Loading branch information
EimaMei committed Dec 8, 2024
1 parent b8b1734 commit 29155c7
Show file tree
Hide file tree
Showing 9 changed files with 576 additions and 622 deletions.
2 changes: 1 addition & 1 deletion examples/bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int main(void) {
si_printf(
"Leading 1s of '%#b': '%zd', trailing 0s: '%zd'\n",
leadTrailNum,
si_numLeadingBit(u8, leadTrailNum, SI_BIT_ONE), si_numTrailingBit(u8, leadTrailNum, SI_BIT_ZERO)
si_numLeadingOnes(u8, leadTrailNum), si_numTrailingBit(u8, leadTrailNum, SI_BIT_ZERO)
);

u32 rotateAdr = si_numRotateLeft(u32, 0x00001234, 24);
Expand Down
21 changes: 3 additions & 18 deletions examples/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,6 @@ void example3(void) {
si_printf("Error '%S' occurred: '%S'\n", si_pathFsErrorName(res.code), si_pathFsErrorDesc(res.code));
#endif
}
{
siString test_folder = SI_STR("testFolder");

siError res = si_pathCreateFolder(test_folder);
SI_ASSERT(res.code == 0 || si_pathExists(test_folder));

siFilePermissions perms = si_pathPermissions(test_folder);
si_printf("Permissions of 'testFolder' (in octal): %o\n", perms);

si_pathEditPermissions(test_folder, SI_FS_PERM_ALL);
perms = si_pathPermissions(test_folder);
si_printf("Permissions of 'testFolder' (in octal): %o\n", perms);

si_pathRemove(test_folder);
}

{
u64 lastWriteTime, curWriteTime;
Expand Down Expand Up @@ -238,7 +223,7 @@ void example4(void) {
siDirectoryEntry entry;

usize count = 0;
while (si_directoryPollEntryEx(&dir, &entry, false)) {
while (si_directoryPollEntry(&dir, &entry)) {
si_printf(
"%zu: %S ('%zu' bytes, type '%i')\n",
count, entry.path, entry.path.len, entry.type
Expand Down Expand Up @@ -266,12 +251,12 @@ void example5(siAllocator* alloc) {
si_printf(
"%CThis text will be displayed in red%C, while this - %Cin blue%C!\n"
"%CSome terminals might support 8-bit color%C, %Csome may even have 24-bit color support.%C\n",
si_printColor3bit(siPrintColorAnsi_Red), si_printColor3bitEx(siPrintColorAnsi_Blue, true, true),
si_printColor3bit(siPrintColor3bit_Red), si_printColor3bitEx(siPrintColor3bit_Blue, true, true),
si_printColor8bit(202), si_printColor24bit(90, 242, 166)
);
si_fprintf(
si_stdout,
"Unicode works both on Unix and Windows* (ąčęėįšųū„“)\n\t%C* - Works as long as the font supports the codepoint, which for some reason isn't common.%C\n",
si_printColor3bit(siPrintColorAnsi_Yellow)
si_printColor3bit(siPrintColor3bit_Yellow)
);
}
4 changes: 2 additions & 2 deletions siarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ void si_argvHelp(siOptionContext ctx) {

SIDEF
void si_argvError(siOptionContext ctx) {
siPrintColor red = si_printColor3bitEx(siPrintColorAnsi_Red, true, false),
bold = si_printColor3bitEx(siPrintColorAnsi_White, true, true);
siPrintColor red = si_printColor3bitEx(siPrintColor3bit_Red, true, false),
bold = si_printColor3bitEx(siPrintColor3bit_White, true, true);
siArgvOption* option = ctx.error.option;
siString type = si__argvType(option->type);

Expand Down
Loading

0 comments on commit 29155c7

Please sign in to comment.