Skip to content

Commit

Permalink
Bug fixes and updates to package_release.ps1
Browse files Browse the repository at this point in the history
- Incrased size of the defines_map_arena to 256KB
- Various fixes for the parser
- Various fixes for code serialization
- Fix for is_equal member func in Code types
- Fixes for hasthable container
- Added are_equal static func to String type for use against StrC
- Added starts_with functions to String type
- package_release.ps1 now packages all docs (forgot to update it with last release)
  • Loading branch information
Ed94 committed May 6, 2024
1 parent 4a2a93d commit e1592ba
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 134 deletions.
4 changes: 3 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Its not meant to be a black box metaprogramming utility, it should be easy to in

## Notes

**On Partial Hiatus: Working on handmade hero for now. Only fixes will be pushed as I come across them until I get what I want done from the series**
**On Partial Hiatus: Life has got me tackling other issues..**
I will be passively updating the library with bug fixes and minor improvements as I use it for my personal projects.
There won't be any major reworks or features to this thing for a while.

This project is still in development (very much an alpha state), so expect bugs and missing features.
See [issues](https://github.com/Ed94/gencpp/issues) for a list of known bugs or todos.
Expand Down
4 changes: 3 additions & 1 deletion project/auxillary/scanner.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#include "scanner.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# include "scanner.hpp"
#endif
22 changes: 14 additions & 8 deletions project/components/code_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void CodeConstructor::to_string_fwd( String& result )
if ( ast->InlineCmt )
result.append_fmt( "; // %S\n", ast->InlineCmt->Content );
else
result.append( ";" );
result.append( ";\n" );
}

String CodeClass::to_string()
Expand Down Expand Up @@ -183,7 +183,7 @@ void CodeClass::to_string_def( String& result )
while ( interface )
{
result.append_fmt( ", %S", interface.to_string() );
interface = interface->Next ? interface->Next->cast< CodeType >() : Code { nullptr };
interface = interface->Next ? interface->Next->cast< CodeType >() : CodeType { nullptr };
}
}
else if ( ast->Name )
Expand Down Expand Up @@ -480,6 +480,7 @@ void CodeFn::to_string_def( String& result )
if ( ast->Attributes )
result.append_fmt( " %S ", ast->Attributes.to_string() );

b32 prefix_specs = false;
if ( ast->Specs )
{
for ( SpecifierT spec : ast->Specs )
Expand All @@ -488,11 +489,13 @@ void CodeFn::to_string_def( String& result )
{
StrC spec_str = ESpecifier::to_str( spec );
result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr );

prefix_specs = true;
}
}
}

if ( ast->Attributes || ast->Specs )
if ( ast->Attributes || prefix_specs )
result.append( "\n" );

if ( ast->ReturnType )
Expand Down Expand Up @@ -530,19 +533,22 @@ void CodeFn::to_string_fwd( String& result )
if ( ast->Attributes )
result.append_fmt( "%S ", ast->Attributes.to_string() );

b32 prefix_specs = false;
if ( ast->Specs )
{
for ( SpecifierT spec : ast->Specs )
{
if ( ESpecifier::is_trailing( spec ) && ! (spec != ESpecifier::Pure) )
if ( ! ESpecifier::is_trailing( spec ) || ! (spec != ESpecifier::Pure) )
{
StrC spec_str = ESpecifier::to_str( spec );
result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr );

prefix_specs = true;
}
}
}

if ( ast->Attributes || ast->Specs )
if ( ast->Attributes || prefix_specs )
{
result.append("\n" );
}
Expand Down Expand Up @@ -571,7 +577,7 @@ void CodeFn::to_string_fwd( String& result )
}
}

if ( ast->Specs.has( ESpecifier::Pure ) >= 0 )
if ( ast->Specs && ast->Specs.has( ESpecifier::Pure ) >= 0 )
result.append( " = 0;" );
else if (ast->Body)
result.append_fmt( " = %S;", ast->Body.to_string() );
Expand Down Expand Up @@ -983,7 +989,7 @@ void CodeStruct::to_string_def( String& result )
while ( interface )
{
result.append_fmt( ", %S", interface.to_string() );
interface = interface->Next ? interface->Next->cast< CodeType >() : Code { nullptr };
interface = interface->Next ? interface->Next->cast< CodeType >() : CodeType { nullptr };
}
}
else if ( ast->Name )
Expand Down Expand Up @@ -1247,7 +1253,7 @@ void CodeVar::to_string( String& result )

result.append( ast->Name );

if ( ast->ValueType->ArrExpr )
if ( ast->ValueType && ast->ValueType->ArrExpr )
{
result.append_fmt( "[ %S ]", ast->ValueType->ArrExpr.to_string() );

Expand Down
87 changes: 29 additions & 58 deletions project/components/gen/ast_inlines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ bool Code::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -96,8 +95,7 @@ bool CodeBody::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -164,8 +162,7 @@ bool CodeAttributes::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -252,8 +249,7 @@ bool CodeComment::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -340,8 +336,7 @@ bool CodeConstructor::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -428,8 +423,7 @@ bool CodeClass::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -496,8 +490,7 @@ bool CodeDefine::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -584,8 +577,7 @@ bool CodeDestructor::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -672,8 +664,7 @@ bool CodeEnum::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -760,8 +751,7 @@ bool CodeExec::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -848,8 +838,7 @@ bool CodeExtern::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -936,8 +925,7 @@ bool CodeFriend::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1024,8 +1012,7 @@ bool CodeFn::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1112,8 +1099,7 @@ bool CodeInclude::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1200,8 +1186,7 @@ bool CodeModule::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1288,8 +1273,7 @@ bool CodeNS::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1376,8 +1360,7 @@ bool CodeOperator::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1464,8 +1447,7 @@ bool CodeOpCast::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1552,8 +1534,7 @@ bool CodeParam::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1620,8 +1601,7 @@ bool CodePragma::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1708,8 +1688,7 @@ bool CodePreprocessCond::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1796,8 +1775,7 @@ bool CodeSpecifiers::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1864,8 +1842,7 @@ bool CodeStruct::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -1932,8 +1909,7 @@ bool CodeTemplate::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -2020,8 +1996,7 @@ bool CodeType::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -2108,8 +2083,7 @@ bool CodeTypedef::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -2196,8 +2170,7 @@ bool CodeUnion::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -2284,8 +2257,7 @@ bool CodeUsing::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down Expand Up @@ -2372,8 +2344,7 @@ bool CodeVar::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
{
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
return false;
return rcast( AST*, ast ) == other.ast;
}
return rcast( AST*, ast )->is_equal( other.ast );
}
Expand Down
Loading

0 comments on commit e1592ba

Please sign in to comment.