mirror of
https://github.com/Ed94/refactor.git
synced 2024-12-22 15:04:45 -08:00
Updated test to use latest from my fork of zpl.
This commit is contained in:
parent
892d0cba64
commit
d44f7ed6fa
@ -23,4 +23,6 @@ TODO:
|
|||||||
* Cleanup memory usage (it hogs quite a bit for what it does..)
|
* Cleanup memory usage (it hogs quite a bit for what it does..)
|
||||||
* Split lines of file and refactor it that way instead (better debug, problably negligable performance loss, worst case can have both depending on build type)
|
* Split lines of file and refactor it that way instead (better debug, problably negligable performance loss, worst case can have both depending on build type)
|
||||||
* Accept multiple files at once `-files`
|
* Accept multiple files at once `-files`
|
||||||
|
* Add support for `macro` keyword (single out macro identifiers)
|
||||||
|
* Add support for `include` keyword (single out include definitions)
|
||||||
|
* Add support for auto-translating a namespace in a macro to a cpp namespace
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
// # define ZPL_HEAP_ANALYSIS
|
// # define ZPL_HEAP_ANALYSIS
|
||||||
# define ZPL_NO_MATH_H
|
# define ZPL_NO_MATH_H
|
||||||
|
# define ZPL_DISABLE_C_DECLS
|
||||||
|
# define ZPL_WRAP_IN_NAMESPACE
|
||||||
# define ZPL_CUSTOM_MODULES
|
# define ZPL_CUSTOM_MODULES
|
||||||
# define ZPL_MODULE_ESSENTIALS
|
# define ZPL_MODULE_ESSENTIALS
|
||||||
# define ZPL_MODULE_CORE
|
# define ZPL_MODULE_CORE
|
||||||
@ -78,7 +80,7 @@ ct char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
|||||||
|
|
||||||
namespace Memory
|
namespace Memory
|
||||||
{
|
{
|
||||||
zpl_arena Global_Arena {};
|
zpl::arena Global_Arena {};
|
||||||
#define g_allocator arena_allocator( & Memory::Global_Arena)
|
#define g_allocator arena_allocator( & Memory::Global_Arena)
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
@ -87,7 +89,7 @@ namespace Memory
|
|||||||
|
|
||||||
if ( Global_Arena.total_size == 0 )
|
if ( Global_Arena.total_size == 0 )
|
||||||
{
|
{
|
||||||
assert_crash( "Failed to reserve memory for Tests:: Global_Arena" );
|
zpl::assert_crash( "Failed to reserve memory for Tests:: Global_Arena" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,13 +99,13 @@ namespace Memory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sw log_fmt(char const *fmt, ...)
|
zpl::sw log_fmt(char const *fmt, ...)
|
||||||
{
|
{
|
||||||
#if Build_Debug
|
#if Build_Debug
|
||||||
sw res;
|
zpl::sw res;
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
res = zpl_printf_va(fmt, va);
|
res = zpl::printf_va(fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@ -121,15 +123,15 @@ void fatal(char const *fmt, ...)
|
|||||||
|
|
||||||
#if Build_Debug
|
#if Build_Debug
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
zpl_snprintf_va(buf, ZPL_PRINTF_MAXLEN, fmt, va);
|
zpl::snprintf_va(buf, ZPL_PRINTF_MAXLEN, fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
assert_crash(buf);
|
zpl::assert_crash(buf);
|
||||||
#else
|
#else
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
zpl_printf_err_va( fmt, va);
|
zpl::printf_err_va( fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
exit(1);
|
zpl::exit(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
namespace File
|
namespace File
|
||||||
{
|
{
|
||||||
|
using namespace zpl;
|
||||||
|
|
||||||
string Source = nullptr;
|
string Source = nullptr;
|
||||||
string Destination = nullptr;
|
string Destination = nullptr;
|
||||||
file_contents Content {};
|
file_contents Content {};
|
||||||
|
|
||||||
zpl_arena Buffer;
|
arena Buffer;
|
||||||
|
|
||||||
void cleanup()
|
void cleanup()
|
||||||
{
|
{
|
||||||
@ -17,7 +19,7 @@ namespace File
|
|||||||
|
|
||||||
void read()
|
void read()
|
||||||
{
|
{
|
||||||
zpl_file file_src = {};
|
file file_src = {};
|
||||||
|
|
||||||
Content.allocator = g_allocator;
|
Content.allocator = g_allocator;
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ namespace File
|
|||||||
if ( refactored == nullptr)
|
if ( refactored == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zpl_file file_dest {};
|
file file_dest {};
|
||||||
file_error error = file_create( & file_dest, Destination );
|
file_error error = file_create( & file_dest, Destination );
|
||||||
|
|
||||||
if ( error != ZPL_FILE_ERROR_NONE )
|
if ( error != ZPL_FILE_ERROR_NONE )
|
||||||
@ -65,6 +67,8 @@ namespace File
|
|||||||
|
|
||||||
namespace Spec
|
namespace Spec
|
||||||
{
|
{
|
||||||
|
using namespace zpl;
|
||||||
|
|
||||||
string File;
|
string File;
|
||||||
|
|
||||||
enum Tok
|
enum Tok
|
||||||
@ -124,7 +128,7 @@ namespace Spec
|
|||||||
string Sub = nullptr; // Substitute
|
string Sub = nullptr; // Substitute
|
||||||
};
|
};
|
||||||
|
|
||||||
zpl_arena Buffer {};
|
arena Buffer {};
|
||||||
zpl_array(Entry) Word_Ignores;
|
zpl_array(Entry) Word_Ignores;
|
||||||
zpl_array(Entry) Namespace_Ignores;
|
zpl_array(Entry) Namespace_Ignores;
|
||||||
zpl_array(Entry) Words;
|
zpl_array(Entry) Words;
|
||||||
@ -159,7 +163,7 @@ namespace Spec
|
|||||||
|
|
||||||
// Get the contents of the file.
|
// Get the contents of the file.
|
||||||
{
|
{
|
||||||
zpl_file file {};
|
file file {};
|
||||||
file_error error = file_open( & file, File);
|
file_error error = file_open( & file, File);
|
||||||
|
|
||||||
if ( error != ZPL_FILE_ERROR_NONE )
|
if ( error != ZPL_FILE_ERROR_NONE )
|
||||||
@ -408,6 +412,7 @@ namespace Spec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace zpl;
|
||||||
|
|
||||||
struct Token
|
struct Token
|
||||||
{
|
{
|
||||||
@ -640,7 +645,7 @@ void refactor()
|
|||||||
content = rcast( char*, File::Content.data);
|
content = rcast( char*, File::Content.data);
|
||||||
|
|
||||||
// Generate the refactored file content.
|
// Generate the refactored file content.
|
||||||
zpl_arena buffer;
|
arena buffer;
|
||||||
string refactored = nullptr;
|
string refactored = nullptr;
|
||||||
{
|
{
|
||||||
Token* entry = tokens;
|
Token* entry = tokens;
|
||||||
@ -697,7 +702,7 @@ void refactor()
|
|||||||
inline
|
inline
|
||||||
void parse_options( int num, char** arguments )
|
void parse_options( int num, char** arguments )
|
||||||
{
|
{
|
||||||
zpl_opts opts;
|
opts opts;
|
||||||
opts_init( & opts, g_allocator, "refactor");
|
opts_init( & opts, g_allocator, "refactor");
|
||||||
opts_add( & opts, "source" , "src" , "File to refactor" , ZPL_OPTS_STRING);
|
opts_add( & opts, "source" , "src" , "File to refactor" , ZPL_OPTS_STRING);
|
||||||
opts_add( & opts, "destination" , "dst" , "File post refactor" , ZPL_OPTS_STRING);
|
opts_add( & opts, "destination" , "dst" , "File post refactor" , ZPL_OPTS_STRING);
|
||||||
|
@ -37,32 +37,38 @@ word zpl_usize, uw
|
|||||||
word zpl_isize, sw
|
word zpl_isize, sw
|
||||||
|
|
||||||
// Undesired exposures.
|
// Undesired exposures.
|
||||||
not word zpl_allocator
|
//not word zpl_allocator
|
||||||
not word zpl_arena
|
//not word zpl_arena
|
||||||
not word zpl_array
|
not word zpl_array
|
||||||
not word zpl_file
|
//not word zpl_file
|
||||||
not word zpl_list
|
//not word zpl_list
|
||||||
not word zpl_pool
|
//not word zpl_pool
|
||||||
not word zpl_opts
|
//not word zpl_opts
|
||||||
|
|
||||||
// Conflicts with refactor
|
// Conflicts with refactor
|
||||||
word alloc, allocator
|
word arena, a_arena
|
||||||
|
word alloc, a_allocator
|
||||||
|
word file, a_file
|
||||||
word file_size, fsize
|
word file_size, fsize
|
||||||
|
word list, a_list
|
||||||
|
word opts, a_opts
|
||||||
|
word pool, a_pool
|
||||||
|
|
||||||
// Conflicts with std.
|
// Conflicts with std. (Uncomment if using c externs)
|
||||||
not word zpl_memchr
|
//not word zpl_memchr
|
||||||
not word zpl_memmove
|
//not word zpl_memmove
|
||||||
not word zpl_memset
|
//not word zpl_memset
|
||||||
not word zpl_memswap
|
//not word zpl_memswap
|
||||||
not word zpl_memcopy
|
//not word zpl_memcopy
|
||||||
not word zpl_printf
|
//not word zpl_printf
|
||||||
not word zpl_printf_va
|
//not word zpl_printf_va
|
||||||
not word zpl_printf_err
|
//not word zpl_printf_err
|
||||||
not word zpl_printf_err_va
|
//not word zpl_printf_err_va
|
||||||
not word zpl_fprintf
|
//not word zpl_fprintf
|
||||||
not word zpl_fprintf_va
|
//not word zpl_fprintf_va
|
||||||
not word zpl_snprintf
|
//not word zpl_snprintf
|
||||||
not word zpl_snprintf_va
|
//not word zpl_snprintf_va
|
||||||
not word zpl_strlen
|
//not word zpl_strchr
|
||||||
not word zpl_strnlen
|
//not word zpl_strlen
|
||||||
not word zpl_exit
|
//not word zpl_strnlen
|
||||||
|
//not word zpl_exit
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
// # define ZPL_MODULE_DLL
|
// # define ZPL_MODULE_DLL
|
||||||
# define ZPL_MODULE_OPTS
|
# define ZPL_MODULE_OPTS
|
||||||
// # define ZPL_MODULE_PROCESS
|
// # define ZPL_MODULE_PROCESS
|
||||||
// # define ZPL_MODULE_MATH
|
// # define ZPL_MODULE_MAT
|
||||||
// # define ZPL_MODULE_THREADING
|
// # define ZPL_MODULE_THREADING
|
||||||
// # define ZPL_MODULE_JOBS
|
// # define ZPL_MODULE_JOBS
|
||||||
// # define ZPL_MODULE_PARSER
|
// # define ZPL_MODULE_PARSER
|
||||||
|
253
thirdparty/zpl.h
vendored
253
thirdparty/zpl.h
vendored
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user