241 Commits

Author SHA1 Message Date
Abdelrahman Said eb98de7c2b Unify build flags 2025-08-16 13:16:21 +01:00
abdelrahman d3fccd61b5 Reintroduce C++ support and add usage tests for C++ (#4)
Reviewed-on: #4
Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com>
Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
2025-08-10 22:33:40 +00:00
abdelrahman 011083ab83 Replace bool, true and false with aliases 2025-08-09 22:38:03 +01:00
abdelrahman b8c548ee4b Add static, runtime and debug assert utilities 2025-08-09 22:37:55 +01:00
abdelrahman 75be2316e0 Add vim encoding and folding marker 2025-08-09 14:35:28 +01:00
Abdelrahman Said d452225d02 Don't use uchar.h on macos 2025-05-20 16:52:12 +01:00
abdelrahman 74164717d0 Fix bug in array codegen 2025-05-05 19:15:58 +01:00
abdelrahman 6c8434a530 Use asserts in array 2025-05-05 20:06:58 +01:00
abdelrahman cac66b9dbb Use asserts in dbl_list 2025-05-05 19:55:42 +01:00
abdelrahman 175f627f93 Remove text from asserts 2025-05-05 19:29:44 +01:00
abdelrahman be30189d15 Assert uuid argument isn't NULL 2025-05-05 19:12:13 +01:00
abdelrahman 3689c17d09 Use asserts to validate arguments for Str8 2025-05-05 19:08:44 +01:00
abdelrahman 8e952d9bc8 Use assert to validate inputs to allocator functions 2025-05-05 19:01:10 +01:00
abdelrahman def7576101 Use asserts in arena 2025-05-05 18:57:11 +01:00
abdelrahman 3fed536a74 Use assert in wapp_mem_util_align_forward instead of returning NULL 2025-05-05 18:51:10 +01:00
abdelrahman aae39fe656 Fix MSVC errors 2025-05-05 16:41:56 +01:00
abdelrahman 4e3945d1d0 Refactor array to avoid having to include external types 2025-05-05 16:33:08 +01:00
abdelrahman 98a802e3eb Remove C++ pseudo support 2025-05-05 02:48:35 +01:00
abdelrahman 0d4aa7a9c2 Modify README.md 2025-05-05 02:28:29 +01:00
abdelrahman a229f9be8c Run codegen on Linux 2025-05-05 00:04:24 +01:00
abdelrahman 2156d2ff3a Fix MSVC Spectre warnings 2025-05-04 23:59:50 +01:00
abdelrahman 12f083edb0 Add code generation for array 2025-05-04 23:26:03 +01:00
abdelrahman f444911452 Refactor strings and allocator to primitives 2025-05-04 23:25:27 +01:00
abdelrahman 163283f77f Remove unnecessary separate handling for bool type 2025-05-04 22:20:38 +01:00
abdelrahman 6064ed346c Ensure arena capacity is a power of 2 2025-05-04 18:02:32 +01:00
abdelrahman 77f3c40ebd Add copy array with allocation and finish writing array tests 2025-04-27 19:30:14 +01:00
abdelrahman d3f1686d58 Add testing for i32 array to test array logic 2025-04-21 17:47:33 +01:00
abdelrahman a359331df7 Complete array implementation before moving it to codegen 2025-04-21 17:46:59 +01:00
abdelrahman 14115f7e7e Move rounding up and va_args count to misc_utils 2025-04-21 17:46:27 +01:00
abdelrahman 12bd3eb489 Add .clangd config file 2025-04-21 14:21:40 +01:00
abdelrahman 266d43e262 Update Makefile 2025-04-21 14:16:54 +01:00
abdelrahman a568b30163 Update snippets 2025-04-21 13:52:24 +01:00
abdelrahman b1773746d8 Add missing include 2025-04-21 13:45:29 +01:00
abdelrahman a479a43f4c Reformat 2025-04-20 21:32:38 +01:00
abdelrahman b476ceaeef Fix MSVC Spectre warnings 2025-04-20 20:28:02 +01:00
abdelrahman 4d69b97149 Add /std:c11 to Windows build 2025-04-20 20:20:39 +01:00
abdelrahman 181c4b8614 Update xorshift 2025-04-20 20:47:20 +01:00
abdelrahman 0d541f6ee8 Add aliases.h and platform.h by default in codegen 2025-04-20 20:10:10 +01:00
abdelrahman 9e34b37d8d Update codegen with WAPP_PLATFORM_CPP 2025-04-20 19:57:57 +01:00
abdelrahman b884d0e6a6 Switch to using WAPP_PLATFORM_CPP instead of __cplusplus 2025-04-20 19:52:33 +01:00
abdelrahman 494bbeb398 Update platform cracking 2025-04-20 19:42:45 +01:00
abdelrahman 7605eb4e57 Add C and CPP version macros 2025-04-20 19:39:16 +01:00
abdelrahman 037b0fe698 Enforce C11 with GNU extensions on POSIX platforms 2025-04-20 18:28:17 +01:00
abdelrahman b13274cd81 Add compiler detection macros 2025-04-20 18:27:57 +01:00
abdelrahman 4f9f632362 Update windows build script 2025-04-20 17:28:38 +01:00
abdelrahman 6b039aeac0 Use posix path separator for codegen even on Windows 2025-04-20 16:47:11 +01:00
abdelrahman 2ab3bfc2e1 Fix wrong include 2025-04-20 16:46:31 +01:00
abdelrahman bf99bef291 Support multiple python versions for code generation 2025-04-20 16:23:23 +01:00
abdelrahman 50e23d8a13 Testing ideas for array implementation 2025-04-20 00:21:22 +01:00
abdelrahman 3a49dba366 Generate dbl_list for default C types 2025-04-19 22:17:26 +01:00
abdelrahman 1cfc52b35e Handle pointer types properly in dbl_list codegen 2025-04-19 21:27:00 +01:00
abdelrahman 25395553d7 Fix codegen hidden bugs 2025-04-19 21:11:10 +01:00
abdelrahman 9a651665ba Remove forward declaration from dbl_list source 2025-04-19 20:56:15 +01:00
abdelrahman 8dbdfa2094 Update dbl_list codegen 2025-04-19 20:54:04 +01:00
abdelrahman add2ba541d Merge branch 'codegen' 2025-04-19 13:52:27 +01:00
abdelrahman 63ed2633ea Update code generation to create one file for dbl_list 2025-04-19 13:33:09 +01:00
Abdelrahman Said 3c32b247c0 Upgrade codegen 2025-04-17 09:03:30 +01:00
Abdelrahman Said aa04fab6ea Update codegen 2025-04-16 10:05:42 +01:00
Abdelrahman Said 2017f6de79 Start updating code for new Str8List 2025-04-16 08:14:02 +01:00
Abdelrahman Said 63acdd1336 Fix codegen bugs 2025-04-16 08:13:31 +01:00
Abdelrahman Said cfa8094260 Fix codegen hidden bugs 2025-04-16 08:06:05 +01:00
Abdelrahman Said 31373eba03 Update dbl_list functionality 2025-04-16 00:42:20 +01:00
Abdelrahman Said 778a4da092 Add utility to create list node from item 2025-04-16 00:27:01 +01:00
Abdelrahman Said 6fb078a868 Remove codegen and implement dbl_list as generic container 2025-04-16 00:07:11 +01:00
abdelrahman 0942643b4e Update Makefile 2025-04-13 22:21:55 +01:00
Abdelrahman Said 0e5942af34 Switch to using Makefile for *nix systems 2025-04-13 20:11:05 +01:00
Abdelrahman Said c83c652b37 Add UUIDv4 generator 2025-03-22 02:27:59 +00:00
Abdelrahman Said 74428f1caf Rename xorshift functions 2025-03-22 00:30:20 +00:00
Abdelrahman Said d661312cfa Add xorshift prng 2025-03-16 22:34:56 +00:00
abdelrahman 70e075d2f6 Add message at top of codegen files to avoid overwriting them 2025-03-02 13:42:23 +00:00
abdelrahman 96db885344 Remove codegen as submodule and just add it in place 2025-03-02 13:28:26 +00:00
abdelrahman fb512e4a15 Add code generation for windows 2025-03-02 13:22:05 +00:00
abdelrahman 9361f0fe37 Run code generation for posix platforms 2025-03-02 13:20:51 +00:00
abdelrahman e7d2553400 Add code generation for doubly linked list 2025-03-02 13:20:27 +00:00
abdelrahman 509724cc31 Update .gitignore 2025-03-02 13:17:50 +00:00
Abdelrahman Said 82c23eed5e Use the wapp.h header in tests 2025-02-24 08:52:46 +00:00
Abdelrahman Said 9403193f09 Update build scripts 2025-02-24 07:58:42 +00:00
Abdelrahman Said fa1d9eec0d Fix files not using relative includes 2025-02-24 07:58:22 +00:00
Abdelrahman Said 4c14588d92 Update core headers and sources to use relative includes 2025-02-24 07:51:08 +00:00
Abdelrahman Said 9e66bd60bd Update testing headers to user relative includes 2025-02-24 07:24:26 +00:00
Abdelrahman Said ce4957d0a0 Update common headers to user relative includes 2025-02-24 07:21:28 +00:00
abdelrahman b9ea290322 Update posix compile script 2025-02-24 00:30:48 +00:00
abdelrahman 1479c13417 Move os layer to be part of the core 2025-02-24 00:30:25 +00:00
abdelrahman 4520f2269d Reorganise memory utilities 2025-02-24 00:21:14 +00:00
abdelrahman 6119cf5c5f Improve Str8 macros ergonomics 2025-02-23 23:53:28 +00:00
abdelrahman 358f61e556 Reorder tests 2025-02-23 19:27:54 +00:00
abdelrahman 7ac6100a5a Add platform detection to Windows build 2025-02-23 16:26:47 +00:00
abdelrahman 19efb08a3a Add platform detection to posix compilation script 2025-02-23 15:32:13 +00:00
abdelrahman 491c742189 Add single header and single source entries for all components as well as the full library (#2)
Reviewed-on: #2
Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com>
Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
2025-02-23 15:19:14 +00:00
abdelrahman 4f5dd3900f Remove unused join_root_and_leaf 2025-02-22 22:11:51 +00:00
abdelrahman dbedcb3100 Replace char * with Str8 in cpath dirup 2025-02-22 22:09:04 +00:00
abdelrahman d9314fb41e Update slice and substr functions 2025-02-22 21:34:29 +00:00
abdelrahman fe2bb65b06 Fix spectre warning for MSVC 2025-02-22 18:04:05 +00:00
abdelrahman ed4ec54c7a Switch wapp_cpath_join_path to use Str8 2025-02-22 17:48:25 +00:00
abdelrahman ba5e902a1d Add wapp_str8_push_back and wapp_str8_list_empty 2025-02-22 17:48:04 +00:00
abdelrahman 01f066d20c Add test for wapp_str8_format 2025-02-22 16:44:19 +00:00
abdelrahman 80bd68f313 Add string formatting to Str8 2025-02-22 16:41:05 +00:00
abdelrahman cda7e413e2 Rename tester directory 2025-02-22 15:26:40 +00:00
abdelrahman 54da75f89f Update comment for wapp_str8_lit_ro_initialiser_list 2025-02-22 15:03:13 +00:00
abdelrahman 7df64a3168 Fix ASan linking error when compiling with gcc 2025-02-22 14:58:41 +00:00
abdelrahman f9f8f092b5 Fix compilation error in gcc 2025-02-22 14:58:19 +00:00
abdelrahman f89a4bf343 Add wapp_str8_lit_ro_initialiser_list to fix gcc compilation errors 2025-02-22 14:33:15 +00:00
abdelrahman 0d795cc0d9 Update wapp_str8_alloc_buf to make a single big allocation 2025-02-22 13:54:03 +00:00
abdelrahman 28ac9ed8c8 Modify Str8 substr functionality 2025-02-22 13:39:03 +00:00
abdelrahman 99f7dcd794 Rename wapp_str8_buf_alloc to wapp_str8_alloc_buf 2025-02-18 21:02:02 +00:00
abdelrahman c5ca39939d Fix shell commander test on Windows 2025-02-16 22:44:42 +00:00
abdelrahman a308359942 Add wapp_str8_equal_to_count function 2025-02-16 22:44:18 +00:00
abdelrahman a3d9bcf1a1 Update .gitignore 2025-02-16 21:42:14 +00:00
Abdelrahman Said a534d44db5 Reduce arena size in wapp_shell_commander_execute 2025-02-16 21:39:09 +00:00
abdelrahman 11949e69be Update shell_commander to use Str8 instead of const char * 2025-02-16 21:31:22 +00:00
abdelrahman 2c9e4c91a0 Add function to copy Str8 to C string buffer 2025-02-16 21:30:25 +00:00
abdelrahman 76b078fbc0 Use str8_copy function in tester 2025-02-16 17:35:10 +00:00
abdelrahman 0569fca193 Add str8_copy functions 2025-02-16 17:34:48 +00:00
abdelrahman 6078e54087 Fix windows bugs 2025-02-16 17:09:40 +00:00
abdelrahman 180425707b Use Str8 instead of const char * in termcolour functions 2025-02-16 16:32:52 +00:00
abdelrahman 62dcfdaa93 Use Str8 instead of const char * in tester functions 2025-02-16 16:32:29 +00:00
abdelrahman 19134d0e15 Address Windows Spectre mitigation warnings 2025-02-16 14:55:17 +00:00
abdelrahman ca2b1cbf23 Reformat 2025-02-16 14:53:29 +00:00
abdelrahman f60442bfcf Fix bug with arena allocation on Windows 2025-02-16 14:52:31 +00:00
abdelrahman a4a1e82c40 Add tests for str8 splitting, joining and concatenation 2025-02-15 23:45:37 +00:00
abdelrahman d50b41acac Add str8 split, rsplit, join, concat and concat_capped functions 2025-02-15 23:45:07 +00:00
abdelrahman 71b6242f16 Update allocator free to take object size 2025-02-15 23:44:23 +00:00
abdelrahman 241edfc7e4 Change Str8Node to use Str8 instead of Str8RO 2025-02-15 20:36:31 +00:00
abdelrahman d635e03cd8 Add tests for Str8List utilities 2025-02-15 20:29:50 +00:00
abdelrahman 68fe421ab0 Add Str8List and str8 equality function 2025-02-15 20:29:15 +00:00
abdelrahman 622a4391a0 Update compile script 2025-02-15 10:49:23 +00:00
abdelrahman ff4d3c9e99 Add tests for string allocation functions 2025-02-09 18:47:10 +00:00
abdelrahman 023c74d8d9 Add functions to dynamically allocate strings 2025-02-09 18:46:32 +00:00
abdelrahman 86fe867011 Reformat 2025-02-09 18:21:36 +00:00
abdelrahman 98829b8400 Reformat 2025-02-09 18:19:27 +00:00
abdelrahman a7e98211f9 Update find and rfind tests 2025-02-09 16:41:29 +00:00
abdelrahman 4642361969 Add tests for find and rfind 2025-02-09 16:35:42 +00:00
abdelrahman 093d0daf6f Add find and rfine functions 2025-02-09 16:35:28 +00:00
abdelrahman f8e0804dd2 Fix unused variable error 2025-02-09 16:34:36 +00:00
abdelrahman fdb0650634 Add -Wextra flag for compilation 2025-02-09 16:34:12 +00:00
abdelrahman d1d6a8e64b Add utils for str8 printing 2025-02-09 15:13:50 +00:00
abdelrahman bbf38499ca Implement read-only string literals 2025-02-09 14:29:54 +00:00
abdelrahman 7657ad1b58 Remove libc allocator 2025-02-01 21:39:27 +00:00
abdelrahman 70399cb797 Change c16 and c32 defintions 2025-02-01 20:21:45 +00:00
abdelrahman 76c3b02e45 Change char type to c8 in Str8 functions 2024-10-17 00:13:35 +01:00
abdelrahman abf9b09495 Implement test for wapp_str8_set 2024-10-17 00:08:08 +01:00
abdelrahman 6d09059911 Change wapp_str8_lit implementation to support mutable string literals 2024-10-17 00:07:30 +01:00
abdelrahman 894ae028b7 Add aliases for character data types 2024-10-17 00:06:56 +01:00
abdelrahman 84a4ec223c Commit the Str8 tests 2024-10-08 23:58:24 +01:00
abdelrahman 8f10ac2916 Add string buffer macro and tests for Str8 2024-10-08 23:57:55 +01:00
abdelrahman bfb4e87a1e Remove extra spaces in aliases.h 2024-10-08 22:45:48 +01:00
abdelrahman 685682e1c8 revamp-strings (#1)
Co-authored-by: Abdelrahman Said <said.abdelrahman@flawlessai.com>
Reviewed-on: #1
Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com>
Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
2024-10-07 22:35:56 +00:00
abdelrahman 40d301fd95 Reformat 2024-10-06 21:31:04 +01:00
abdelrahman 7d8df816a5 Move cpath to os 2024-10-06 20:04:38 +01:00
abdelrahman 17f0f0eaf3 Fix cpath tests on Windows 2024-10-06 19:54:34 +01:00
abdelrahman ce656a6275 Fix Spectre warnings for MSVC 2024-10-06 19:54:13 +01:00
abdelrahman 8d8fcf9dc5 Improve early exit code in test_cpath 2024-10-06 19:33:13 +01:00
abdelrahman 77e634ec2d Fix comment 2024-10-06 19:30:19 +01:00
abdelrahman 22ece7215a Move path utils to os, fix bugs with it and write tests 2024-10-06 19:28:34 +01:00
abdelrahman 4af4b39d6f Remove unnecessary clang-format comments 2024-10-06 12:59:21 +01:00
abdelrahman a48002996e Reorganise src directory 2024-10-06 12:54:04 +01:00
abdelrahman e9451f10f8 Reformat and increase minimum arena capacity to 4 pages 2024-10-06 12:42:12 +01:00
abdelrahman 1de3608b1f Pass MemInitType to platform functions 2024-10-05 22:30:11 +01:00
abdelrahman 3a25571105 Reformat 2024-10-05 23:18:23 +01:00
abdelrahman 139b4ca589 Restore missing mem_utils code 2024-10-05 23:17:23 +01:00
abdelrahman e431cf729e Reformat 2024-10-05 23:15:03 +01:00
abdelrahman 1d1c3ca928 Split the platform specific mem_utils implementations 2024-10-05 23:05:32 +01:00
abdelrahman f2f155744a Declare external functions for termcolour and commander in the headers 2024-10-05 23:04:35 +01:00
abdelrahman d3a86ec6cb Add extern alias 2024-10-05 23:03:19 +01:00
abdelrahman e053aa44ab Remove unnecessary termcolour header files 2024-10-05 22:28:24 +01:00
abdelrahman a546a09565 Split commander windows and posix implementations 2024-10-05 22:25:21 +01:00
abdelrahman 12f182f0cf Define macros for C linkage 2024-10-05 22:06:13 +01:00
abdelrahman ffb99a3644 Fix MSVC errors and warnings 2024-10-05 20:07:48 +01:00
abdelrahman 1ddc5610f9 Remove aligned_alloc from libc allocator since it's not implemented on Windows 2024-10-05 19:11:13 +01:00
abdelrahman d8c7b3162f Split termcolour implementations by platform and simplify the API 2024-10-05 18:46:14 +01:00
abdelrahman 9e1e4688e4 Reformat 2024-10-05 18:45:32 +01:00
abdelrahman cd38672581 Add test for Arena's reallocation functionality 2024-09-14 17:28:07 +01:00
abdelrahman 7fea236618 Implement reallocation functionality for Arena allocator 2024-09-14 17:27:33 +01:00
abdelrahman 16a1b8fa35 Reformat 2024-09-14 14:49:18 +01:00
abdelrahman a0dfe8acd0 Start implementing realloc functions for Arena allocator 2024-09-14 13:39:59 +01:00
abdelrahman 95c47ec940 Update libc allocator realloc function 2024-09-14 13:39:32 +01:00
abdelrahman 46f32f2ba9 Update signature of realloc functions to expect old and new sizes 2024-09-14 13:38:55 +01:00
abdelrahman 8f794dee15 Reformat 2024-09-07 20:54:49 +01:00
abdelrahman 034b105ea1 Reformat 2024-09-07 20:53:20 +01:00
abdelrahman c90874ad10 Reformat 2024-09-07 20:49:13 +01:00
abdelrahman 8468bb8e28 Reorganise allocators 2024-09-07 20:27:49 +01:00
abdelrahman d30eee0cf8 Add tests for Allocator implementations 2024-09-07 15:43:47 +01:00
abdelrahman 59e56a75d3 Reimplement Allocator API for Arena 2024-09-07 15:43:25 +01:00
abdelrahman 5d6ce1d2c3 Restore libc Allocator implementation 2024-09-07 15:43:00 +01:00
abdelrahman ce537b7494 Restore Allocator implementation 2024-09-07 15:42:36 +01:00
abdelrahman b8f6e5f187 Fix bug in memory allocation function 2024-08-24 19:07:00 +01:00
abdelrahman 775f0864a8 Rename arena default allocation function 2024-08-23 22:29:56 +01:00
abdelrahman 8b6fb23bac Use size utils in arena tests 2024-08-23 21:50:22 +01:00
abdelrahman 1fb340561f Add size utils 2024-08-23 21:48:38 +01:00
abdelrahman 8ed372d938 Ensure stderr is piped to stdout to capture errors in output 2024-06-17 00:18:27 +01:00
abdelrahman 8a91a0ec6b Add tests for the shell commander 2024-06-17 00:15:10 +01:00
abdelrahman 802b70f5ee Add option to discard command output 2024-06-17 00:14:34 +01:00
abdelrahman 92c2439b56 Ensure cleanup on command failure 2024-06-16 23:29:19 +01:00
abdelrahman 781a46713b Add shell commander 2024-06-16 23:19:34 +01:00
abdelrahman 7c4725edef Add shell_utils 2024-06-16 23:18:52 +01:00
abdelrahman 4fc99f76a5 Move termcolour to shell 2024-06-16 23:17:54 +01:00
abdelrahman 25ab75f74f Move memory utilities to common 2024-06-16 15:30:53 +01:00
abdelrahman f6dd7e7aa8 Reorganise files 2024-06-16 12:29:43 +01:00
abdelrahman 8f5bee45c6 Reformat compile script 2024-06-12 23:20:49 +01:00
abdelrahman 25964d9a3c Run tests before building library 2024-06-09 22:46:17 +01:00
abdelrahman d9cf98da73 Rename print_test_result and exit on any failing function 2024-06-09 22:45:27 +01:00
abdelrahman 8c153b5321 Build tests on Windows 2024-06-09 22:31:14 +01:00
abdelrahman 3c4112d080 Remove building test.c from the Posix compilation script 2024-06-09 22:30:46 +01:00
abdelrahman aa28dd481b Platform abstraction for terminal colour 2024-06-09 22:30:21 +01:00
abdelrahman 42187beee5 Fix auto formatting 2024-06-09 22:29:30 +01:00
abdelrahman 8cc17f1490 Reformat and update types 2024-06-09 22:28:07 +01:00
abdelrahman b4c1301600 Update .gitignore 2024-06-09 22:25:46 +01:00
abdelrahman 2c556e12f1 Initial implementation of Windows build script 2024-06-09 18:27:34 +01:00
abdelrahman 6c82898225 Update dstr to remove MSVC warnings 2024-06-09 18:25:37 +01:00
abdelrahman a85508e0a4 Add padding to StringUpdate struct 2024-06-09 18:25:00 +01:00
abdelrahman cd78913e83 Add padding to arena and test_func_result structs 2024-06-09 17:40:41 +01:00
abdelrahman a0acada9b4 Fix Windows warning about assigning in conditional expression 2024-06-09 17:40:01 +01:00
abdelrahman 8eaa4afed1 Add WINDOWS_LEAN_AND_MEAN to mem_utils.c 2024-06-09 17:35:22 +01:00
abdelrahman 1ce07e9e4e Add WINDOWS_LEAN_AND_MEAN 2024-06-09 17:34:54 +01:00
abdelrahman 162b255e1b Add utility for calculating padding size 2024-06-09 17:34:16 +01:00
abdelrahman 99a9cd10f5 Update .gitignore 2024-06-09 16:20:15 +01:00
abdelrahman 7e1c25b649 Use out of source build 2024-06-09 16:19:44 +01:00
abdelrahman 9008e10651 Fix bug in dirup function 2024-06-09 16:19:26 +01:00
abdelrahman d27fc14b31 Fix termcolour include in tester.c 2024-06-09 15:26:20 +01:00
abdelrahman dbdab01a2c Merge branch 'temp' into 'main' 2024-06-09 01:50:51 +01:00
abdelrahman cf12144230 Add utility macros for arena initialisation 2024-06-09 01:46:23 +01:00
abdelrahman ccc86342cd Add address parameter to wapp_mem_util_alloc 2024-06-09 01:45:29 +01:00
Abdelrahman Said 8d89695fcc Test reserving a massive arena 2024-06-03 08:05:14 +01:00
Abdelrahman Said 6499dd7be9 Rename testing macros 2024-06-03 07:58:24 +01:00
abdelrahman 75bbb82058 Add helper macro for running test functions 2024-06-02 23:55:41 +01:00
abdelrahman 7fb13f2439 Update compile script to run tests 2024-06-02 23:35:34 +01:00
abdelrahman 0b63bc746d Add tests 2024-06-02 23:35:26 +01:00
abdelrahman 6ee3c762df Add terminal colour constants 2024-06-02 23:35:04 +01:00
abdelrahman 59f1c3eb58 Add testing utilities 2024-06-02 23:34:53 +01:00
abdelrahman 55d0c25c90 Reformat 2024-06-02 23:34:38 +01:00
abdelrahman cfc98e0137 Update .gitignore 2024-06-02 21:26:32 +01:00
Abdelrahman Said 32877cdeaa Fix platform detection on Apple platforms 2024-06-02 20:54:20 +01:00
Abdelrahman Said 7e2d7b28b7 Update .gitignore 2024-06-02 20:54:07 +01:00
abdelrahman 23886f40e8 Switch to using wapp_mem_util_alloc instead of calloc 2024-06-02 20:42:10 +01:00
abdelrahman 57de75c1f8 Set allocation flags per platform 2024-06-02 20:41:30 +01:00
abdelrahman 9807334ac9 Complete memory allocation and deallocation function definitions 2024-06-02 20:09:56 +01:00
abdelrahman 18448dd7c1 Define memory allocation and deallocation functions 2024-06-02 20:09:08 +01:00
abdelrahman 62fdef8601 Add platform detection definitions 2024-06-02 20:08:28 +01:00
abdelrahman 61c29ee564 Remove growing_arena and use base_arena 2024-06-02 01:17:03 +01:00
abdelrahman 36bc8ab54a Ignore test files 2024-06-02 01:16:46 +01:00
abdelrahman a8e5913254 Add release build and compile test 2024-06-02 01:16:24 +01:00
131 changed files with 15980 additions and 680 deletions
+2
View File
@@ -0,0 +1,2 @@
CompileFlags:
Add: -ferror-limit=0
+9
View File
@@ -1,4 +1,13 @@
.cache .cache
.vscode .vscode
test
test.*
*.dSYM
.DS_Store
*.pdb
*.obj
compile_commands.json compile_commands.json
libwapp-build
libwapp.so libwapp.so
*.vs
__pycache__
+86
View File
@@ -0,0 +1,86 @@
CC = clang
CXX = clang++
AR = ar
BUILD_TYPE = debug
CSTD = -std=gnu11
CXXSTD = -std=gnu++11
CFLAGS = -Wall -Wextra -Werror -pedantic -Isrc
LIBFLAGS = -fPIC
KERNEL = $(shell uname -s)
MACHINE = $(shell uname -m)
PLATFORM = $(KERNEL)_$(MACHINE)
TEST_INCLUDE = -Isrc $(shell find tests -type d | xargs -I{} echo -n "-I{} ")
TEST_SRC = $(shell find tests -type f -name "*.c" | xargs -I{} echo -n "{} ")
TEST_C_SRC = src/wapp.c $(TEST_SRC)
TEST_CXX_SRC = $(shell find tests -type f -name "*.cc" | xargs -I{} echo -n "{} ")
BUILD_DIR = libwapp-build/$(PLATFORM)-$(BUILD_TYPE)
LIB_NAME = wapp
OBJ_OUT = $(BUILD_DIR)/$(LIB_NAME).o
LIB_OUT = $(BUILD_DIR)/lib$(LIB_NAME).a
TEST_C_OUT = $(BUILD_DIR)/wapptest
TEST_CXX_OUT = $(BUILD_DIR)/wapptestcc
ifeq ($(BUILD_TYPE),debug)
CFLAGS += -g -fsanitize=address,undefined -DWAPP_DEBUG_ASSERT
else ifeq ($(BUILD_TYPE),release)
CFLAGS += -O3
else
$(error Invalid BUILD type '$(BUILD_TYPE)'. Use 'debug' or 'release')
endif
ifeq ($(CC),gcc)
# Used to disable the "ASan runtime does not come first in initial library list" error when compiling with gcc
export ASAN_OPTIONS=verify_asan_link_order=0
endif
.PHONY: all clean builddir build-test run-test codegen build-lib full prng testing uuid core primitives
all: clean builddir codegen run-c-test full run-cc-test
clean:
@rm -rf $(BUILD_DIR)
builddir:
@mkdir -p $(BUILD_DIR)
build-c-test:
$(CC) $(CSTD) $(CFLAGS) $(TEST_INCLUDE) $(TEST_C_SRC) -o $(TEST_C_OUT)
run-c-test: build-c-test
@echo -e "\n\033[34;1mRUNNING C TESTS\033[0m"
@$(TEST_C_OUT)
@rm $(TEST_C_OUT)
build-cc-test:
$(CXX) $(CXXSTD) $(CFLAGS) $(TEST_INCLUDE) $(TEST_CXX_SRC) $(LIB_OUT) -o $(TEST_CXX_OUT)
run-cc-test: build-cc-test
@echo -e "\n\033[34;1mRUNNING C++ TESTS\033[0m"
@export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(BUILD_DIR) && $(TEST_CXX_OUT)
@rm $(TEST_CXX_OUT)
codegen:
python3 -m codegen
build-lib:
$(CC) -c $(CSTD) $(CFLAGS) $(LIBFLAGS) $(LIB_SRC) -o $(OBJ_OUT)
$(AR) r $(LIB_OUT) $(OBJ_OUT)
@rm $(OBJ_OUT)
full: LIB_SRC = src/wapp.c
full: build-lib
prng: LIB_SRC = src/prng/wapp_prng.c
prng: build-lib
testing: LIB_SRC = src/testing/wapp_testing.c
testing: build-lib
uuid: LIB_SRC = src/uuid/wapp_uuid.c
uuid: build-lib
core: LIB_SRC = src/core/wapp_core.c
core: build-lib
primitives: LIB_SRC = src/core/wapp_primitives.c
primitives: build-lib
+1 -1
View File
@@ -1,3 +1,3 @@
# Wizard Apprentice Standard Library # Wizard Apprentice Standard Library
A collection of useful C/C++ utilities for my projects A collection of useful C utilities for my projects
+18 -1
View File
@@ -1,3 +1,20 @@
#!/bin/bash #!/bin/bash
bear -- ./compile $@ BUILD_TYPE="debug"
ARGS=""
while [[ $# > 0 ]];do
case $1 in
--release)
BUILD_TYPE="release"
shift
;;
*|-*|--*)
rest=("$@")
ARGS+=" ${rest[0]}"
shift
;;
esac
done
bear -- make BUILD_TYPE=$BUILD_TYPE $ARGS
+65
View File
@@ -0,0 +1,65 @@
Param(
[switch]$Release
)
$Compiler = "cl.exe"
$GeneralFlags = "/Wall /WX /wd4996 /wd4464 /wd5105 /std:c11"
$LibraryFlags = "/LD"
$Kernel = (Get-ChildItem Env:OS).Value
$Machine = (Get-ChildItem Env:PROCESSOR_ARCHITECTURE).Value
$Platform = "${Kernel}_${Machine}"
$IncludeDirs = "/I src"
$SrcFiles = "src/wapp.c"
$TestIncludeDirs = Get-ChildItem -Path tests -Recurse -Directory -ErrorAction SilentlyContinue -Force | %{$("/I " + '"' + $_.FullName + '"')}
$TestSrcFiles = Get-ChildItem -Path tests -Recurse -Filter *.c -ErrorAction SilentlyContinue -Force | %{$('"' + $_.FullName + '"')}
If ($Release -eq $True) {
$GeneralFlags += " /O2 /Og"
$BuildType = "release"
} Else {
$GeneralFlags += " /Zi /Od /fsanitize=address"
$BuildType = "debug"
}
$BuildDir = "./libwapp-build/${Platform}-${BuildType}"
$ObjDir = "$BuildDir/objects"
$OutDir = "$BuildDir/output"
$TestsDir = "$BuildDir/tests"
$OutBasename = "libwapp"
$Objects = "/Fo:$ObjDir/"
$Outputs = "/Fd:$OutDir/$OutBasename /Fe:$OutDir/$OutBasename"
$TestOutBasename = "wapptest"
$TestOutputs = "/Fo:$TestsDir/ /Fe:$TestsDir/$TestOutBasename"
If (Test-Path $BuildDir) {
Remove-Item $BuildDir -Recurse -Force
}
mkdir -p $ObjDir > $null
mkdir -p $OutDir > $null
mkdir -p $TestsDir > $null
# Run code generation
Invoke-Expression "python -m codegen"
# Build and run tests
Invoke-Expression "$Compiler $GeneralFlags $IncludeDirs $TestIncludeDirs $SrcFiles $TestSrcFiles $TestOutputs" -ErrorAction Stop
Invoke-Expression "$TestsDir/$TestOutBasename.exe"
$Status = $LASTEXITCODE
Remove-Item $TestsDir -Recurse -Force
If ($Status -ne 0) {
Write-Error "Tests failed"
Exit 1
}
# Build library
Invoke-Expression "$Compiler $GeneralFlags $LibraryFlags $SrcFiles $Objects $Outputs"
+23
View File
@@ -0,0 +1,23 @@
from typing import Dict
from codegen.datatypes import CDataType
from codegen.dbl_list.make_dbl_list import DblListData, make_dbl_list
from codegen.array.make_array import ArrayData, make_array
def main():
gen_dbl_list()
gen_array()
def gen_dbl_list():
datatypes: Dict[CDataType, DblListData] = {}
make_dbl_list(datatypes)
def gen_array():
datatypes: Dict[CDataType, ArrayData] = {}
make_array(datatypes)
if __name__ == "__main__":
main()
+431
View File
@@ -0,0 +1,431 @@
from pathlib import Path
from dataclasses import dataclass, field
from typing import List, Dict
from codegen.constants import WAPP_SRC_ROOT
from codegen.utils import load_func_body_from_file, convert_to_relative
from codegen.datatypes import (
CDataType,
CMacro,
CStruct,
CFunc,
CHeader,
CSource,
CArg,
CType,
CPointer,
CPointerType,
CQualifier,
CInclude,
get_datatype_string,
)
@dataclass
class ArrayData:
array_typename: str
hdr_decl_types: List[CStruct] = field(default_factory=list)
src_decl_types: List[CStruct] = field(default_factory=list)
def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
def __format_func_body(
filename: Path,
type_string: str,
type_string_upper: str,
type_string_lower: str,
array_typename: str
):
return load_func_body_from_file(filename).format(
T=type_string,
ArrayType=array_typename,
Tupper=type_string_upper,
Tlower=type_string_lower,
)
out_dir = WAPP_SRC_ROOT / "primitives" / "array"
out_dir.mkdir(parents=True, exist_ok=True)
common_includes: List[CInclude] = [
CInclude(
header=str(convert_to_relative(WAPP_SRC_ROOT / "common" / "aliases" / "aliases.h", out_dir)).replace("\\", "/"),
local=True,
),
CInclude(
header=str(convert_to_relative(WAPP_SRC_ROOT / "primitives" / "mem_allocator" / "mem_allocator.h", out_dir)).replace("\\", "/"),
local=True,
),
CInclude(
header=str(convert_to_relative(WAPP_SRC_ROOT / "common" / "misc" / "misc_utils.h", out_dir)).replace("\\", "/"),
local=True,
),
]
common_decl_types: List[CStruct] = []
datatypes: dict[CDataType, ArrayData] = {
"Str8": ArrayData(
array_typename="Str8Array",
hdr_decl_types=[
CStruct(name="str8", cargs=[], typedef_name="Str8"),
],
),
}
for _type in CType:
if _type == CType.VOID:
datatypes["void *"] = ArrayData(
array_typename="VoidPArray",
)
continue
type_title = _type.value.title()
datatypes[_type.value] = ArrayData(
array_typename=f"{type_title}Array",
)
datatypes.update(user_datatypes)
snippets_dir = Path(__file__).parent / "snippets"
header = CHeader(
name="array",
decl_types=[*common_decl_types],
includes=[],
types=[],
funcs=[]
)