mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-14 18:51:47 -07:00
Got it to compile (without Incremental, parsing, editor, scanner)
This commit is contained in:
@ -80,10 +80,10 @@ using zpl::pool_init;
|
||||
using zpl::pool_free;
|
||||
using zpl::process_exit;
|
||||
using zpl::str_copy;
|
||||
using zpl::str_fmt_va;
|
||||
using zpl::str_fmt_out_va;
|
||||
using zpl::str_fmt_out_err_va;
|
||||
using zpl::str_compare;
|
||||
using zpl::str_fmt_va;
|
||||
using zpl::string_appendc;
|
||||
using zpl::string_append_fmt;
|
||||
using zpl::string_append_length;
|
||||
@ -104,6 +104,7 @@ using zpl::str_len;
|
||||
# pragma clang diagnostic ignored "-Wunused-variable"
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
# pragma clang diagnostic ignored "-Wvarargs"
|
||||
# pragma clang diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
|
||||
@ -264,14 +265,12 @@ char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
||||
if ( ! str )
|
||||
mem_set( allocation, 0, alloc_size );
|
||||
|
||||
Header
|
||||
header = { allocator, length, length };
|
||||
Header header = { allocator, length, length };
|
||||
String result = { rcast( char*, allocation) + header_size };
|
||||
|
||||
if ( length && str )
|
||||
mem_copy( allocation + header_size, str, length );
|
||||
mem_copy( result, str, length );
|
||||
|
||||
String
|
||||
result = { rcast( char*, allocation + header_size) };
|
||||
result[ length ] = '\0';
|
||||
|
||||
return result;
|
||||
@ -327,8 +326,45 @@ char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool make_space_for( char const* str, sw add_len )
|
||||
{
|
||||
sw available = avail_space();
|
||||
|
||||
// NOTE: Return if there is enough space left
|
||||
if ( available >= add_len )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sw new_len, old_size, new_size;
|
||||
|
||||
void* ptr;
|
||||
void* new_ptr;
|
||||
|
||||
AllocatorInfo allocator = get_header().Allocator;
|
||||
Header* header = nullptr;
|
||||
|
||||
new_len = length() + add_len;
|
||||
ptr = & get_header();
|
||||
old_size = size_of( Header ) + length() + 1;
|
||||
new_size = size_of( Header ) + new_len + 1;
|
||||
|
||||
new_ptr = resize( allocator, ptr, old_size, new_size );
|
||||
|
||||
if ( new_ptr == nullptr )
|
||||
return false;
|
||||
|
||||
header = zpl_cast( Header* ) new_ptr;
|
||||
header->Allocator = allocator;
|
||||
header->Capacity = new_len;
|
||||
|
||||
Data = rcast( char*, header + 1 );
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
bool make_space_for( char const* str, sw add_len );
|
||||
|
||||
bool append( char const* str )
|
||||
{
|
||||
@ -339,7 +375,7 @@ char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
||||
{
|
||||
Header& header = get_header();
|
||||
|
||||
if ( str > 0 )
|
||||
if ( sptr(str) > 0 )
|
||||
{
|
||||
sw curr_len = header.Length;
|
||||
|
||||
@ -428,60 +464,12 @@ char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
||||
return header.Length;
|
||||
}
|
||||
|
||||
bool make_space_for( char const* str, sw add_len )
|
||||
{
|
||||
sw available = avail_space();
|
||||
|
||||
// NOTE: Return if there is enough space left
|
||||
if ( available >= add_len )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sw new_len, old_size, new_size;
|
||||
|
||||
void* ptr;
|
||||
void* new_ptr;
|
||||
|
||||
AllocatorInfo allocator = get_header().Allocator;
|
||||
Header* header = nullptr;
|
||||
|
||||
new_len = length() + add_len;
|
||||
ptr = & get_header();
|
||||
old_size = size_of( Header ) + length() + 1;
|
||||
new_size = size_of( Header ) + new_len + 1;
|
||||
|
||||
new_ptr = resize( allocator, ptr, old_size, new_size );
|
||||
|
||||
if ( new_ptr == nullptr )
|
||||
return false;
|
||||
|
||||
header = zpl_cast( Header* ) new_ptr;
|
||||
header->Allocator = allocator;
|
||||
header->Capacity = new_len;
|
||||
|
||||
Data = rcast( char*, header + 1 );
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
void trim( char const* cut_set )
|
||||
{
|
||||
char* start;
|
||||
char* end;
|
||||
|
||||
char* start_pos;
|
||||
char* end_pos;
|
||||
|
||||
sw len = 0;
|
||||
|
||||
start_pos = Data;
|
||||
start = Data;
|
||||
|
||||
end_pos = Data + length() - 1;
|
||||
end = Data + length() - 1;
|
||||
char* start_pos = Data;
|
||||
char* end_pos = Data + length() - 1;
|
||||
|
||||
while ( start_pos <= end_pos && char_first_occurence( cut_set, *start_pos ) )
|
||||
start_pos++;
|
||||
@ -606,7 +594,7 @@ sw fatal(char const* fmt, ...)
|
||||
|
||||
#if Build_Debug
|
||||
va_start(va, fmt);
|
||||
zpl::snprintf_va(buf, ZPL_PRINTF_MAXLEN, fmt, va);
|
||||
str_fmt_va(buf, ZPL_PRINTF_MAXLEN, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
assert_crash(buf);
|
||||
|
@ -28,10 +28,10 @@ namespace gen
|
||||
#pragma region Constants
|
||||
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
Code type_ns(void);
|
||||
|
||||
Code type_ns(int);
|
||||
Code type_ns(bool);
|
||||
Code type_ns(char);
|
||||
Code type_ns(char_wide);
|
||||
Code type_ns(wchar_t);
|
||||
|
||||
Code type_ns(s8);
|
||||
Code type_ns(s16);
|
||||
@ -421,7 +421,8 @@ namespace gen
|
||||
switch ( Type )
|
||||
{
|
||||
case Invalid:
|
||||
break;
|
||||
log_failure( "AST::duplicate: Cannot duplicate an invalid AST." );
|
||||
return nullptr;
|
||||
|
||||
case Untyped:
|
||||
case Comment:
|
||||
@ -484,6 +485,9 @@ namespace gen
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
log_failure( "AST::duplicate: Unknown AST type %s.", type_str() );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
String AST::to_string()
|
||||
@ -606,6 +610,7 @@ namespace gen
|
||||
break;
|
||||
|
||||
case Enum:
|
||||
{
|
||||
result.append( indent );
|
||||
|
||||
ProcessModuleFlags();
|
||||
@ -640,6 +645,7 @@ namespace gen
|
||||
, body()->to_string()
|
||||
, indent_str
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case Enum_Fwd:
|
||||
@ -651,6 +657,7 @@ namespace gen
|
||||
break;
|
||||
|
||||
case Enum_Class:
|
||||
{
|
||||
result.append( indent );
|
||||
|
||||
ProcessModuleFlags();
|
||||
@ -685,9 +692,11 @@ namespace gen
|
||||
, body()->to_string()
|
||||
, indent_str
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case Enum_Class_Fwd:
|
||||
{
|
||||
result.append( indent );
|
||||
|
||||
ProcessModuleFlags();
|
||||
@ -703,6 +712,7 @@ namespace gen
|
||||
}
|
||||
|
||||
result.append_fmt( ": %s;\n", Name, Entries[idx]->to_string() );
|
||||
}
|
||||
break;
|
||||
|
||||
case Execution:
|
||||
@ -900,7 +910,7 @@ namespace gen
|
||||
|
||||
ProcessModuleFlags();
|
||||
|
||||
s32 idx;
|
||||
s32 idx = 0;
|
||||
|
||||
if ( Entries[idx]->Type == Specifiers )
|
||||
{
|
||||
@ -1022,6 +1032,7 @@ namespace gen
|
||||
break;
|
||||
|
||||
case Typedef:
|
||||
{
|
||||
result.append( indent );
|
||||
|
||||
ProcessModuleFlags();
|
||||
@ -1043,6 +1054,7 @@ namespace gen
|
||||
{
|
||||
result.append( ";" );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Typename:
|
||||
@ -1057,6 +1069,7 @@ namespace gen
|
||||
break;
|
||||
|
||||
case Union:
|
||||
{
|
||||
result.append( indent );
|
||||
|
||||
ProcessModuleFlags();
|
||||
@ -1077,9 +1090,11 @@ namespace gen
|
||||
, body()->to_string()
|
||||
, indent_str
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case Using:
|
||||
{
|
||||
result.append( indent );
|
||||
|
||||
ProcessModuleFlags();
|
||||
@ -1103,6 +1118,7 @@ namespace gen
|
||||
result.append_fmt( "using %s", Name );
|
||||
|
||||
result.append( ";" );
|
||||
}
|
||||
break;
|
||||
|
||||
case Using_Namespace:
|
||||
@ -1195,16 +1211,17 @@ namespace gen
|
||||
|
||||
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
Code&
|
||||
t_bool_write = ccast( Code, t_void );
|
||||
t_bool_write = def_type( name(void) );
|
||||
t_void_write = ccast( Code, t_void );
|
||||
t_void_write = def_type( name(void) );
|
||||
t_void_write->Readonly = true;
|
||||
|
||||
# define def_constant_code_type( Type_ ) \
|
||||
Code& \
|
||||
t_##Type_ = def_type( name(Type_) ); \
|
||||
t_##Type_->Readonly = true;
|
||||
# define def_constant_code_type( Type_ ) \
|
||||
Code& \
|
||||
t_##Type_##write = ccast( Code, type_ns(Type_) ); \
|
||||
t_##Type_##write = def_type( name(Type_) ); \
|
||||
t_##Type_##write->Readonly = true;
|
||||
|
||||
def_constant_code_type( int );
|
||||
|
||||
def_constant_code_type( bool );
|
||||
def_constant_code_type( char );
|
||||
def_constant_code_type( wchar_t );
|
||||
@ -1231,10 +1248,11 @@ namespace gen
|
||||
spec_constexpr_write = ccast( Code, spec_constexpr );
|
||||
spec_constexpr_write = def_specifiers( 1, ESpecifier::Constexpr );
|
||||
|
||||
# define def_constant_spec( Type_, ... ) \
|
||||
Code& \
|
||||
spec_##Type_ = def_specifiers( macro_num_args(__VA_ARGS__), __VA_ARGS__); \
|
||||
spec_##Type_.lock();
|
||||
# define def_constant_spec( Type_, ... ) \
|
||||
Code& \
|
||||
spec_##Type_##write = ccast( Code, spec_##Type_); \
|
||||
spec_##Type_##write = def_specifiers( macro_num_args(__VA_ARGS__), __VA_ARGS__); \
|
||||
spec_##Type_##write.lock()
|
||||
|
||||
def_constant_spec( const, ESpecifier::Const );
|
||||
def_constant_spec( inline, ESpecifier::Inline );
|
||||
@ -1855,7 +1873,7 @@ namespace gen
|
||||
return Code::Invalid;
|
||||
}
|
||||
|
||||
if ( parent && parent->Type != Class || parent->Type != Struct || parent->Type != Typename || parent->Type != Untyped )
|
||||
if ( parent && (parent->Type != Class || parent->Type != Struct || parent->Type != Typename || parent->Type != Untyped) )
|
||||
{
|
||||
log_failure( "gen::def_class: parent provided is not type 'Class', 'Struct', 'Typeanme', or 'Untyped': %s", parent->debug_str() );
|
||||
return Code::Invalid;
|
||||
|
@ -16,10 +16,10 @@
|
||||
// #define GEN_DONT_USE_FATAL
|
||||
#define GEN_ENFORCE_READONLY_AST
|
||||
|
||||
#define GEN_FEATURE_INCREMENTAL
|
||||
#define GEN_FEATURE_PARSING
|
||||
#define GEN_FEATURE_EDITOR
|
||||
#define GEN_FEATURE_SCANNER
|
||||
// #define GEN_FEATURE_INCREMENTAL
|
||||
// #define GEN_FEATURE_PARSING
|
||||
// #define GEN_FEATURE_EDITOR
|
||||
// #define GEN_FEATURE_SCANNER
|
||||
|
||||
|
||||
#ifdef gen_time
|
||||
@ -188,9 +188,6 @@ namespace gen
|
||||
inline
|
||||
char const* to_str( Type op )
|
||||
{
|
||||
using something = u8;
|
||||
typedef u8 another;
|
||||
|
||||
local_persist
|
||||
char const* lookup[ Num_Ops ] = {
|
||||
# define Entry( Type_, Token_ ) txt(Token_),
|
||||
@ -312,7 +309,7 @@ namespace gen
|
||||
};
|
||||
|
||||
if ( type > AccessSpec::Public )
|
||||
return lookup[ (u32)AccessSpec::Invalid ];
|
||||
return "Invalid";
|
||||
|
||||
return lookup[ (u32)type ];
|
||||
}
|
||||
@ -482,12 +479,14 @@ namespace gen
|
||||
bool typename_is_ptr()
|
||||
{
|
||||
assert_crash("not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool typename_is_ref()
|
||||
{
|
||||
assert_crash("not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
@ -572,7 +571,7 @@ namespace gen
|
||||
struct CodePOD
|
||||
{
|
||||
Using_Code_POD
|
||||
# undef Using_CodePOD;
|
||||
# undef Using_CodePOD
|
||||
};
|
||||
|
||||
constexpr sw size_AST = sizeof(AST);
|
||||
@ -667,6 +666,8 @@ namespace gen
|
||||
return ast;
|
||||
}
|
||||
|
||||
// Cannot be done unfortunately c++ sucks. (Will lose POD by doing so)
|
||||
#if 0
|
||||
inline
|
||||
Code& operator=( Code other )
|
||||
{
|
||||
@ -688,6 +689,7 @@ namespace gen
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
AST* operator->()
|
||||
@ -823,6 +825,7 @@ namespace gen
|
||||
, ModuleFlag mflags = ModuleFlag::None );
|
||||
|
||||
Code def_class_body ( s32 num, ... );
|
||||
Code def_class_body ( s32 num, Code* codes );
|
||||
Code def_enum_body ( s32 num, ... );
|
||||
Code def_enum_body ( s32 num, Code* codes );
|
||||
Code def_export_body ( s32 num, ... );
|
||||
|
Reference in New Issue
Block a user