Skip to content

Commit e1592ba

Browse files
committed
Bug fixes and updates to package_release.ps1
- 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)
1 parent 4a2a93d commit e1592ba

12 files changed

Lines changed: 161 additions & 134 deletions

File tree

Readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ Its not meant to be a black box metaprogramming utility, it should be easy to in
1010

1111
## Notes
1212

13-
**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**
13+
**On Partial Hiatus: Life has got me tackling other issues..**
14+
I will be passively updating the library with bug fixes and minor improvements as I use it for my personal projects.
15+
There won't be any major reworks or features to this thing for a while.
1416

1517
This project is still in development (very much an alpha state), so expect bugs and missing features.
1618
See [issues](https://github.com/Ed94/gencpp/issues) for a list of known bugs or todos.

project/auxillary/scanner.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
#include "scanner.hpp"
1+
#ifdef GEN_INTELLISENSE_DIRECTIVES
2+
# include "scanner.hpp"
3+
#endif

project/components/code_serialization.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void CodeConstructor::to_string_fwd( String& result )
139139
if ( ast->InlineCmt )
140140
result.append_fmt( "; // %S\n", ast->InlineCmt->Content );
141141
else
142-
result.append( ";" );
142+
result.append( ";\n" );
143143
}
144144

145145
String CodeClass::to_string()
@@ -183,7 +183,7 @@ void CodeClass::to_string_def( String& result )
183183
while ( interface )
184184
{
185185
result.append_fmt( ", %S", interface.to_string() );
186-
interface = interface->Next ? interface->Next->cast< CodeType >() : Code { nullptr };
186+
interface = interface->Next ? interface->Next->cast< CodeType >() : CodeType { nullptr };
187187
}
188188
}
189189
else if ( ast->Name )
@@ -480,6 +480,7 @@ void CodeFn::to_string_def( String& result )
480480
if ( ast->Attributes )
481481
result.append_fmt( " %S ", ast->Attributes.to_string() );
482482

483+
b32 prefix_specs = false;
483484
if ( ast->Specs )
484485
{
485486
for ( SpecifierT spec : ast->Specs )
@@ -488,11 +489,13 @@ void CodeFn::to_string_def( String& result )
488489
{
489490
StrC spec_str = ESpecifier::to_str( spec );
490491
result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr );
492+
493+
prefix_specs = true;
491494
}
492495
}
493496
}
494497

495-
if ( ast->Attributes || ast->Specs )
498+
if ( ast->Attributes || prefix_specs )
496499
result.append( "\n" );
497500

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

536+
b32 prefix_specs = false;
533537
if ( ast->Specs )
534538
{
535539
for ( SpecifierT spec : ast->Specs )
536540
{
537-
if ( ESpecifier::is_trailing( spec ) && ! (spec != ESpecifier::Pure) )
541+
if ( ! ESpecifier::is_trailing( spec ) || ! (spec != ESpecifier::Pure) )
538542
{
539543
StrC spec_str = ESpecifier::to_str( spec );
540544
result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr );
545+
546+
prefix_specs = true;
541547
}
542548
}
543549
}
544550

545-
if ( ast->Attributes || ast->Specs )
551+
if ( ast->Attributes || prefix_specs )
546552
{
547553
result.append("\n" );
548554
}
@@ -571,7 +577,7 @@ void CodeFn::to_string_fwd( String& result )
571577
}
572578
}
573579

574-
if ( ast->Specs.has( ESpecifier::Pure ) >= 0 )
580+
if ( ast->Specs && ast->Specs.has( ESpecifier::Pure ) >= 0 )
575581
result.append( " = 0;" );
576582
else if (ast->Body)
577583
result.append_fmt( " = %S;", ast->Body.to_string() );
@@ -983,7 +989,7 @@ void CodeStruct::to_string_def( String& result )
983989
while ( interface )
984990
{
985991
result.append_fmt( ", %S", interface.to_string() );
986-
interface = interface->Next ? interface->Next->cast< CodeType >() : Code { nullptr };
992+
interface = interface->Next ? interface->Next->cast< CodeType >() : CodeType { nullptr };
987993
}
988994
}
989995
else if ( ast->Name )
@@ -1247,7 +1253,7 @@ void CodeVar::to_string( String& result )
12471253

12481254
result.append( ast->Name );
12491255

