diff --git a/gencpp.vcxproj b/gencpp.vcxproj index fd76f32..9004c40 100644 --- a/gencpp.vcxproj +++ b/gencpp.vcxproj @@ -108,31 +108,37 @@ - - - + + + + + + + + + + - - + - + diff --git a/gencpp.vcxproj.filters b/gencpp.vcxproj.filters index d73968e..c21cf77 100644 --- a/gencpp.vcxproj.filters +++ b/gencpp.vcxproj.filters @@ -15,15 +15,9 @@ - - Source Files - Source Files - - Source Files - Source Files @@ -33,24 +27,69 @@ Source Files + + Source Files + + + Source Files + - - Header Files - - - Header Files - - - Header Files - Header Files - + Header Files - + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + Header Files @@ -61,13 +100,12 @@ - - + \ No newline at end of file diff --git a/project/gen.cpp b/project/gen.cpp index e603ebf..c065ee4 100644 --- a/project/gen.cpp +++ b/project/gen.cpp @@ -1854,6 +1854,7 @@ namespace gen Code result = make_code(); + // TODO : Bring back some of the old way, we need to recursively duplicate the children. mem_copy( result.ast, this, sizeof( AST ) ); return result.ast; @@ -2219,11 +2220,13 @@ namespace gen else result.append_fmt( "%s", ValueType->to_string() ); - if ( NumEntries ) - for ( CodeParam param : cast() ) + if ( NumEntries - 1) + { + for ( CodeParam param : Next->cast() ) { - result.append( param.to_string() ); + result.append_fmt( ", %s", param.to_string() ); } + } } break; @@ -3732,6 +3735,8 @@ namespace gen if ( value ) result->Value = value; + result->NumEntries++; + return (CodeParam) result; } @@ -7839,3 +7844,4 @@ namespace gen } // End: gen_time #endif + diff --git a/project/gen.hpp b/project/gen.hpp index f508941..c5fbff5 100644 --- a/project/gen.hpp +++ b/project/gen.hpp @@ -2760,7 +2760,8 @@ namespace gen template< class Type > Type cast() { - return (Type)(Code){ this }; + AST* ast = this; + return * rcast( Type*, & ast ); } operator Code(); @@ -3003,7 +3004,7 @@ namespace gen Define_CodeType( Struct ); Define_CodeType( Template ); Define_CodeType( Type ); - Define_CodeType( Typedef ); + Define_CodeType(Typedef); Define_CodeType( Union ); Define_CodeType( Using ); Define_CodeType( UsingNamespace ); @@ -3053,22 +3054,24 @@ namespace gen return { (AST*)ast }; } #pragma region Iterator - CodeParam* begin() + CodeParam begin() { if ( ast ) - return rcast( CodeParam*, ast ); + return { ast }; - return nullptr; + return { nullptr }; } - CodeParam* end() + CodeParam end() { - return nullptr; + return { (AST_Param*) rcast( AST*, ast)->Next }; } CodeParam& operator++() { - if ( ast && raw()->Next ) - ast = (AST_Param*) raw()->Next; - + ast = (AST_Param*) rcast( AST*, ast )->Next; + return * this; + } + CodeParam operator*() + { return * this; } #pragma endregion Iterator @@ -3212,25 +3215,6 @@ namespace gen }; static_assert( sizeof(AST_Class) == sizeof(AST), "ERROR: AST_Class is not the same size as AST"); - struct AST_Exec - { - union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; - struct - { - char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; - CodeBody Body; - }; - }; - Code Prev; - Code Next; - Code Parent; - StringCached Name; - CodeT Type; - char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; - }; - static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST"); - struct AST_Enum { union { @@ -3254,6 +3238,25 @@ namespace gen }; static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same size as AST"); + struct AST_Exec + { + union { + char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; + struct + { + char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; + Code Body; + }; + }; + Code Prev; + Code Next; + Code Parent; + StringCached Name; + CodeT Type; + char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; + }; + static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST"); + struct AST_Extern { union { @@ -3261,7 +3264,7 @@ namespace gen struct { char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; - CodeBody Body; + Code Body; }; }; Code Prev; @@ -3347,7 +3350,10 @@ namespace gen { union { char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; - CodeBody Body; + struct { + char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; + CodeBody Body; + }; }; Code Prev; Code Next; @@ -3388,8 +3394,9 @@ namespace gen char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; struct { - char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; + char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ]; CodeType ValueType; + char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; CodeBody Body; }; }; @@ -3398,8 +3405,7 @@ namespace gen Code Parent; StringCached Name; CodeT Type; - ModuleFlag ModuleFlags; - char _PAD_UNUSED_[ sizeof(u32) ]; + char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the same size as AST"); @@ -3409,8 +3415,9 @@ namespace gen char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; struct { - char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; + char _PAD_PROPERTIES_2_[ sizeof(AST*) * 2 ]; CodeType ValueType; + char _PAD_PROPERTIES_[ sizeof(AST*) ]; Code Value; }; }; @@ -3419,7 +3426,7 @@ namespace gen Code Parent; StringCached Name; CodeT Type; - ModuleFlag ModuleFlags; + char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; u32 NumEntries; }; static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the same size as AST"); @@ -3432,7 +3439,7 @@ namespace gen Code Parent; StringCached Name; CodeT Type; - ModuleFlag ModuleFlags; + char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; u32 NumEntries; }; static_assert( sizeof(AST_Specifier) == sizeof(AST), "ERROR: AST_Specifier is not the same size as AST"); @@ -3466,9 +3473,7 @@ namespace gen char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; struct { - CodeAttributes Attributes; - CodeType ReturnType; - CodeSpecifier Specs; + char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ]; CodeParam Params; Code Declaration; }; @@ -4137,7 +4142,7 @@ namespace gen } Define_CodeImpl( Code ); - Define_CodeImpl( CodeBody); + Define_CodeImpl( CodeBody ); Define_CodeImpl( CodeAttributes ); Define_CodeImpl( CodeComment ); Define_CodeImpl( CodeClass ); @@ -4195,12 +4200,12 @@ namespace gen Define_AST_Cast( Var ); #undef Define_AST_Cast -#pragma region Code Operator Cast Impl +#pragma region Code Operator Cast Impj #define Define_CodeCast( type ) \ Code::operator Code ## type() const \ { \ - return * rcast( Code ## type*, ast ); \ + return { (AST_ ## type*) ast }; \ } Define_CodeCast( Attributes ); @@ -4277,3 +4282,4 @@ namespace gen // end: gen_time #endif + diff --git a/scripts/genccp.natstepfilter b/scripts/genccp.natstepfilter.dontuse similarity index 100% rename from scripts/genccp.natstepfilter rename to scripts/genccp.natstepfilter.dontuse diff --git a/scripts/gencpp.natvis b/scripts/gencpp.natvis index 0fe6710..9d8dc48 100644 --- a/scripts/gencpp.natvis +++ b/scripts/gencpp.natvis @@ -53,309 +53,146 @@ - AST: {Name} + {Name} Type: {Type} + Content Parent - Name - Type - ModuleFlags - - - - Content - - - - ArrSpecs - - - - - - - - Prev - Next - - - Front - Back - - - - - Attributes - Specs - - - - ParentType - - - ReturnType - - - UnderlyingType - - - ValueType - - - - Params - - - - ArrExpr - - - Body - - - Declaration - - - Value - - - - - - - - Op - - - ParentAccess - - - NumEntries - - - + Prev + Next + NumEntries - AST: {ast->Name} Type: {ast->Type} - + Null + {ast->Name} Type: {ast->Type} + + ast->Content + ast->Body ast->Parent - ast->ModuleFlags - - - - ast->Content - - - - ast->ArrSpecs - - - - - - - - ast->Prev - ast->Next - - - ast->Front - ast->Back - - - - - ast->Attributes - ast->Specs - - - - ast->ParentType - - - ast->ReturnType - - - ast->UnderlyingType - - - ast->ValueType - - - - ast->Params - - - - ast->ArrExpr - - - ast->Body - - - ast->Declaration - - - ast->Value - - - - - - - - ast->Op - - - ast->ParentAccess - - - ast->NumEntries - - - + ast->ModuleFlags + ast->ArrSpecs + ast->Prev + ast->Next + ast->NumEntries - {Name} {Type} + {Name} Type: {Type} - Name - Type Parent Front Back + NumEntries - {Name} {Type} + {Name} Type: {Type} - Name - Type + Content Parent Prev Next - Content - {Name} {Type} + {Name} Type: {Type} - Name - Type + Content Parent Prev Next - Content - {Name} {Type} + {Name} Type: {Type} - Name - Type ModuleFlags - Parent Attributes ParentType - Body - Prev - Next ParentAccess - - - - - {Name} {Type} - - Name - Type - Parent Body + Parent Prev Next - {Name} {Type} + {Name} Type: {Type} - Name - Type - ModuleFlags - Parent Attributes UnderlyingType Body + ModuleFlags + Parent + Prev + Next + + + + + {Name} Type: {Type} + + Body + Parent Prev Next - {Name} {Type} + {Name} Type: {Type} - Name - Type + Body Parent Prev Next - Body - {Name} {Type} + {Name} Type: {Type} - Name - Type + Content Parent Prev Next - Content - {Name} {Type} + {Name} Type: {Type} - Name - Type + Declaration Parent Prev Next - Declaration - {Name} {Type} + {Name} Type: {Type} - Name - Type ModuleFlags - Parent - Prev - Next Attributes Specs ReturnType Params Body + Parent + Prev + Next - {Name} {Type} + {Name} Type: {Type} - Name - Type ModuleFlags Parent Prev @@ -364,10 +201,8 @@ - {Name} {Type} + {Name} Type: {Type} - Name - Type ModuleFlags Parent Prev @@ -377,154 +212,131 @@ - {Name} {Type} + {Name} Type: {Type} - Name - Type ModuleFlags - Parent - Prev - Next Attributes Specs ReturnType + Op Params Body - Op + Parent + Prev + Next - {Name} {Type} + {Name} Type: {Type} - Name - Type - ModuleFlags + ValueType + Body Parent Prev Next - ValueType - Body - {Name} {Type} + {Name} Type: {Type} - Name - ModuleFlags + ValueType + Value Parent Prev Next - ValueType - Value NumEntries - {Name} {Type} + {Name} Type: {Type} - Name - ModuleFlags + NumEntries Parent Prev Next - - ArrSpecs - - NumEntries - {Name} {Type} + {Name} Type: {Type} - Name ModuleFlags + Attributes + ParentType + ParentAccess + Body Parent Prev Next - Attributes - ParentType - Body - ParentAccess - {Name} {Type} + {Name} Type: {Type} - Name ModuleFlags + Declaration + Params Parent Prev Next - Attributes - ReturnType - Specs - Params - Declaration - {Name} {Type} + {Name} Type: {Type} - Name - Parent - Prev - Next Attributes Specs ArrExpr + Parent + Prev + Next - {Name} {Type} + {Name} Type: {Type} - Name ModuleFlags + Attributes + UnderlyingType Parent Prev Next - Attributes - UnderlyingType - {Name} {Type} + {Name} Type: {Type} - Name ModuleFlags + Attributes + Body Parent Prev Next - Attributes - Body - {Name} {Type} + {Name} Type: {Type} - Name ModuleFlags - Parent - Prev - Next Attributes UnderlyingType - Op + Parent ParentAccess - NumEntries + Prev + Next - {Name} {Type} + {Name} Type: {Type} Name Parent @@ -534,76 +346,69 @@ - {Name} {Type} + {Name} Type: {Type} - Name ModuleFlags - Parent - Prev - Next Attributes Specs ValueType Value - Op - ParentAccess - NumEntries + Parent + Prev + Next - + + Null {ast->Name} {ast->Type} - ast->Attributes - ast->Specs - ast->Front - ast->Back + ast->Parent + ast->Front + ast->Back + ast->NumEntries - + + Null {ast->Name} {ast->Type} - ast->Attributes - ast->Specs + ast->Content + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} ast->Content + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Attributes ast->ParentType + ast->ParentAccess ast->Body + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags - ast->ParentAccess + Null {ast->Name} {ast->Type} ast->Body @@ -616,258 +421,214 @@ + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Attributes ast->UnderlyingType ast->Body ast->Prev ast->Next ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} ast->Content + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type + Null {ast->Name} {ast->Type} ast->Declaration + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Attributes ast->Specs ast->ReturnType ast->Params ast->Body + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} + ast->ModuleFlags + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Body + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Attributes ast->Specs ast->ReturnType + ast->Op ast->Params ast->Body + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags - ast->Op + Null {ast->Name} {ast->Type} ast->ValueType ast->Body + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} ast->ValueType ast->Value + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags ast->NumEntries + Null {ast->Name} {ast->Type} - - ast->ArrSpecs - + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags ast->NumEntries + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Attributes ast->ParentType - ast->Body - ast->Prev - ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags ast->ParentAccess - - - - - {ast->Name} {ast->Type} - - ast->Attributes - ast->Specs - ast->ValueType - ast->Value + ast->Body + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} - ast->Attributes - ast->ReturnType - ast->Specs - ast->Params + ast->ModuleFlags ast->Declaration + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} ast->Attributes ast->Specs ast->ArrExpr + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Attributes ast->UnderlyingType + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Attributes ast->Body + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Attributes ast->UnderlyingType + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags - ast->Op - ast->ParentAccess - ast->NumEntries + Null {ast->Name} {ast->Type} ast->Prev @@ -879,18 +640,17 @@ + Null {ast->Name} {ast->Type} + ast->ModuleFlags ast->Attributes ast->Specs ast->ValueType ast->Value + ast->Parent ast->Prev ast->Next - ast->Parent - ast->Name - ast->Type - ast->ModuleFlags @@ -902,4 +662,4 @@ Current[ { Arr[Idx] } ] Idx:{ Idx } - \ No newline at end of file + diff --git a/test/Upfront/Sanity.Upfront.hpp b/test/Upfront/Sanity.Upfront.hpp index 416e955..f984f3c 100644 --- a/test/Upfront/Sanity.Upfront.hpp +++ b/test/Upfront/Sanity.Upfront.hpp @@ -139,7 +139,7 @@ u32 gen_sanity_upfront() // Namespace { - Code namespace_def; + CodeNamespace namespace_def; { Code body = def_namespace_body( 1 , def_comment( txt_StrC("Empty namespace body") ) diff --git a/x64/Debug/gencpp.log b/x64/Debug/gencpp.log index 6f97317..6c64119 100644 --- a/x64/Debug/gencpp.log +++ b/x64/Debug/gencpp.log @@ -3,5 +3,16 @@ Building Test ninja: Entering directory `C:\projects\gencpp\test\gen\build' - [1/2] Compiling C++ object gencpp.exe.p/.._test.cpp.obj + [1/2] Compiling C++ object gencpp.exe.p/.._test.Upfront.cpp.obj [2/2] Linking target gencpp.exe + + Generating files Parsed... + + Beginning format... + Formatting [1/5] C:\projects\gencpp\test\gen\array.Upfront.gen.hpp + Formatting [2/5] C:\projects\gencpp\test\gen\buffer.Upfront.gen.hpp + Formatting [3/5] C:\projects\gencpp\test\gen\hashtable.Upfront.gen.hpp + Formatting [4/5] C:\projects\gencpp\test\gen\ring.Upfront.gen.hpp + Formatting [5/5] C:\projects\gencpp\test\gen\sanity.Upfront.gen.hpp + + Formatting complete