Updated zpl to latest, update refactor scripts based on convention used in gencpp

This commit is contained in:
Edward R. Gonzalez 2023-04-19 15:53:01 -04:00
parent c4efd1890d
commit 5efd14322e
4 changed files with 18087 additions and 17754 deletions

View File

@ -2,7 +2,7 @@
Refactor c/c++ files (and problably others) with ease. Refactor c/c++ files (and problably others) with ease.
## Parameters ## Parameters
* `-num` : Used if more than one source file is provided (if used, number of destination files provided MUST MATCH). * `-num` : Used if more than one source file is provided (if used, number of destination files provided MUST MATCH).
* `-src` : Source file to refactor * `-src` : Source file to refactor
@ -20,10 +20,10 @@ Refactor c/c++ files (and problably others) with ease.
* `L-Value` is the signature to modify. * `L-Value` is the signature to modify.
* `R-Value` is the substitute ( only available if rule does not use `not` keyword ) * `R-Value` is the substitute ( only available if rule does not use `not` keyword )
The only keyword here excluisve to c/c++ is the `include` as it does search specifically for `#include <L-Value>`. The only keyword here excluisve to c/c++ is the `include` as it does search specifically for `#include <L-Value>`.
However, the rest of the categorical keywords (word, namespace), can really be used for any langauge. However, the rest of the categorical keywords (word, namespace), can really be used for any langauge.
There is no semantic awareness this is truely just a simple find and replace, but with some filters specifiable, and There is no semantic awareness this is truely just a simple find and replace, but with some filters specifiable, and
words/namespaces only being restricted to the rules for C/C++ identifiers (alphanumeric or underscores only) words/namespaces only being restricted to the rules for C/C++ identifiers (alphanumeric or underscores only)
The main benefit for using this over alts is its problably more ergonomic and performant for large refactors on libraries you may want to have automated in a script. The main benefit for using this over alts is its problably more ergonomic and performant for large refactors on libraries you may want to have automated in a script.
@ -40,23 +40,23 @@ There is a desire also to get this setup as a single-header library and also alt
### Notes ### Notes
* Building for debug provides some nice output with context on a per-line basis. * Building for debug provides some nice output with context on a per-line basis.
* Release will only show errors for asserts (that will kill the refactor early). * Release will only show errors for asserts (that will kill the refactor early).
* If the refactor crashes, the files previously written to will retain their changes. * If the refactor crashes, the files previously written to will retain their changes.
* Make sure to have the code backed up on a VCS or in some other way. * Make sure to have the code backed up on a VCS or in some other way.
* The scripts used for building and otherwise are in the scripts directory and are all in powershell (with exception to the meson.build). Techncially there should be a powershell package available on other platorms but worst case it should be pretty easy to port these scripts to w/e shell script you'd perfer. * The scripts used for building and otherwise are in the scripts directory and are all in powershell (with exception to the meson.build). Techncially there should be a powershell package available on other platorms but worst case it should be pretty easy to port these scripts to w/e shell script you'd perfer.
## Building ## Building
The project has all build configuration in the `scripts` directory. The project has all build configuration in the `scripts` directory.
* `build.ci.ps1` is intended for a continuous intergration setup (GH-worfklow for now). * `build.ci.ps1` is intended for a continuous intergration setup (GH-worfklow for now).
* `build.ps1` is just a wrap of build.ci that just calls cls. * `build.ps1` is just a wrap of build.ci that just calls cls.
* `clean.ps1` will clean the workspace of all generated files. * `clean.ps1` will clean the workspace of all generated files.
* `get_sources.ps1` is used to gather sources since meson devs refuse to add dynamic retrival of sources for a build. * `get_sources.ps1` is used to gather sources since meson devs refuse to add dynamic retrival of sources for a build.
The project uses [meson](https://github.com/mesonbuild/meson) as the build tool. The project uses [meson](https://github.com/mesonbuild/meson) as the build tool.
Compiler : clang Compiler : clang
OS: Windows 11 (windows-latest for github actions) OS: Windows 11 (windows-latest for github actions)
There should theoretically not be anything stopping it from building on other plaforms. There should theoretically not be anything stopping it from building on other plaforms.
@ -71,22 +71,21 @@ With the refactors applied a meson configuraiton is setup (`meson.build` in test
* There is an extra file `stb_image` that is parsed but unused during compilation. * There is an extra file `stb_image` that is parsed but unused during compilation.
* Planned for use in the namespace addition todo. * Planned for use in the namespace addition todo.
## TODO: ## TODO:
* Possibly come up with a better name.
* Test to see how much needs to be ported for other platforms (if at all)
* Provide binaries in the release page for github. (debug and release builds) * Provide binaries in the release page for github. (debug and release builds)
* Ability to run and not emit any changes to files unless all files sucessfully are refactored. * Ability to run and not emit any changes to files unless all files sucessfully are refactored.
* Would fix issue where a refactor overwrites files but failed to complete * Would fix issue where a refactor overwrites files but failed to complete
* Can have a heavy memory cost, so most likely do not want on by default. * Can have a heavy memory cost, so most likely do not want on by default.
* Directive to ignore comments (with a way to specify the comment signature). Right now comments that
meet the signature of words or namespaces are refactored.
* Make comments ignored by default, and just have ability to specify custom comments. * Make comments ignored by default, and just have ability to specify custom comments.
* Would need a directive to add refactors to comments. * Would need a directive to add refactors to comments.
* Directive to add cpp namespaces on specific lines of a file, or near specific signatures. * Directive to add cpp namespaces on specific lines of a file, or near specific signatures.
* This can honestly be done also with placing words on specific lines.. * This can honestly be done also with placing words on specific lines..
* Provide a GUI build. * Provide a GUI build.
* Provide as a single-header library. * Provide as a single-header library.
* Could add a test case where this library is refactored into pure C (most likely c99 or c11). * Could add a test case where this library is refactored into pure C (most likely c99 or c11).
* Better tests: * Better tests:
* Automatically pull the zpl repo, refactor and format the library, and package the single header before using it in testing. * Automatically pull the zpl repo, refactor and format the library, and package the single header before using it in testing.
* Use gencpp editor/scanner functionality to give it more rich context refactors.
* Port to other platforms.
* Ability to change the naming convention of a signature (snake_case to PascalCase, etc)

View File

@ -4,7 +4,7 @@ __VERSION 1
// include : #includes // include : #includes
// word : Alphanumeric or underscore // word : Alphanumeric or underscore
// namespace : Prefix search and replace (c-namspaces). // namespace : Prefix search and replace (c-namspaces).
// regex : Unavailable in __VERSION 1. // regex : Unavailable in __VERSION 1.
// Precedence (highest to lowest): // Precedence (highest to lowest):
// word, namespace, regex // word, namespace, regex
@ -21,21 +21,168 @@ include IO.cpp, IO.refactored.cpp
include Spec.hpp, Spec.refactored.hpp include Spec.hpp, Spec.refactored.hpp
include Spec.cpp, Spec.refactored.cpp include Spec.cpp, Spec.refactored.cpp
// Remove the zpl namespace. // Removes the namespace.
namespace zpl_ namespace zpl_
namespace zpl_re_, regex_
// Don't expose zpl internals namespace zpl_random_, rng_
not namespace zpl__ namespace zpl_pr, process_
namespace zpl__, __
namespace ZPL_ADT_, EADT
namespace ZPL_ALLOCATION_, EAllocation
namespace ZPL_CSV_ERROR, ECSV_Error
namespace ZPL_FILE_MODE_, EFileMode_
namespace ZPL_FILE_ERROR_, EFileError_
namespace ZPL_SEEK_WHENCE_, ESeekWhence_
namespace ZPL_FILE_STANDARD_, EFileStandard_
namespace ZPL_FILE_STREAM_, EFileStream_
namespace ZPL_JSON_ERROR_, EJSON_Error_
namespace ZPL_RE_ERROR_, ERegexError_
namespace ZPL_OPTS_, EOpts_
namespace ZPL_OPTS_ERR, EOptsError_
namespace ZPL_PR_OPTS_, EProcessOpts_
// Macro exposure // Macro exposure
//namespace ZPL_ //namespace ZPL_
//not word ZPL_IMPLEMENTATION //not word ZPL_IMPLEMENTATION
// Name conflicts // Type Renames
word opts, options word zpl_aabb2, AABB2
word zpl_aabb3, AABB3
word zpl_adt_assign_style, ADT_AssignStyle
word zpl_adt_delim_style, ADT_DelimStyle
word zpl_adt_error, ADT_Error
word zpl_adt_naming_style, ADT_NamingStyle
word zpl_adt_node, ADT_Node
word zpl_adt_props, ADT_Props
word zpl_adt_type, ADT_Type
word zpl_affinity, Affinity
word zpl_allocation_header_event, AllocationHeaderEvent
word zpl_allocator, AllocatorInfo
word zpl_allocator_proc, AllocatorProc
word zpl_alloc_flags, AllocFlags
word zpl_alloc_type, AllocType
word zpl_arena, Arena
word zpl_arena_snapshot, ArenaSnapshot
word zpl_array, Array
word zpl_array_header, ArrayHeader
word zpl_buffer, Buffer
word zpl_buffer_header, BufferHeader
word zpl_compare_proc, CompareProc
word zpl_csv_error, CSV_Error
word zpl_csv_object, CSV_Object
word zpl_dll_handle, DLLHandle
word zpl_dll_proc, DLLProc
word zpl_dir_type, DirType
word zpl_dir_entry, DirEntry
word zpl_dir_info, DirInfo
word zpl_file_contents, FileContents
word zpl_file_descriptor, FileDescriptor
word zpl_file_error, FileError
word zpl_file, FileInfo
word zpl_file_mode, FileMode
word zpl_file_mode_flag, FileModeFlag
word zpl_file_operations, FileOperations
word zpl_file_close_proc, FileCloseProc
word zpl_file_read_proc, FileReadProc
word zpl_file_seek_proc, FileSeekProc
word zpl_file_write_proc, FileWriteProc
word zpl_file_standard_type, FileStandardType
word zpl_file_stream_flags, FileStreamFlags
word zpl_float2, Float2
word zpl_float3, Float3
word zpl_float4, Float4
word zpl_frustum, Frustum
word zpl_half, Half
word zpl_jobs_priority, JobsPriority
word zpl_jobs_status, JobsStatus
word zpl_jobs_system, JobsSystem
word zpl_json_error, JSON_Error
word zpl_json_object, JSON_Object
word zpl_list, List
word zpl_mat2, Mat2
word zpl_mat3, Mat3
word zpl_mat4, Mat4
word zpl_mutex, Mutex
word zpl_plane, Plane
word zpl_pool, Pool
word zpl_pr, Process
word zpl_pr_si, ProcessStartupInfo
word zpl_quat, Quat
word zpl_rect2, Rect2
word zpl_rect3, Rect3
word zpl_re, Regex
word zpl_re_capture, RegexCapture
word zpl_regex_error, RegexError
wrod zpl_random, RNG
word zpl_rune, Rune
word zpl_scratch_memory, ScratchMemory
word zpl_seek_whence_type, SeekWhenceType
word zpl_semaphore, Semaphore
word zpl_string, String
word zpl_string_header, StringHeader
word zpl_sync, Sync
word zpl_opts, Opts
word zpl_opts_entry, OptsEntry
word zpl_opts_err, OptsError
word zpl_opts_err_type, OptsErrorType
word zpl_opts_types, OptsTypes
word zpl_tar_errors, TarErrors
word zpl_tar_file_type, TarFileType
word zpl_tar_record, TarRecord
word zpl_tar_unpack_proc, TarUnpackProc
word zpl_thread, Thread
word zpl_thread_job, ThreadJob
word zpl_thread_proc, ThreadProc
word zpl_thread_queue, ThreadQueue
word zpl_thread_worker, ThreadWorker
word zpl_vec2, Vec2
word zpl_vec3, Vec3
word zpl_vec4, Vec4
word zpl_virtual_memory, VirtualMemory
word zpl_strncmp, str_compare // Function Renames
word zpl_strcmp, str_compare word zpl_lfence, fence_load
word zpl_mfence, fence_memory
word zpl_sfence, fence_store
word zpl_memchr, mem_find
word zpl_memcopy, mem_copy
word zpl_memmove, mem_move
word zpl_memset, mem_set
word zpl_memswap, mem_swap
word zpl_exit, process_exit
word zpl_rdtsc, read_cpu_time_stamp_counter
word zpl_strcmp, str_compare
word zpl_strncmp, str_compare
word zpl_strcat, str_concat
word zpl_strcpy, str_copy
word zpl_strncpy, str_copy
word zpl_strlcpy, str_copy_nulpad
word zpl_strdup, str_dup
word zpl_strchr, str_find
word zpl_strrchr, str_find_last
word zpl_strstr, str_find_substr
word zpl_snprintf, str_fmt
word zpl_snprintf_va, str_fmt_va
word zpl_asprintf, str_fmt_alloc
word zpl_asprintf_va, str_fmt_alloc_va
word zpl_bprintf, str_fmt_buf
word zpl_bprintf_va, str_fmt_buf_va
word zpl_printf, str_fmt_out
word zpl_printf_va, str_fmt_out_va
word zpl_printf_err, str_fmt_out_err
word zpl_printf_err_va, str_fmt_out_err_va
word zpl_fprintf, str_fmt_file
word zpl_fprintf_va, str_fmt_file_va
word zpl_strlen, str_len
word zpl_strnlen, str_len
word zpl_strrev, str_reverse
word zpl_strtok, str_tok
word zpl_strtok_r, str_tok_reentrant
word zpl_sleep, thread_sleep
word zpl_sleep_ms, thread_sleep_ms
word zpl_yield_thread, thread_yield
word zpl_utf8_strlen, utf8_len
word zpl_utf8_strnlen, utf8_len
// Undesired typedefs // Undesired typedefs
word zpl_i8, s8 word zpl_i8, s8
@ -51,21 +198,7 @@ word zpl_uintptr, uptr
word zpl_usize, uw word zpl_usize, uw
word zpl_isize, sw word zpl_isize, sw
// Conflicts with std. (Uncomment if using c externs) // Undesired exposures.
not word zpl_memchr word cast, zpl_cast
not word zpl_memmove
not word zpl_memset not word zpl_thread_local
not word zpl_memswap
not word zpl_memcopy
not word zpl_printf
not word zpl_printf_va
not word zpl_printf_err
not word zpl_printf_err_va
not word zpl_fprintf
not word zpl_fprintf_va
not word zpl_snprintf
not word zpl_snprintf_va
not word zpl_strchr
not word zpl_strlen
not word zpl_strnlen
not word zpl_exit

View File

@ -4,11 +4,14 @@ __VERSION 1
// include : #includes // include : #includes
// word : Alphanumeric or underscore // word : Alphanumeric or underscore
// namespace : Prefix search and replace (c-namspaces). // namespace : Prefix search and replace (c-namspaces).
// regex : Unavailable in __VERSION 1. // regex : Unavailable in __VERSION 1.
// Precedence (highest to lowest): // Precedence (highest to lowest):
// word, namespace, regex // word, namespace, regex
// This is a cpp refactor specification for zpl.h
// Its intended that the content will be within a cpp namesapce
// Comments // Comments
not comments not comments
@ -20,22 +23,172 @@ not include header/essentials/collections/array.h
not include header/essentials/collections/list.h not include header/essentials/collections/list.h
not include header/core/file.h not include header/core/file.h
not include header/opts.h not include header/opts.h
not include header/regex.h
not include source/core/file.c not include source/core/file.c
not include source/opts.c not include source/opts.c
// Removes the namespace. // Removes the namespace.
namespace zpl_ namespace zpl_
namespace zpl_re_, regex_
// Don't expose internals namespace zpl_random_, rng_
not namespace zpl__ namespace zpl_pr, process_
namespace zpl__, __
namespace ZPL_ADT_, EADT
namespace ZPL_ALLOCATION_, EAllocation
namespace ZPL_CSV_ERROR, ECSV_Error
namespace ZPL_FILE_MODE_, EFileMode_
namespace ZPL_FILE_ERROR_, EFileError_
namespace ZPL_SEEK_WHENCE_, ESeekWhence_
namespace ZPL_FILE_STANDARD_, EFileStandard_
namespace ZPL_FILE_STREAM_, EFileStream_
namespace ZPL_JSON_ERROR_, EJSON_Error_
namespace ZPL_RE_ERROR_, ERegexError_
namespace ZPL_OPTS_, EOpts_
namespace ZPL_OPTS_ERR, EOptsError_
namespace ZPL_PR_OPTS_, EProcessOpts_
// Macro exposure // Macro exposure
//namespace ZPL_ //namespace ZPL_
//not word ZPL_IMPLEMENTATION //not word ZPL_IMPLEMENTATION
word cast, zpl_cast // Type Renames
word zpl_strncmp, str_compare word zpl_aabb2, AABB2
word zpl_strcmp, str_compare word zpl_aabb3, AABB3
word zpl_adt_assign_style, ADT_AssignStyle
word zpl_adt_delim_style, ADT_DelimStyle
word zpl_adt_error, ADT_Error
word zpl_adt_naming_style, ADT_NamingStyle
word zpl_adt_node, ADT_Node
word zpl_adt_props, ADT_Props
word zpl_adt_type, ADT_Type
word zpl_affinity, Affinity
word zpl_allocation_header_event, AllocationHeaderEvent
word zpl_allocator, AllocatorInfo
word zpl_allocator_proc, AllocatorProc
word zpl_alloc_flags, AllocFlags
word zpl_alloc_type, AllocType
word zpl_arena, Arena
word zpl_arena_snapshot, ArenaSnapshot
word zpl_array, Array
word zpl_array_header, ArrayHeader
word zpl_buffer, Buffer
word zpl_buffer_header, BufferHeader
word zpl_compare_proc, CompareProc
word zpl_csv_error, CSV_Error
word zpl_csv_object, CSV_Object
word zpl_dll_handle, DLLHandle
word zpl_dll_proc, DLLProc
word zpl_dir_type, DirType
word zpl_dir_entry, DirEntry
word zpl_dir_info, DirInfo
word zpl_file_contents, FileContents
word zpl_file_descriptor, FileDescriptor
word zpl_file_error, FileError
word zpl_file, FileInfo
word zpl_file_mode, FileMode
word zpl_file_mode_flag, FileModeFlag
word zpl_file_operations, FileOperations
word zpl_file_close_proc, FileCloseProc
word zpl_file_read_proc, FileReadProc
word zpl_file_seek_proc, FileSeekProc
word zpl_file_write_proc, FileWriteProc
word zpl_file_standard_type, FileStandardType
word zpl_file_stream_flags, FileStreamFlags
word zpl_float2, Float2
word zpl_float3, Float3
word zpl_float4, Float4
word zpl_frustum, Frustum
word zpl_half, Half
word zpl_jobs_priority, JobsPriority
word zpl_jobs_status, JobsStatus
word zpl_jobs_system, JobsSystem
word zpl_json_error, JSON_Error
word zpl_json_object, JSON_Object
word zpl_list, List
word zpl_mat2, Mat2
word zpl_mat3, Mat3
word zpl_mat4, Mat4
word zpl_mutex, Mutex
word zpl_plane, Plane
word zpl_pool, Pool
word zpl_pr, Process
word zpl_pr_si, ProcessStartupInfo
word zpl_quat, Quat
word zpl_rect2, Rect2
word zpl_rect3, Rect3
word zpl_re, Regex
word zpl_re_capture, RegexCapture
word zpl_regex_error, RegexError
wrod zpl_random, RNG
word zpl_rune, Rune
word zpl_scratch_memory, ScratchMemory
word zpl_seek_whence_type, SeekWhenceType
word zpl_semaphore, Semaphore
word zpl_string, String
word zpl_string_header, StringHeader
word zpl_sync, Sync
word zpl_opts, Opts
word zpl_opts_entry, OptsEntry
word zpl_opts_err, OptsError
word zpl_opts_err_type, OptsErrorType
word zpl_opts_types, OptsTypes
word zpl_tar_errors, TarErrors
word zpl_tar_file_type, TarFileType
word zpl_tar_record, TarRecord
word zpl_tar_unpack_proc, TarUnpackProc
word zpl_thread, Thread
word zpl_thread_job, ThreadJob
word zpl_thread_proc, ThreadProc
word zpl_thread_queue, ThreadQueue
word zpl_thread_worker, ThreadWorker
word zpl_vec2, Vec2
word zpl_vec3, Vec3
word zpl_vec4, Vec4
word zpl_virtual_memory, VirtualMemory
// Function Renames
word zpl_lfence, fence_load
word zpl_mfence, fence_memory
word zpl_sfence, fence_store
word zpl_memchr, mem_find
word zpl_memcopy, mem_copy
word zpl_memmove, mem_move
word zpl_memset, mem_set
word zpl_memswap, mem_swap
word zpl_exit, process_exit
word zpl_rdtsc, read_cpu_time_stamp_counter
word zpl_strcmp, str_compare
word zpl_strncmp, str_compare
word zpl_strcat, str_concat
word zpl_strcpy, str_copy
word zpl_strncpy, str_copy
word zpl_strlcpy, str_copy_nulpad
word zpl_strdup, str_dup
word zpl_strchr, str_find
word zpl_strrchr, str_find_last
word zpl_strstr, str_find_substr
word zpl_snprintf, str_fmt
word zpl_snprintf_va, str_fmt_va
word zpl_asprintf, str_fmt_alloc
word zpl_asprintf_va, str_fmt_alloc_va
word zpl_bprintf, str_fmt_buf
word zpl_bprintf_va, str_fmt_buf_va
word zpl_printf, str_fmt_out
word zpl_printf_va, str_fmt_out_va
word zpl_printf_err, str_fmt_out_err
word zpl_printf_err_va, str_fmt_out_err_va
word zpl_fprintf, str_fmt_file
word zpl_fprintf_va, str_fmt_file_va
word zpl_strlen, str_len
word zpl_strnlen, str_len
word zpl_strrev, str_reverse
word zpl_strtok, str_tok
word zpl_strtok_r, str_tok_reentrant
word zpl_sleep, thread_sleep
word zpl_sleep_ms, thread_sleep_ms
word zpl_yield_thread, thread_yield
word zpl_utf8_strlen, utf8_len
word zpl_utf8_strnlen, utf8_len
// Undesired typedefs // Undesired typedefs
word zpl_i8, s8 word zpl_i8, s8
@ -52,39 +205,10 @@ word zpl_usize, uw
word zpl_isize, sw word zpl_isize, sw
// Undesired exposures. // Undesired exposures.
//not word zpl_allocator word cast, zpl_cast
//not word zpl_arena
//not word zpl_array
//not word zpl_file
//not word zpl_list
//not word zpl_pool
//not word zpl_opts
// Conflicts with refactor not word zpl_thread_local
word arena, a_arena
word array, a_array // Name Conflicts
word alloc, a_allocator
word file, a_file
word file_size, fsize word file_size, fsize
word list, a_list word alloc, allocator
word opts, a_opts
word pool, a_pool
// Conflicts with std. (Uncomment if using c externs)
not word zpl_memchr
not word zpl_memmove
not word zpl_memset
not word zpl_memswap
not word zpl_memcopy
not word zpl_printf
not word zpl_printf_va
not word zpl_printf_err
not word zpl_printf_err_va
not word zpl_fprintf
not word zpl_fprintf_va
not word zpl_snprintf
not word zpl_snprintf_va
not word zpl_strchr
not word zpl_strlen
not word zpl_strnlen
not word zpl_exit

35417
thirdparty/zpl.h vendored

File diff suppressed because it is too large Load Diff