1250-
if ( ast->ValueType->ArrExpr )
1256+
if ( ast->ValueType && ast->ValueType->ArrExpr )
12511257
{
12521258
result.append_fmt( "[ %S ]", ast->ValueType->ArrExpr.to_string() );
12531259

project/components/gen/ast_inlines.hpp

Lines changed: 29 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ bool Code::is_equal( Code other )
2828
{
2929
if ( ast == nullptr || other.ast == nullptr )
3030
{
31-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
32-
return false;
31+
return rcast( AST*, ast ) == other.ast;
3332
}
3433
return rcast( AST*, ast )->is_equal( other.ast );
3534
}
@@ -96,8 +95,7 @@ bool CodeBody::is_equal( Code other )
9695
{
9796
if ( ast == nullptr || other.ast == nullptr )
9897
{
99-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
100-
return false;
98+
return rcast( AST*, ast ) == other.ast;
10199
}
102100
return rcast( AST*, ast )->is_equal( other.ast );
103101
}
@@ -164,8 +162,7 @@ bool CodeAttributes::is_equal( Code other )
164162
{
165163
if ( ast == nullptr || other.ast == nullptr )
166164
{
167-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
168-
return false;
165+
return rcast( AST*, ast ) == other.ast;
169166
}
170167
return rcast( AST*, ast )->is_equal( other.ast );
171168
}
@@ -252,8 +249,7 @@ bool CodeComment::is_equal( Code other )
252249
{
253250
if ( ast == nullptr || other.ast == nullptr )
254251
{
255-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
256-
return false;
252+
return rcast( AST*, ast ) == other.ast;
257253
}
258254
return rcast( AST*, ast )->is_equal( other.ast );
259255
}
@@ -340,8 +336,7 @@ bool CodeConstructor::is_equal( Code other )
340336
{
341337
if ( ast == nullptr || other.ast == nullptr )
342338
{
343-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
344-
return false;
339+
return rcast( AST*, ast ) == other.ast;
345340
}
346341
return rcast( AST*, ast )->is_equal( other.ast );
347342
}
@@ -428,8 +423,7 @@ bool CodeClass::is_equal( Code other )
428423
{
429424
if ( ast == nullptr || other.ast == nullptr )
430425
{
431-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
432-
return false;
426+
return rcast( AST*, ast ) == other.ast;
433427
}
434428
return rcast( AST*, ast )->is_equal( other.ast );
435429
}
@@ -496,8 +490,7 @@ bool CodeDefine::is_equal( Code other )
496490
{
497491
if ( ast == nullptr || other.ast == nullptr )
498492
{
499-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
500-
return false;
493+
return rcast( AST*, ast ) == other.ast;
501494
}
502495
return rcast( AST*, ast )->is_equal( other.ast );
503496
}
@@ -584,8 +577,7 @@ bool CodeDestructor::is_equal( Code other )
584577
{
585578
if ( ast == nullptr || other.ast == nullptr )
586579
{
587-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
588-
return false;
580+
return rcast( AST*, ast ) == other.ast;
589581
}
590582
return rcast( AST*, ast )->is_equal( other.ast );
591583
}
@@ -672,8 +664,7 @@ bool CodeEnum::is_equal( Code other )
672664
{
673665
if ( ast == nullptr || other.ast == nullptr )
674666
{
675-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
676-
return false;
667+
return rcast( AST*, ast ) == other.ast;
677668
}
678669
return rcast( AST*, ast )->is_equal( other.ast );
679670
}
@@ -760,8 +751,7 @@ bool CodeExec::is_equal( Code other )
760751
{
761752
if ( ast == nullptr || other.ast == nullptr )
762753
{
763-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
764-
return false;
754+
return rcast( AST*, ast ) == other.ast;
765755
}
766756
return rcast( AST*, ast )->is_equal( other.ast );
767757
}
@@ -848,8 +838,7 @@ bool CodeExtern::is_equal( Code other )
848838
{
849839
if ( ast == nullptr || other.ast == nullptr )
850840
{
851-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
852-
return false;
841+
return rcast( AST*, ast ) == other.ast;
853842
}
854843
return rcast( AST*, ast )->is_equal( other.ast );
855844
}
@@ -936,8 +925,7 @@ bool CodeFriend::is_equal( Code other )
936925
{
937926
if ( ast == nullptr || other.ast == nullptr )
938927
{
939-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
940-
return false;
928+
return rcast( AST*, ast ) == other.ast;
941929
}
942930
return rcast( AST*, ast )->is_equal( other.ast );
943931
}
@@ -1024,8 +1012,7 @@ bool CodeFn::is_equal( Code other )
10241012
{
10251013
if ( ast == nullptr || other.ast == nullptr )
10261014
{
1027-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1028-
return false;
1015+
return rcast( AST*, ast ) == other.ast;
10291016
}
10301017
return rcast( AST*, ast )->is_equal( other.ast );
10311018
}
@@ -1112,8 +1099,7 @@ bool CodeInclude::is_equal( Code other )
11121099
{
11131100
if ( ast == nullptr || other.ast == nullptr )
11141101
{
1115-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1116-
return false;
1102+
return rcast( AST*, ast ) == other.ast;
11171103
}
11181104
return rcast( AST*, ast )->is_equal( other.ast );
11191105
}
@@ -1200,8 +1186,7 @@ bool CodeModule::is_equal( Code other )
12001186
{
12011187
if ( ast == nullptr || other.ast == nullptr )
12021188
{
1203-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1204-
return false;
1189+
return rcast( AST*, ast ) == other.ast;
12051190
}
12061191
return rcast( AST*, ast )->is_equal( other.ast );
12071192
}
@@ -1288,8 +1273,7 @@ bool CodeNS::is_equal( Code other )
12881273
{
12891274
if ( ast == nullptr || other.ast == nullptr )
12901275
{
1291-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1292-
return false;
1276+
return rcast( AST*, ast ) == other.ast;
12931277
}
12941278
return rcast( AST*, ast )->is_equal( other.ast );
12951279
}
@@ -1376,8 +1360,7 @@ bool CodeOperator::is_equal( Code other )
13761360
{
13771361
if ( ast == nullptr || other.ast == nullptr )
13781362
{
1379-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1380-
return false;
1363+
return rcast( AST*, ast ) == other.ast;
13811364
}
13821365
return rcast( AST*, ast )->is_equal( other.ast );
13831366
}
@@ -1464,8 +1447,7 @@ bool CodeOpCast::is_equal( Code other )
14641447
{
14651448
if ( ast == nullptr || other.ast == nullptr )
14661449
{
1467-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1468-
return false;
1450+
return rcast( AST*, ast ) == other.ast;
14691451
}
14701452
return rcast( AST*, ast )->is_equal( other.ast );
14711453
}
@@ -1552,8 +1534,7 @@ bool CodeParam::is_equal( Code other )
15521534
{
15531535
if ( ast == nullptr || other.ast == nullptr )
15541536
{
1555-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1556-
return false;
1537+
return rcast( AST*, ast ) == other.ast;
15571538
}
15581539
return rcast( AST*, ast )->is_equal( other.ast );
15591540
}
@@ -1620,8 +1601,7 @@ bool CodePragma::is_equal( Code other )
16201601
{
16211602
if ( ast == nullptr || other.ast == nullptr )
16221603
{
1623-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1624-
return false;
1604+
return rcast( AST*, ast ) == other.ast;
16251605
}
16261606
return rcast( AST*, ast )->is_equal( other.ast );
16271607
}
@@ -1708,8 +1688,7 @@ bool CodePreprocessCond::is_equal( Code other )
17081688
{
17091689
if ( ast == nullptr || other.ast == nullptr )
17101690
{
1711-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1712-
return false;
1691+
return rcast( AST*, ast ) == other.ast;
17131692
}
17141693
return rcast( AST*, ast )->is_equal( other.ast );
17151694
}
@@ -1796,8 +1775,7 @@ bool CodeSpecifiers::is_equal( Code other )
17961775
{
17971776
if ( ast == nullptr || other.ast == nullptr )
17981777
{
1799-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1800-
return false;
1778+
return rcast( AST*, ast ) == other.ast;
18011779
}
18021780
return rcast( AST*, ast )->is_equal( other.ast );
18031781
}
@@ -1864,8 +1842,7 @@ bool CodeStruct::is_equal( Code other )
18641842
{
18651843
if ( ast == nullptr || other.ast == nullptr )
18661844
{
1867-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1868-
return false;
1845+
return rcast( AST*, ast ) == other.ast;
18691846
}
18701847
return rcast( AST*, ast )->is_equal( other.ast );
18711848
}
@@ -1932,8 +1909,7 @@ bool CodeTemplate::is_equal( Code other )
19321909
{
19331910
if ( ast == nullptr || other.ast == nullptr )
19341911
{
1935-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
1936-
return false;
1912+
return rcast( AST*, ast ) == other.ast;
19371913
}
19381914
return rcast( AST*, ast )->is_equal( other.ast );
19391915
}
@@ -2020,8 +1996,7 @@ bool CodeType::is_equal( Code other )
20201996
{
20211997
if ( ast == nullptr || other.ast == nullptr )
20221998
{
2023-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
2024-
return false;
1999+
return rcast( AST*, ast ) == other.ast;
20252000
}
20262001
return rcast( AST*, ast )->is_equal( other.ast );
20272002
}
@@ -2108,8 +2083,7 @@ bool CodeTypedef::is_equal( Code other )
21082083
{
21092084
if ( ast == nullptr || other.ast == nullptr )
21102085
{
2111-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
2112-
return false;
2086+
return rcast( AST*, ast ) == other.ast;
21132087
}
21142088
return rcast( AST*, ast )->is_equal( other.ast );
21152089
}
@@ -2196,8 +2170,7 @@ bool CodeUnion::is_equal( Code other )
21962170
{
21972171
if ( ast == nullptr || other.ast == nullptr )
21982172
{
2199-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
2200-
return false;
2173+
return rcast( AST*, ast ) == other.ast;
22012174
}
22022175
return rcast( AST*, ast )->is_equal( other.ast );
22032176
}
@@ -2284,8 +2257,7 @@ bool CodeUsing::is_equal( Code other )
22842257
{
22852258
if ( ast == nullptr || other.ast == nullptr )
22862259
{
2287-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
2288-
return false;
2260+
return rcast( AST*, ast ) == other.ast;
22892261
}
22902262
return rcast( AST*, ast )->is_equal( other.ast );
22912263
}
@@ -2372,8 +2344,7 @@ bool CodeVar::is_equal( Code other )
23722344
{
23732345
if ( ast == nullptr || other.ast == nullptr )
23742346
{
2375-
log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
2376-
return false;
2347+
return rcast( AST*, ast ) == other.ast;
23772348
}
23782349
return rcast( AST*, ast )->is_equal( other.ast );
23792350
}

0 commit comments

Comments
 (0)