DId a pass on ast.hpp, types.hpp and helper.hpp for C compatability (unfortuantely clang-format doesn't like my enum macro...

This commit is contained in:
2024-12-06 05:29:17 -05:00
parent 9b059dca47
commit 92e0d3ab8b
16 changed files with 691 additions and 661 deletions

View File

@ -1,6 +1,5 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#pragma once #include "components/types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
@ -11,7 +10,7 @@ inline Code& Code::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -27,7 +26,7 @@ inline CodeBody& CodeBody::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -43,7 +42,7 @@ inline CodeAttributes& CodeAttributes::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -74,7 +73,7 @@ inline CodeComment& CodeComment::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -105,7 +104,7 @@ inline CodeConstructor& CodeConstructor::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -136,7 +135,7 @@ inline CodeClass& CodeClass::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -152,7 +151,7 @@ inline CodeDefine& CodeDefine::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -183,7 +182,7 @@ inline CodeDestructor& CodeDestructor::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -214,7 +213,7 @@ inline CodeEnum& CodeEnum::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -245,7 +244,7 @@ inline CodeExec& CodeExec::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -276,7 +275,7 @@ inline CodeExtern& CodeExtern::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -307,7 +306,7 @@ inline CodeFriend& CodeFriend::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -338,7 +337,7 @@ inline CodeFn& CodeFn::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -369,7 +368,7 @@ inline CodeInclude& CodeInclude::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -400,7 +399,7 @@ inline CodeModule& CodeModule::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -431,7 +430,7 @@ inline CodeNS& CodeNS::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -462,7 +461,7 @@ inline CodeOperator& CodeOperator::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -493,7 +492,7 @@ inline CodeOpCast& CodeOpCast::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -524,7 +523,7 @@ inline CodeParam& CodeParam::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -540,7 +539,7 @@ inline CodePragma& CodePragma::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -571,7 +570,7 @@ inline CodePreprocessCond& CodePreprocessCond::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -602,7 +601,7 @@ inline CodeSpecifiers& CodeSpecifiers::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -618,7 +617,7 @@ inline CodeStruct& CodeStruct::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -634,7 +633,7 @@ inline CodeTemplate& CodeTemplate::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -665,7 +664,7 @@ inline CodeTypename& CodeTypename::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -696,7 +695,7 @@ inline CodeTypedef& CodeTypedef::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -727,7 +726,7 @@ inline CodeUnion& CodeUnion::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -758,7 +757,7 @@ inline CodeUsing& CodeUsing::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -789,7 +788,7 @@ inline CodeVar& CodeVar::operator=( Code other )
{
if ( other.ast && other->Parent )
{
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
ast->Parent = { nullptr };
}
ast = rcast( decltype( ast ), other.ast );
@ -817,7 +816,6 @@ inline AST_Var* CodeVar::operator->()
}
#pragma endregion generated code inline implementation
#pragma region generated AST/Code cast implementation
inline Code::operator CodeBody() const

View File

@ -1,80 +1,78 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#pragma once #include "components/types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
enum CodeType_Def : u32
{
CT_Invalid,
CT_Untyped,
CT_NewLine,
CT_Comment,
CT_Access_Private,
CT_Access_Protected,
CT_Access_Public,
CT_PlatformAttributes,
CT_Class,
CT_Class_Fwd,
CT_Class_Body,
CT_Constructor,
CT_Constructor_Fwd,
CT_Destructor,
CT_Destructor_Fwd,
CT_Enum,
CT_Enum_Fwd,
CT_Enum_Body,
CT_Enum_Class,
CT_Enum_Class_Fwd,
CT_Execution,
CT_Export_Body,
CT_Extern_Linkage,
CT_Extern_Linkage_Body,
CT_Friend,
CT_Function,
CT_Function_Fwd,
CT_Function_Body,
CT_Global_Body,
CT_Module,
CT_Namespace,
CT_Namespace_Body,
CT_Operator,
CT_Operator_Fwd,
CT_Operator_Member,
CT_Operator_Member_Fwd,
CT_Operator_Cast,
CT_Operator_Cast_Fwd,
CT_Parameters,
CT_Preprocess_Define,
CT_Preprocess_Include,
CT_Preprocess_If,
CT_Preprocess_IfDef,
CT_Preprocess_IfNotDef,
CT_Preprocess_ElIf,
CT_Preprocess_Else,
CT_Preprocess_EndIf,
CT_Preprocess_Pragma,
CT_Specifiers,
CT_Struct,
CT_Struct_Fwd,
CT_Struct_Body,
CT_Template,
CT_Typedef,
CT_Typename,
CT_Union,
CT_Union_Fwd,
CT_Union_Body,
CT_Using,
CT_Using_Namespace,
CT_Variable,
CT_NumTypes
};
enum CodeType_Def enum_underlying( u32 )
{ CT_Invalid,
CT_Untyped,
CT_NewLine,
CT_Comment,
CT_Access_Private,
CT_Access_Protected,
CT_Access_Public,
CT_PlatformAttributes,
CT_Class,
CT_Class_Fwd,
CT_Class_Body,
CT_Constructor,
CT_Constructor_Fwd,
CT_Destructor,
CT_Destructor_Fwd,
CT_Enum,
CT_Enum_Fwd,
CT_Enum_Body,
CT_Enum_Class,
CT_Enum_Class_Fwd,
CT_Execution,
CT_Export_Body,
CT_Extern_Linkage,
CT_Extern_Linkage_Body,
CT_Friend,
CT_Function,
CT_Function_Fwd,
CT_Function_Body,
CT_Global_Body,
CT_Module,
CT_Namespace,
CT_Namespace_Body,
CT_Operator,
CT_Operator_Fwd,
CT_Operator_Member,
CT_Operator_Member_Fwd,
CT_Operator_Cast,
CT_Operator_Cast_Fwd,
CT_Parameters,
CT_Preprocess_Define,
CT_Preprocess_Include,
CT_Preprocess_If,
CT_Preprocess_IfDef,
CT_Preprocess_IfNotDef,
CT_Preprocess_ElIf,
CT_Preprocess_Else,
CT_Preprocess_EndIf,
CT_Preprocess_Pragma,
CT_Specifiers,
CT_Struct,
CT_Struct_Fwd,
CT_Struct_Body,
CT_Template,
CT_Typedef,
CT_Typename,
CT_Union,
CT_Union_Fwd,
CT_Union_Body,
CT_Using,
CT_Using_Namespace,
CT_Variable,
CT_NumTypes };
typedef enum CodeType_Def CodeType;
inline StrC to_str( CodeType type )
inline StrC codetype_to_str( CodeType type )
{
local_persist StrC lookup[] {
local_persist StrC lookup[61] = {
{ sizeof( "Invalid" ), "Invalid" },
{ sizeof( "Untyped" ), "Untyped" },
{ sizeof( "NewLine" ), "NewLine" },

View File

@ -1,66 +1,64 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#pragma once #include "components/types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
enum Operator_Def : u32
{
Op_Invalid,
Op_Assign,
Op_Assign_Add,
Op_Assign_Subtract,
Op_Assign_Multiply,
Op_Assign_Divide,
Op_Assign_Modulo,
Op_Assign_BAnd,
Op_Assign_BOr,
Op_Assign_BXOr,
Op_Assign_LShift,
Op_Assign_RShift,
Op_Increment,
Op_Decrement,
Op_Unary_Plus,
Op_Unary_Minus,
Op_UnaryNot,
Op_Add,
Op_Subtract,
Op_Multiply,
Op_Divide,
Op_Modulo,
Op_BNot,
Op_BAnd,
Op_BOr,
Op_BXOr,
Op_LShift,
Op_RShift,
Op_LAnd,
Op_LOr,
Op_LEqual,
Op_LNot,
Op_Lesser,
Op_Greater,
Op_LesserEqual,
Op_GreaterEqual,
Op_Subscript,
Op_Indirection,
Op_AddressOf,
Op_MemberOfPointer,
Op_PtrToMemOfPtr,
Op_FunctionCall,
Op_Comma,
Op_New,
Op_NewArray,
Op_Delete,
Op_DeleteArray,
NumOps
};
enum Operator_Def enum_underlying( u32 )
{ Op_Invalid,
Op_Assign,
Op_Assign_Add,
Op_Assign_Subtract,
Op_Assign_Multiply,
Op_Assign_Divide,
Op_Assign_Modulo,
Op_Assign_BAnd,
Op_Assign_BOr,
Op_Assign_BXOr,
Op_Assign_LShift,
Op_Assign_RShift,
Op_Increment,
Op_Decrement,
Op_Unary_Plus,
Op_Unary_Minus,
Op_UnaryNot,
Op_Add,
Op_Subtract,
Op_Multiply,
Op_Divide,
Op_Modulo,
Op_BNot,
Op_BAnd,
Op_BOr,
Op_BXOr,
Op_LShift,
Op_RShift,
Op_LAnd,
Op_LOr,
Op_LEqual,
Op_LNot,
Op_Lesser,
Op_Greater,
Op_LesserEqual,
Op_GreaterEqual,
Op_Subscript,
Op_Indirection,
Op_AddressOf,
Op_MemberOfPointer,
Op_PtrToMemOfPtr,
Op_FunctionCall,
Op_Comma,
Op_New,
Op_NewArray,
Op_Delete,
Op_DeleteArray,
NumOps };
typedef enum Operator_Def Operator;
inline StrC to_str( Operator op )
inline StrC operator_to_str( Operator op )
{
local_persist StrC lookup[] {
local_persist StrC lookup[47] = {
{ sizeof( "INVALID" ), "INVALID" },
{ sizeof( "=" ), "=" },
{ sizeof( "+=" ), "+=" },

View File

@ -1,50 +1,25 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#pragma once #include "components/types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
enum Specifier_Def : u32
{
Spec_Invalid,
Spec_Consteval,
Spec_Constexpr,
Spec_Constinit,
Spec_Explicit,
Spec_External_Linkage,
Spec_ForceInline,
Spec_Global,
Spec_Inline,
Spec_Internal_Linkage,
Spec_Local_Persist,
Spec_Mutable,
Spec_NeverInline,
Spec_Ptr,
Spec_Ref,
Spec_Register,
Spec_RValue,
Spec_Static,
Spec_Thread_Local,
Spec_Virtual,
Spec_Const,
Spec_Final,
Spec_NoExceptions,
Spec_Override,
Spec_Pure,
Spec_Volatile,
Spec_NumSpecifiers
};
enum Specifier_Def enum_underlying( u32 )
{ Spec_Invalid, Spec_Consteval, Spec_Constexpr, Spec_Constinit, Spec_Explicit, Spec_External_Linkage, Spec_ForceInline,
Spec_Global, Spec_Inline, Spec_Internal_Linkage, Spec_Local_Persist, Spec_Mutable, Spec_NeverInline, Spec_Ptr,
Spec_Ref, Spec_Register, Spec_RValue, Spec_Static, Spec_Thread_Local, Spec_Virtual, Spec_Const,
Spec_Final, Spec_NoExceptions, Spec_Override, Spec_Pure, Spec_Volatile, Spec_NumSpecifiers };
typedef enum Specifier_Def Specifier;
inline bool is_trailing( Specifier specifier )
inline bool spec_is_trailing( Specifier specifier )
{
return specifier > Spec_Virtual;
}
inline StrC to_str( Specifier type )
inline StrC spec_to_str( Specifier type )
{
local_persist StrC lookup[] {
local_persist StrC lookup[26] = {
{ sizeof( "INVALID" ), "INVALID" },
{ sizeof( "consteval" ), "consteval" },
{ sizeof( "constexpr" ), "constexpr" },
@ -75,12 +50,12 @@ inline StrC to_str( Specifier type )
return lookup[type];
}
inline Specifier to_specifier( StrC str )
inline Specifier strc_to_specifier( StrC str )
{
local_persist u32 keymap[Spec_NumSpecifiers];
do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
{
StrC enum_str = to_str( (Specifier)index );
StrC enum_str = spec_to_str( (Specifier)index );
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
}
do_once_end u32 hash = crc32( str.Ptr, str.Len );

View File

@ -1,6 +1,5 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#pragma once #include "components/types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)