mirror of
https://github.com/Ed94/gencpp.git
synced 2025-07-30 00:46:59 -07:00
Removed incremental API, fixes for operator__validation
, added formatting pass on generated files
Decided not to support the incremental API, its not necessary as the ergonomics are not that big a deal. Got operators to pass the sanity base cases, which means now all upfront constructors pass the base cases! Next up is getting it to pass the array container generation.
This commit is contained in:
@@ -56,11 +56,9 @@ u32 gen_sanity()
|
||||
Code def;
|
||||
{
|
||||
Code body = untyped_str( StrC::from(
|
||||
#define enum_entry( id ) "\t" #id ",\n"
|
||||
enum_entry( A )
|
||||
enum_entry( B )
|
||||
enum_entry( C )
|
||||
#undef enum_entry
|
||||
));
|
||||
|
||||
def = def_enum( name(ETestEnum), body, t_u8 );
|
||||
@@ -120,7 +118,7 @@ u32 gen_sanity()
|
||||
|
||||
// Include
|
||||
{
|
||||
Code include = def_include( StrC::from("DummyInclude.hpp") );
|
||||
Code include = def_include( StrC::from("../DummyInclude.hpp") );
|
||||
|
||||
gen_sanity_file.print(include);
|
||||
}
|
||||
@@ -161,7 +159,37 @@ u32 gen_sanity()
|
||||
|
||||
// Operator
|
||||
{
|
||||
// This is nasty...
|
||||
// Going to make a bit flag set of overloads for this.
|
||||
|
||||
|
||||
Code bitflagtest;
|
||||
{
|
||||
Code body = def_enum_body( 1, untyped_str( StrC::from(
|
||||
enum_entry( A = 1 << 0 )
|
||||
enum_entry( B = 1 << 1 )
|
||||
enum_entry( C = 1 << 2 )
|
||||
)));
|
||||
bitflagtest = def_enum( name(EBitFlagtest), body, t_u8, EnumClass );
|
||||
}
|
||||
Code t_bitflag = def_type( name(EBitFlagtest) );
|
||||
|
||||
Code op_fwd, op_or;
|
||||
{
|
||||
Code params = def_params( code_args( 2,
|
||||
def_param( t_bitflag, name(a) ),
|
||||
def_param( t_bitflag, name(b) )
|
||||
));
|
||||
|
||||
op_fwd = def_operator( EOperator::BOr, params, t_bitflag );
|
||||
op_or = def_operator( EOperator::BOr, params, t_bitflag, untyped_str( code(
|
||||
return EBitFlagtest( (u8)a | (u8)b );
|
||||
)));
|
||||
}
|
||||
|
||||
gen_sanity_file.print(bitflagtest);
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
gen_sanity_file.print(op_fwd);
|
||||
gen_sanity_file.print(op_or);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
163
test/gen/.clang-format
Normal file
163
test/gen/.clang-format
Normal file
@@ -0,0 +1,163 @@
|
||||
# Format Style Options - Created with Clang Power Tools
|
||||
---
|
||||
AccessModifierOffset: -4
|
||||
|
||||
AlignAfterOpenBracket: BlockIndent
|
||||
AlignArrayOfStructures: Right
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: true
|
||||
AlignCompound: true
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields: AcrossComments
|
||||
AlignConsecutiveDeclarations: AcrossComments
|
||||
AlignConsecutiveMacros: AcrossComments
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: DontAlign
|
||||
|
||||
AlignTrailingComments: true
|
||||
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortLambdasOnASingleLine: None
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
|
||||
BitFieldColonSpacing: Both
|
||||
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
|
||||
# BreakAfterAttributes: Always
|
||||
# BreakArrays: false
|
||||
# BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Allman
|
||||
BreakBeforeInheritanceComma: true
|
||||
BreakInheritanceList: BeforeComma
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakStringLiterals: true
|
||||
|
||||
ColumnLimit: 180
|
||||
|
||||
CompactNamespaces: true
|
||||
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth : 4
|
||||
|
||||
ContinuationIndentWidth: 4
|
||||
|
||||
Cpp11BracedListStyle: false
|
||||
|
||||
DeriveLineEnding: true
|
||||
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
|
||||
FixNamespaceComments: true
|
||||
|
||||
IncludeBlocks: Preserve
|
||||
|
||||
|
||||
IndentCaseBlocks: true
|
||||
IndentCaseLabels: true
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentRequires: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
|
||||
# InsertNewlineAtEOF: true
|
||||
InsertTrailingCommas: Wrapped
|
||||
|
||||
LambdaBodyIndentation: OuterScope
|
||||
|
||||
Language: Cpp
|
||||
|
||||
MaxEmptyLinesToKeep: 4
|
||||
|
||||
NamespaceIndentation: All
|
||||
|
||||
PointerAlignment: Left
|
||||
|
||||
QualifierAlignment: Leave
|
||||
|
||||
ReferenceAlignment: Left
|
||||
|
||||
ReflowComments: true
|
||||
|
||||
# RequiresExpressionIndentation: OuterScope
|
||||
|
||||
SeparateDefinitionBlocks: Always
|
||||
|
||||
ShortNamespaceLines: 40
|
||||
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: true
|
||||
SpaceAfterTemplateKeyword: false
|
||||
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: true
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatementsExceptControlMacros
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpacesBeforeTrailingComments: 4
|
||||
|
||||
SpaceInEmptyBlock: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInAngles: true
|
||||
SpacesInCStyleCastParentheses: true
|
||||
SpacesInConditionalStatement: true
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: 20
|
||||
SpacesInParentheses: true
|
||||
SpacesInSquareBrackets: true
|
||||
|
||||
Standard: c++17
|
||||
|
||||
TabWidth: 4
|
||||
|
||||
UseTab: ForIndentation
|
||||
...
|
@@ -3,15 +3,16 @@
|
||||
// The following will show a series of base cases for the gen api.
|
||||
|
||||
class TestEmptyClass;
|
||||
|
||||
class TestEmptyClass
|
||||
{
|
||||
// Empty class body
|
||||
|
||||
};
|
||||
|
||||
typedef unsigned char u8;
|
||||
|
||||
enum ETestEnum : u8;
|
||||
|
||||
enum ETestEnum : u8
|
||||
{
|
||||
A,
|
||||
@@ -23,24 +24,21 @@ enum class ETestEnumClass : u8;
|
||||
extern "C"
|
||||
{
|
||||
// Empty extern body
|
||||
|
||||
}
|
||||
|
||||
class TestFriend
|
||||
{
|
||||
friend class TestFriendFwd;
|
||||
|
||||
friend class TestFriendFwd;
|
||||
};
|
||||
|
||||
void test_function(void);
|
||||
void test_function(void)
|
||||
void test_function( void );
|
||||
|
||||
void test_function( void )
|
||||
{
|
||||
// Empty function body
|
||||
|
||||
}
|
||||
|
||||
#include "DummyInclude.hpp"
|
||||
|
||||
#include "../DummyInclude.hpp"
|
||||
|
||||
namespace TestNamespace
|
||||
{
|
||||
@@ -48,31 +46,43 @@ namespace TestNamespace
|
||||
|
||||
};
|
||||
|
||||
|
||||
void test_function_wparam(u8 a);
|
||||
void test_function_wparams(u8 a, u8 b)
|
||||
enum class EBitFlagtest : u8
|
||||
{
|
||||
// Empty function body
|
||||
A = 1 << 0,
|
||||
B = 1 << 1,
|
||||
C = 1 << 2,
|
||||
};
|
||||
|
||||
EBitFlagtest operator|( EBitFlagtest a, EBitFlagtest b );
|
||||
|
||||
EBitFlagtest operator|( EBitFlagtest a, EBitFlagtest b )
|
||||
{
|
||||
return EBitFlagtest( ( u8 )a | ( u8 )b );
|
||||
}
|
||||
void test_function_wparams2(u8 a, u8 b)
|
||||
|
||||
void test_function_wparam( u8 a );
|
||||
|
||||
void test_function_wparams( u8 a, u8 b )
|
||||
{
|
||||
// Empty function body
|
||||
}
|
||||
|
||||
void test_function_wparams2( u8 a, u8 b )
|
||||
{
|
||||
// Empty function body
|
||||
}
|
||||
|
||||
|
||||
class TestEmptyStruct;
|
||||
|
||||
class TestEmptyStruct
|
||||
{
|
||||
// Empty class body
|
||||
|
||||
};
|
||||
|
||||
union TestEmptyUnion
|
||||
{
|
||||
// Empty union body
|
||||
|
||||
};
|
||||
|
||||
using TestUsing = u8;
|
||||
@@ -82,4 +92,3 @@ u8 test_variable;
|
||||
u8 test_variable2 = 0x12;
|
||||
|
||||
// End of base case tests.
|
||||
|
||||
|
@@ -1,51 +0,0 @@
|
||||
#include "Bloat.cpp"
|
||||
|
||||
|
||||
#ifdef gen_time
|
||||
#include "gen.cpp"
|
||||
|
||||
|
||||
void case_untyped()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int gen_main()
|
||||
{
|
||||
Memory::setup();
|
||||
|
||||
log_fmt("\nPress any key after attaching to process\n");
|
||||
getchar();
|
||||
|
||||
gen::init();
|
||||
|
||||
case_untyped();
|
||||
|
||||
Memory::cleanup();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef runtime
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user