From 1309bdddd1d6db4f4f61f3c1d458700484b684bc Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sat, 7 Dec 2024 09:40:17 +0100 Subject: [PATCH 1/4] [cleanup] Remove duplicate file from LibCxxParser --- CodeLite/cl_typedef.h | 67 ------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 CodeLite/cl_typedef.h diff --git a/CodeLite/cl_typedef.h b/CodeLite/cl_typedef.h deleted file mode 100644 index 29496e8a2c..0000000000 --- a/CodeLite/cl_typedef.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// Copyright : (C) 2015 Eran Ifrah -// File name : cl_typedef.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifndef TYPEDEF_H -#define TYPEDEF_H - -#include -#include "variable.h" - -#ifndef WXDLLIMPEXP_CL - -#ifdef WXMAKINGDLL_CL -# define WXDLLIMPEXP_CL __declspec(dllexport) -#elif defined(WXUSINGDLL_CL) -# define WXDLLIMPEXP_CL __declspec(dllimport) -#else // not making nor using DLL -# define WXDLLIMPEXP_CL -#endif - -#endif - - -class WXDLLIMPEXP_CL clTypedef -{ -public: - std::string m_name; - Variable m_realType; - -public: - clTypedef() {} - ~clTypedef() {} - - void print() { - printf("Name: %s\n", m_name.c_str()); - m_realType.Print(); - } - - void clear() { - m_realType.Reset(); - m_name.clear(); - } -}; - -typedef std::list clTypedefList; -#endif // TYPEDEF_H From 31d57bfeb7f5799d5ecec08f97c802e8947c8795 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sat, 7 Dec 2024 10:04:13 +0100 Subject: [PATCH 2/4] [cleanup] Remove always null parameter `additionlNS` of `Language::GetScopeName` --- CodeLite/ctags_manager.cpp | 19 +------------------ CodeLite/ctags_manager.h | 1 - CodeLite/language.cpp | 32 +------------------------------- CodeLite/language.h | 2 +- 4 files changed, 3 insertions(+), 51 deletions(-) diff --git a/CodeLite/ctags_manager.cpp b/CodeLite/ctags_manager.cpp index 6fba1296ed..e43e0ad5e0 100644 --- a/CodeLite/ctags_manager.cpp +++ b/CodeLite/ctags_manager.cpp @@ -348,7 +348,7 @@ void TagsManager::SetCtagsOptions(const TagsOptionsData& options) wxString TagsManager::GetScopeName(const wxString& scope) { Language* lang = GetLanguage(); - return lang->GetScopeName(scope, NULL); + return lang->GetScopeName(scope); } void TagsManager::GetFiles(const wxString& partialName, std::vector& files) @@ -774,23 +774,6 @@ bool TagsManager::IsBinaryFile(const wxString& filepath, const TagsOptionsData& return true; } -wxArrayString TagsManager::BreakToOuterScopes(const wxString& scope) -{ - wxArrayString outerScopes; - wxArrayString scopes = wxStringTokenize(scope, wxT(":"), wxTOKEN_STRTOK); - for(size_t i = 1; i < scopes.GetCount(); i++) { - wxString newScope; - for(size_t j = 0; j < i; j++) { - newScope << scopes.Item(j) << wxT("::"); - } - if(newScope.Len() >= 2) { - newScope.RemoveLast(2); - } - outerScopes.Add(newScope); - } - return outerScopes; -} - ITagsStoragePtr TagsManager::GetDatabase() { return m_db; } wxString TagsManager::DoReplaceMacrosFromDatabase(const wxString& name) diff --git a/CodeLite/ctags_manager.h b/CodeLite/ctags_manager.h index 82a06dab61..9a6f179e4f 100644 --- a/CodeLite/ctags_manager.h +++ b/CodeLite/ctags_manager.h @@ -405,7 +405,6 @@ class WXDLLIMPEXP_CL TagsManager : public wxEvtHandler protected: void DoFindByNameAndScope(const wxString& name, const wxString& scope, std::vector& tags); wxString DoReplaceMacros(const wxString& name); - wxArrayString BreakToOuterScopes(const wxString& scope); wxString DoReplaceMacrosFromDatabase(const wxString& name); void GetScopesByScopeName(const wxString& scopeName, wxArrayString& scopes); }; diff --git a/CodeLite/language.cpp b/CodeLite/language.cpp index ce8eae4b1c..d243b80376 100644 --- a/CodeLite/language.cpp +++ b/CodeLite/language.cpp @@ -143,7 +143,7 @@ void Language::ParseTemplateInitList(const wxString& argListStr, wxArrayString& typeName.Empty(); } -wxString Language::GetScopeName(const wxString& in, std::vector* additionlNS) +wxString Language::GetScopeName(const wxString& in) { std::vector moreNS; @@ -157,36 +157,6 @@ wxString Language::GetScopeName(const wxString& in, std::vector* addit if(scope.IsEmpty()) { scope = wxT(""); } - - if(additionlNS) { - for(size_t i = 0; i < moreNS.size(); i++) { - additionlNS->push_back(_U(moreNS.at(i).c_str())); - } - - // In case we are found some 'using namesapce XXX;' statement - // we should scan the following scopes: - // XXX - // and also: - // XXX::CurrentScope (assuming that CurrentScope != ) - if(scope != wxT("")) { - std::vector tmpScopes; - for(size_t i = 0; i < additionlNS->size(); i++) { - tmpScopes.push_back(additionlNS->at(i)); - tmpScopes.push_back(additionlNS->at(i) + wxT("::") + scope); - } - additionlNS->clear(); - additionlNS->insert(additionlNS->begin(), tmpScopes.begin(), tmpScopes.end()); - } - - wxArrayString moreScopes = GetTagsManager()->BreakToOuterScopes(scope); - for(size_t i = 0; i < moreScopes.GetCount(); i++) { - if(moreScopes.Item(i) != scope && - std::find(additionlNS->begin(), additionlNS->end(), moreScopes.Item(i)) == additionlNS->end()) { - additionlNS->push_back(moreScopes.Item(i)); - } - } - } - return scope; } diff --git a/CodeLite/language.h b/CodeLite/language.h index bf14fff136..d3845a5b4c 100644 --- a/CodeLite/language.h +++ b/CodeLite/language.h @@ -120,7 +120,7 @@ class WXDLLIMPEXP_CL Language * @param in input string * @return scope name or empty string */ - wxString GetScopeName(const wxString& in, std::vector* additionlNS); + wxString GetScopeName(const wxString& in); /** * Collect local variables from given scope text (in) and an optional symbol name From 51bfd4d6911c37e67bd92e474782a86993ad849c Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sat, 7 Dec 2024 10:05:32 +0100 Subject: [PATCH 3/4] [cleanup] Remove unused `#include "code_completion_api.h"` --- CodeLite/ctags_manager.cpp | 1 - CodeLite/database/entry.cpp | 1 - LiteEditor/code_completion_manager.cpp | 1 - LiteEditor/context_cpp.cpp | 1 - 4 files changed, 4 deletions(-) diff --git a/CodeLite/ctags_manager.cpp b/CodeLite/ctags_manager.cpp index e43e0ad5e0..7588bae65d 100644 --- a/CodeLite/ctags_manager.cpp +++ b/CodeLite/ctags_manager.cpp @@ -30,7 +30,6 @@ #include "Cxx/cpp_comment_creator.h" #include "StdToWX.h" #include "cl_command_event.h" -#include "code_completion_api.h" #include "codelite_events.h" #include "database/tags_storage_sqlite3.h" #include "event_notifier.h" diff --git a/CodeLite/database/entry.cpp b/CodeLite/database/entry.cpp index 47572aef51..1b5ed93694 100644 --- a/CodeLite/database/entry.cpp +++ b/CodeLite/database/entry.cpp @@ -28,7 +28,6 @@ #include "CompletionHelper.hpp" #include "Cxx/CxxScannerTokens.h" #include "Cxx/CxxTokenizer.h" -#include "code_completion_api.h" #include "ctags_manager.h" #include "language.h" #include "macros.h" diff --git a/LiteEditor/code_completion_manager.cpp b/LiteEditor/code_completion_manager.cpp index 3150295d7c..1718cc7af8 100644 --- a/LiteEditor/code_completion_manager.cpp +++ b/LiteEditor/code_completion_manager.cpp @@ -30,7 +30,6 @@ #include "bitmap_loader.h" #include "clangd/compilation_database.h" #include "cl_editor.h" -#include "code_completion_api.h" #include "compiler_command_line_parser.h" #include "ctags_manager.h" #include "database/entry.h" diff --git a/LiteEditor/context_cpp.cpp b/LiteEditor/context_cpp.cpp index f4c2251cce..d29d16ce1b 100644 --- a/LiteEditor/context_cpp.cpp +++ b/LiteEditor/context_cpp.cpp @@ -44,7 +44,6 @@ #include "cl_command_event.h" #include "cl_editor.h" #include "cl_editor_tip_window.h" -#include "code_completion_api.h" #include "code_completion_manager.h" #include "codelite_events.h" #include "commentconfigdata.h" From 1b7fdf393251719214d50c15f101aad1068c21bb Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sat, 7 Dec 2024 11:15:52 +0100 Subject: [PATCH 4/4] [cleanup] Remove fixed parameters of `Language::GetLocalVariables` --- CodeLite/Cxx/cpp_comment_creator.cpp | 2 +- CodeLite/language.cpp | 71 +----- CodeLite/language.h | 9 +- CodeLite/pptable.cpp | 310 --------------------------- CodeLite/pptable.h | 163 ++++++-------- 5 files changed, 67 insertions(+), 488 deletions(-) delete mode 100644 CodeLite/pptable.cpp diff --git a/CodeLite/Cxx/cpp_comment_creator.cpp b/CodeLite/Cxx/cpp_comment_creator.cpp index f05deb548b..05047e4558 100644 --- a/CodeLite/Cxx/cpp_comment_creator.cpp +++ b/CodeLite/Cxx/cpp_comment_creator.cpp @@ -58,7 +58,7 @@ wxString CppCommentCreator::FunctionComment() // parse the function signature Language* lang = LanguageST::Get(); - const std::vector tags = lang->GetLocalVariables(m_tag->GetSignature(), true); + const std::vector tags = lang->GetLocalVariables(m_tag->GetSignature()); comment << wxT("$(FunctionPattern)\n"); for(size_t i = 0; i < tags.size(); i++) diff --git a/CodeLite/language.cpp b/CodeLite/language.cpp index d243b80376..c2a6aca1db 100644 --- a/CodeLite/language.cpp +++ b/CodeLite/language.cpp @@ -206,46 +206,19 @@ bool Language::VariableFromPattern(const wxString& in, const wxString& name, Var bool Language::FunctionFromPattern(TagEntryPtr tag, clFunction& foo) { return false; } -std::vector Language::GetLocalVariables(const wxString& in, bool isFuncSignature, const wxString& name, - size_t flags) +std::vector Language::GetLocalVariables(const wxString& in) { wxString pattern(in); pattern = pattern.Trim().Trim(false); - if(flags & ReplaceTokens) { - // Apply ctags replcements table on the current input string - pattern = ApplyCtagsReplacementTokens(in); - } - CxxVariableScanner scanner(pattern, eCxxStandard::kCxx11, GetTagsManager()->GetCtagsOptions().GetTokensWxMap(), - isFuncSignature); + true); CxxVariable::Vec_t locals = scanner.GetVariables(false); std::vector tags; for(CxxVariable::Ptr_t local : locals) { const wxString& tagName = local->GetName(); - // if we have name, collect only tags that matches name - if(!name.IsEmpty()) { - // incase CaseSensitive is not required, make both string lower case - wxString tmpName(name); - wxString tmpTagName(tagName); - if(flags & IgnoreCaseSensitive) { - tmpName.MakeLower(); - tmpTagName.MakeLower(); - } - - if((flags & PartialMatch) && !tmpTagName.StartsWith(tmpName)) - continue; - // Don't suggest what we have typed so far - if((flags & PartialMatch) && tmpTagName == tmpName) - continue; - ; - if((flags & ExactMatch) && tmpTagName != tmpName) - continue; - ; - } // else no name is specified, collect all tags - TagEntryPtr tag(new TagEntry()); tag->SetName(tagName); tag->SetKind(wxT("variable")); @@ -379,46 +352,6 @@ Language* LanguageST::Get() return gs_Language; } -wxString Language::ApplyCtagsReplacementTokens(const wxString& in) -{ - // First, get the replacement map - CLReplacementList replacements; - const wxStringTable_t& replacementMap = GetTagsManager()->GetCtagsOptions().GetTokensWxMap(); - wxStringTable_t::const_iterator iter = replacementMap.begin(); - for(; iter != replacementMap.end(); ++iter) { - - if(iter->second.IsEmpty()) - continue; - - wxString pattern = iter->first; - wxString replace = iter->second; - pattern.Trim().Trim(false); - replace.Trim().Trim(false); - CLReplacement repl; - repl.construct(pattern.To8BitData().data(), replace.To8BitData().data()); - if(repl.is_ok) { - replacements.push_back(repl); - } - } - - if(replacements.empty()) - return in; - - // Now, apply the replacements - wxString outputStr; - wxArrayString lines = ::wxStringTokenize(in, wxT("\r\n"), wxTOKEN_STRTOK); - for(size_t i = 0; i < lines.GetCount(); i++) { - std::string outStr = lines.Item(i).mb_str(wxConvUTF8).data(); - CLReplacementList::iterator iter = replacements.begin(); - for(; iter != replacements.end(); iter++) { - ::CLReplacePatternA(outStr, *iter, outStr); - } - - outputStr << wxString(outStr.c_str(), wxConvUTF8) << wxT("\n"); - } - return outputStr; -} - int Language::DoReadClassName(CppScanner& scanner, wxString& clsname) const { clsname.clear(); diff --git a/CodeLite/language.h b/CodeLite/language.h index d3845a5b4c..18f4d3daed 100644 --- a/CodeLite/language.h +++ b/CodeLite/language.h @@ -29,7 +29,6 @@ #include "Cxx/cpp_scanner.h" #include "codelite_exports.h" #include "database/entry.h" -#include "expression_result.h" #include "function.h" #include "macros.h" #include "variable.h" @@ -123,16 +122,12 @@ class WXDLLIMPEXP_CL Language wxString GetScopeName(const wxString& in); /** - * Collect local variables from given scope text (in) and an optional symbol name + * Collect local variables from given scope text (in (a function signature)) * @param in scope to search for - * @param name optional name to look for (name can be partial). * @return since we dont have full information about each token, * all local variables returned are of type 'variable' with public access */ - std::vector GetLocalVariables(const wxString& in, bool isFuncSignature, - const wxString& name = wxEmptyString, size_t flag = PartialMatch); - - wxString ApplyCtagsReplacementTokens(const wxString& in); + std::vector GetLocalVariables(const wxString& in); bool VariableFromPattern(const wxString& pattern, const wxString& name, Variable& var); bool FunctionFromPattern(TagEntryPtr tag, clFunction& foo); diff --git a/CodeLite/pptable.cpp b/CodeLite/pptable.cpp deleted file mode 100644 index 3eec897497..0000000000 --- a/CodeLite/pptable.cpp +++ /dev/null @@ -1,310 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : pptable.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#include "pptable.h" - -#include "Cxx/CxxLexerAPI.h" -#include "Cxx/CxxScannerTokens.h" - -#include -#include -#include - -bool IsWordCharA(char c, int strSize) -{ - if(strSize) { - return ((c >= 97 && c <= 122) || // a-z - (c >= 65 && c <= 90) || // A-Z - (c >= 48 && c <= 57) || // 0-9 - (c == '_')); - - } else { - return ((c >= 97 && c <= 122) || // a-z - (c >= 65 && c <= 90) || // A-Z - (c == '_')); - } -} - -std::string ReplaceWordA(const std::string& str, const std::string& word, const std::string& replaceWith) -{ - char currChar; - char nextChar; - std::string currentWord; - std::string output; - - output.reserve(str.length() * 2); - - for(size_t i = 0; i < str.length(); i++) { - // Look ahead - if(str.length() > i + 1) { - nextChar = str[i + 1]; - } else { - // we are at the end of buffer - nextChar = '\0'; - } - - currChar = str[i]; - if(!IsWordCharA(currChar, currentWord.length())) { - output += str[i]; - currentWord.clear(); - - } else { - - currentWord += currChar; - if(IsWordCharA(nextChar, currentWord.length())) { - // do nothing - - } else if(!IsWordCharA(nextChar, currentWord.length()) && currentWord == word) { - output += replaceWith; - currentWord.clear(); - - } else { - output += currentWord; - currentWord.clear(); - } - } - } - return output; -} - -void PPToken::print(wxFFile& fp) -{ - wxString buff; - buff << name << wxT("(") << (flags & IsFunctionLike) << wxT(")") << wxT("=") << replacement << wxT("\n"); - fp.Write(buff); -} - -bool -PPToken::readInitList(const std::string& in, size_t from, std::string& initList, std::vector& initListArr) -{ - if(in.length() < from) { - return false; - } - - std::string tmpString = in.substr(from); - size_t start = tmpString.find('('); - if(start == std::string::npos) { - return false; - } - - // skip the open brace - tmpString = tmpString.substr(start + 1); - - for(size_t i = 0; i < start; i++) { - initList += " "; - } - - initList += "("; - std::string word; - int depth(1); - - for(size_t i = 0; i < tmpString.length(); i++) { - char ch = tmpString[i]; - initList += ch; - switch(ch) { - case ')': - depth--; - if(depth == 0) { - initListArr.push_back(word); - return true; - } else { - word += ch; - } - break; - case '(': - depth++; - word += ch; - break; - case ',': - if(depth == 1) { - initListArr.push_back(word); - word.clear(); - } else { - word += ch; - } - break; - default: - word += ch; - break; - } - } - return false; -} - -bool PPToken::readInitList(const wxString& in, int from, wxString& initList, wxArrayString& initListArr) -{ - // sanity - if(in.length() > 100) return false; - - if((int)in.Length() < from) { - return false; - } - - wxString tmpString = in.Mid(from); - int start = tmpString.Find(wxT("(")); - if(start == wxNOT_FOUND) { - return false; - } - tmpString = tmpString.Mid(start + 1); - - for(size_t i = 0; i < (size_t)start; i++) { - initList << wxT(" "); - } - - initList << wxT("("); - wxString word; - int depth(1); - - for(size_t i = 0; i < tmpString.Length(); i++) { - wxChar ch = tmpString[i]; - initList << ch; - switch(ch) { - case wxT(')'): - depth--; - if(depth == 0) { - initListArr.Add(word); - return true; - } else { - word << ch; - } - break; - case wxT('('): - depth++; - word << ch; - break; - case wxT(','): - if(depth == 1) { - initListArr.Add(word); - word.Clear(); - } else { - word << ch; - } - break; - default: - word << ch; - break; - } - } - return false; -} - -void PPToken::expandOnce(const wxArrayString& initList) -{ - if(initList.size() != args.size()) return; - - for(size_t i = 0; i < args.size(); i++) { - wxString placeHolder; - placeHolder << wxT("%") << i; - - wxString replaceWith = initList.Item(i); - replaceWith.Trim().Trim(false); - - if(replaceWith.Contains(placeHolder)) continue; - - replacement.Replace(placeHolder, initList.Item(i)); - } -} - -/////////////////////////////////////////////////// -std::string replacement; - -bool CLReplacePatternA(const std::string& in, const CLReplacement& repl, std::string& outStr) -{ - if(repl.is_compound) { - size_t where = in.find(repl.searchFor); - if(where == std::string::npos) return false; - - std::string initList; - std::vector initListArr; - if(PPToken::readInitList(in, repl.searchFor.length() + where, initList, initListArr) == false) return false; - - // update the 'replacement' with the actual values ( replace %0..%n) - replacement = repl.replaceWith; - char placeHolder[4]; - for(size_t i = 0; i < initListArr.size(); i++) { - - memset(placeHolder, 0, sizeof(placeHolder)); - sprintf(placeHolder, "%%%d", (int)i); - - size_t pos = replacement.find(placeHolder); - const std::string& init = initListArr[i]; - while(pos != std::string::npos) { - replacement.replace(pos, strlen(placeHolder), init.c_str()); - - // search for the next match - pos = replacement.find(placeHolder, pos + 1); - } - } - - outStr = in; - where = outStr.find(repl.searchFor); - if(where == std::string::npos) return false; - - outStr.replace(where, repl.searchFor.length() + initList.length(), replacement); - return true; - - } else { - - size_t where = in.find(repl.searchFor); - if(where == std::string::npos) { - return false; - } - - outStr = ReplaceWordA(in, repl.searchFor, repl.replaceWith); - - // outStr = in; - // outStr.replace(where, repl.searchFor.length(), repl.replaceWith); - - // simple replacement - return outStr != in; - } -} - -void CLReplacement::construct(const std::string& pattern, const std::string& replacement) -{ - is_ok = true; - full_pattern = pattern; - is_compound = full_pattern.find("%0") != std::string::npos; - if(is_compound) { - // a patterened expression - replaceWith = replacement; - size_t where = pattern.find('('); - if(where == std::string::npos) { - is_ok = false; - return; - } - - searchFor = pattern.substr(0, where); - if(searchFor.empty()) { - is_ok = false; - return; - } - - } else { - // simple Key=Value pair - replaceWith = replacement; - searchFor = full_pattern; - } -} diff --git a/CodeLite/pptable.h b/CodeLite/pptable.h index 0cf4a01e9f..eaebed4eae 100644 --- a/CodeLite/pptable.h +++ b/CodeLite/pptable.h @@ -1,101 +1,62 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : pptable.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifndef PPTABLE_H -#define PPTABLE_H - -#include -#include -#include -#include -#include -#include -#include - -#ifndef WXDLLIMPEXP_CL - -#ifdef WXMAKINGDLL_CL -#define WXDLLIMPEXP_CL __declspec(dllexport) -#elif defined(WXUSINGDLL_CL) -#define WXDLLIMPEXP_CL __declspec(dllimport) -#else // not making nor using DLL -#define WXDLLIMPEXP_CL -#endif - -#endif - -struct WXDLLIMPEXP_CL CLReplacement { - bool is_compound; - bool is_ok; - std::string full_pattern; - std::string searchFor; - std::string replaceWith; - void construct(const std::string& pattern, const std::string& replacement); -}; - -typedef std::list CLReplacementList; - -/** - * @brief perform search and replace using CL pattern - * an example: - * pattern=wx_dynamic_cast(%0, %1) - * replacement=dynamic_cast<%0>(%1) - * in=wx_dynamic_cast(wxApp*, ptr)->OnInit(); - * - * the expected result is: - * dynamic_cast(ptr)->OnInit() - * - * It also supports simple search and replace - */ -bool CLReplacePatternA(const std::string& in, const CLReplacement& repl, std::string& outStr); - -/** - * - */ -struct WXDLLIMPEXP_CL PPToken { - enum { IsFunctionLike = 0x00000001, IsValid = 0x00000002, IsOverridable = 0x00000004 }; - - int line; // line where found - wxString name; // preprocessor name - wxString replacement; // un processed replacement - wxArrayString args; // for function like macros, contains the argument's names - size_t flags; // PP token flags - wxString fileName; - - PPToken() - : line(0) - , flags(IsOverridable) - { - } - - ~PPToken() {} - - void expandOnce(const wxArrayString& initList); - void print(wxFFile& fp); - static bool readInitList(const wxString& in, int from, wxString& initList, wxArrayString& initListArr); - static bool - readInitList(const std::string& in, size_t from, std::string& initList, std::vector& initListArr); -}; -#endif // PPTABLE_H +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2014 Eran Ifrah +// file name : pptable.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +#ifndef PPTABLE_H +#define PPTABLE_H + +#include + +#ifndef WXDLLIMPEXP_CL + +#ifdef WXMAKINGDLL_CL +#define WXDLLIMPEXP_CL __declspec(dllexport) +#elif defined(WXUSINGDLL_CL) +#define WXDLLIMPEXP_CL __declspec(dllimport) +#else // not making nor using DLL +#define WXDLLIMPEXP_CL +#endif + +#endif + +/** + * + */ +struct WXDLLIMPEXP_CL PPToken { + enum { IsFunctionLike = 0x00000001, IsValid = 0x00000002, IsOverridable = 0x00000004 }; + + int line; // line where found + wxString name; // preprocessor name + wxString replacement; // un processed replacement + wxArrayString args; // for function like macros, contains the argument's names + size_t flags; // PP token flags + wxString fileName; + + PPToken() + : line(0) + , flags(IsOverridable) + { + } +}; +#endif // PPTABLE_H