mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
more progress
This commit is contained in:
parent
3a55af9ce4
commit
f7709bb64e
@ -53,7 +53,7 @@ constexpr StrC implementation_guard_end = txt(R"(
|
|||||||
|
|
||||||
void format_file( char const* path )
|
void format_file( char const* path )
|
||||||
{
|
{
|
||||||
String resolved_path = String::make(GlobalAllocator, to_str(path));
|
String resolved_path = String::make(GlobalAllocator, to_strc_from_c_str(path));
|
||||||
|
|
||||||
String style_arg = String::make(GlobalAllocator, txt("-style=file:"));
|
String style_arg = String::make(GlobalAllocator, txt("-style=file:"));
|
||||||
style_arg.append("../scripts/.clang-format ");
|
style_arg.append("../scripts/.clang-format ");
|
||||||
@ -289,7 +289,7 @@ int gen_main()
|
|||||||
break;
|
break;
|
||||||
case CT_Variable:
|
case CT_Variable:
|
||||||
{
|
{
|
||||||
if (contains(entry->Name, txt("Msg_Invalid_Value")))
|
if ( strc_contains(entry->Name, txt("Msg_Invalid_Value")))
|
||||||
{
|
{
|
||||||
CodeDefine define = def_define(entry->Name, entry->Value->Content);
|
CodeDefine define = def_define(entry->Name, entry->Value->Content);
|
||||||
printing.append(define);
|
printing.append(define);
|
||||||
|
@ -283,11 +283,11 @@ CodeBody gen_array( StrC type, StrC array_name )
|
|||||||
#pragma pop_macro( "GEN_ASSERT" )
|
#pragma pop_macro( "GEN_ASSERT" )
|
||||||
|
|
||||||
return def_global_body( args(
|
return def_global_body( args(
|
||||||
def_pragma( to_str( str_fmt_buf( "region %S", array_type ))),
|
def_pragma( string_to_strc( string_fmt_buf( GlobalAllocator, "region %S", array_type ))),
|
||||||
fmt_newline,
|
fmt_newline,
|
||||||
result,
|
result,
|
||||||
fmt_newline,
|
fmt_newline,
|
||||||
def_pragma( to_str( str_fmt_buf( "endregion %S", array_type ))),
|
def_pragma( string_to_strc(string_fmt_buf( GlobalAllocator, "endregion %S", array_type ))),
|
||||||
fmt_newline
|
fmt_newline
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
@ -341,14 +341,14 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
|||||||
, type.Len, type.Ptr );
|
, type.Len, type.Ptr );
|
||||||
|
|
||||||
return def_global_body(args(
|
return def_global_body(args(
|
||||||
def_pragma( to_str( str_fmt_buf( "region %S", tbl_type ))),
|
def_pragma( string_to_strc( string_fmt_buf( GlobalAllocator, "region %S", tbl_type ))),
|
||||||
fmt_newline,
|
fmt_newline,
|
||||||
hashtable_types,
|
hashtable_types,
|
||||||
fmt_newline,
|
fmt_newline,
|
||||||
entry_array,
|
entry_array,
|
||||||
hashtable_def,
|
hashtable_def,
|
||||||
fmt_newline,
|
fmt_newline,
|
||||||
def_pragma( to_str( str_fmt_buf( "endregion %S", tbl_type ))),
|
def_pragma( string_to_strc( string_fmt_buf( GlobalAllocator, "endregion %S", tbl_type ))),
|
||||||
fmt_newline
|
fmt_newline
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ int gen_main()
|
|||||||
def_include(txt("components/types.hpp")),
|
def_include(txt("components/types.hpp")),
|
||||||
preprocess_endif,
|
preprocess_endif,
|
||||||
fmt_newline,
|
fmt_newline,
|
||||||
untyped_str( strc_to_str(generation_notice) )
|
untyped_str( to_strc_from_c_str(generation_notice) )
|
||||||
));
|
));
|
||||||
|
|
||||||
// gen.hpp
|
// gen.hpp
|
||||||
|
@ -265,7 +265,7 @@ char const* debug_str(Code self)
|
|||||||
case CT_Specifiers:
|
case CT_Specifiers:
|
||||||
{
|
{
|
||||||
string_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
|
string_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
|
||||||
string_append_c_str( result, "\n\tArrSpecs: " );
|
string_append_strc( result, txt("\n\tArrSpecs: ") );
|
||||||
|
|
||||||
s32 idx = 0;
|
s32 idx = 0;
|
||||||
s32 left = self->NumEntries;
|
s32 left = self->NumEntries;
|
||||||
@ -387,7 +387,7 @@ void to_string( Code self, String* result )
|
|||||||
#ifdef GEN_DONT_ALLOW_INVALID_CODE
|
#ifdef GEN_DONT_ALLOW_INVALID_CODE
|
||||||
log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->debug_str() : Name );
|
log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->debug_str() : Name );
|
||||||
#else
|
#else
|
||||||
append_fmt( result, "Invalid Code!" );
|
string_append_fmt( result, "Invalid Code!" );
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ void reset()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
Pool* code_pool = & CodePools[index];
|
Pool* code_pool = & CodePools[index];
|
||||||
clear(* code_pool);
|
pool_clear(code_pool);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
while ( left--, left );
|
while ( left--, left );
|
||||||
|
@ -907,14 +907,14 @@ CodeInclude def_include( StrC path, Opts_def_include p )
|
|||||||
return InvalidCode;
|
return InvalidCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
StrC content = p.foreign ?
|
String content = p.foreign ?
|
||||||
string_to_strc( str_fmt_buf( "<%.*s>", path.Len, path.Ptr ))
|
string_fmt_buf( GlobalAllocator, "<%.*s>", path.Len, path.Ptr )
|
||||||
: string_to_strc( str_fmt_buf( "\"%.*s\"", path.Len, path.Ptr ));
|
: string_fmt_buf( GlobalAllocator, "\"%.*s\"", path.Len, path.Ptr );
|
||||||
|
|
||||||
Code
|
Code
|
||||||
result = make_code();
|
result = make_code();
|
||||||
result->Type = CT_Preprocess_Include;
|
result->Type = CT_Preprocess_Include;
|
||||||
result->Name = get_cached_string( content );
|
result->Name = get_cached_string( string_to_strc(content) );
|
||||||
result->Content = result->Name;
|
result->Content = result->Name;
|
||||||
|
|
||||||
return (CodeInclude) result;
|
return (CodeInclude) result;
|
||||||
|
@ -96,7 +96,7 @@ String to_string(Token tok)
|
|||||||
|
|
||||||
StrC type_str = to_str( tok.Type );
|
StrC type_str = to_str( tok.Type );
|
||||||
|
|
||||||
append_fmt( & result, "Line: %d Column: %d, Type: %.*s Content: %.*s"
|
string_append_fmt( & result, "Line: %d Column: %d, Type: %.*s Content: %.*s"
|
||||||
, tok.Line, tok.Column
|
, tok.Line, tok.Column
|
||||||
, type_str.Len, type_str.Ptr
|
, type_str.Len, type_str.Ptr
|
||||||
, tok.Length, tok.Text
|
, tok.Length, tok.Text
|
||||||
|
@ -365,7 +365,7 @@ String strip_formatting( StrC raw_text, bool preserve_newlines = true )
|
|||||||
string_append_c_str_len( & content, cut_ptr, cut_length);
|
string_append_c_str_len( & content, cut_ptr, cut_length);
|
||||||
|
|
||||||
if ( * string_back( content ) != ' ' )
|
if ( * string_back( content ) != ' ' )
|
||||||
string_append_strc( & content, txt(' '));
|
string_append_char( & content, ' ' );
|
||||||
|
|
||||||
move_fwd();
|
move_fwd();
|
||||||
last_cut = sptr(scanner) - sptr(raw_text.Ptr);
|
last_cut = sptr(scanner) - sptr(raw_text.Ptr);
|
||||||
@ -391,7 +391,7 @@ String strip_formatting( StrC raw_text, bool preserve_newlines = true )
|
|||||||
|
|
||||||
// Replace with a space
|
// Replace with a space
|
||||||
if ( * string_back( content ) != ' ' )
|
if ( * string_back( content ) != ' ' )
|
||||||
string_append_strc( & content, txt(' ') );
|
string_append_char( & content, ' ' );
|
||||||
|
|
||||||
scanner += 2;
|
scanner += 2;
|
||||||
tokleft -= 2;
|
tokleft -= 2;
|
||||||
@ -417,8 +417,8 @@ String strip_formatting( StrC raw_text, bool preserve_newlines = true )
|
|||||||
string_append_c_str_len( & content, cut_ptr, cut_length );
|
string_append_c_str_len( & content, cut_ptr, cut_length );
|
||||||
|
|
||||||
// Replace with a space
|
// Replace with a space
|
||||||
if ( * back( & content ) != ' ' )
|
if ( * string_back( content ) != ' ' )
|
||||||
string_append_strc( & content, txt(' ') );
|
string_append_char( & content, ' ' );
|
||||||
|
|
||||||
move_fwd();
|
move_fwd();
|
||||||
|
|
||||||
@ -466,9 +466,9 @@ String strip_formatting( StrC raw_text, bool preserve_newlines = true )
|
|||||||
last_cut = sptr( scanner ) - sptr( raw_text.Ptr );
|
last_cut = sptr( scanner ) - sptr( raw_text.Ptr );
|
||||||
|
|
||||||
// Preserve only 1 space of formattting
|
// Preserve only 1 space of formattting
|
||||||
char* last = back(& content);
|
char* last = string_back(content);
|
||||||
if ( last == nullptr || * last != ' ' )
|
if ( last == nullptr || * last != ' ' )
|
||||||
string_append_strc( & content, txt(' ') );
|
string_append_char( & content, ' ' );
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#pragma region Memory
|
#pragma region Memory
|
||||||
|
|
||||||
|
GEN_API_C_BEGIN
|
||||||
|
|
||||||
void* mem_copy( void* dest, void const* source, ssize n )
|
void* mem_copy( void* dest, void const* source, ssize n )
|
||||||
{
|
{
|
||||||
if ( dest == NULL )
|
if ( dest == NULL )
|
||||||
@ -495,16 +497,16 @@ Pool pool_init_align( AllocatorInfo backing, ssize num_blocks, ssize block_size,
|
|||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear(Pool& pool)
|
void pool_clear(Pool* pool)
|
||||||
{
|
{
|
||||||
ssize actual_block_size, block_index;
|
ssize actual_block_size, block_index;
|
||||||
void* curr;
|
void* curr;
|
||||||
uptr* end;
|
uptr* end;
|
||||||
|
|
||||||
actual_block_size = pool.BlockSize + pool.BlockAlign;
|
actual_block_size = pool->BlockSize + pool->BlockAlign;
|
||||||
|
|
||||||
curr = pool.PhysicalStart;
|
curr = pool->PhysicalStart;
|
||||||
for ( block_index = 0; block_index < pool.NumBlocks - 1; block_index++ )
|
for ( block_index = 0; block_index < pool->NumBlocks - 1; block_index++ )
|
||||||
{
|
{
|
||||||
uptr* next = ( uptr* ) curr;
|
uptr* next = ( uptr* ) curr;
|
||||||
*next = ( uptr ) curr + actual_block_size;
|
*next = ( uptr ) curr + actual_block_size;
|
||||||
@ -514,7 +516,9 @@ void clear(Pool& pool)
|
|||||||
end = ( uptr* ) curr;
|
end = ( uptr* ) curr;
|
||||||
*end = ( uptr ) NULL;
|
*end = ( uptr ) NULL;
|
||||||
|
|
||||||
pool.FreeList = pool.PhysicalStart;
|
pool->FreeList = pool->PhysicalStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GEN_API_C_END
|
||||||
|
|
||||||
#pragma endregion Memory
|
#pragma endregion Memory
|
||||||
|
@ -222,6 +222,7 @@ struct Arena_Def
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if GEN_SUPPORT_CPP_REFERENCES
|
#if GEN_SUPPORT_CPP_REFERENCES
|
||||||
|
GEN_API_C_END
|
||||||
forceinline AllocatorInfo allocator_info(Arena& arena ) { return arena_allocator_info(& arena); }
|
forceinline AllocatorInfo allocator_info(Arena& arena ) { return arena_allocator_info(& arena); }
|
||||||
forceinline Arena init_sub (Arena& parent, ssize size) { return arena_init_sub( & parent, size); }
|
forceinline Arena init_sub (Arena& parent, ssize size) { return arena_init_sub( & parent, size); }
|
||||||
forceinline ssize alignment_of (Arena& arena, ssize alignment) { return arena_alignment_of( & arena, alignment); }
|
forceinline ssize alignment_of (Arena& arena, ssize alignment) { return arena_alignment_of( & arena, alignment); }
|
||||||
@ -231,8 +232,9 @@ forceinline ssize size_remaining(Arena& arena, ssize alignment) { return
|
|||||||
// This id is defined by Unreal for asserts
|
// This id is defined by Unreal for asserts
|
||||||
#pragma push_macro("check")
|
#pragma push_macro("check")
|
||||||
#undef check
|
#undef check
|
||||||
forceinline void check(Arena& arena) { return check(& arena); };
|
forceinline void check(Arena& arena) { return arena_check(& arena); };
|
||||||
#pragma pop_macro("check")
|
#pragma pop_macro("check")
|
||||||
|
GEN_API_C_BEGIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -397,9 +399,11 @@ void pool_clear(Pool* pool);
|
|||||||
void pool_free(Pool* pool);
|
void pool_free(Pool* pool);
|
||||||
|
|
||||||
#if GEN_SUPPORT_CPP_REFERENCES
|
#if GEN_SUPPORT_CPP_REFERENCES
|
||||||
AllocatorInfo allocator_info(Pool& pool) { return GEN_NS allocator_info(& pool); }
|
GEN_API_C_END
|
||||||
void clear(Pool& pool) { return GEN_NS clear(& pool); }
|
AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); }
|
||||||
void free(Pool& pool) { return GEN_NS free(& pool); }
|
void clear(Pool& pool) { return pool_clear(& pool); }
|
||||||
|
void free(Pool& pool) { return pool_free(& pool); }
|
||||||
|
GEN_API_C_BEGIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Pool_Def
|
struct Pool_Def
|
||||||
|
@ -170,7 +170,7 @@ struct String
|
|||||||
|
|
||||||
forceinline operator char*() { return Data; }
|
forceinline operator char*() { return Data; }
|
||||||
forceinline operator char const*() const { return Data; }
|
forceinline operator char const*() const { return Data; }
|
||||||
forceinline operator StrC() const { return { GEN_NS length(* this), Data }; }
|
forceinline operator StrC() const { return { string_length(* this), Data }; }
|
||||||
|
|
||||||
String const& operator=(String const& other) const {
|
String const& operator=(String const& other) const {
|
||||||
if (this == &other)
|
if (this == &other)
|
||||||
@ -191,23 +191,23 @@ struct String
|
|||||||
friend forceinline bool operator!=(std::nullptr_t, const String str) { return str.Data != nullptr; }
|
friend forceinline bool operator!=(std::nullptr_t, const String str) { return str.Data != nullptr; }
|
||||||
|
|
||||||
forceinline char* begin() const { return Data; }
|
forceinline char* begin() const { return Data; }
|
||||||
forceinline char* end() const { return Data + GEN_NS length(* this); }
|
forceinline char* end() const { return Data + string_length(* this); }
|
||||||
|
|
||||||
#pragma region Member Mapping
|
#pragma region Member Mapping
|
||||||
forceinline static String make(AllocatorInfo allocator, char const* str) { return GEN_NS string_make(allocator, str); }
|
forceinline static String make(AllocatorInfo allocator, char const* str) { return string_make_c_str(allocator, str); }
|
||||||
forceinline static String make(AllocatorInfo allocator, StrC str) { return GEN_NS string_make(allocator, str); }
|
forceinline static String make(AllocatorInfo allocator, StrC str) { return string_make_strc(allocator, str); }
|
||||||
forceinline static String make_reserve(AllocatorInfo allocator, ssize cap) { return GEN_NS string_make_reserve(allocator, cap); }
|
forceinline static String make_reserve(AllocatorInfo allocator, ssize cap) { return string_make_reserve(allocator, cap); }
|
||||||
forceinline static String make_length(AllocatorInfo a, char const* s, ssize l) { return GEN_NS string_make_length(a, s, l); }
|
forceinline static String make_length(AllocatorInfo a, char const* s, ssize l) { return string_make_length(a, s, l); }
|
||||||
forceinline static String join(AllocatorInfo a, char const** p, ssize n, char const* g) { return GEN_NS string_join(a, p, n, g); }
|
forceinline static String join(AllocatorInfo a, char const** p, ssize n, char const* g) { return string_join(a, p, n, g); }
|
||||||
forceinline static usize grow_formula(usize value) { return GEN_NS string_grow_formula(value); }
|
forceinline static usize grow_formula(usize value) { return string_grow_formula(value); }
|
||||||
|
|
||||||
static
|
static
|
||||||
String fmt(AllocatorInfo allocator, char* buf, ssize buf_size, char const* fmt, ...) {
|
String fmt(AllocatorInfo allocator, char* buf, ssize buf_size, char const* fmt, ...) {
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
str_fmt_va(buf, buf_size, fmt, va);
|
ssize res = str_fmt_va(buf, buf_size, fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
return GEN_NS string_make(allocator, buf);
|
return string_make_length(allocator, buf, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -216,37 +216,37 @@ struct String
|
|||||||
char buf[GEN_PRINTF_MAXLEN] = { 0 };
|
char buf[GEN_PRINTF_MAXLEN] = { 0 };
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va);
|
ssize res = str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
return GEN_NS string_make(allocator, buf);
|
return string_make_length(allocator, buf, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
forceinline bool make_space_for(char const* str, ssize add_len) { return GEN_NS make_space_for(this, str, add_len); }
|
forceinline bool make_space_for(char const* str, ssize add_len) { return string_make_space_for(this, str, add_len); }
|
||||||
forceinline bool append(char c) { return GEN_NS string_append_char(this, c); }
|
forceinline bool append(char c) { return string_append_char(this, c); }
|
||||||
forceinline bool append(char const* str) { return GEN_NS string_append_c_str(this, str); }
|
forceinline bool append(char const* str) { return string_append_c_str(this, str); }
|
||||||
forceinline bool append(char const* str, ssize length) { return GEN_NS string_append_c_str_len(this, str, length); }
|
forceinline bool append(char const* str, ssize length) { return string_append_c_str_len(this, str, length); }
|
||||||
forceinline bool append(StrC str) { return GEN_NS string_append_strc(this, str); }
|
forceinline bool append(StrC str) { return string_append_strc(this, str); }
|
||||||
forceinline bool append(const String other) { return GEN_NS string_append_string(this, other); }
|
forceinline bool append(const String other) { return string_append_string(this, other); }
|
||||||
forceinline ssize avail_space() const { return GEN_NS string_avail_space(* this); }
|
forceinline ssize avail_space() const { return string_avail_space(* this); }
|
||||||
forceinline char* back() { return GEN_NS string_back(* this); }
|
forceinline char* back() { return string_back(* this); }
|
||||||
forceinline bool contains(StrC substring) const { return GEN_NS string_contains_strc(* this, substring); }
|
forceinline bool contains(StrC substring) const { return string_contains_strc(* this, substring); }
|
||||||
forceinline bool contains(String const& substring) const { return GEN_NS string_contains_string(* this, substring); }
|
forceinline bool contains(String const& substring) const { return string_contains_string(* this, substring); }
|
||||||
forceinline ssize capacity() const { return GEN_NS capacity(* this); }
|
forceinline ssize capacity() const { return string_capacity(* this); }
|
||||||
forceinline void clear() { GEN_NS clear(* this); }
|
forceinline void clear() { string_clear(* this); }
|
||||||
forceinline String duplicate(AllocatorInfo allocator) const { return GEN_NS duplicate(* this, allocator); }
|
forceinline String duplicate(AllocatorInfo allocator) const { return string_duplicate(* this, allocator); }
|
||||||
forceinline void free() { GEN_NS free(this); }
|
forceinline void free() { string_free(this); }
|
||||||
forceinline bool is_equal(String const& other) const { return GEN_NS are_equal(* this, other); }
|
forceinline bool is_equal(String const& other) const { return string_are_equal(* this, other); }
|
||||||
forceinline bool is_equal(StrC other) const { return GEN_NS are_equal(* this, other); }
|
forceinline bool is_equal(StrC other) const { return string_are_equal_strc(* this, other); }
|
||||||
forceinline ssize length() const { return GEN_NS length(* this); }
|
forceinline ssize length() const { return string_length(* this); }
|
||||||
forceinline b32 starts_with(StrC substring) const { return GEN_NS starts_with(* this, substring); }
|
forceinline b32 starts_with(StrC substring) const { return string_starts_with_strc(* this, substring); }
|
||||||
forceinline b32 starts_with(String substring) const { return GEN_NS starts_with(* this, substring); }
|
forceinline b32 starts_with(String substring) const { return string_starts_with_string(* this, substring); }
|
||||||
forceinline void skip_line() { GEN_NS skip_line(* this); }
|
forceinline void skip_line() { string_skip_line(* this); }
|
||||||
forceinline void strip_space() { GEN_NS strip_space(* this); }
|
forceinline void strip_space() { string_strip_space(* this); }
|
||||||
forceinline StrC to_strc() { return { length(), Data}; }
|
forceinline StrC to_strc() { return { string_length(*this), Data}; }
|
||||||
forceinline void trim(char const* cut_set) { GEN_NS trim(* this, cut_set); }
|
forceinline void trim(char const* cut_set) { string_trim(* this, cut_set); }
|
||||||
forceinline void trim_space() { GEN_NS trim_space(* this); }
|
forceinline void trim_space() { string_trim_space(* this); }
|
||||||
forceinline String visualize_whitespace() const { return GEN_NS visualize_whitespace(* this); }
|
forceinline String visualize_whitespace() const { return string_visualize_whitespace(* this); }
|
||||||
forceinline StringHeader& get_header() { return * GEN_NS get_header(* this); }
|
forceinline StringHeader& get_header() { return * string_get_header(* this); }
|
||||||
|
|
||||||
bool append_fmt(char const* fmt, ...) {
|
bool append_fmt(char const* fmt, ...) {
|
||||||
ssize res;
|
ssize res;
|
||||||
@ -257,7 +257,7 @@ struct String
|
|||||||
res = str_fmt_va(buf, count_of(buf) - 1, fmt, va) - 1;
|
res = str_fmt_va(buf, count_of(buf) - 1, fmt, va) - 1;
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
return GEN_NS append(this, buf, res);
|
return string_append_c_str_len(this, buf, res);
|
||||||
}
|
}
|
||||||
#pragma endregion Member Mapping
|
#pragma endregion Member Mapping
|
||||||
};
|
};
|
||||||
@ -360,7 +360,7 @@ bool string_append_c_str(String* str, char const* str_to_append) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool string_append_str_c_len(String* str, char const* str_to_append, ssize append_length)
|
bool string_append_c_str_len(String* str, char const* str_to_append, ssize append_length)
|
||||||
{
|
{
|
||||||
GEN_ASSERT(str != nullptr);
|
GEN_ASSERT(str != nullptr);
|
||||||
if (sptr(str_to_append) > 0)
|
if (sptr(str_to_append) > 0)
|
||||||
@ -394,7 +394,7 @@ bool string_append_string(String* str, String const other) {
|
|||||||
return string_append_c_str_len(str, (char const*)other, string_length(other));
|
return string_append_c_str_len(str, (char const*)other, string_length(other));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool append_fmt(String* str, char const* fmt, ...) {
|
bool string_append_fmt(String* str, char const* fmt, ...) {
|
||||||
GEN_ASSERT(str != nullptr);
|
GEN_ASSERT(str != nullptr);
|
||||||
ssize res;
|
ssize res;
|
||||||
char buf[GEN_PRINTF_MAXLEN] = { 0 };
|
char buf[GEN_PRINTF_MAXLEN] = { 0 };
|
||||||
@ -434,18 +434,18 @@ bool string_are_equal_strc(String const lhs, StrC rhs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
forceinline
|
forceinline
|
||||||
ssize avail_space(String const str) {
|
ssize string_avail_space(String const str) {
|
||||||
StringHeader const* header = rcast(StringHeader const*, scast(char const*, str) - sizeof(StringHeader));
|
StringHeader const* header = rcast(StringHeader const*, scast(char const*, str) - sizeof(StringHeader));
|
||||||
return header->Capacity - header->Length;
|
return header->Capacity - header->Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
forceinline
|
forceinline
|
||||||
char* back(String* str) {
|
char* string_back(String str) {
|
||||||
return & (*str)[string_length(* str) - 1];
|
return & (str)[string_length(str) - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool contains(String const str, StrC substring)
|
bool string_contains_StrC(String const str, StrC substring)
|
||||||
{
|
{
|
||||||
StringHeader const* header = rcast(StringHeader const*, scast(char const*, str) - sizeof(StringHeader));
|
StringHeader const* header = rcast(StringHeader const*, scast(char const*, str) - sizeof(StringHeader));
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ CodeBody gen_ecode( char const* path )
|
|||||||
{
|
{
|
||||||
char const* code = node->string;
|
char const* code = node->string;
|
||||||
|
|
||||||
append_fmt( & enum_entries, "CT_%s,\n", code );
|
string_append_fmt( & enum_entries, "CT_%s,\n", code );
|
||||||
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", code, code );
|
string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", code, code );
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", string_to_strc(enum_entries),
|
CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", string_to_strc(enum_entries),
|
||||||
@ -79,8 +79,8 @@ CodeBody gen_eoperator( char const* path )
|
|||||||
char const* enum_str = enum_strs[idx].string;
|
char const* enum_str = enum_strs[idx].string;
|
||||||
char const* entry_to_str = str_strs [idx].string;
|
char const* entry_to_str = str_strs [idx].string;
|
||||||
|
|
||||||
append_fmt( & enum_entries, "Op_%s,\n", enum_str );
|
string_append_fmt( & enum_entries, "Op_%s,\n", enum_str );
|
||||||
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeEnum enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
CodeEnum enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
||||||
@ -135,8 +135,8 @@ CodeBody gen_especifier( char const* path )
|
|||||||
char const* enum_str = enum_strs[idx].string;
|
char const* enum_str = enum_strs[idx].string;
|
||||||
char const* entry_to_str = str_strs [idx].string;
|
char const* entry_to_str = str_strs [idx].string;
|
||||||
|
|
||||||
append_fmt( & enum_entries, "Spec_%s,\n", enum_str );
|
string_append_fmt( & enum_entries, "Spec_%s,\n", enum_str );
|
||||||
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeEnum enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
CodeEnum enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
||||||
@ -252,8 +252,8 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
|||||||
char const* enum_str = enum_strs[idx].string;
|
char const* enum_str = enum_strs[idx].string;
|
||||||
char const* entry_to_str = enum_str_strs [idx].string;
|
char const* entry_to_str = enum_str_strs [idx].string;
|
||||||
|
|
||||||
append_fmt( & enum_entries, "Tok_%s,\n", enum_str );
|
string_append_fmt( & enum_entries, "Tok_%s,\n", enum_str );
|
||||||
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( usize idx = 0; idx < array_num(attribute_strs); idx++ )
|
for ( usize idx = 0; idx < array_num(attribute_strs); idx++ )
|
||||||
@ -261,9 +261,9 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
|||||||
char const* attribute_str = attribute_strs[idx].string;
|
char const* attribute_str = attribute_strs[idx].string;
|
||||||
char const* entry_to_str = attribute_str_strs [idx].string;
|
char const* entry_to_str = attribute_str_strs [idx].string;
|
||||||
|
|
||||||
append_fmt( & attribute_entries, "Tok_Attribute_%s,\n", attribute_str );
|
string_append_fmt( & attribute_entries, "Tok_Attribute_%s,\n", attribute_str );
|
||||||
append_fmt( & to_str_attributes, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
string_append_fmt( & to_str_attributes, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||||
append_fmt( & attribute_define_entries, "Entry( Tok_Attribute_%s, \"%s\" )", attribute_str, entry_to_str );
|
string_append_fmt( & attribute_define_entries, "Entry( Tok_Attribute_%s, \"%s\" )", attribute_str, entry_to_str );
|
||||||
|
|
||||||
if ( idx < array_num(attribute_strs) - 1 )
|
if ( idx < array_num(attribute_strs) - 1 )
|
||||||
string_append_strc( & attribute_define_entries, txt(" \\\n"));
|
string_append_strc( & attribute_define_entries, txt(" \\\n"));
|
||||||
|
Loading…
Reference in New Issue
Block a user