From b2c2b80edf345b66af0fceb7822dab99662f3be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Fri, 6 Oct 2023 19:56:21 -0300 Subject: [PATCH] Fix Windows build. Disabled dynamic syntax until it works properly. --- src/eepp/system/filesystem.cpp | 8 ++-- src/eepp/ui/doc/languages/markdown.cpp | 40 +++++++++++++++++-- src/eepp/ui/doc/syntaxtokenizer.cpp | 13 +++--- .../ecode/statusbuildoutputcontroller.cpp | 2 +- .../ecode/statusbuildoutputcontroller.hpp | 2 +- 5 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/eepp/system/filesystem.cpp b/src/eepp/system/filesystem.cpp index 516f6e050..fbbf89d2d 100644 --- a/src/eepp/system/filesystem.cpp +++ b/src/eepp/system/filesystem.cpp @@ -344,7 +344,7 @@ std::string FileSystem::getRealPath( const std::string& path ) { realPath = std::string( dir ); #elif EE_PLATFORM == EE_PLATFORM_WIN wchar_t dir[_MAX_PATH + 1]; - GetFullPathNameW( String::fromUtf8( path.c_str() ).toWideString().c_str(), _MAX_PATH, &dir[0], + GetFullPathNameW( String::fromUtf8( path ).toWideString().c_str(), _MAX_PATH, &dir[0], nullptr ); realPath = String( dir ).toUtf8(); #else @@ -608,9 +608,9 @@ bool FileSystem::changeWorkingDirectory( const std::string& path ) { int res; #ifdef EE_COMPILER_MSVC #ifdef UNICODE - res = _wchdir( String::fromUtf8( path.c_str() ).toWideString().c_str() ); + res = _wchdir( String::fromUtf8( path ).toWideString().c_str() ); #else - res = _chdir( String::fromUtf8( path.c_str() ).toAnsiString().c_str() ); + res = _chdir( String::fromUtf8( path ).toAnsiString().c_str() ); #endif #else res = chdir( path.c_str() ); @@ -649,7 +649,7 @@ Int64 FileSystem::getDiskFreeSpace( const std::string& path ) { Int64 TotalBytes; Int64 FreeBytes; #ifdef UNICODE - GetDiskFreeSpaceEx( String::fromUtf8( path.c_str() ).toWideString().c_str(), + GetDiskFreeSpaceEx( String::fromUtf8( path ).toWideString().c_str(), (PULARGE_INTEGER)&AvailableBytes, #else GetDiskFreeSpaceEx( path.c_str(), (PULARGE_INTEGER)&AvailableBytes, diff --git a/src/eepp/ui/doc/languages/markdown.cpp b/src/eepp/ui/doc/languages/markdown.cpp index 854728fcc..6d50e84ee 100644 --- a/src/eepp/ui/doc/languages/markdown.cpp +++ b/src/eepp/ui/doc/languages/markdown.cpp @@ -4,13 +4,13 @@ namespace EE { namespace UI { namespace Doc { namespace Language { void addMarkdown() { - auto dynSyntax = []( const SyntaxPattern&, const std::string_view& match ) -> std::string { + /* auto dynSyntax = []( const SyntaxPattern&, const std::string_view& match ) -> std::string { std::string lang = String::toLower( std::string{ match.substr( 3 ) } ); String::trimInPlace( lang ); if ( !lang.empty() && lang[lang.size() - 1] == '\n' ) lang.pop_back(); return SyntaxDefinitionManager::instance()->findFromString( lang ).getLanguageName(); - }; + }; */ SyntaxDefinitionManager::instance()->add( @@ -18,7 +18,41 @@ void addMarkdown() { { "%.md$", "%.markdown$" }, { { { "\\." }, "normal" }, - { { "```[%w%s+-#]+", "```" }, "function", dynSyntax }, + { { "```[Xx][Mm][Ll]", "```" }, "function", "XML" }, + { { "```[Hh][Tt][Mm][Ll]", "```" }, "function", "html" }, + { { "```[Cc]++", "```" }, "function", "C++" }, + { { "```[Cc][Pp][Pp]", "```" }, "function", "C++" }, + { { "```[Cc]sharp", "```" }, "function", "C#" }, + { { "```[Cc][Ss][Ss]", "```" }, "function", "CSS" }, + { { "```[Cc]", "```" }, "function", "C" }, + { { "```[Dd][Aa][Rr][Tt]", "```" }, "function", "Dart" }, + { { "```[Dd]", "```" }, "function", "D" }, + { { "```[Ll]ua", "```" }, "function", "Lua" }, + { { "```[Jj][Ss][Oo][Nn]", "```" }, "function", "JSON" }, + { { "```[Ja]va[Ss]cript", "```" }, "function", "JavaScript" }, + { { "```[Tt]ype[Ss]cript", "```" }, "function", "TypeScript" }, + { { "```[Pp]ython", "```" }, "function", "Python" }, + { { "```[Bb]ash", "```" }, "function", "Bash" }, + { { "```[Pp][Hh][Pp]", "```" }, "function", "PHPCore" }, + { { "```[Ss][Qq][Ll]", "```" }, "function", "SQL" }, + { { "```[Gg][Ll][Ss][Ll]", "```" }, "function", "GLSL" }, + { { "```[Ii][Nn][Ii]", "```" }, "function", "Config File" }, + { { "```[Mm]akefile", "```" }, "function", "Makefile" }, + { { "```[Gg][Oo]", "```" }, "function", "Go" }, + { { "```[Rr]ust", "```" }, "function", "Rust" }, + { { "```[Rr]uby", "```" }, "function", "Ruby" }, + { { "```[Gg][Dd][Ss]cript", "```" }, "function", "GSCript" }, + { { "```[Jj]ava", "```" }, "function", "java" }, + { { "```[Ss]wift", "```" }, "function", "Swift" }, + { { "```[Oo]bjective[Cc]", "```" }, "function", "Objective-C" }, + { { "```[Yy][Aa][Mm][Ll]", "```" }, "function", "YAML" }, + { { "```[Kk]otlin", "```" }, "function", "Kotlin" }, + { { "```[Ss]olidity", "```" }, "function", "Solidity" }, + { { "```[Hh]askell", "```" }, "function", "Haskell" }, + { { "```[Oo]din", "```" }, "function", "Odin" }, + { { "```[Nn]im", "```" }, "function", "Nim" }, + { { "```[Zz]ig", "```" }, "function", "Zig" }, + // { { "```[%w%s+-#]+", "```" }, "function", dynSyntax }, { { "" }, "comment" }, { { "```", "```" }, "string" }, { { "``", "``" }, "string" }, diff --git a/src/eepp/ui/doc/syntaxtokenizer.cpp b/src/eepp/ui/doc/syntaxtokenizer.cpp index 7c8d696ed..1caba6539 100644 --- a/src/eepp/ui/doc/syntaxtokenizer.cpp +++ b/src/eepp/ui/doc/syntaxtokenizer.cpp @@ -163,12 +163,10 @@ _tokenize( const SyntaxDefinition& syntax, const std::string& text, const Syntax curState.currentPatternIdx = patternIndex; retState.state &= ~( 0xFF << ( curState.currentLevel << 3 ) ); retState.state |= ( patternIndex << ( curState.currentLevel << 3 ) ); - if ( curState.currentSyntax ) - retState.hash = curState.currentSyntax->getLanguageId(); }; - auto pushSubsyntax = [&setSubsyntaxPatternIdx, - &curState]( const SyntaxPattern& enteringSubsyntax, + auto pushSubsyntax = [&setSubsyntaxPatternIdx, &curState, + &retState]( const SyntaxPattern& enteringSubsyntax, const Uint32& patternIndex, const std::string& patternStr ) { setSubsyntaxPatternIdx( patternIndex ); curState.currentLevel++; @@ -177,6 +175,8 @@ _tokenize( const SyntaxDefinition& syntax, const std::string& text, const Syntax curState.subsyntaxInfo->dynSyntax ? curState.subsyntaxInfo->dynSyntax( enteringSubsyntax, patternStr ) : curState.subsyntaxInfo->syntax ); + if ( curState.subsyntaxInfo->dynSyntax ) + retState.hash = curState.currentSyntax->getLanguageId(); setSubsyntaxPatternIdx( SYNTAX_TOKENIZER_STATE_NONE ); }; @@ -184,11 +184,14 @@ _tokenize( const SyntaxDefinition& syntax, const std::string& text, const Syntax setSubsyntaxPatternIdx( SYNTAX_TOKENIZER_STATE_NONE ); curState.currentLevel--; setSubsyntaxPatternIdx( SYNTAX_TOKENIZER_STATE_NONE ); + retState.hash = 0; curState = SyntaxTokenizer::retrieveSyntaxState( syntax, retState ); }; size_t size = !text.empty() ? ( text[text.size() - 1] == '\n' ? text.size() - 1 : text.size() ) : 0; // skip last char ( new line char ) + std::string patternStr; + std::string patternText; while ( i < size ) { if ( curState.currentPatternIdx != SYNTAX_TOKENIZER_STATE_NONE ) { @@ -248,8 +251,6 @@ _tokenize( const SyntaxDefinition& syntax, const std::string& text, const Syntax } bool matched = false; - std::string patternStr; - std::string patternText; for ( size_t patternIndex = 0; patternIndex < curState.currentSyntax->getPatterns().size(); patternIndex++ ) { diff --git a/src/tools/ecode/statusbuildoutputcontroller.cpp b/src/tools/ecode/statusbuildoutputcontroller.cpp index a98ecfe71..5325ee45e 100644 --- a/src/tools/ecode/statusbuildoutputcontroller.cpp +++ b/src/tools/ecode/statusbuildoutputcontroller.cpp @@ -171,7 +171,7 @@ void StatusBuildOutputController::runBuild( const std::string& buildName, auto configs = { outputParser.getPresetConfig(), outputParser.getConfig() }; for ( const auto& config : configs ) { for ( const auto& parser : config ) { - mPatternHolder.push_back( { LuaPattern( parser.pattern ), parser } ); + mPatternHolder.push_back( { LuaPatternStorage( parser.pattern ), parser } ); SyntaxPattern ptn( { parser.pattern }, getProjectOutputParserTypeToString( parser.type ) ); diff --git a/src/tools/ecode/statusbuildoutputcontroller.hpp b/src/tools/ecode/statusbuildoutputcontroller.hpp index 4f66689d7..5c9722d9e 100644 --- a/src/tools/ecode/statusbuildoutputcontroller.hpp +++ b/src/tools/ecode/statusbuildoutputcontroller.hpp @@ -30,7 +30,7 @@ struct StatusMessage { }; struct PatternHolder { - LuaPattern pattern; + LuaPatternStorage pattern; ProjectBuildOutputParserConfig config; };