diff --git a/.vscode/launch.json b/.vscode/launch.json index 4b13ea2..60fd398 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -41,6 +41,15 @@ "cwd": "${workspaceFolder}/singleheader/", "visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" }, + { + "type": "cppvsdbg", + "request": "launch", + "name": "Debug unreal vsdbg", + "program": "${workspaceFolder}/unreal_engine/build/unreal.exe", + "args": [], + "cwd": "${workspaceFolder}/unreal_engine/", + "visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" + }, { "type": "cppvsdbg", "request": "launch", diff --git a/project/components/gen/ast_inlines.hpp b/project/components/gen/ast_inlines.hpp index 4091986..d7dda4e 100644 --- a/project/components/gen/ast_inlines.hpp +++ b/project/components/gen/ast_inlines.hpp @@ -28,8 +28,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -96,8 +95,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -164,8 +162,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -252,8 +249,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -340,8 +336,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -428,8 +423,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -496,8 +490,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -584,8 +577,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -672,8 +664,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -760,8 +751,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -848,8 +838,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -936,8 +925,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1024,8 +1012,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1112,8 +1099,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1200,8 +1186,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1288,8 +1273,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1376,8 +1360,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1464,8 +1447,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1552,8 +1534,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1620,8 +1601,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1708,8 +1688,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1796,8 +1775,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1864,8 +1842,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -1932,8 +1909,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -2020,8 +1996,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -2108,8 +2083,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -2196,8 +2170,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -2284,8 +2257,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } @@ -2372,8 +2344,7 @@ inline 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 ast == nullptr && other.ast == nullptr; } return rcast( AST*, ast )->is_equal( other.ast ); } diff --git a/project/components/inlines.hpp b/project/components/inlines.hpp index 36fd03a..7c4d792 100644 --- a/project/components/inlines.hpp +++ b/project/components/inlines.hpp @@ -124,11 +124,11 @@ CodeParam CodeParam::get( s32 idx ) if ( ! ++ param ) return { nullptr }; - return { (AST_Param*) param.raw()->Next }; + param = { (AST_Param*) param.raw()->Next }; } while ( --idx ); - return { nullptr }; + return param; } inline diff --git a/project/components/parser.cpp b/project/components/parser.cpp index 68c2c33..afc37aa 100644 --- a/project/components/parser.cpp +++ b/project/components/parser.cpp @@ -2699,7 +2699,7 @@ CodeParam parse_params( bool use_template_capture ) s32 capture_level = 0; s32 template_level = 0; - while ( left && ( currtok.Type != TokType::Comma ) && template_level >= 0 && (CheckEndParams() || capture_level > 0 || template_level > 0) ) + while ( (left && ( currtok.Type != TokType::Comma ) && template_level >= 0 && CheckEndParams()) || (capture_level > 0 || template_level > 0) ) { if (currtok.Text[ 0 ] == '<') ++ template_level; @@ -2811,10 +2811,10 @@ CodeParam parse_params( bool use_template_capture ) s32 capture_level = 0; s32 template_level = 0; - while ( left + while ( (left && currtok.Type != TokType::Comma && template_level >= 0 - && (CheckEndParams() || capture_level > 0 || template_level > 0) ) + && CheckEndParams()) || (capture_level > 0 || template_level > 0) ) { if (currtok.Text[ 0 ] == '<') ++ template_level; diff --git a/project/dependencies/parsing.cpp b/project/dependencies/parsing.cpp index f975f17..9ec7cac 100644 --- a/project/dependencies/parsing.cpp +++ b/project/dependencies/parsing.cpp @@ -36,7 +36,7 @@ u8 adt_destroy_branch( ADT_Node* node ) GEN_ASSERT_NOT_NULL( node ); if ( ( node->type == EADT_TYPE_OBJECT || node->type == EADT_TYPE_ARRAY ) && node->nodes ) { - for ( sw i = 0; i < node->nodes.num(); ++i ) + for ( sw i = 0; i < scast(sw, node->nodes.num()); ++i ) { adt_destroy_branch( node->nodes + i ); } @@ -66,7 +66,7 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search ) return NULL; } - for ( sw i = 0; i < node->nodes.num(); i++ ) + for ( sw i = 0; i < scast(sw, node->nodes.num()); i++ ) { if ( ! str_compare( node->nodes[ i ].name, name ) ) { @@ -76,7 +76,7 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search ) if ( deep_search ) { - for ( sw i = 0; i < node->nodes.num(); i++ ) + for ( sw i = 0; i < scast(sw, node->nodes.num()); i++ ) { ADT_Node* res = adt_find( node->nodes + i, name, deep_search ); @@ -132,7 +132,7 @@ internal ADT_Node* _adt_get_value( ADT_Node* node, char const* value ) internal ADT_Node* _adt_get_field( ADT_Node* node, char* name, char* value ) { - for ( sw i = 0; i < node->nodes.num(); i++ ) + for ( sw i = 0; i < scast(sw, node->nodes.num()); i++ ) { if ( ! str_compare( node->nodes[ i ].name, name ) ) { @@ -207,7 +207,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri ) /* run a value comparison against any child that is an object node */ else if ( node->type == EADT_TYPE_ARRAY ) { - for ( sw i = 0; i < node->nodes.num(); i++ ) + for ( sw i = 0; i < scast(sw, node->nodes.num()); i++ ) { ADT_Node* child = &node->nodes[ i ]; if ( child->type != EADT_TYPE_OBJECT ) @@ -225,7 +225,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri ) /* [value] */ else { - for ( sw i = 0; i < node->nodes.num(); i++ ) + for ( sw i = 0; i < scast(sw, node->nodes.num()); i++ ) { ADT_Node* child = &node->nodes[ i ]; if ( _adt_get_value( child, l_b2 ) ) @@ -257,7 +257,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri ) else { sw idx = ( sw )str_to_i64( buf, NULL, 10 ); - if ( idx >= 0 && idx < node->nodes.num() ) + if ( idx >= 0 && idx < scast(sw, node->nodes.num()) ) { found_node = &node->nodes[ idx ]; @@ -282,7 +282,7 @@ ADT_Node* adt_alloc_at( ADT_Node* parent, sw index ) if ( ! parent->nodes ) return NULL; - if ( index < 0 || index > parent->nodes.num() ) + if ( index < 0 || index > scast(sw, parent->nodes.num()) ) return NULL; ADT_Node o = { 0 }; @@ -946,7 +946,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b } } - if ( columnIndex >= root->nodes.num() ) + if ( columnIndex >= scast(sw, root->nodes.num()) ) { adt_append_arr( root, NULL ); } @@ -989,7 +989,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b /* consider first row as a header. */ if ( has_header ) { - for ( sw i = 0; i < root->nodes.num(); i++ ) + for ( sw i = 0; i < scast(sw, root->nodes.num()); i++ ) { CSV_Object* col = root->nodes + i; CSV_Object* hdr = col->nodes; diff --git a/project/dependencies/strings.hpp b/project/dependencies/strings.hpp index d1d1f07..c755729 100644 --- a/project/dependencies/strings.hpp +++ b/project/dependencies/strings.hpp @@ -18,6 +18,7 @@ struct StrC #define cast_to_strc( str ) * rcast( StrC*, (str) - sizeof(sw) ) #define txt( text ) StrC { sizeof( text ) - 1, ( text ) } +inline StrC to_str( char const* str ) { return { str_len( str ), str }; diff --git a/project/helpers/helper.hpp b/project/helpers/helper.hpp index 4d972ec..3085396 100644 --- a/project/helpers/helper.hpp +++ b/project/helpers/helper.hpp @@ -371,8 +371,8 @@ CodeBody gen_ast_inlines() if ( ast == nullptr || other.ast == nullptr ) { // Just check if they're both null. - log_failure( "Code::is_equal: Cannot compare code, AST is null!" ); - return false; + // log_failure( "Code::is_equal: Cannot compare code, AST is null!" ); + return ast == nullptr && other.ast == nullptr; } return rcast(AST*, ast)->is_equal( other.ast ); } diff --git a/scripts/build.ci.ps1 b/scripts/build.ci.ps1 index d35ef22..6bd482b 100644 --- a/scripts/build.ci.ps1 +++ b/scripts/build.ci.ps1 @@ -6,6 +6,7 @@ Import-Module ./helpers/target_arch.psm1 $target_arch = Join-Path $PSScriptRoot 'helpers/target_arch.psm1' $devshell = Join-Path $PSScriptRoot 'helpers/devshell.ps1' $format_cpp = Join-Path $PSScriptRoot 'helpers/format_cpp.psm1' +$refactor_unreal = Join-Path $PSScriptRoot 'refactor_unreal.ps1' $incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1' $vendor_toolchain = Join-Path $PSScriptRoot 'helpers/vendor_toolchain.ps1' @@ -201,6 +202,8 @@ if ( $unreal ) write-host "`n Unreal variant generator completed in $($time_taken.TotalMilliseconds) ms" } Pop-Location + + . $refactor_unreal } if ( $test ) diff --git a/scripts/package_release.ps1 b/scripts/package_release.ps1 index be7efc3..9dec819 100644 --- a/scripts/package_release.ps1 +++ b/scripts/package_release.ps1 @@ -3,20 +3,22 @@ cls $build = Join-Path $PSScriptRoot 'build.ci.ps1' if ( $IsWindows ) { - & $build release msvc bootstrap singleheader + & $build release msvc bootstrap singleheader unreal } else { - & $build release clang bootstrap singleheader + & $build release clang bootstrap singleheader unreal } $path_root = git rev-parse --show-toplevel -$path_docs = Join-Path $path_root docs -$path_project = Join-Path $path_root project -$path_project_gen = Join-Path $path_project gen -$path_singleheader = Join-Path $path_root singleheader +$path_docs = Join-Path $path_root docs +$path_project = Join-Path $path_root project +$path_project_gen = Join-Path $path_project gen +$path_singleheader = Join-Path $path_root singleheader $path_singleheader_gen = Join-Path $path_singleheader gen -$path_release = Join-Path $path_root release -$path_release_content = Join-Path $path_release content +$path_unreal = Join-Path $path_root unreal_engine +$path_unreal_gen = Join-Path $path_unreal gen +$path_release = Join-Path $path_root release +$path_release_content = Join-Path $path_release content if ( -not(Test-Path $path_release) ) { New-Item -ItemType Directory -Path $path_release @@ -50,5 +52,17 @@ Remove-Item -Path $path_release_content\gen.hpp # Segmented Copy-Item -Path $path_project_gen\* -Destination $path_release_content Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_segmented.zip -Force +Remove-Item -Path $path_release_content\gen.dep.hpp +Remove-Item -Path $path_release_content\gen.dep.cpp +Remove-Item -Path $path_release_content\gen.hpp +Remove-Item -Path $path_release_content\gen.cpp +Remove-Item -Path $path_release_content\gen.builder.hpp +Remove-Item -Path $path_release_content\gen.builder.cpp +Remove-Item -Path $path_release_content\gen.scanner.hpp +Remove-Item -Path $path_release_content\gen.scanner.cpp + +# Unreal +Copy-Item -Path $path_unreal_gen\* -Destination $path_release_content +Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_unreal.zip -Force Remove-Item -Path $path_release_content -Recurse diff --git a/scripts/refactor_unreal.ps1 b/scripts/refactor_unreal.ps1 new file mode 100644 index 0000000..be53c21 --- /dev/null +++ b/scripts/refactor_unreal.ps1 @@ -0,0 +1,56 @@ +[string] $format = $false + +foreach ( $arg in $args ) +{ + if ( $arg -eq "format" ) + { + $format = $true + } +} + +[string[]] $include = 'gen.*.hpp', 'gen.*.cpp', 'gen.hpp', 'gen.cpp' +[string[]] $exclude + +$path_root = git rev-parse --show-toplevel +$path_project = Join-Path $path_root project +$path_scripts = Join-Path $path_root scripts +$path_singlheader = Join-Path $path_root singleheader +$path_singleheader_comp = Join-Path $path_singlheader components +$path_unreal = Join-Path $path_root unreal_engine +$path_unreal_gen = Join-Path $path_unreal gen + +$file_spec = Join-Path $path_scripts unreal.refactor + +# Gather the files to be formatted. +$targetFiles = @() +$targetFiles += Get-ChildItem -Recurse -Path $path_unreal_gen -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName +# $targetFiles += Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName +# $targetFiles += Get-ChildItem -Recurse -Path $path_singleheader_comp -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName + +# Format the files. +$formatParams = @( + '-i' # In-place + '-style=file:./.clang-format' # Search for a .clang-format file in the parent directory of the source file. + '-verbose' +) + +write-host "Beginning refactor...`n" + +$refactorParams = @( + # "-debug", + "-num=$($targetFiles.Count)" + "-src=$($targetFiles)", + "-spec=$($file_spec)" +) + +& refactor $refactorParams + +Write-Host "`nRefactoring complete`n`n" + +if ( $format -eq $true ) { + Write-Host "Beginning format...`n" + + & clang-format $formatParams $targetFiles + + Write-Host "`nFormatting complete" +} diff --git a/unreal_engine/Readme.md b/unreal_engine/Readme.md index 7fc3ca5..ce25b71 100644 --- a/unreal_engine/Readme.md +++ b/unreal_engine/Readme.md @@ -1,4 +1,3 @@ # Unreal Engine Version Generator -This generates a variant of gencpp thats compatiable with use as a thirdparty module within a plugin or module of an Unreal Project or the Engine itself. - +This generates a variant of gencpp thats compatiable with use as a thirdparty module within a plugin or module of an Unreal Project or the Engine itself. \ No newline at end of file diff --git a/unreal_engine/components/dependencies.header_start.hpp b/unreal_engine/components/dependencies.header_start.hpp deleted file mode 100644 index e314c43..0000000 --- a/unreal_engine/components/dependencies.header_start.hpp +++ /dev/null @@ -1,126 +0,0 @@ -#pragma once - -#pragma region Platform Detection - -/* Platform architecture */ - -#if defined( _WIN64 ) || defined( __x86_64__ ) || defined( _M_X64 ) || defined( __64BIT__ ) || defined( __powerpc64__ ) || defined( __ppc64__ ) || defined( __aarch64__ ) -# ifndef GEN_ARCH_64_BIT -# define GEN_ARCH_64_BIT 1 -# endif -#else -# ifndef GEN_ARCH_32_BItxt_StrCaT -# define GEN_ARCH_32_BIT 1 -# endif -#endif - -/* Platform OS */ - -#if defined( _WIN32 ) || defined( _WIN64 ) -# ifndef GEN_SYSTEM_WINDOWS -# define GEN_SYSTEM_WINDOWS 1 -# endif -#elif defined( __APPLE__ ) && defined( __MACH__ ) -# ifndef GEN_SYSTEM_OSX -# define GEN_SYSTEM_OSX 1 -# endif -# ifndef GEN_SYSTEM_MACOS -# define GEN_SYSTEM_MACOS 1 -# endif -# include -# if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1 -# ifndef GEN_SYSTEM_IOS -# define GEN_SYSTEM_IOS 1 -# endif -# endif -#elif defined( __unix__ ) -# ifndef GEN_SYSTEM_UNIX -# define GEN_SYSTEM_UNIX 1 -# endif -# if defined( ANDROID ) || defined( __ANDROID__ ) -# ifndef GEN_SYSTEM_ANDROID -# define GEN_SYSTEM_ANDROID 1 -# endif -# ifndef GEN_SYSTEM_LINUX -# define GEN_SYSTEM_LINUX 1 -# endif -# elif defined( __linux__ ) -# ifndef GEN_SYSTEM_LINUX -# define GEN_SYSTEM_LINUX 1 -# endif -# elif defined( __FreeBSD__ ) || defined( __FreeBSD_kernel__ ) -# ifndef GEN_SYSTEM_FREEBSD -# define GEN_SYSTEM_FREEBSD 1 -# endif -# elif defined( __OpenBSD__ ) -# ifndef GEN_SYSTEM_OPENBSD -# define GEN_SYSTEM_OPENBSD 1 -# endif -# elif defined( __EMSCRIPTEN__ ) -# ifndef GEN_SYSTEM_EMSCRIPTEN -# define GEN_SYSTEM_EMSCRIPTEN 1 -# endif -# elif defined( __CYGWIN__ ) -# ifndef GEN_SYSTEM_CYGWIN -# define GEN_SYSTEM_CYGWIN 1 -# endif -# else -# error This UNIX operating system is not supported -# endif -#else -# error This operating system is not supported -#endif - -/* Platform compiler */ - -#if defined( _MSC_VER ) -# define GEN_COMPILER_MSVC 1 -#elif defined( __GNUC__ ) -# define GEN_COMPILER_GCC 1 -#elif defined( __clang__ ) -# define GEN_COMPILER_CLANG 1 -#elif defined( __MINGW32__ ) -# define GEN_COMPILER_MINGW 1 -# error Unknown compiler -#endif - -#if defined( __has_attribute ) -# define GEN_HAS_ATTRIBUTE( attribute ) __has_attribute( attribute ) -#else -# define GEN_HAS_ATTRIBUTE( attribute ) ( 0 ) -#endif - -#if defined(GEN_GCC_VERSION_CHECK) -# undef GEN_GCC_VERSION_CHECK -#endif -#if defined(GEN_GCC_VERSION) -# define GEN_GCC_VERSION_CHECK(major,minor,patch) (GEN_GCC_VERSION >= GEN_VERSION_ENCODE(major, minor, patch)) -#else -# define GEN_GCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#define GEN_DEF_INLINE static -#define GEN_IMPL_INLINE static inline - -#pragma endregion Platform Detection - -#pragma region Mandatory Includes - -# include -# include - -# if defined( GEN_SYSTEM_WINDOWS ) -# include -# endif - -#pragma endregion Mandatory Includes - -#ifdef GEN_DONT_USE_NAMESPACE -# define GEN_NS -# define GEN_NS_BEGIN -# define GEN_NS_END -#else -# define GEN_NS gen:: -# define GEN_NS_BEGIN namespace gen { -# define GEN_NS_END } -#endif diff --git a/unreal_engine/components/header_start.hpp b/unreal_engine/components/header_start.hpp new file mode 100644 index 0000000..950a08b --- /dev/null +++ b/unreal_engine/components/header_start.hpp @@ -0,0 +1,31 @@ +/* + gencpp: An attempt at "simple" staged metaprogramming for c/c++. + + See Readme.md for more information from the project repository. + + Public Address: + https://github.com/Ed94/gencpp + + This is a variant intended for use with Unreal Engine 5 +*/ +#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME) +# error Gen.hpp : GEN_TIME not defined +#endif + +//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file. +// Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl +#ifndef GEN_ROLL_OWN_DEPENDENCIES +# include "gen.dep.hpp" +#endif + +#ifndef GEN_NS_BEGIN +# ifdef GEN_DONT_USE_NAMESPACE +# define GEN_NS +# define GEN_NS_BEGIN +# define GEN_NS_END +# else +# define GEN_NS gen:: +# define GEN_NS_BEGIN namespace gen { +# define GEN_NS_END } +# endif +#endif diff --git a/unreal_engine/components/source_start.cpp b/unreal_engine/components/source_start.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/unreal_engine/components/src_start.cpp b/unreal_engine/components/src_start.cpp new file mode 100644 index 0000000..36b728c --- /dev/null +++ b/unreal_engine/components/src_start.cpp @@ -0,0 +1,5 @@ +#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME) +# error Gen.hpp : GEN_TIME not defined +#endif + +#include "gen.hpp" diff --git a/unreal_engine/enums/AttributeTokens.csv b/unreal_engine/enums/AttributeTokens.csv index b85565b..e56b45b 100644 --- a/unreal_engine/enums/AttributeTokens.csv +++ b/unreal_engine/enums/AttributeTokens.csv @@ -1,3 +1,7 @@ -// TODO(Ed): The Attribute tokens need to be expanded and regenerated on a per-project/installation of this library for a specific codebase of Unreal. -// We can support an arbitrary set of modules or plugin apis for parsing -// but its up to the user to define them all (This will just provide whats be used in previous usages with Unreal). +API_Export, GEN_API_Export_Code +API_Import, GEN_API_Import_Code +UE_DEPRECATED, UE_DEPRECATED +UMG_API, UMG_API +COREUOBJECT_API, COREUOBJECT_API +ENGINE_API, ENGINE_API +GAMEPLAYABILITIES_API, GAMEPLAYABILITIES_API diff --git a/unreal_engine/unreal.cpp b/unreal_engine/unreal.cpp index 389eb8f..cc2111c 100644 --- a/unreal_engine/unreal.cpp +++ b/unreal_engine/unreal.cpp @@ -17,7 +17,7 @@ GEN_NS_END using namespace gen; constexpr char const* generation_notice = -"// This file was generated automatially by gencpp's unreal.cpp" +"// This file was generated automatially by gencpp's unreal.cpp " "(See: https://github.com/Ed94/gencpp)\n\n"; constexpr StrC implementation_guard_start = txt(R"( @@ -193,4 +193,224 @@ R"(#ifdef GEN_COMPILER_MSVC header.print( pop_ignores ); header.write(); } + + // gen_dep.cpp + { + Code src_start = scan_file( project_dir "dependencies/src_start.cpp" ); + Code debug = scan_file( project_dir "dependencies/debug.cpp" ); + Code string_ops = scan_file( project_dir "dependencies/string_ops.cpp" ); + Code printing = scan_file( project_dir "dependencies/printing.cpp" ); + Code memory = scan_file( project_dir "dependencies/memory.cpp" ); + Code hashing = scan_file( project_dir "dependencies/hashing.cpp" ); + Code strings = scan_file( project_dir "dependencies/strings.cpp" ); + Code filesystem = scan_file( project_dir "dependencies/filesystem.cpp" ); + Code timing = scan_file( project_dir "dependencies/timing.cpp" ); + + Builder + src = Builder::open( "gen/gen.dep.cpp" ); + src.print_fmt( generation_notice ); + src.print( def_include(txt("gen.dep.hpp"))); + src.print( fmt_newline ); + src.print( push_ignores ); + src.print( src_start ); + src.print_fmt( "\nGEN_NS_BEGIN\n" ); + + src.print( debug ); + src.print( string_ops ); + src.print( printing ); + src.print( hashing ); + src.print( memory ); + src.print( strings ); + src.print( filesystem ); + src.print( timing ); + + src.print_fmt( "\nGEN_NS_END\n" ); + src.print( fmt_newline ); + src.print( pop_ignores ); + src.write(); + } + + // gen.hpp + { + Code header_start = scan_file( "components/header_start.hpp" ); + Code types = scan_file( project_dir "components/types.hpp" ); + Code ast = scan_file( project_dir "components/ast.hpp" ); + Code ast_types = scan_file( project_dir "components/ast_types.hpp" ); + Code code_types = scan_file( project_dir "components/code_types.hpp" ); + Code interface = scan_file( project_dir "components/interface.hpp" ); + Code inlines = scan_file( project_dir "components/inlines.hpp" ); + Code header_end = scan_file( project_dir "components/header_end.hpp" ); + + CodeBody ecode = gen_ecode ( project_dir "enums/ECode.csv" ); + CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv" ); + CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" ); + CodeBody ast_inlines = gen_ast_inlines(); + + Builder + header = Builder::open( "gen/gen.hpp" ); + header.print_fmt( generation_notice ); + header.print_fmt( "#pragma once\n\n" ); + header.print( push_ignores ); + header.print( fmt_newline ); + header.print( header_start ); + header.print_fmt( "\nGEN_NS_BEGIN\n\n" ); + + header.print_fmt( "#pragma region Types\n" ); + header.print( types ); + header.print( ecode ); + header.print( eoperator ); + header.print( especifier ); + header.print_fmt( "#pragma endregion Types\n\n" ); + + header.print_fmt( "#pragma region AST\n" ); + header.print( ast ); + header.print( code_types ); + header.print( ast_types ); + header.print_fmt( "\n#pragma endregion AST\n" ); + + header.print( interface ); + + header.print_fmt( "\n#pragma region Inlines\n" ); + header.print( inlines ); + header.print( fmt_newline ); + header.print( ast_inlines ); + header.print_fmt( "#pragma endregion Inlines\n" ); + + header.print( header_end ); + header.print_fmt( "GEN_NS_END\n\n" ); + header.print( pop_ignores ); + header.write(); + } + + // gen.cpp + { + Code src_start = scan_file( "components/src_start.cpp" ); + Code static_data = scan_file( project_dir "components/static_data.cpp" ); + Code ast_case_macros = scan_file( project_dir "components/ast_case_macros.cpp" ); + Code ast = scan_file( project_dir "components/ast.cpp" ); + Code code_serialization = scan_file( project_dir "components/code_serialization.cpp" ); + Code interface = scan_file( project_dir "components/interface.cpp" ); + Code upfront = scan_file( project_dir "components/interface.upfront.cpp" ); + Code lexer = scan_file( project_dir "components/lexer.cpp" ); + Code parser = scan_file( project_dir "components/parser.cpp" ); + Code parsing_interface = scan_file( project_dir "components/interface.parsing.cpp" ); + Code untyped = scan_file( project_dir "components/interface.untyped.cpp" ); + + // Note(Ed): The Attribute tokens need to be expanded and regenerated on a per-project/installation of this library for a specific codebase of Unreal. + // We can support an arbitrary set of modules or plugin apis for parsing + // but its up to the user to define them all (This will just provide whats I've used up till now). + CodeBody etoktype = gen_etoktype( project_dir "enums/ETokType.csv", "enums/AttributeTokens.csv" ); + CodeNS nspaced_etoktype = def_namespace( name(parser), def_namespace_body( args(etoktype)) ); + + Builder + src = Builder::open( "gen/gen.cpp" ); + src.print_fmt( generation_notice ); + src.print( push_ignores ); + src.print( fmt_newline ); + src.print( src_start ); + src.print( fmt_newline ); + src.print_fmt( "GEN_NS_BEGIN\n"); + + src.print( static_data ); + + src.print_fmt( "\n#pragma region AST\n\n" ); + src.print( ast_case_macros ); + src.print( ast ); + src.print( code_serialization ); + src.print_fmt( "\n#pragma endregion AST\n" ); + + src.print_fmt( "\n#pragma region Interface\n" ); + src.print( interface ); + src.print( upfront ); + src.print_fmt( "\n#pragma region Parsing\n\n" ); + src.print( nspaced_etoktype ); + src.print( lexer ); + src.print( parser ); + src.print( parsing_interface ); + src.print( untyped ); + src.print_fmt( "\n#pragma endregion Parsing\n\n" ); + src.print_fmt( "#pragma endregion Interface\n\n" ); + + src.print_fmt( "GEN_NS_END\n\n"); + src.print( pop_ignores ); + src.write(); + } + + // gen_builder.hpp + { + Code builder = scan_file( project_dir "auxillary/builder.hpp" ); + + Builder + header = Builder::open( "gen/gen.builder.hpp" ); + header.print_fmt( generation_notice ); + header.print( push_ignores ); + header.print( fmt_newline ); + header.print_fmt( "#pragma once\n\n" ); + header.print( def_include( txt("gen.hpp") )); + header.print_fmt( "\nGEN_NS_BEGIN\n" ); + header.print( builder ); + header.print_fmt( "GEN_NS_END\n" ); + header.print( fmt_newline ); + header.print( pop_ignores ); + header.write(); + } + + // gen_builder.cpp + { + Code builder = scan_file( project_dir "auxillary/builder.cpp" ); + + Builder + src = Builder::open( "gen/gen.builder.cpp" ); + src.print_fmt( generation_notice ); + src.print( push_ignores ); + src.print( fmt_newline ); + src.print( def_include( txt("gen.builder.hpp") ) ); + src.print_fmt( "\nGEN_NS_BEGIN\n" ); + src.print( builder ); + src.print_fmt( "\nGEN_NS_END\n" ); + src.print( fmt_newline ); + src.print( pop_ignores ); + src.write(); + } + + // gen_scanner.hpp + { + Code parsing = scan_file( project_dir "dependencies/parsing.hpp" ); + Code scanner = scan_file( project_dir "auxillary/scanner.hpp" ); + + Builder + header = Builder::open( "gen/gen.scanner.hpp" ); + header.print_fmt( generation_notice ); + header.print_fmt( "#pragma once\n\n" ); + header.print( push_ignores ); + header.print( fmt_newline ); + header.print( def_include( txt("gen.hpp") ) ); + header.print_fmt( "\nGEN_NS_BEGIN\n" ); + header.print( parsing ); + header.print( scanner ); + header.print_fmt( "GEN_NS_END\n" ); + header.print( fmt_newline ); + header.print( pop_ignores ); + header.write(); + } + + // gen.scanner.cpp + { + Code parsing = scan_file( project_dir "dependencies/parsing.cpp" ); + Code scanner = scan_file( project_dir "auxillary/scanner.cpp" ); + + Builder + src = Builder::open( "gen/gen.scanner.cpp" ); + src.print_fmt( generation_notice ); + src.print( push_ignores ); + src.print( fmt_newline ); + src.print( def_include( txt("gen.scanner.hpp") ) ); + src.print_fmt( "\nGEN_NS_BEGIN\n" ); + src.print( parsing ); + // src.print( scanner ); + src.print_fmt( "GEN_NS_END\n" ); + src.print( fmt_newline ); + src.print( pop_ignores ); + src.write(); + } }