diff --git a/CMakePlugin/CMake.cpp b/CMakePlugin/CMake.cpp index ff91569190..4d6b0b4b74 100644 --- a/CMakePlugin/CMake.cpp +++ b/CMakePlugin/CMake.cpp @@ -111,7 +111,7 @@ CMake::CMake(const wxFileName& path) PrepareDatabase(); // Register the CMake builder - BuildManagerST::Get()->AddBuilder(new CMakeBuilder()); + BuildManagerST::Get()->AddBuilder(std::make_shared()); } /* ************************************************************************ */ diff --git a/CodeLite/CodeLite.project b/CodeLite/CodeLite.project index 1baff34f5b..9c106ae8ff 100644 --- a/CodeLite/CodeLite.project +++ b/CodeLite/CodeLite.project @@ -277,7 +277,6 @@ - diff --git a/CodeLite/CompletionHelper.cpp b/CodeLite/CompletionHelper.cpp index 702e92b4fc..a31ff1e86a 100644 --- a/CodeLite/CompletionHelper.cpp +++ b/CodeLite/CompletionHelper.cpp @@ -807,7 +807,7 @@ thread_local wxRegEx reFN("([@\\\\]{1}fn)[ \t]*", wxRE_DEFAULT | wxRE_ICASE); wxString CompletionHelper::format_comment(TagEntryPtr tag, const wxString& input_comment) const { - return format_comment(tag.Get(), input_comment); + return format_comment(tag.get(), input_comment); } wxString CompletionHelper::format_comment(TagEntry* tag, const wxString& input_comment) const @@ -983,7 +983,7 @@ wxString CompletionHelper::normalize_function(const TagEntry* tag, size_t flags) wxString CompletionHelper::normalize_function(TagEntryPtr tag, size_t flags) { - return normalize_function(tag.Get(), flags); + return normalize_function(tag.get(), flags); } void CompletionHelper::get_cxx_keywords(std::vector& keywords) diff --git a/CodeLite/CxxCodeCompletion.cpp b/CodeLite/CxxCodeCompletion.cpp index 41875ca89e..075e041eb3 100644 --- a/CodeLite/CxxCodeCompletion.cpp +++ b/CodeLite/CxxCodeCompletion.cpp @@ -896,8 +896,8 @@ void CxxCodeCompletion::reset() m_template_manager->clear(); m_file_only_tags.clear(); m_recurse_protector = 0; - m_current_function_tag.Reset(nullptr); - m_current_container_tag.Reset(nullptr); + m_current_function_tag = nullptr; + m_current_container_tag = nullptr; } namespace diff --git a/CodeLite/CxxCodeCompletion.hpp b/CodeLite/CxxCodeCompletion.hpp index 1c7624f63b..999add4622 100644 --- a/CodeLite/CxxCodeCompletion.hpp +++ b/CodeLite/CxxCodeCompletion.hpp @@ -252,7 +252,7 @@ class WXDLLIMPEXP_CL CxxCodeCompletion TagEntryPtr find_scope_tag(CxxExpression& curexp, const std::vector& visible_scopes); bool is_scope_tag(CxxExpression& curexp, const std::vector& visible_scopes) { - return find_scope_tag(curexp, visible_scopes); + return find_scope_tag(curexp, visible_scopes) != nullptr; } TagEntryPtr find_scope_tag_externvar(CxxExpression& curexp, const std::vector& visible_scopes); TagEntryPtr on_extern_var(CxxExpression& curexp, TagEntryPtr var, const std::vector& visible_scopes); diff --git a/CodeLite/CxxVariable.h b/CodeLite/CxxVariable.h index 1ed4608307..ed465af85e 100644 --- a/CodeLite/CxxVariable.h +++ b/CodeLite/CxxVariable.h @@ -4,9 +4,9 @@ #include "CxxLexerAPI.h" #include "codelite_exports.h" #include "macros.h" -#include "smart_ptr.h" #include +#include #include #include #include @@ -65,9 +65,9 @@ class WXDLLIMPEXP_CL CxxVariable int m_lineNumber = wxNOT_FOUND; public: - typedef SmartPtr Ptr_t; - typedef std::vector Vec_t; - typedef std::unordered_map Map_t; + using Ptr_t = std::shared_ptr; + using Vec_t = std::vector; + using Map_t = std::unordered_map; public: CxxVariable(eCxxStandard standard); diff --git a/CodeLite/PHPDocVar.h b/CodeLite/PHPDocVar.h index 571ee5f033..f97e9f1126 100644 --- a/CodeLite/PHPDocVar.h +++ b/CodeLite/PHPDocVar.h @@ -1,13 +1,14 @@ #ifndef PHPDOCVAR_H #define PHPDOCVAR_H -#include "codelite_exports.h" -#include #include "PHPSourceFile.h" -#include "smart_ptr.h" +#include "codelite_exports.h" + #include #include -#include "wx/wxsqlite3.h" +#include +#include +#include class WXDLLIMPEXP_CL PHPDocVar { @@ -23,9 +24,9 @@ class WXDLLIMPEXP_CL PHPDocVar void Parse(PHPSourceFile& sourceFile, const wxString& doc); public: - typedef SmartPtr Ptr_t; - typedef std::list List_t; - typedef std::map Map_t; + using Ptr_t = std::shared_ptr; + using List_t = std::list; + using Map_t = std::map; public: PHPDocVar(PHPSourceFile& sourceFile, const wxString& doc); diff --git a/CodeLite/PHPDocVisitor.cpp b/CodeLite/PHPDocVisitor.cpp index d47fe7f462..5d716832be 100644 --- a/CodeLite/PHPDocVisitor.cpp +++ b/CodeLite/PHPDocVisitor.cpp @@ -32,7 +32,7 @@ void PHPDocVisitor::OnEntity(PHPEntityBase::Ptr_t entity) PHPEntityBase::Ptr_t child = entity->FindChild(p.second.name); if(!child) { // No child of this type, create a new property and add it - child.Reset(new PHPEntityVariable()); + child = std::make_shared(); child->SetFilename(m_sourceFile.GetFilename()); child->SetLine(entity->GetLine()); child->Cast()->SetTypeHint(p.second.type); diff --git a/CodeLite/PHPEntityBase.h b/CodeLite/PHPEntityBase.h index 976c0b1b35..b2affcde3a 100644 --- a/CodeLite/PHPEntityBase.h +++ b/CodeLite/PHPEntityBase.h @@ -26,20 +26,21 @@ #ifndef PHPENTITYIMPL_H #define PHPENTITYIMPL_H +#include "JSON.h" #include "codelite_exports.h" -#include +#include "commentconfigdata.h" +#include "wxStringHash.h" + +#include #include #include -#include -#include +#include +#include #include -#include "wx/wxsqlite3.h" +#include +#include #include // Needed for wxPrintf -#include "smart_ptr.h" -#include -#include "commentconfigdata.h" -#include "wxStringHash.h" -#include "JSON.h" +#include // The entity type class WXDLLIMPEXP_CL PHPLookupTable; @@ -88,9 +89,9 @@ enum { class WXDLLIMPEXP_CL PHPEntityBase { public: - typedef SmartPtr Ptr_t; - typedef std::vector List_t; - typedef std::unordered_map Map_t; + using Ptr_t = std::shared_ptr; + using List_t = std::vector; + using Map_t = std::unordered_map; protected: PHPEntityBase::Map_t m_childrenMap; diff --git a/CodeLite/PHPEntityFunctionAlias.cpp b/CodeLite/PHPEntityFunctionAlias.cpp index 73361f81e4..382568d82c 100644 --- a/CodeLite/PHPEntityFunctionAlias.cpp +++ b/CodeLite/PHPEntityFunctionAlias.cpp @@ -70,7 +70,7 @@ void PHPEntityFunctionAlias::FromJSON(const JSONItem& json) m_scope = json.namedObject("scope").toString(); if(json.hasNamedObject("func")) { JSONItem func = json.namedObject("func"); - m_func.Reset(new PHPEntityFunction()); + m_func = std::make_shared(); m_func->FromJSON(func); } } diff --git a/CodeLite/PHPLookupTable.cpp b/CodeLite/PHPLookupTable.cpp index 835769f5b0..5384d069eb 100644 --- a/CodeLite/PHPLookupTable.cpp +++ b/CodeLite/PHPLookupTable.cpp @@ -521,7 +521,6 @@ void PHPLookupTable::DoGetInheritanceParentIDs(PHPEntityBase::Ptr_t cls, std::ve if(parent && !parentsVisited.count(parent->GetDbId())) { DoGetInheritanceParentIDs(parent, parents, parentsVisited, false); } - parent.Reset(nullptr); } } @@ -552,10 +551,10 @@ PHPEntityBase::Ptr_t PHPLookupTable::DoFindScope(const wxString& fullname, ePhpS int scopeType = res.GetInt("SCOPE_TYPE", 1); if(scopeType == 0) { // namespace - match.Reset(new PHPEntityNamespace()); + match = std::make_shared(); } else { // class - match.Reset(new PHPEntityClass()); + match = std::make_shared(); } match->FromResultSet(res); } @@ -594,10 +593,10 @@ PHPEntityBase::Ptr_t PHPLookupTable::DoFindScope(wxLongLong id, ePhpScopeType sc int scopeType = res.GetInt("SCOPE_TYPE", 1); if(scopeType == kPhpScopeTypeNamespace) { // namespace - match.Reset(new PHPEntityNamespace()); + match = std::make_shared(); } else { // class - match.Reset(new PHPEntityClass()); + match = std::make_shared(); } match->FromResultSet(res); return match; @@ -1060,7 +1059,7 @@ PHPEntityBase::Ptr_t PHPLookupTable::FindFunction(const wxString& fullname) return PHPEntityBase::Ptr_t(NULL); } - match.Reset(new PHPEntityFunction()); + match = std::make_shared(); match->FromResultSet(res); } return match; @@ -1093,7 +1092,7 @@ PHPEntityBase::Ptr_t PHPLookupTable::CreateNamespaceForDefine(PHPEntityBase::Ptr PHPEntityBase::Ptr_t pNamespace = DoFindScope(nameSpaceName, kPhpScopeTypeNamespace); if(!pNamespace) { // Create it - pNamespace.Reset(new PHPEntityNamespace()); + pNamespace = std::make_shared(); pNamespace->SetFullName(nameSpaceName); pNamespace->SetShortName(nameSpaceName.AfterLast('\\')); pNamespace->SetFilename(define->GetFilename()); @@ -1384,7 +1383,7 @@ PHPEntityBase::Ptr_t PHPLookupTable::FindFunctionNearLine(const wxFileName& file PHPEntityBase::Ptr_t match(NULL); if(res.NextRow()) { - match.Reset(new PHPEntityFunction()); + match = std::make_shared(); match->FromResultSet(res); } return match; diff --git a/CodeLite/PHPLookupTable.h b/CodeLite/PHPLookupTable.h index 9c4bf84d01..9495e89935 100644 --- a/CodeLite/PHPLookupTable.h +++ b/CodeLite/PHPLookupTable.h @@ -34,8 +34,6 @@ #include "file_logger.h" #include "fileextmanager.h" #include "fileutils.h" -#include "smart_ptr.h" -#include "wx/wxsqlite3.h" #include #include @@ -43,6 +41,7 @@ #include #include #include +#include #include wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxPHP_PARSE_STARTED, clParseEvent); @@ -89,7 +88,7 @@ class WXDLLIMPEXP_CL PHPLookupTable kUpdateMode_Fast, kUpdateMode_Full, }; - typedef SmartPtr Ptr_t; + static void DoSplitFullname(const wxString& fullname, wxString& ns, wxString& shortName); private: diff --git a/CodeLite/PHPSourceFile.cpp b/CodeLite/PHPSourceFile.cpp index 17333e02e1..f16091c440 100644 --- a/CodeLite/PHPSourceFile.cpp +++ b/CodeLite/PHPSourceFile.cpp @@ -938,7 +938,7 @@ void PHPSourceFile::UngetToken(const phpLexerToken& token) const PHPEntityBase* PHPSourceFile::Class() { PHPEntityBase::Ptr_t curScope = CurrentScope(); - PHPEntityBase* pScope = curScope.Get(); + PHPEntityBase* pScope = curScope.get(); while(pScope) { PHPEntityClass* cls = pScope->Cast(); if(cls) { @@ -1407,11 +1407,11 @@ void PHPSourceFile::OnConstant(const phpLexerToken& tok) } else if(token.type == ',') { if(member) { CurrentScope()->AddChild(member); - member.Reset(NULL); + member = nullptr; } } else if(token.type == kPHP_T_IDENTIFIER) { // found the constant name - member.Reset(new PHPEntityVariable()); + member = std::make_shared(); member->Cast()->SetFlag(kVar_Const); member->Cast()->SetFlag(kVar_Member); member->SetFullName(token.Text()); diff --git a/CodeLite/cl_calltip.h b/CodeLite/cl_calltip.h index c569056d1d..a66313456e 100644 --- a/CodeLite/cl_calltip.h +++ b/CodeLite/cl_calltip.h @@ -27,9 +27,10 @@ #include "codelite_exports.h" #include "entry.h" -#include "smart_ptr.h" #include "tokenizer.h" +#include + struct clTipInfo { wxString str; std::vector> paramLen; @@ -144,5 +145,5 @@ class WXDLLIMPEXP_CL clCallTip wxString TipAt(int at); }; -typedef SmartPtr clCallTipPtr; +using clCallTipPtr = std::shared_ptr; #endif // CODELITE_CALLTIP_H diff --git a/CodeLite/comment.h b/CodeLite/comment.h index 8e71a5943d..e9ec002470 100644 --- a/CodeLite/comment.h +++ b/CodeLite/comment.h @@ -25,8 +25,8 @@ #ifndef CODELITE_COMMENT_H #define CODELITE_COMMENT_H +#include #include -#include "smart_ptr.h" class Comment { @@ -82,6 +82,6 @@ class Comment } }; -typedef SmartPtr CommentPtr; +using CommentPtr = std::unique_ptr; #endif // CODELITE_COMMENT_H diff --git a/CodeLite/comment_parser.h b/CodeLite/comment_parser.h index 068dd12a2b..c4656bbd7c 100644 --- a/CodeLite/comment_parser.h +++ b/CodeLite/comment_parser.h @@ -26,19 +26,17 @@ #ifndef COMMENT_PARSER_H #define COMMENT_PARSER_H +#include "codelite_exports.h" + #include #include -#include "codelite_exports.h" -#include "smart_ptr.h" class WXDLLIMPEXP_CL CommentParseResult { private: std::map m_comments; std::string m_filename; -public: - typedef SmartPtr Ptr_t; - + public: void addComment(const std::string& comment, size_t line, bool cppComment) { diff --git a/CodeLite/cpp_scanner.h b/CodeLite/cpp_scanner.h index 4ad2e4040f..cbcd435820 100644 --- a/CodeLite/cpp_scanner.h +++ b/CodeLite/cpp_scanner.h @@ -26,8 +26,9 @@ #define CODELITE_CPPSCANNER_H #include "FlexLexer.h" -#include "smart_ptr.h" -#include "codelite_exports.h" +#include "codelite_exports.h" + +#include class WXDLLIMPEXP_CL CppScanner : public flex::yyFlexLexer { @@ -61,5 +62,5 @@ class WXDLLIMPEXP_CL CppScanner : public flex::yyFlexLexer int m_curr; }; -typedef SmartPtr CppScannerPtr; +using CppScannerPtr = std::unique_ptr; #endif // CODELITE_CPPSCANNER_H diff --git a/CodeLite/cppwordscanner.h b/CodeLite/cppwordscanner.h index 72f4c09e8f..2127036c96 100644 --- a/CodeLite/cppwordscanner.h +++ b/CodeLite/cppwordscanner.h @@ -25,15 +25,16 @@ #ifndef __cppwordscanner__ #define __cppwordscanner__ -#include -#include -#include "cpptoken.h" -#include "smart_ptr.h" #include "codelite_exports.h" -#include +#include "cpptoken.h" #include "macros.h" #include "wxStringHash.h" +#include +#include +#include +#include + struct ByteState { short state; // Holds the current byte state (one of CppWordScanner::STATE_*) short depth; // The current char depth @@ -83,7 +84,7 @@ class WXDLLIMPEXP_CL TextStates int LineToPos(int lineNo); }; -typedef SmartPtr TextStatesPtr; +using TextStatesPtr = std::shared_ptr; class WXDLLIMPEXP_CL CppWordScanner { diff --git a/CodeLite/ctags_manager.cpp b/CodeLite/ctags_manager.cpp index 30b23f383a..db9ae407e6 100644 --- a/CodeLite/ctags_manager.cpp +++ b/CodeLite/ctags_manager.cpp @@ -128,7 +128,7 @@ TagsManager::TagsManager() , m_evtHandler(NULL) , m_encoding(wxFONTENCODING_DEFAULT) { - m_db = new TagsStorageSQLite(); + m_db = std::make_shared(); m_db->SetSingleSearchLimit(MAX_SEARCH_LIMIT); // CPP keywords that are usually followed by open brace '(' @@ -180,7 +180,7 @@ TagTreePtr TagsManager::Load(const wxFileName& fileName, TagEntryPtrVector_t* ta // Load the records and build a language tree TagEntry root; root.SetName(wxT("")); - tree.Reset(new TagTree(wxT(""), root)); + tree = std::make_shared(wxT(""), root); for(size_t i = 0; i < tagsByFile.size(); i++) { tree->AddEntry(*(tagsByFile.at(i))); } @@ -923,8 +923,8 @@ void TagsManager::GetFunctionTipFromTags(const std::vector& tags, c void TagsManager::CloseDatabase() { m_dbFile.Clear(); - m_db = NULL; // Free the current database - m_db = new TagsStorageSQLite(); + m_db = nullptr; // Free the current database + m_db = std::make_shared(); m_db->SetSingleSearchLimit(m_tagsOptions.GetCcNumberOfDisplayItems()); m_db->SetUseCache(false); } @@ -1570,7 +1570,7 @@ void TagsManager::FilterNonNeededFilesForRetaging(wxArrayString& strFiles, ITags } for(size_t i = 0; i < files_entries.size(); i++) { - FileEntryPtr fe = files_entries.at(i); + const FileEntryPtr& fe = files_entries.at(i); // does the file exist in both lists? std::unordered_set::iterator iter = files_set.find(fe->GetFile()); diff --git a/CodeLite/entry.h b/CodeLite/entry.h index c5e7cad576..8a7126165a 100644 --- a/CodeLite/entry.h +++ b/CodeLite/entry.h @@ -31,15 +31,15 @@ #include "codelite_exports.h" #include "macros.h" -#include "smart_ptr.h" #include +#include #include #include class TagEntry; -typedef SmartPtr TagEntryPtr; -typedef std::vector TagEntryPtrVector_t; +using TagEntryPtr = std::shared_ptr; +using TagEntryPtrVector_t = std::vector; #define KIND_CLASS "class" #define KIND_ENUM "enum" diff --git a/CodeLite/fileentry.h b/CodeLite/fileentry.h index 7f7eca91d6..2a50cc1605 100644 --- a/CodeLite/fileentry.h +++ b/CodeLite/fileentry.h @@ -26,8 +26,9 @@ #ifndef __fileentry__ #define __fileentry__ +#include #include -#include "smart_ptr.h" + class FileEntry { long m_id; @@ -58,6 +59,6 @@ class FileEntry return m_id; } }; -typedef SmartPtr FileEntryPtr; +using FileEntryPtr = std::unique_ptr; #endif // __fileentry__ diff --git a/CodeLite/fileextmanager.cpp b/CodeLite/fileextmanager.cpp index 35eac9626e..c5ca2ac43d 100644 --- a/CodeLite/fileextmanager.cpp +++ b/CodeLite/fileextmanager.cpp @@ -29,6 +29,7 @@ #include "file_logger.h" #include "fileutils.h" +#include #include #include #include @@ -36,7 +37,7 @@ #include struct Matcher { - SmartPtr m_regex; + std::unique_ptr m_regex; wxString m_exactMatch; FileExtManager::FileType m_fileType; @@ -44,7 +45,7 @@ struct Matcher { : m_fileType(fileType) { if(regex) { - m_regex = new wxRegEx(pattern, wxRE_ADVANCED | wxRE_ICASE); + m_regex = std::make_unique(pattern, wxRE_ADVANCED | wxRE_ICASE); } else { m_exactMatch = pattern; } @@ -53,7 +54,7 @@ struct Matcher { bool Matches(const wxString& in) const { auto lines = ::wxStringTokenize(in, "\r\n", wxTOKEN_STRTOK); - bool use_regex = m_regex; + bool use_regex = static_cast(m_regex); for(const auto& line : lines) { if(use_regex && m_regex->Matches(line)) { return true; diff --git a/CodeLite/fileextmanager.h b/CodeLite/fileextmanager.h index 0ba8df6abb..d28429c140 100644 --- a/CodeLite/fileextmanager.h +++ b/CodeLite/fileextmanager.h @@ -27,7 +27,6 @@ #define __FILEEXTMANAGER__ #include "codelite_exports.h" -#include "smart_ptr.h" #include "wxStringHash.h" #include diff --git a/CodeLite/istorage.h b/CodeLite/istorage.h index 4c2e3ae84f..962116b355 100644 --- a/CodeLite/istorage.h +++ b/CodeLite/istorage.h @@ -31,6 +31,8 @@ #include "fileentry.h" #include "pptable.h" #include "tag_tree.h" + +#include #include #define MAX_SEARCH_LIMIT 250 @@ -547,6 +549,6 @@ class ITagsStorage enum { TagOk = 0, TagExist, TagError }; -typedef SmartPtr ITagsStoragePtr; +using ITagsStoragePtr = std::shared_ptr; #endif // ISTORAGE_H diff --git a/CodeLite/language.cpp b/CodeLite/language.cpp index 1db8c710b7..44893f1f22 100644 --- a/CodeLite/language.cpp +++ b/CodeLite/language.cpp @@ -807,7 +807,7 @@ void Language::ParseComments(const wxFileName& fileName, std::vector // save the previous comment buffer if(comment.IsEmpty() == false) { - comments->push_back(new Comment(comment, fileName.GetFullPath(), line - 1)); + comments->push_back(std::make_unique(comment, fileName.GetFullPath(), line - 1)); comment.Empty(); line = -1; } @@ -820,19 +820,19 @@ void Language::ParseComments(const wxFileName& fileName, std::vector continue; } - comments->push_back(new Comment(m_scanner->GetComment(), fileName.GetFullPath(), m_scanner->lineno() - 1)); + comments->push_back(std::make_unique(m_scanner->GetComment(), fileName.GetFullPath(), m_scanner->lineno() - 1)); comment.Empty(); line = -1; m_scanner->ClearComment(); } else if(type == CComment) { - comments->push_back(new Comment(m_scanner->GetComment(), fileName.GetFullPath(), m_scanner->lineno())); + comments->push_back(std::make_unique(m_scanner->GetComment(), fileName.GetFullPath(), m_scanner->lineno())); m_scanner->ClearComment(); } } if(comment.IsEmpty() == false) { - comments->push_back(new Comment(comment, fileName.GetFullPath(), line - 1)); + comments->push_back(std::make_unique(comment, fileName.GetFullPath(), line - 1)); } // reset the scanner diff --git a/CodeLite/smart_ptr.h b/CodeLite/smart_ptr.h deleted file mode 100644 index 6050a8b709..0000000000 --- a/CodeLite/smart_ptr.h +++ /dev/null @@ -1,221 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : smart_ptr.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 CODELITE_SMART_PTR_H -#define CODELITE_SMART_PTR_H -#include -/** - * A smart pointer class that provides a reference counting and auto delete memory. - * - * This class is similar to std::auto_ptr, with 2 exceptions: - * - This class uses reference counting - * - We dont provide a release() function (because of the reference counting) - * It is recommended to use this class instead of using raw pointer wherever possible. - * - * \note smart pointer to NULL is valid. - * - * \ingroup CodeLite - * \version 1.0 - * first version - * \date 09-17-2006 - * \author Eran - */ -template class SmartPtr -{ - /** - * The reference counting class - * - * \ingroup CodeLite - * \version 1.0 - * first version - * - * \date 09-17-2006 - * \author Eran - */ - class SmartPtrRef - { - T* m_data; - int m_refCount; - - public: - /** - * Construct a reference counting class for row pointer data - * \param data pointer - */ - SmartPtrRef(T* data) - : m_data(data) - , m_refCount(1) - { - } - - /** - * Destructor - */ - virtual ~SmartPtrRef() { delete m_data; } - - /** - * \return Pointer to the row data - */ - T* GetData() { return m_data; } - - const T* GetData() const { return m_data; } - /** - * Increase reference counting by 1 - */ - void IncRef() { m_refCount++; } - - /** - * Decrease reference counting by 1 - */ - void DecRef() { m_refCount--; } - /** - * Return the current reference counting - * \return current reference counting - */ - int GetRefCount() { return m_refCount; } - }; - - SmartPtrRef* m_ref; - -public: - /** - * Construct smart pointer from ptr - * \param ptr pointer - */ - SmartPtr(T* ptr) - { - // create a fresh copy - CreateFresh(ptr); - } - - /** - * Default constructor - */ - SmartPtr() - : m_ref(NULL) - { - } - - /** - * Copy constructor - * \param rhs right hand side - */ - SmartPtr(const SmartPtr& rhs) - : m_ref(NULL) - { - *this = rhs; - } - - /** - * Assignment operator - * \param rhs right hand side - * \return reference to this - */ - SmartPtr& operator=(const SmartPtr& rhs) - { - // increase the reference count - if(m_ref == rhs.m_ref) return *this; - - // Delete previous reference - DeleteRefCount(); - - if(!rhs.m_ref) return *this; - - m_ref = rhs.m_ref; - if(m_ref) { - m_ref->IncRef(); - } - return *this; - } - - /** - * Destructor - */ - virtual ~SmartPtr() { DeleteRefCount(); } - - /** - * Replace the current pointer with ptr - * if the current ptr is not NULL, it will be freed (reference counting free) before assingning the new ptr - * \param ptr new pointer - */ - void Reset(T* ptr) - { - DeleteRefCount(); - CreateFresh(ptr); - } - - /** - * Return pointer the row data pointer - * \return pointer to the row data pointer - */ - T* Get() { return m_ref->GetData(); } - - const T* Get() const { return m_ref->GetData(); } - /** - * Overload the '->' operator - * \return pointer to the row data pointer - */ - T* operator->() const { return m_ref->GetData(); } - - /** - * Dereference operator - * \return dereference the row data - */ - T& operator*() const { return *(m_ref->GetData()); } - - /** - * Test for NULL operator - * \return true if the internal row data or the reference counting class are NULL false otherwise - */ - bool operator!() const - { - if(!m_ref) return true; - - return m_ref->GetData() == NULL; - } - - /** - * test for bool operation - * \return true of the internal raw data exist and it is not null - */ - operator bool() const { return m_ref && m_ref->GetData(); } - -private: - void DeleteRefCount() - { - // decrease the ref count (or delete pointer if it is 1) - if(m_ref) { - if(m_ref->GetRefCount() == 1) { - delete m_ref; - m_ref = NULL; - } else { - m_ref->DecRef(); - } - } - }; - - void CreateFresh(T* ptr) { m_ref = new SmartPtrRef(ptr); } -}; - -#endif // CODELITE_SMART_PTR_H diff --git a/CodeLite/ssh/cl_sftp_attribute.h b/CodeLite/ssh/cl_sftp_attribute.h index 4c7e6f8726..26f604f32e 100644 --- a/CodeLite/ssh/cl_sftp_attribute.h +++ b/CodeLite/ssh/cl_sftp_attribute.h @@ -28,8 +28,9 @@ #if USE_SFTP #include "codelite_exports.h" -#include "smart_ptr.h" + #include +#include #include #include @@ -47,8 +48,8 @@ class WXDLLIMPEXP_CL SFTPAttribute : public wxClientData wxString m_symlinkPath; // incase this file represents a symlink, this member will hold the target path public: - typedef SmartPtr Ptr_t; - typedef std::list List_t; + using Ptr_t = std::shared_ptr; + using List_t = std::list; enum { TYPE_FOLDER = 0x00000001, diff --git a/CodeLite/tag_tree.h b/CodeLite/tag_tree.h index 853c4ac2d3..8d42b7bc36 100644 --- a/CodeLite/tag_tree.h +++ b/CodeLite/tag_tree.h @@ -25,11 +25,12 @@ #ifndef CODELITE_TAG_TREE_H #define CODELITE_TAG_TREE_H -#include -#include "smart_ptr.h" -#include "tree.h" #include "codelite_exports.h" #include "entry.h" +#include "tree.h" + +#include +#include typedef TreeNode TagNode; @@ -69,6 +70,6 @@ class WXDLLIMPEXP_CL TagTree : public Tree }; -typedef SmartPtr TagTreePtr; +using TagTreePtr = std::shared_ptr; #endif // CODELITE_TAG_TREE_H diff --git a/CodeLite/tags_storage_sqlite3.cpp b/CodeLite/tags_storage_sqlite3.cpp index 5143711fc9..809823e007 100644 --- a/CodeLite/tags_storage_sqlite3.cpp +++ b/CodeLite/tags_storage_sqlite3.cpp @@ -321,7 +321,7 @@ void TagsStorageSQLite::Store(const std::vector& tags, bool auto_co // we dont store local variables if(tag->IsLocalVariable()) continue; - DoInsertTagEntry(*tag.Get()); + DoInsertTagEntry(*tag); } } catch(wxSQLite3Exception& e) { clWARNING() << "TagsStorageSQLite::Store(): failed to insert entires into the db." << e.GetMessage() << endl; @@ -477,7 +477,7 @@ void TagsStorageSQLite::GetFiles(const wxString& partialName, std::vector& files) fe->SetFile(res.GetString(1)); fe->SetLastRetaggedTimestamp(res.GetInt(2)); - files.push_back(fe); + files.push_back(std::move(fe)); } // release unneeded memory files.shrink_to_fit(); diff --git a/CodeLite/winprocess_impl.cpp b/CodeLite/winprocess_impl.cpp index 38eadf1b2d..3c10fcc3e3 100644 --- a/CodeLite/winprocess_impl.cpp +++ b/CodeLite/winprocess_impl.cpp @@ -58,7 +58,6 @@ thread_local ClosePseudoConsole_T ClosePseudoConsole = nullptr; #include "fileutils.h" #include "processreaderthread.h" #include "procutils.h" -#include "smart_ptr.h" #include #include @@ -833,20 +832,20 @@ bool WinProcessImpl::WriteToConsole(const wxString& buff) } pass += wxT("\r\n"); - SmartPtr pKeyEvents(new INPUT_RECORD[pass.Len()]); + std::vector pKeyEvents(pass.Len()); for(size_t i = 0; i < pass.Len(); i++) { - (pKeyEvents.Get())[i].EventType = KEY_EVENT; - (pKeyEvents.Get())[i].Event.KeyEvent.bKeyDown = TRUE; - (pKeyEvents.Get())[i].Event.KeyEvent.wRepeatCount = 1; - (pKeyEvents.Get())[i].Event.KeyEvent.wVirtualKeyCode = LOBYTE(::VkKeyScan(pass[i])); - (pKeyEvents.Get())[i].Event.KeyEvent.wVirtualScanCode = 0; - (pKeyEvents.Get())[i].Event.KeyEvent.uChar.UnicodeChar = pass[i]; - (pKeyEvents.Get())[i].Event.KeyEvent.dwControlKeyState = 0; + pKeyEvents[i].EventType = KEY_EVENT; + pKeyEvents[i].Event.KeyEvent.bKeyDown = TRUE; + pKeyEvents[i].Event.KeyEvent.wRepeatCount = 1; + pKeyEvents[i].Event.KeyEvent.wVirtualKeyCode = LOBYTE(::VkKeyScan(pass[i])); + pKeyEvents[i].Event.KeyEvent.wVirtualScanCode = 0; + pKeyEvents[i].Event.KeyEvent.uChar.UnicodeChar = pass[i]; + pKeyEvents[i].Event.KeyEvent.dwControlKeyState = 0; } DWORD dwTextWritten; - if(::WriteConsoleInput(hStdIn, pKeyEvents.Get(), pass.Len(), &dwTextWritten) == FALSE) { + if(::WriteConsoleInput(hStdIn, pKeyEvents.data(), pass.Len(), &dwTextWritten) == FALSE) { CloseHandle(hStdIn); return false; } diff --git a/DatabaseExplorer/IDbAdapter.h b/DatabaseExplorer/IDbAdapter.h index 40a0b85979..5e91250376 100644 --- a/DatabaseExplorer/IDbAdapter.h +++ b/DatabaseExplorer/IDbAdapter.h @@ -25,22 +25,24 @@ #ifndef IDBADAPTER_H #define IDBADAPTER_H -#include -#include "smart_ptr.h" -#include -#include + #include "IDbType.h" //#include "columncol.h" -//#include "tablecol.h" //#include "databasecol.h" +//#include "tablecol.h" + +#include +#include +#include +#include + class DbConnection; class Database; class Table; class View; class IDbType; - -typedef SmartPtr DatabaseLayerPtr; +using DatabaseLayerPtr = std::shared_ptr; /*! \brief Basic virtual class for creating universal interface between different database servers. */ class IDbAdapter diff --git a/DatabaseExplorer/MySqlDbAdapter.cpp b/DatabaseExplorer/MySqlDbAdapter.cpp index 2defb580b6..9c9d2ca757 100644 --- a/DatabaseExplorer/MySqlDbAdapter.cpp +++ b/DatabaseExplorer/MySqlDbAdapter.cpp @@ -58,12 +58,12 @@ void MySqlDbAdapter::CloseConnection() DatabaseLayerPtr MySqlDbAdapter::GetDatabaseLayer(const wxString& dbName) { - DatabaseLayer* dbLayer = NULL; + DatabaseLayerPtr dbLayer; #ifdef DBL_USE_MYSQL if(!CanConnect()) - return new MysqlDatabaseLayer(); - dbLayer = new MysqlDatabaseLayer(this->m_serverName, wxT(""), this->m_userName, this->m_password); + return std::make_shared(); + dbLayer = std::make_shared(this->m_serverName, wxT(""), this->m_userName, this->m_password); #endif this->m_pDbLayer = dbLayer; diff --git a/DatabaseExplorer/MySqlDbAdapter.h b/DatabaseExplorer/MySqlDbAdapter.h index a353d66f43..fa0c1507da 100644 --- a/DatabaseExplorer/MySqlDbAdapter.h +++ b/DatabaseExplorer/MySqlDbAdapter.h @@ -83,7 +83,7 @@ class MySqlDbAdapter : public IDbAdapter { wxString m_userName; wxString m_password; - DatabaseLayer* m_pDbLayer; + DatabaseLayerPtr m_pDbLayer; }; #endif // MYSQLDBADAPTER_H diff --git a/DatabaseExplorer/PostgreSqlDbAdapter.cpp b/DatabaseExplorer/PostgreSqlDbAdapter.cpp index a1a2e42891..8b4f870765 100644 --- a/DatabaseExplorer/PostgreSqlDbAdapter.cpp +++ b/DatabaseExplorer/PostgreSqlDbAdapter.cpp @@ -60,19 +60,19 @@ void PostgreSqlDbAdapter::CloseConnection() DatabaseLayerPtr PostgreSqlDbAdapter::GetDatabaseLayer(const wxString& dbName) { - DatabaseLayer* dbLayer = NULL; + DatabaseLayerPtr dbLayer; #ifdef DBL_USE_POSTGRES if(!CanConnect()) - return new PostgresDatabaseLayer(); + return std::make_shared(); if(m_port == 0) m_port = 5432; if(!dbName.IsEmpty()) - dbLayer = - new PostgresDatabaseLayer(this->m_serverName, this->m_port, dbName, this->m_userName, this->m_password); + dbLayer = std::make_shared(this->m_serverName, this->m_port, dbName, this->m_userName, + this->m_password); else - dbLayer = new PostgresDatabaseLayer(this->m_serverName, this->m_port, this->m_defaultDb, this->m_userName, - this->m_password); + dbLayer = std::make_shared(this->m_serverName, this->m_port, this->m_defaultDb, + this->m_userName, this->m_password); #endif this->m_pDbLayer = dbLayer; diff --git a/DatabaseExplorer/PostgreSqlDbAdapter.h b/DatabaseExplorer/PostgreSqlDbAdapter.h index 37a3196e6f..b21df5c520 100644 --- a/DatabaseExplorer/PostgreSqlDbAdapter.h +++ b/DatabaseExplorer/PostgreSqlDbAdapter.h @@ -87,7 +87,7 @@ class PostgreSqlDbAdapter : public IDbAdapter { wxString m_password; wxString m_defaultDb; - DatabaseLayer* m_pDbLayer; + DatabaseLayerPtr m_pDbLayer; }; #endif // POSTGRESQLDBADAPTER_H diff --git a/DatabaseExplorer/SqlCommandPanel.cpp b/DatabaseExplorer/SqlCommandPanel.cpp index 8e82794ad2..ad843c1833 100644 --- a/DatabaseExplorer/SqlCommandPanel.cpp +++ b/DatabaseExplorer/SqlCommandPanel.cpp @@ -91,7 +91,7 @@ SQLCommandPanel::SQLCommandPanel(wxWindow* parent, IDbAdapter* dbAdapter, const m_dbName = dbName; m_dbTable = dbTable; - m_editHelper.Reset(new clEditEventsHandler(m_scintillaSQL)); + m_editHelper = std::make_unique(m_scintillaSQL); m_scintillaSQL->AddText(wxString::Format(_(" -- selected database %s\n"), m_dbName.c_str())); if(!dbTable.IsEmpty()) { m_scintillaSQL->AddText(m_pDbAdapter->GetDefaultSelect(m_dbName, m_dbTable)); diff --git a/DatabaseExplorer/SqliteDbAdapter.cpp b/DatabaseExplorer/SqliteDbAdapter.cpp index f849b11396..c7fe0a40c5 100644 --- a/DatabaseExplorer/SqliteDbAdapter.cpp +++ b/DatabaseExplorer/SqliteDbAdapter.cpp @@ -44,10 +44,10 @@ SQLiteDbAdapter::~SQLiteDbAdapter() {} void SQLiteDbAdapter::CloseConnection() {} DatabaseLayerPtr SQLiteDbAdapter::GetDatabaseLayer(const wxString& dbName) { - DatabaseLayer* pDatabase = NULL; + DatabaseLayerPtr pDatabase; #ifdef DBL_USE_SQLITE - pDatabase = new SqliteDatabaseLayer(m_sFileName); + pDatabase = std::make_shared(m_sFileName); #endif return pDatabase; diff --git a/DebugAdapterClient/DebugAdapterClient.cpp b/DebugAdapterClient/DebugAdapterClient.cpp index e2e02d8de4..c228dd1302 100644 --- a/DebugAdapterClient/DebugAdapterClient.cpp +++ b/DebugAdapterClient/DebugAdapterClient.cpp @@ -437,7 +437,7 @@ void DebugAdapterClient::OnDebugStart(clDebugEvent& event) // Determine the executable to debug, working directory and arguments LOG_DEBUG(LOG) << "Preparing environment variables.." << endl; - env = bldConf->GetEnvironment(project.Get()); + env = bldConf->GetEnvironment(project.get()); LOG_DEBUG(LOG) << "Success" << endl; exepath = bldConf->GetCommand(); diff --git a/LanguageServer/LanguageServerCluster.cpp b/LanguageServer/LanguageServerCluster.cpp index f269e00ef7..ca157bbbaa 100644 --- a/LanguageServer/LanguageServerCluster.cpp +++ b/LanguageServer/LanguageServerCluster.cpp @@ -308,7 +308,7 @@ void LanguageServerCluster::OnSignatureHelp(LSPEvent& event) if(tags.empty()) { return; } - editor->ShowCalltip(new clCallTip(tags)); + editor->ShowCalltip(std::make_shared(tags)); } void LanguageServerCluster::OnHover(LSPEvent& event) diff --git a/LiteEditor/BuildTab.cpp b/LiteEditor/BuildTab.cpp index 1aeed90a4a..ab4a0d91b3 100644 --- a/LiteEditor/BuildTab.cpp +++ b/LiteEditor/BuildTab.cpp @@ -93,7 +93,7 @@ void BuildTab::OnBuildStarted(clBuildEvent& e) EditorConfigST::Get()->ReadObject(wxT("BuildTabSettings"), &m_buildTabSettings); // clean the last used compiler - m_activeCompiler.Reset(nullptr); + m_activeCompiler = nullptr; m_error_count = m_warn_count = 0; // get the toolchain from the event and attempt to load the compiler @@ -251,7 +251,7 @@ void BuildTab::Cleanup() m_buildInProgress = false; m_buffer.clear(); ClearView(); - m_activeCompiler.Reset(nullptr); + m_activeCompiler = nullptr; m_error_count = 0; m_warn_count = 0; m_buildInterrupted = false; diff --git a/LiteEditor/configuration_manager_dlg.cpp b/LiteEditor/configuration_manager_dlg.cpp index ba74545aa6..a5d423bc25 100644 --- a/LiteEditor/configuration_manager_dlg.cpp +++ b/LiteEditor/configuration_manager_dlg.cpp @@ -248,7 +248,7 @@ void ConfigurationManagerDlg::SaveCurrentSettings() WorkspaceConfigurationPtr conf = matrix->GetConfigurationByName(m_currentWorkspaceConfiguration); if(!conf) { // create new configuration - conf = new WorkspaceConfiguration(NULL); + conf = std::make_shared(nullptr); conf->SetName(m_currentWorkspaceConfiguration); matrix->SetConfiguration(conf); } diff --git a/LiteEditor/configuration_manager_dlg.h b/LiteEditor/configuration_manager_dlg.h index a1f1b97e78..84aac75fa2 100644 --- a/LiteEditor/configuration_manager_dlg.h +++ b/LiteEditor/configuration_manager_dlg.h @@ -26,10 +26,10 @@ #define __configuration_manager_dlg__ #include "ConfigManagerBaseDlg.h" -#include "smart_ptr.h" -#include -#include "project_settings.h" #include "configuration_mapping.h" +#include "project_settings.h" + +#include /** Implementing ConfigManagerBaseDlg */ class ConfigurationManagerDlg : public ConfigManagerBaseDlg diff --git a/LiteEditor/context_base.h b/LiteEditor/context_base.h index 5746d24e8e..03157f8c32 100644 --- a/LiteEditor/context_base.h +++ b/LiteEditor/context_base.h @@ -28,13 +28,13 @@ #include "entry.h" #include "lexer_configuration.h" #include "macros.h" -#include "smart_ptr.h" -#include "wx/filename.h" -#include "wx/string.h" +#include #include #include +#include #include +#include class clEditor; @@ -168,5 +168,5 @@ class ContextBase : public wxEvtHandler int PositionBeforeCurrent() const; }; -typedef SmartPtr ContextBasePtr; +using ContextBasePtr = std::shared_ptr; #endif // CONTEXT_BASE_H diff --git a/LiteEditor/context_manager.cpp b/LiteEditor/context_manager.cpp index db24332ca0..4161e89787 100644 --- a/LiteEditor/context_manager.cpp +++ b/LiteEditor/context_manager.cpp @@ -50,10 +50,10 @@ ContextBasePtr ContextManager::NewContext(clEditor* parent, const wxString& lexe lex_name.MakeLower(); auto iter = m_contextPool.find(lex_name); if(iter == m_contextPool.end()) { - return m_contextPool["text"]->NewInstance(parent); + return ContextBasePtr(m_contextPool["text"]->NewInstance(parent)); } - return iter->second->NewInstance((clEditor*)parent); + return ContextBasePtr(iter->second->NewInstance((clEditor*)parent)); } ContextBasePtr ContextManager::NewContextByFileName(clEditor* parent, const wxFileName& fileName) @@ -72,24 +72,24 @@ void ContextManager::Initialize() m_contextPool.clear(); // register available contexts - m_contextPool["c++"] = new ContextCpp(); - m_contextPool["diff"] = new ContextDiff(); - m_contextPool["html"] = new ContextHtml(); - m_contextPool["php"] = new ContextPhp(); - m_contextPool["javascript"] = new ContextJavaScript(); - m_contextPool["python"] = new ContextPython(); - m_contextPool["rust"] = new ContextRust(); + m_contextPool["c++"] = std::make_shared(); + m_contextPool["diff"] = std::make_shared(); + m_contextPool["html"] = std::make_shared(); + m_contextPool["php"] = std::make_shared(); + m_contextPool["javascript"] = std::make_shared(); + m_contextPool["python"] = std::make_shared(); + m_contextPool["rust"] = std::make_shared(); // load generic lexers wxArrayString names = ColoursAndFontsManager::Get().GetAllLexersNames(); for(const auto& name : names) { if(m_contextPool.count(name) == 0) { - m_contextPool.insert({ name, new ContextGeneric(name) }); + m_contextPool.insert({ name, std::make_shared(name) }); } } // make sure there is a "fallback" lexer for unrecognized file types if(m_contextPool.find("text") == m_contextPool.end()) { - m_contextPool[wxT("text")] = new ContextGeneric(wxT("text")); + m_contextPool[wxT("text")] = std::make_shared(wxT("text")); } } diff --git a/LiteEditor/editorsettingslocal.cpp b/LiteEditor/editorsettingslocal.cpp index 9ebce07cb1..d9bb116fdb 100644 --- a/LiteEditor/editorsettingslocal.cpp +++ b/LiteEditor/editorsettingslocal.cpp @@ -45,7 +45,7 @@ EditorSettingsLocal::EditorSettingsLocal(OptionsConfigPtr hrOptions, wxXmlNode* } SetTitle(label); - localOptions = new LocalOptionsConfig; + localOptions = std::make_shared(); LocalOptionsConfig pOC(localOptions, node); DisplayHigherValues(higherOptions); // Sets the 'global'? defaults, and the enabling checkboxes to disabling @@ -203,7 +203,7 @@ void EditorSettingsLocal::DisplayLocalValues(const LocalOptionsConfigPtr options void EditorSettingsLocal::OnOK(wxCommandEvent& event) { // Kill the old LocalOptionsConfigPtr, which now holds stale data - localOptions.Reset(new LocalOptionsConfig); + localOptions = std::make_shared(); // Assume that, for any items still disabled, the user wants to use the global setting // That's true even if he decided to change an item, then disabled it again diff --git a/LiteEditor/fileview.cpp b/LiteEditor/fileview.cpp index f941a3f191..92ab7a04fa 100644 --- a/LiteEditor/fileview.cpp +++ b/LiteEditor/fileview.cpp @@ -188,7 +188,7 @@ FileViewTree::FileViewTree(wxWindow* parent, const wxWindowID id, const wxPoint& return (a->GetData().GetDisplayName().CmpNoCase(b->GetData().GetDisplayName()) < 0); }; SetSortFunction(SortFunc); - m_colourHelper.Reset(new clTreeCtrlColourHelper(this)); + m_colourHelper = std::make_unique(this); // Initialise images map BitmapLoader* bmpLoader = PluginManager::Get()->GetStdIcons(); @@ -2374,7 +2374,7 @@ void FileViewTree::OnFolderDropped(clCommandEvent& event) pd.m_path = folder; // Set a default empty project - pd.m_srcProject.Reset(new Project()); + pd.m_srcProject = std::make_shared(); // Use sensible debugger defaults #ifdef __WXMAC__ diff --git a/LiteEditor/frame.cpp b/LiteEditor/frame.cpp index be6d8a35c0..cfc8b530ee 100644 --- a/LiteEditor/frame.cpp +++ b/LiteEditor/frame.cpp @@ -872,7 +872,7 @@ void clMainFrame::Construct() m_highlightWord = (bool)value; // Initialize the frame helper - m_frameHelper.Reset(new clMainFrameHelper(this, &m_mgr)); + m_frameHelper = std::make_unique(this, &m_mgr); CreateGUIControls(); ManagerST::Get(); // Dummy call diff --git a/LiteEditor/menu_event_handlers.h b/LiteEditor/menu_event_handlers.h index 11ca933372..bb31d24e32 100644 --- a/LiteEditor/menu_event_handlers.h +++ b/LiteEditor/menu_event_handlers.h @@ -25,8 +25,8 @@ #ifndef MENU_EVENT_HANDLERS_H #define MENU_EVENT_HANDLERS_H -#include "wx/event.h" -#include "smart_ptr.h" +#include +#include #include /** @@ -51,7 +51,7 @@ class MenuEventHandler void SetEventId(const int& id) { m_id = id; } }; -typedef SmartPtr MenuEventHandlerPtr; +using MenuEventHandlerPtr = std::shared_ptr; //----------------------------------------------------------------- // Define here a class per event/group diff --git a/LiteEditor/menumanager.cpp b/LiteEditor/menumanager.cpp index 0fc53d0a0a..3ed4f05428 100644 --- a/LiteEditor/menumanager.cpp +++ b/LiteEditor/menumanager.cpp @@ -28,66 +28,66 @@ MenuManager::MenuManager(void) { - PushHandler(new EditHandler(wxID_COPY)); - PushHandler(new EditHandler(wxID_CUT)); - PushHandler(new EditHandler(wxID_PASTE)); - PushHandler(new EditHandler(wxID_UNDO)); - PushHandler(new EditHandler(wxID_REDO)); - PushHandler(new EditHandler(XRCID("label_current_state"))); - PushHandler(new EditHandler(wxID_SELECTALL)); - PushHandler(new EditHandler(wxID_DUPLICATE)); - PushHandler(new EditHandler(wxID_DELETE)); - PushHandler(new EditHandler(wxID_ZOOM_FIT)); - PushHandler(new EditHandler(wxID_ZOOM_IN)); - PushHandler(new EditHandler(wxID_ZOOM_OUT)); - PushHandler(new EditHandler(XRCID("delete_line"))); - PushHandler(new EditHandler(XRCID("delete_line_end"))); - PushHandler(new EditHandler(XRCID("delete_line_start"))); - PushHandler(new EditHandler(XRCID("copy_line"))); - PushHandler(new EditHandler(XRCID("cut_line"))); - PushHandler(new EditHandler(XRCID("transpose_lines"))); - PushHandler(new EditHandler(XRCID("trim_trailing"))); - PushHandler(new EditHandler(XRCID("to_upper"))); - PushHandler(new EditHandler(XRCID("to_lower"))); - PushHandler(new EditHandler(XRCID("swap_files"))); - PushHandler(new EditHandler(XRCID("move_line_down"))); - PushHandler(new EditHandler(XRCID("move_line_up"))); - PushHandler(new EditHandler(XRCID("center_line_roll"))); - PushHandler(new EditHandler(XRCID("convert_indent_to_tabs"))); - PushHandler(new EditHandler(XRCID("convert_indent_to_spaces"))); - PushHandler(new BraceMatchHandler(XRCID("select_to_brace"))); - PushHandler(new BraceMatchHandler(XRCID("match_brace"))); - PushHandler(new FindReplaceHandler(XRCID("id_find"))); - PushHandler(new FindReplaceHandler(XRCID("id_replace"))); - PushHandler(new FindReplaceHandler(XRCID("ID_QUICK_ADD_NEXT"))); - PushHandler(new FindReplaceHandler(XRCID("ID_QUICK_FIND_ALL"))); - PushHandler(new GotoHandler(XRCID("goto_linenumber"))); - PushHandler(new BookmarkHandler(XRCID("toggle_bookmark"))); - PushHandler(new BookmarkHandler(XRCID("next_bookmark"))); - PushHandler(new BookmarkHandler(XRCID("previous_bookmark"))); - PushHandler(new BookmarkHandler(XRCID("removeall_current_bookmarks"))); - PushHandler(new BookmarkHandler(XRCID("removeall_bookmarks"))); - PushHandler(new GotoDefinitionHandler(XRCID("goto_definition"))); - PushHandler(new GotoDefinitionHandler(XRCID("goto_previous_definition"))); - PushHandler(new WordWrapHandler(XRCID("word_wrap"))); - PushHandler(new FoldHandler(XRCID("toggle_fold"))); - PushHandler(new FoldHandler(XRCID("fold_topmost_in_selection"))); - PushHandler(new FoldHandler(XRCID("fold_all_in_selection"))); - PushHandler(new FoldHandler(XRCID("fold_all"))); - PushHandler(new DebuggerMenuHandler(XRCID("add_breakpoint"))); - PushHandler(new DebuggerMenuHandler(XRCID("insert_breakpoint"))); // This actually does 'toggle' - PushHandler(new DebuggerMenuHandler(XRCID("disable_all_breakpoints"))); - PushHandler(new DebuggerMenuHandler(XRCID("enable_all_breakpoints"))); - PushHandler(new DebuggerMenuHandler(XRCID("delete_all_breakpoints"))); - PushHandler(new DebuggerMenuHandler(XRCID("insert_temp_breakpoint"))); - PushHandler(new DebuggerMenuHandler(XRCID("insert_disabled_breakpoint"))); - PushHandler(new DebuggerMenuHandler(XRCID("insert_cond_breakpoint"))); - PushHandler(new DebuggerMenuHandler(XRCID("insert_watchpoint"))); - PushHandler(new DebuggerMenuHandler(XRCID("toggle_breakpoint_enabled_status"))); - PushHandler(new DebuggerMenuHandler(XRCID("ignore_breakpoint"))); - PushHandler(new DebuggerMenuHandler(XRCID("edit_breakpoint"))); - PushHandler(new DebuggerMenuHandler(XRCID("delete_breakpoint"))); - PushHandler(new DebuggerMenuHandler(XRCID("show_breakpoint_dlg"))); + PushHandler(std::make_shared(wxID_COPY)); + PushHandler(std::make_shared(wxID_CUT)); + PushHandler(std::make_shared(wxID_PASTE)); + PushHandler(std::make_shared(wxID_UNDO)); + PushHandler(std::make_shared(wxID_REDO)); + PushHandler(std::make_shared(XRCID("label_current_state"))); + PushHandler(std::make_shared(wxID_SELECTALL)); + PushHandler(std::make_shared(wxID_DUPLICATE)); + PushHandler(std::make_shared(wxID_DELETE)); + PushHandler(std::make_shared(wxID_ZOOM_FIT)); + PushHandler(std::make_shared(wxID_ZOOM_IN)); + PushHandler(std::make_shared(wxID_ZOOM_OUT)); + PushHandler(std::make_shared(XRCID("delete_line"))); + PushHandler(std::make_shared(XRCID("delete_line_end"))); + PushHandler(std::make_shared(XRCID("delete_line_start"))); + PushHandler(std::make_shared(XRCID("copy_line"))); + PushHandler(std::make_shared(XRCID("cut_line"))); + PushHandler(std::make_shared(XRCID("transpose_lines"))); + PushHandler(std::make_shared(XRCID("trim_trailing"))); + PushHandler(std::make_shared(XRCID("to_upper"))); + PushHandler(std::make_shared(XRCID("to_lower"))); + PushHandler(std::make_shared(XRCID("swap_files"))); + PushHandler(std::make_shared(XRCID("move_line_down"))); + PushHandler(std::make_shared(XRCID("move_line_up"))); + PushHandler(std::make_shared(XRCID("center_line_roll"))); + PushHandler(std::make_shared(XRCID("convert_indent_to_tabs"))); + PushHandler(std::make_shared(XRCID("convert_indent_to_spaces"))); + PushHandler(std::make_shared(XRCID("select_to_brace"))); + PushHandler(std::make_shared(XRCID("match_brace"))); + PushHandler(std::make_shared(XRCID("id_find"))); + PushHandler(std::make_shared(XRCID("id_replace"))); + PushHandler(std::make_shared(XRCID("ID_QUICK_ADD_NEXT"))); + PushHandler(std::make_shared(XRCID("ID_QUICK_FIND_ALL"))); + PushHandler(std::make_shared(XRCID("goto_linenumber"))); + PushHandler(std::make_shared(XRCID("toggle_bookmark"))); + PushHandler(std::make_shared(XRCID("next_bookmark"))); + PushHandler(std::make_shared(XRCID("previous_bookmark"))); + PushHandler(std::make_shared(XRCID("removeall_current_bookmarks"))); + PushHandler(std::make_shared(XRCID("removeall_bookmarks"))); + PushHandler(std::make_shared(XRCID("goto_definition"))); + PushHandler(std::make_shared(XRCID("goto_previous_definition"))); + PushHandler(std::make_shared(XRCID("word_wrap"))); + PushHandler(std::make_shared(XRCID("toggle_fold"))); + PushHandler(std::make_shared(XRCID("fold_topmost_in_selection"))); + PushHandler(std::make_shared(XRCID("fold_all_in_selection"))); + PushHandler(std::make_shared(XRCID("fold_all"))); + PushHandler(std::make_shared(XRCID("add_breakpoint"))); + PushHandler(std::make_shared(XRCID("insert_breakpoint"))); // This actually does 'toggle' + PushHandler(std::make_shared(XRCID("disable_all_breakpoints"))); + PushHandler(std::make_shared(XRCID("enable_all_breakpoints"))); + PushHandler(std::make_shared(XRCID("delete_all_breakpoints"))); + PushHandler(std::make_shared(XRCID("insert_temp_breakpoint"))); + PushHandler(std::make_shared(XRCID("insert_disabled_breakpoint"))); + PushHandler(std::make_shared(XRCID("insert_cond_breakpoint"))); + PushHandler(std::make_shared(XRCID("insert_watchpoint"))); + PushHandler(std::make_shared(XRCID("toggle_breakpoint_enabled_status"))); + PushHandler(std::make_shared(XRCID("ignore_breakpoint"))); + PushHandler(std::make_shared(XRCID("edit_breakpoint"))); + PushHandler(std::make_shared(XRCID("delete_breakpoint"))); + PushHandler(std::make_shared(XRCID("show_breakpoint_dlg"))); } MenuManager::~MenuManager(void) diff --git a/LiteEditor/menumanager.h b/LiteEditor/menumanager.h index 219b907f55..2dee3a2fb9 100644 --- a/LiteEditor/menumanager.h +++ b/LiteEditor/menumanager.h @@ -27,7 +27,7 @@ #include "menu_event_handlers.h" #include "singleton.h" -#include "smart_ptr.h" + #include //------------------------------------------------- diff --git a/LiteEditor/new_configuration_dlg.cpp b/LiteEditor/new_configuration_dlg.cpp index abef9892f3..2cc18d1bac 100644 --- a/LiteEditor/new_configuration_dlg.cpp +++ b/LiteEditor/new_configuration_dlg.cpp @@ -138,10 +138,10 @@ void NewConfigurationDlg::OnButtonOK(wxCommandEvent& event) BuildConfigPtr newBuildConf; if(copyFrom == _("-- None --")) { - newBuildConf = new BuildConfig(NULL); + newBuildConf = std::make_shared(nullptr); } else { BuildConfigPtr origBuildConf = settings->GetBuildConfiguration(copyFrom); - newBuildConf = origBuildConf->Clone(); + newBuildConf.reset(origBuildConf->Clone()); } newBuildConf->SetName(newConfName); diff --git a/LiteEditor/outputtabwindow.cpp b/LiteEditor/outputtabwindow.cpp index 28959c40c0..ab5114796a 100644 --- a/LiteEditor/outputtabwindow.cpp +++ b/LiteEditor/outputtabwindow.cpp @@ -67,7 +67,7 @@ OutputTabWindow::OutputTabWindow(wxWindow* parent, wxWindowID id, const wxString , m_autoAppearErrors(false) , m_errorsFirstLine(false) { - m_styler.Reset(new clFindResultsStyler()); + m_styler = std::make_unique(); CreateGUIControls(); wxTheApp->Connect(wxID_COPY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(OutputTabWindow::OnEdit), NULL, this); @@ -81,7 +81,7 @@ OutputTabWindow::OutputTabWindow(wxWindow* parent, wxWindowID id, const wxString OutputTabWindow::~OutputTabWindow() { - m_styler.Reset(NULL); + m_styler.reset(nullptr); EventNotifier::Get()->Disconnect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(OutputTabWindow::OnThemeChanged), NULL, this); wxTheApp->Disconnect(wxID_COPY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(OutputTabWindow::OnEdit), NULL, diff --git a/LiteEditor/tags_options_dlg.cpp b/LiteEditor/tags_options_dlg.cpp index 810b31d565..8c622e07a1 100644 --- a/LiteEditor/tags_options_dlg.cpp +++ b/LiteEditor/tags_options_dlg.cpp @@ -142,8 +142,7 @@ void CodeCompletionSettingsDialog::DoSetEditEventsHandler(wxWindow* win) { // wxTextCtrl needs some extra special handling if(dynamic_cast(win)) { - clEditEventsHandler::Ptr_t handler(new clEditEventsHandler(dynamic_cast(win))); - m_handlers.push_back(handler); + m_handlers.push_back(std::make_unique(dynamic_cast(win))); } // Check the children diff --git a/Plugin/ColoursAndFontsManager.cpp b/Plugin/ColoursAndFontsManager.cpp index 2ea90ae110..e9b1c3f1ae 100644 --- a/Plugin/ColoursAndFontsManager.cpp +++ b/Plugin/ColoursAndFontsManager.cpp @@ -98,7 +98,7 @@ ColoursAndFontsManager::ColoursAndFontsManager() : m_initialized(false) { JSON json(DefaultLexerJSON); - m_defaultLexer.Reset(new LexerConf()); + m_defaultLexer = std::make_shared(); m_defaultLexer->FromJSON(json.toElement()); m_lexersVersion = clConfig::Get().Read(LEXERS_VERSION_STRING, LEXERS_UPGRADE_LINENUM_DEFAULT_COLOURS); diff --git a/Plugin/ThemeImporters/ThemeImporterBase.hpp b/Plugin/ThemeImporters/ThemeImporterBase.hpp index 3c05ad72b2..32207ceeb8 100644 --- a/Plugin/ThemeImporters/ThemeImporterBase.hpp +++ b/Plugin/ThemeImporters/ThemeImporterBase.hpp @@ -30,9 +30,9 @@ #include "codelite_exports.h" #include "lexer_configuration.h" #include "macros.h" -#include "smart_ptr.h" #include +#include #include #include #include @@ -54,8 +54,8 @@ class WXDLLIMPEXP_SDK ThemeImporterBase bool isItalic = false; }; - typedef SmartPtr Ptr_t; - typedef std::list List_t; + using Ptr_t = std::unique_ptr; + using List_t = std::list; protected: wxString m_keywords0; diff --git a/Plugin/ThemeImporters/ThemeImporterManager.cpp b/Plugin/ThemeImporters/ThemeImporterManager.cpp index 87144ca4c0..5eba912363 100644 --- a/Plugin/ThemeImporters/ThemeImporterManager.cpp +++ b/Plugin/ThemeImporters/ThemeImporterManager.cpp @@ -35,35 +35,35 @@ ThemeImporterManager::ThemeImporterManager() { - m_importers.push_back(new ThemeImporterCXX()); - m_importers.push_back(new ThemeImporterCMake()); - m_importers.push_back(new ThemeImporterText()); - m_importers.push_back(new ThemeImporterMakefile()); - m_importers.push_back(new ThemeImporterDiff()); - m_importers.push_back(new ThemeImporterPHP()); - m_importers.push_back(new ThemeImporterCSS()); - m_importers.push_back(new ThemeImporterTCL()); - m_importers.push_back(new ThemeImporterXML()); - m_importers.push_back(new ThemeImporterJavaScript()); - m_importers.push_back(new ThemeImporterINI()); - m_importers.push_back(new ThemeImporterASM()); - m_importers.push_back(new ThemeImporterBatch()); - m_importers.push_back(new ThemeImporterPython()); - m_importers.push_back(new ThemeImporterCobra()); - m_importers.push_back(new ThemeImporterCobraAlt()); - m_importers.push_back(new ThemeImporterFortran()); - m_importers.push_back(new ThemeImporterInnoSetup()); - m_importers.push_back(new ThemeImporterJava()); - m_importers.push_back(new ThemeImporterLua()); - m_importers.push_back(new ThemeImporterScript()); - m_importers.push_back(new ThemeImporterSQL()); - m_importers.push_back(new ThemeImporterSCSS()); - m_importers.push_back(new ThemeImporterDockerfile()); - m_importers.push_back(new ThemeImporterYAML()); - m_importers.push_back(new ThemeImporterRuby()); - m_importers.push_back(new ThemeImporterMarkdown()); - m_importers.push_back(new ThemeImporterRust()); - m_importers.push_back(new ThemeImporterJson()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); + m_importers.push_back(std::make_unique()); } ThemeImporterManager::~ThemeImporterManager() {} @@ -74,7 +74,7 @@ wxString ThemeImporterManager::Import(const wxString& theme_file) wxString name; std::vector lexers; lexers.reserve(m_importers.size()); - for(auto importer : m_importers) { + for (auto& importer : m_importers) { auto lexer = importer->Import(theme_file); if(!lexer) { return wxEmptyString; diff --git a/Plugin/ThemeImporters/ThemeImporterManager.hpp b/Plugin/ThemeImporters/ThemeImporterManager.hpp index 88c52c8e51..959b32294e 100644 --- a/Plugin/ThemeImporters/ThemeImporterManager.hpp +++ b/Plugin/ThemeImporters/ThemeImporterManager.hpp @@ -39,6 +39,9 @@ class WXDLLIMPEXP_SDK ThemeImporterManager ThemeImporterManager(); virtual ~ThemeImporterManager(); + ThemeImporterManager(const ThemeImporterManager&) = delete; + ThemeImporterManager& operator=(const ThemeImporterManager&) = delete; + /** * @brief import the XML and create a lexer out of it * @param theme_file path to the XML file diff --git a/Plugin/build_config.h b/Plugin/build_config.h index 6a8353d729..be6edd18ec 100644 --- a/Plugin/build_config.h +++ b/Plugin/build_config.h @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -388,6 +389,6 @@ class WXDLLIMPEXP_SDK BuildConfig : public ConfObject clEnvList_t GetEnvironment(Project* project = nullptr) const; }; -typedef SmartPtr BuildConfigPtr; +using BuildConfigPtr = std::shared_ptr; #endif // BUILD_CONFIGURATION_H diff --git a/Plugin/build_config_common.h b/Plugin/build_config_common.h index 702cb1cc70..5e3e2de73e 100644 --- a/Plugin/build_config_common.h +++ b/Plugin/build_config_common.h @@ -28,6 +28,7 @@ #include "codelite_exports.h" #include "configuration_object.h" +#include #include #include @@ -88,6 +89,6 @@ class WXDLLIMPEXP_SDK BuildConfigCommon : public ConfObject void SetResCmpOptions(const wxString& options) { m_resCompileOptions = options; } }; -typedef SmartPtr BuildConfigCommonPtr; +using BuildConfigCommonPtr = std::shared_ptr; #endif // BUILD_CONFIGURATION_COMMON_H diff --git a/Plugin/build_settings_config.cpp b/Plugin/build_settings_config.cpp index 6a96aacfb1..f94d8e7a30 100644 --- a/Plugin/build_settings_config.cpp +++ b/Plugin/build_settings_config.cpp @@ -136,7 +136,7 @@ CompilerPtr BuildSettingsConfig::GetCompiler(const wxString& name) const if(!m_compilers.count(name)) { // no such compiler... - return new Compiler(NULL); + return std::make_shared(nullptr); } else { @@ -176,7 +176,7 @@ CompilerPtr BuildSettingsConfig::GetNextCompiler(BuildSettingsConfigCookie& cook if(cookie.child == NULL) { cookie.parent = NULL; } - return new Compiler(n); + return std::make_shared(n); } cookie.child = cookie.child->GetNext(); } @@ -214,7 +214,7 @@ BuilderConfigPtr BuildSettingsConfig::GetBuilderConfig(const wxString& name) wxXmlNode* node = XmlUtils::FindNodeByName(m_doc->GetRoot(), wxT("BuildSystem"), name.IsEmpty() ? GetSelectedBuildSystem() : name); if(node) { - return new BuilderConfig(node); + return std::make_shared(node); } return NULL; } diff --git a/Plugin/build_system.h b/Plugin/build_system.h index e6b53af516..3d6af81f3d 100644 --- a/Plugin/build_system.h +++ b/Plugin/build_system.h @@ -26,10 +26,11 @@ #define BUILD_SYSTEM_H #include "codelite_exports.h" -#include "list" -#include "smart_ptr.h" -#include "wx/string.h" -#include "wx/xml/xml.h" + +#include +#include +#include +#include class WXDLLIMPEXP_SDK BuilderConfig { @@ -56,6 +57,6 @@ class WXDLLIMPEXP_SDK BuilderConfig void SetToolJobs(const wxString& jobs) { m_toolJobs = jobs; } }; -typedef SmartPtr BuilderConfigPtr; +using BuilderConfigPtr = std::shared_ptr; #endif // BUILD_SYSTEM_H diff --git a/Plugin/builder.h b/Plugin/builder.h index 3873f1e791..7edede9ec8 100644 --- a/Plugin/builder.h +++ b/Plugin/builder.h @@ -26,9 +26,10 @@ #define BUILDER_H #include "codelite_exports.h" -#include "smart_ptr.h" -#include "wx/event.h" -#include "wx/string.h" + +#include +#include +#include /** * \ingroup SDK @@ -185,6 +186,6 @@ class WXDLLIMPEXP_SDK Builder virtual wxString GetStaticLibSuffix() const { return ".a"; } }; -typedef SmartPtr BuilderPtr; +using BuilderPtr = std::shared_ptr; #endif // BUILDER_H diff --git a/Plugin/buildmanager.cpp b/Plugin/buildmanager.cpp index f400196046..1c8a111489 100644 --- a/Plugin/buildmanager.cpp +++ b/Plugin/buildmanager.cpp @@ -34,12 +34,12 @@ BuildManager::BuildManager() { // register all builders here - AddBuilder(new BuilderGnuMake()); - AddBuilder(new BuilderGNUMakeClassic()); - AddBuilder(new BuilderGnuMakeOneStep()); + AddBuilder(std::make_shared()); + AddBuilder(std::make_shared()); + AddBuilder(std::make_shared()); #ifdef __WXMSW__ - AddBuilder(new BuilderNMake()); - AddBuilder(new BuilderGnuMakeMSYS()); + AddBuilder(std::make_shared()); + AddBuilder(std::make_shared()); #endif } diff --git a/Plugin/clEditorEditEventsHandler.h b/Plugin/clEditorEditEventsHandler.h index 779bf98d19..c6e91632e0 100644 --- a/Plugin/clEditorEditEventsHandler.h +++ b/Plugin/clEditorEditEventsHandler.h @@ -2,8 +2,8 @@ #define CLEDITOREDITEVENTSHANDLER_H #include "codelite_exports.h" -#include "smart_ptr.h" +#include #include #include #include @@ -59,7 +59,7 @@ class WXDLLIMPEXP_SDK clEditEventsHandler : public wxEvtHandler clEditEventsHandler(wxComboBox* wnd, const wxString& name = wxEmptyString); virtual ~clEditEventsHandler(); void NoUnbind() { m_noUnbind = true; } - typedef SmartPtr Ptr_t; + using Ptr_t = std::unique_ptr; }; #endif // CLEDITOREDITEVENTSHANDLER_H diff --git a/Plugin/clFindResultsStyler.h b/Plugin/clFindResultsStyler.h index e4e32c5a02..f0313030f7 100644 --- a/Plugin/clFindResultsStyler.h +++ b/Plugin/clFindResultsStyler.h @@ -2,8 +2,8 @@ #define CLFINDRESULTSSTYLER_H #include "codelite_exports.h" -#include "smart_ptr.h" +#include #include class WXDLLIMPEXP_SDK clFindResultsStyler : public wxEvtHandler @@ -28,7 +28,7 @@ class WXDLLIMPEXP_SDK clFindResultsStyler : public wxEvtHandler LEX_FIF_SCOPE, LEX_FIF_MATCH_COMMENT, }; - typedef SmartPtr Ptr_t; + using Ptr_t = std::unique_ptr; protected: wxStyledTextCtrl* m_stc; diff --git a/Plugin/clMainFrameHelper.h b/Plugin/clMainFrameHelper.h index 242189944b..4e4ea4fa1d 100644 --- a/Plugin/clMainFrameHelper.h +++ b/Plugin/clMainFrameHelper.h @@ -2,8 +2,8 @@ #define CLMAINFRAMEHELPER_H #include "codelite_exports.h" -#include "smart_ptr.h" +#include #include class clMainFrame; @@ -16,7 +16,7 @@ class WXDLLIMPEXP_SDK clMainFrameHelper : public wxEvtHandler size_t m_debuggerFeatures; public: - typedef SmartPtr Ptr_t; + using Ptr_t = std::unique_ptr; public: clMainFrameHelper(clMainFrame* frame, clDockingManager* dockMgr); diff --git a/Plugin/clPluginsFindBar.cpp b/Plugin/clPluginsFindBar.cpp index b5a4a2bca7..1840e30f59 100644 --- a/Plugin/clPluginsFindBar.cpp +++ b/Plugin/clPluginsFindBar.cpp @@ -105,8 +105,8 @@ clPluginsFindBar::clPluginsFindBar(wxWindow* parent, wxWindowID id) , m_replaceInSelection(false) { // Handle Edit events - m_findEventsHandler.Reset(new clEditEventsHandler(m_textCtrlFind)); - m_replaceEventsHandler.Reset(new clEditEventsHandler(m_textCtrlReplace)); + m_findEventsHandler = std::make_unique(m_textCtrlFind); + m_replaceEventsHandler = std::make_unique(m_textCtrlReplace); m_findEventsHandler->NoUnbind(); m_replaceEventsHandler->NoUnbind(); m_toolbar->SetMiniToolBar(true); diff --git a/Plugin/clThemedSTC.cpp b/Plugin/clThemedSTC.cpp index d21398681b..5a4519572d 100644 --- a/Plugin/clThemedSTC.cpp +++ b/Plugin/clThemedSTC.cpp @@ -6,7 +6,7 @@ clThemedSTC::clThemedSTC(wxWindow* parent, wxWindowID id, const wxPoint& pos, co const wxString& name) : wxStyledTextCtrl(parent, id, pos, size, style, name) { - m_editEventsHandler.Reset(new clEditEventsHandler(this)); + m_editEventsHandler = std::make_unique(this); LexerConf::Ptr_t lex = ColoursAndFontsManager::Get().GetLexer("text"); if(lex) { lex->ApplySystemColours(this); @@ -17,7 +17,7 @@ clThemedSTC::clThemedSTC(wxWindow* parent, wxWindowID id, const wxString& defaul const wxSize& size, long style, const wxString& name) : wxStyledTextCtrl(parent, id, pos, size, style, name) { - m_editEventsHandler.Reset(new clEditEventsHandler(this)); + m_editEventsHandler = std::make_unique(this); LexerConf::Ptr_t lex = ColoursAndFontsManager::Get().GetLexer("text"); if(lex) { lex->ApplySystemColours(this); @@ -28,7 +28,7 @@ clThemedSTC::clThemedSTC(wxWindow* parent, wxWindowID id, const wxString& defaul } } -clThemedSTC::clThemedSTC() { m_editEventsHandler.Reset(nullptr); } +clThemedSTC::clThemedSTC() {} bool clThemedSTC::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) diff --git a/Plugin/clThemedTextCtrl.cpp b/Plugin/clThemedTextCtrl.cpp index 1db5048932..6e2f0efbc1 100644 --- a/Plugin/clThemedTextCtrl.cpp +++ b/Plugin/clThemedTextCtrl.cpp @@ -74,7 +74,7 @@ clThemedTextCtrl::clThemedTextCtrl(wxWindow* parent, wxWindowID id, const wxStri Bind(wxEVT_STC_CLIPBOARD_PASTE, &clThemedTextCtrl::OnPaste, this); #endif EventNotifier::Get()->Bind(wxEVT_SYS_COLOURS_CHANGED, &clThemedTextCtrl::OnSysColours, this); - m_editEventsHandler.Reset(new clEditEventsHandler(this)); + m_editEventsHandler = std::make_unique(this); } clThemedTextCtrl::~clThemedTextCtrl() diff --git a/Plugin/clTreeCtrlColourHelper.h b/Plugin/clTreeCtrlColourHelper.h index 72ec8b44bf..82830ba1cd 100644 --- a/Plugin/clTreeCtrlColourHelper.h +++ b/Plugin/clTreeCtrlColourHelper.h @@ -3,9 +3,9 @@ #include "VirtualDirectoryColour.h" #include "clThemedTreeCtrl.h" -#include "smart_ptr.h" +#include "codelite_exports.h" -#include +#include #include #include @@ -14,7 +14,7 @@ class WXDLLIMPEXP_SDK clTreeCtrlColourHelper clThemedTreeCtrl* m_tree; public: - typedef SmartPtr Ptr_t; + using Ptr_t = std::unique_ptr; protected: wxString GetItemPath(const wxTreeItemId& item) const; diff --git a/Plugin/compiler.h b/Plugin/compiler.h index a90b50bf28..446983cbe4 100644 --- a/Plugin/compiler.h +++ b/Plugin/compiler.h @@ -29,7 +29,6 @@ #include "asyncprocess.h" #include "codelite_exports.h" #include "configuration_object.h" -#include "smart_ptr.h" #include #include @@ -266,7 +265,7 @@ class WXDLLIMPEXP_SDK Compiler : public ConfObject bool HasMetadata() const; }; -typedef SmartPtr CompilerPtr; -typedef std::vector CompilerPtrVec_t; +using CompilerPtr = std::shared_ptr; +using CompilerPtrVec_t = std::vector; #endif // COMPILER_H diff --git a/Plugin/configuration_mapping.cpp b/Plugin/configuration_mapping.cpp index bbe55ccd26..d591e8eecf 100644 --- a/Plugin/configuration_mapping.cpp +++ b/Plugin/configuration_mapping.cpp @@ -36,14 +36,14 @@ BuildMatrix::BuildMatrix(wxXmlNode* node, const wxString& selectedConfiguration) wxXmlNode* config = node->GetChildren(); while(config) { if(config->GetName() == wxT("WorkspaceConfiguration")) { - m_configurationList.push_back(new WorkspaceConfiguration(config)); + m_configurationList.push_back(std::make_shared(config)); } config = config->GetNext(); } } else { // construct default empty mapping with a default build configuration - m_configurationList.push_back(new WorkspaceConfiguration(wxT("Debug"))); - m_configurationList.push_back(new WorkspaceConfiguration(wxT("Release"))); + m_configurationList.push_back(std::make_shared(wxT("Debug"))); + m_configurationList.push_back(std::make_shared(wxT("Release"))); } // verify the selected configuration diff --git a/Plugin/configuration_mapping.h b/Plugin/configuration_mapping.h index 0d743b2cf4..b24c92802a 100644 --- a/Plugin/configuration_mapping.h +++ b/Plugin/configuration_mapping.h @@ -26,10 +26,11 @@ #define CONFIGURATION_MAPPING_H #include "codelite_exports.h" -#include "list" -#include "smart_ptr.h" -#include "wx/string.h" -#include "wx/xml/xml.h" + +#include +#include +#include +#include class WXDLLIMPEXP_SDK ConfigMappingEntry { @@ -82,7 +83,7 @@ class WXDLLIMPEXP_SDK WorkspaceConfiguration } }; -typedef SmartPtr WorkspaceConfigurationPtr; +using WorkspaceConfigurationPtr = std::shared_ptr; class WXDLLIMPEXP_SDK BuildMatrix { @@ -108,6 +109,6 @@ class WXDLLIMPEXP_SDK BuildMatrix WorkspaceConfigurationPtr GetConfigurationByName(const wxString& name) const; }; -typedef SmartPtr BuildMatrixPtr; +using BuildMatrixPtr = std::shared_ptr; #endif // CONFIGURATION_MAPPING_H diff --git a/Plugin/configuration_object.h b/Plugin/configuration_object.h index b7ce506ad4..f8f260aa1c 100644 --- a/Plugin/configuration_object.h +++ b/Plugin/configuration_object.h @@ -25,7 +25,6 @@ #ifndef CONF_OBJECT_H #define CONF_OBJECT_H -#include "smart_ptr.h" #include "wx/xml/xml.h" #ifdef WXMAKINGDLL_LE_SDK @@ -50,5 +49,4 @@ class WXDLLIMPEXP_LE_SDK ConfObject virtual wxXmlNode* ToXml() const = 0; }; -typedef SmartPtr ConfObjectPtr; #endif // CONFIGURATION_OBJECT_H diff --git a/Plugin/editor_config.cpp b/Plugin/editor_config.cpp index 635f987594..0b554d7133 100644 --- a/Plugin/editor_config.cpp +++ b/Plugin/editor_config.cpp @@ -175,7 +175,7 @@ OptionsConfigPtr EditorConfig::GetOptions() const { wxXmlNode* node = XmlUtils::FindFirstByTagName(m_doc->GetRoot(), wxT("Options")); // node can be null ... - OptionsConfigPtr opts = new OptionsConfig(node); + OptionsConfigPtr opts = std::make_shared(node); // import legacy tab-width setting into opts long tabWidth = const_cast(this)->GetInteger(wxT("EditorTabWidth"), -1); diff --git a/Plugin/lexer_configuration.h b/Plugin/lexer_configuration.h index 5f8c62eafe..eafc61d94b 100644 --- a/Plugin/lexer_configuration.h +++ b/Plugin/lexer_configuration.h @@ -28,14 +28,14 @@ #include "JSON.h" #include "attribute_style.h" #include "codelite_exports.h" -#include "wx/filename.h" -#include "wx/string.h" -#include "wx/xml/xml.h" -#include +#include +#include #include #include #include +#include +#include #define ANNOTATION_STYLE_WARNING 210 #define ANNOTATION_STYLE_ERROR 211 @@ -106,7 +106,7 @@ class WXDLLIMPEXP_SDK LexerConf int m_substyleBase = wxNOT_FOUND; public: - typedef SmartPtr Ptr_t; + using Ptr_t = std::shared_ptr; protected: enum eLexerConfFlags { diff --git a/Plugin/localworkspace.h b/Plugin/localworkspace.h index 54810e1984..f1de22d14a 100644 --- a/Plugin/localworkspace.h +++ b/Plugin/localworkspace.h @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -40,7 +41,7 @@ enum prefsLevel { pLevel_global, pLevel_workspace, pLevel_project, pLevel_file, pLevel_dunno }; class LocalOptionsConfig; -typedef SmartPtr LocalOptionsConfigPtr; +using LocalOptionsConfigPtr = std::shared_ptr; template class validVar { diff --git a/Plugin/optionsconfig.h b/Plugin/optionsconfig.h index ca537d2277..5bfc4bed12 100644 --- a/Plugin/optionsconfig.h +++ b/Plugin/optionsconfig.h @@ -30,10 +30,12 @@ #include "clEditorConfig.h" #include "codelite_exports.h" #include "configuration_object.h" -#include "wx/colour.h" -#include "wx/font.h" -#include "wx/string.h" -#include "wx/xml/xml.h" + +#include +#include +#include +#include +#include class WXDLLIMPEXP_SDK OptionsConfig : public ConfObject { @@ -481,6 +483,6 @@ class WXDLLIMPEXP_SDK OptionsConfig : public ConfObject wxXmlNode* ToXml() const; }; -typedef SmartPtr OptionsConfigPtr; +using OptionsConfigPtr = std::shared_ptr; #endif // OPTIONS_CONFIG_H diff --git a/Plugin/project.cpp b/Plugin/project.cpp index 7e5db7b0f9..1b1ccb4e6d 100644 --- a/Plugin/project.cpp +++ b/Plugin/project.cpp @@ -66,10 +66,10 @@ Project::Project() , m_workspace(NULL) { // initialize it with default settings - m_settings.Reset(new ProjectSettings(NULL)); + m_settings = std::make_shared(nullptr); } -Project::~Project() { m_settings.Reset(NULL); } +Project::~Project() {} bool Project::Create(const wxString& name, const wxString& description, const wxString& path, const wxString& projType) { @@ -1652,7 +1652,7 @@ void Project::ReplaceCompilers(const wxStringMap_t& compilers) void Project::DoUpdateProjectSettings() { - m_settings.Reset(new ProjectSettings(XmlUtils::FindFirstByTagName(m_doc.GetRoot(), "Settings"))); + m_settings = std::make_shared(XmlUtils::FindFirstByTagName(m_doc.GetRoot(), "Settings")); } wxArrayString Project::GetPreProcessors(bool clearCache) diff --git a/Plugin/project.h b/Plugin/project.h index d213866007..593e0b4b26 100644 --- a/Plugin/project.h +++ b/Plugin/project.h @@ -32,13 +32,13 @@ #include "optionsconfig.h" #include "project_settings.h" #include "serialized_object.h" -#include "smart_ptr.h" #include "wx/filename.h" #include "wx/string.h" #include "wx/treectrl.h" #include "xmlutils.h" #include +#include #include #include #include @@ -139,16 +139,16 @@ class WXDLLIMPEXP_SDK ProjectItem }; // useful typedefs -typedef Tree ProjectTree; -typedef SmartPtr ProjectTreePtr; -typedef TreeNode ProjectTreeNode; +using ProjectTree = Tree; +using ProjectTreePtr = std::shared_ptr; +using ProjectTreeNode = TreeNode; class Project; class clCxxWorkspace; -typedef SmartPtr ProjectPtr; -typedef std::set FileNameSet_t; -typedef std::vector FileNameVector_t; +using ProjectPtr = std::shared_ptr; +using FileNameSet_t = std::set; +using FileNameVector_t = std::vector; // ----------------------------------------- // File meta data diff --git a/Plugin/project_settings.cpp b/Plugin/project_settings.cpp index b42c63660e..51c563951d 100644 --- a/Plugin/project_settings.cpp +++ b/Plugin/project_settings.cpp @@ -40,7 +40,7 @@ ProjectSettings::ProjectSettings(wxXmlNode* node) wxString configName = XmlUtils::ReadString(child, wxT("Name")); m_configs.insert(std::pair(configName, new BuildConfig(child))); } else if(child->GetName() == wxT("GlobalSettings")) { - m_globalSettings = new BuildConfigCommon(child, wxT("GlobalSettings")); + m_globalSettings = std::make_shared(child, wxT("GlobalSettings")); } child = child->GetNext(); } @@ -59,7 +59,7 @@ ProjectSettings::ProjectSettings(wxXmlNode* node) // Create global settings if it's not been loaded or by default if(!m_globalSettings) { // clLogMessage(wxT("ProjectSettings : Create global settings because it doesn't exists")); - m_globalSettings = new BuildConfigCommon(NULL, wxT("GlobalSettings")); + m_globalSettings = std::make_shared(nullptr, wxT("GlobalSettings")); } } diff --git a/Plugin/project_settings.h b/Plugin/project_settings.h index 417bbc2ab3..603e29d394 100644 --- a/Plugin/project_settings.h +++ b/Plugin/project_settings.h @@ -30,6 +30,7 @@ #include "wx/string.h" #include +#include /** * \ingroup SDK @@ -146,6 +147,6 @@ class WXDLLIMPEXP_SDK ProjectSettings : public ConfObject void SetProjectType(const wxString& type) { m_projectType = type; } }; -typedef SmartPtr ProjectSettingsPtr; +using ProjectSettingsPtr = std::shared_ptr; #endif // PROJECT_SETTINGS_H diff --git a/Plugin/workspace.cpp b/Plugin/workspace.cpp index 7f4723ada6..ad975354e8 100644 --- a/Plugin/workspace.cpp +++ b/Plugin/workspace.cpp @@ -81,7 +81,7 @@ wxString clCxxWorkspace::GetName() const void clCxxWorkspace::CloseWorkspace() { - m_buildMatrix.Reset(NULL); + m_buildMatrix = nullptr; if(m_doc.IsOk()) { SaveXmlFile(); m_doc = wxXmlDocument(); @@ -96,7 +96,7 @@ void clCxxWorkspace::CloseWorkspace() bool clCxxWorkspace::OpenReadOnly(const wxString& fileName, wxString& errMsg) { - m_buildMatrix.Reset(NULL); + m_buildMatrix = nullptr; wxFileName workSpaceFile(fileName); if(!workSpaceFile.FileExists()) { return false; @@ -207,7 +207,7 @@ bool clCxxWorkspace::CreateWorkspace(const wxString& name, const wxString& path, // This function sets the working directory to the workspace directory! ::wxSetWorkingDirectory(m_fileName.GetPath()); - m_buildMatrix.Reset(NULL); + m_buildMatrix = nullptr; wxFileName dbFileName = GetTagsFileName(); TagsManagerST::Get()->OpenDatabase(dbFileName); @@ -1168,8 +1168,8 @@ void clCxxWorkspace::ReplaceCompilers(const wxStringMap_t& compilers) void clCxxWorkspace::DoUpdateBuildMatrix() { - m_buildMatrix.Reset(new BuildMatrix(XmlUtils::FindFirstByTagName(m_doc.GetRoot(), "BuildMatrix"), - GetLocalWorkspace()->GetSelectedBuildConfiguration())); + m_buildMatrix = std::make_shared(XmlUtils::FindFirstByTagName(m_doc.GetRoot(), "BuildMatrix"), + GetLocalWorkspace()->GetSelectedBuildConfiguration()); } void clCxxWorkspace::RenameProject(const wxString& oldname, const wxString& newname) @@ -1434,7 +1434,7 @@ bool clCxxWorkspace::CreateWorkspaceFolder(const wxString& path) { return (DoCre bool clCxxWorkspace::DoLoadWorkspace(const wxString& fileName, wxString& errMsg) { CloseWorkspace(); - m_buildMatrix.Reset(NULL); + m_buildMatrix = nullptr; wxFileName workSpaceFile(fileName); if(workSpaceFile.FileExists() == false) { errMsg = wxString::Format(_("Could not open workspace file: '%s'"), fileName.c_str()); diff --git a/Plugin/wxTerminalCtrl/wxTerminalInputCtrl.cpp b/Plugin/wxTerminalCtrl/wxTerminalInputCtrl.cpp index 28a81858ee..bc0418e850 100644 --- a/Plugin/wxTerminalCtrl/wxTerminalInputCtrl.cpp +++ b/Plugin/wxTerminalCtrl/wxTerminalInputCtrl.cpp @@ -87,7 +87,7 @@ wxTerminalInputCtrl::wxTerminalInputCtrl(wxTerminalCtrl* parent) EventNotifier::Get()->Bind(wxEVT_SYS_COLOURS_CHANGED, &wxTerminalInputCtrl::OnThemeChanged, this); m_ctrl->SetWordChars(R"#(\:~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$/.-)#"); - m_editEvents.Reset(new MyEventsHandler(this, m_ctrl)); + m_editEvents = std::make_unique(this, m_ctrl); m_ctrl->Bind(wxEVT_CONTEXT_MENU, &wxTerminalInputCtrl::OnMenu, this); m_ctrl->Bind(wxEVT_IDLE, &wxTerminalInputCtrl::OnIdle, this); EventNotifier::Get()->Bind(wxEVT_CCBOX_SELECTION_MADE, &wxTerminalInputCtrl::OnCCBoxSelected, this); diff --git a/Plugin/wxTerminalCtrl/wxTerminalOutputCtrl.cpp b/Plugin/wxTerminalCtrl/wxTerminalOutputCtrl.cpp index 5147a9f518..d5e6c631d3 100644 --- a/Plugin/wxTerminalCtrl/wxTerminalOutputCtrl.cpp +++ b/Plugin/wxTerminalCtrl/wxTerminalOutputCtrl.cpp @@ -61,7 +61,7 @@ wxTerminalOutputCtrl::wxTerminalOutputCtrl(wxWindow* parent, wxWindowID winid) , m_terminal(nullptr) { Initialise(); - m_editEvents.Reset(new MyEventsHandler(nullptr, m_ctrl)); + m_editEvents = std::make_unique(nullptr, m_ctrl); } wxTerminalOutputCtrl::wxTerminalOutputCtrl(wxTerminalCtrl* parent, wxWindowID winid, const wxFont& font, @@ -70,12 +70,12 @@ wxTerminalOutputCtrl::wxTerminalOutputCtrl(wxTerminalCtrl* parent, wxWindowID wi , m_terminal(parent) { Initialise(font, bg_colour, text_colour); - m_editEvents.Reset(new MyEventsHandler(nullptr, m_ctrl)); + m_editEvents = std::make_unique(nullptr, m_ctrl); } void wxTerminalOutputCtrl::SetInputCtrl(wxTerminalInputCtrl* input_ctrl) { - m_editEvents.Reset(new MyEventsHandler(input_ctrl, m_ctrl)); + m_editEvents = std::make_unique(input_ctrl, m_ctrl); } void wxTerminalOutputCtrl::Initialise(const wxFont& font, const wxColour& bg_colour, const wxColour& text_colour) diff --git a/SFTP/SFTPStatusPage.cpp b/SFTP/SFTPStatusPage.cpp index e6924903d4..d335a19ece 100644 --- a/SFTP/SFTPStatusPage.cpp +++ b/SFTP/SFTPStatusPage.cpp @@ -52,7 +52,7 @@ SFTPStatusPage::SFTPStatusPage(wxWindow* parent, SFTP* plugin) Bind(wxEVT_SSH_CHANNEL_WRITE_ERROR, &SFTPStatusPage::OnFindError, this); Bind(wxEVT_SSH_CHANNEL_READ_OUTPUT, &SFTPStatusPage::OnFindOutput, this); Bind(wxEVT_SSH_CHANNEL_CLOSED, &SFTPStatusPage::OnFindFinished, this); - m_styler.Reset(new SFTPGrepStyler(m_stcSearch)); + m_styler = std::make_unique(m_stcSearch); m_stcSearch->Bind(wxEVT_STC_HOTSPOT_CLICK, &SFTPStatusPage::OnHotspotClicked, this); } @@ -130,7 +130,7 @@ void SFTPStatusPage::OnThemeChanged(wxCommandEvent& event) lexer->Apply(m_stcOutput); lexer->Apply(m_stcSearch); } - m_styler.Reset(new SFTPGrepStyler(m_stcSearch)); + m_styler = std::make_unique(m_stcSearch); } void SFTPStatusPage::OnCopy(wxCommandEvent& event) diff --git a/Subversion2/SvnCommitDialog.cpp b/Subversion2/SvnCommitDialog.cpp index fc1b31232a..9e62208c65 100644 --- a/Subversion2/SvnCommitDialog.cpp +++ b/Subversion2/SvnCommitDialog.cpp @@ -106,8 +106,8 @@ void SvnCommitDialog::DoCommonInit() m_checkListFiles->Clear(); // These two classes will allow copy / paste etc using the keyboard on the STC classes - m_stcMessageHelper.Reset(new clEditEventsHandler(m_stcMessage)); - m_stcDiffHelper.Reset(new clEditEventsHandler(m_stcDiff)); + m_stcMessageHelper = std::make_unique(m_stcMessage); + m_stcDiffHelper = std::make_unique(m_stcDiff); DoCreateToolbar(); int sashPos = m_plugin->GetSettings().GetCommitDlgSashPos(); if(sashPos != wxNOT_FOUND) { diff --git a/Tail/tail.cpp b/Tail/tail.cpp index da205318cb..91e4dba5d6 100644 --- a/Tail/tail.cpp +++ b/Tail/tail.cpp @@ -62,7 +62,7 @@ void Tail::CreatePluginMenu(wxMenu* pluginsMenu) {} void Tail::UnPlug() { - m_editEventsHandler.Reset(NULL); + m_editEventsHandler = nullptr; // Unbind events EventNotifier::Get()->Unbind(wxEVT_INIT_DONE, &Tail::OnInitDone, this); @@ -113,7 +113,7 @@ void Tail::InitTailWindow(wxWindow* parent, bool isNotebook, const TailData& d, // Hook our output-pane panel m_view = tmpView; - m_editEventsHandler.Reset(new clEditEventsHandler(m_view->GetStc())); + m_editEventsHandler = std::make_unique(m_view->GetStc()); if(isNotebook) { m_mgr->BookAddPage(PaneId::BOTTOM_BAR, m_view, "Tail"); } else { diff --git a/WebTools/CSSCodeCompletion.h b/WebTools/CSSCodeCompletion.h index a891ad97d3..d3c2402937 100644 --- a/WebTools/CSSCodeCompletion.h +++ b/WebTools/CSSCodeCompletion.h @@ -27,8 +27,8 @@ #define CSSCODECOMPLETION_H #include "cl_command_event.h" -#include "smart_ptr.h" +#include #include #include #include // Base class: wxEvtHandler @@ -38,7 +38,7 @@ class IEditor; class CSSCodeCompletion : public wxEvtHandler { public: - typedef SmartPtr Ptr_t; + using Ptr_t = std::unique_ptr; struct Entry { wxString property; wxArrayString values; diff --git a/WebTools/XMLCodeCompletion.h b/WebTools/XMLCodeCompletion.h index 5989c2c132..a0074d6ddf 100644 --- a/WebTools/XMLCodeCompletion.h +++ b/WebTools/XMLCodeCompletion.h @@ -28,8 +28,8 @@ #include "cl_command_event.h" #include "macros.h" -#include "smart_ptr.h" +#include #include #include @@ -38,7 +38,7 @@ class IEditor; class XMLCodeCompletion : public wxEvtHandler { public: - typedef SmartPtr Ptr_t; + using Ptr_t = std::unique_ptr; struct HtmlCompletion { wxString m_tag; wxString m_comment; diff --git a/WebTools/webtools.cpp b/WebTools/webtools.cpp index 956b171f6e..e2da29cba7 100644 --- a/WebTools/webtools.cpp +++ b/WebTools/webtools.cpp @@ -96,8 +96,8 @@ WebTools::WebTools(IManager* manager) Bind(wxEVT_MENU, &WebTools::OnSettings, this, XRCID("webtools_settings")); Bind(wxEVT_NODE_COMMAND_TERMINATED, &WebTools::OnNodeCommandCompleted, this); - m_xmlCodeComplete.Reset(new XMLCodeCompletion(this)); - m_cssCodeComplete.Reset(new CSSCodeCompletion(this)); + m_xmlCodeComplete = std::make_unique(this); + m_cssCodeComplete = std::make_unique(this); // Connect the timer m_timer = new wxTimer(this); diff --git a/codelitephp/PHPParser/php_code_completion.cpp b/codelitephp/PHPParser/php_code_completion.cpp index 196e862199..26d4d7d54c 100644 --- a/codelitephp/PHPParser/php_code_completion.cpp +++ b/codelitephp/PHPParser/php_code_completion.cpp @@ -425,7 +425,7 @@ PHPLocation::Ptr_t PHPCodeCompletion::FindDefinition(IEditor* editor, int pos) // use the internal function resolved = resolved->Cast()->GetFunc(); } - loc = new PHPLocation; + loc = std::make_shared(); loc->filename = resolved->GetFilename().GetFullPath(); loc->linenumber = resolved->GetLine(); loc->what = resolved->GetShortName(); diff --git a/codelitephp/PHPParser/php_code_completion.h b/codelitephp/PHPParser/php_code_completion.h index 71f87db2f5..dc4f2c99e7 100644 --- a/codelitephp/PHPParser/php_code_completion.h +++ b/codelitephp/PHPParser/php_code_completion.h @@ -37,7 +37,7 @@ #include #include -#include +#include #include struct PHPLocation { @@ -45,7 +45,7 @@ struct PHPLocation { wxString filename; // file name (absolute path) int linenumber; // line number within filename PHPEntityBase::Ptr_t entity; - typedef SmartPtr Ptr_t; + using Ptr_t = std::shared_ptr; }; class IManager; diff --git a/cscope/cscopetab.cpp b/cscope/cscopetab.cpp index 956c68c017..92a53f0c7c 100644 --- a/cscope/cscopetab.cpp +++ b/cscope/cscopetab.cpp @@ -46,7 +46,7 @@ CscopeTab::CscopeTab(wxWindow* parent, IManager* mgr) , m_table(NULL) , m_mgr(mgr) { - m_styler.Reset(new clFindResultsStyler(m_stc)); + m_styler = std::make_unique(m_stc); CScopeConfData data; m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &data); diff --git a/ctagsd/lib/LSPUtils.cpp b/ctagsd/lib/LSPUtils.cpp index fef741316e..cbfc10182d 100644 --- a/ctagsd/lib/LSPUtils.cpp +++ b/ctagsd/lib/LSPUtils.cpp @@ -121,7 +121,7 @@ std::vector LSPUtils::to_symbol_information_array(const wxStringSet_t parent_seen; for(auto tag : tags) { LSP::SymbolInformation symbol_information; - to_symbol_information(tag.Get(), symbol_information, for_tree_view ? &parent_seen : nullptr); + to_symbol_information(tag.get(), symbol_information, for_tree_view ? &parent_seen : nullptr); result.push_back(symbol_information); } return result; diff --git a/ctagsd/lib/ProtocolHandler.cpp b/ctagsd/lib/ProtocolHandler.cpp index 28e313d267..eae0e085e4 100644 --- a/ctagsd/lib/ProtocolHandler.cpp +++ b/ctagsd/lib/ProtocolHandler.cpp @@ -59,7 +59,7 @@ void remove_db_if_needed(const wxString& dbpath) clSYSTEM() << "DB version schema upgrade is required" << endl; clSYSTEM() << "New schema version is:" << db->GetVersion() << endl; clSYSTEM() << "Current schema version is:" << db->GetSchemaVersion() << endl; - db.Reset(nullptr); + db = nullptr; FileUtils::RemoveFile(dbpath); } else { clDEBUG() << "No schema changes detected" << endl; @@ -843,7 +843,7 @@ void ProtocolHandler::on_completion(std::unique_ptr&& msg, Channel::ptr_t item.addProperty("detail", tag->GetTypename()); // set the kind - CompletionItem::eCompletionItemKind kind = LSPUtils::get_completion_kind(tag.Get()); + CompletionItem::eCompletionItemKind kind = LSPUtils::get_completion_kind(tag.get()); item.addProperty("kind", static_cast(kind)); counter++; } @@ -1196,7 +1196,7 @@ void ProtocolHandler::on_document_signature_help(std::unique_ptr&& msg, Ch candidates.clear(); m_completer->sort_tags(matches, candidates, true, {}); - clCallTipPtr tip(new clCallTip(candidates)); + clCallTipPtr tip = std::make_shared(candidates); LSP::SignatureHelp sh; if(tip) { CompletionHelper helper; diff --git a/ctagsd/tests/main.cpp b/ctagsd/tests/main.cpp index 6ceb791e60..e144e8edfd 100644 --- a/ctagsd/tests/main.cpp +++ b/ctagsd/tests/main.cpp @@ -55,7 +55,7 @@ TagEntryPtr find_tag_by_name(const wxString& name, const vector& ca bool is_tag_exists(const wxString& path, const vector& candidates) { - return find_tag(path, candidates).Get() != NULL; + return find_tag(path, candidates) != nullptr; } bool is_file_exists(const wxString& suffix, wxString* fullpath) @@ -229,7 +229,7 @@ TEST_FUNC(TestLSPLocation) if(resolved) { completer->get_completions(resolved, wxEmptyString, wxEmptyString, candidates, { "LSP" }); } - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_SIZE(candidates.size(), 18); return true; } @@ -346,12 +346,12 @@ TEST_FUNC(test_cxx_code_complete_macro) ENSURE_DB_LOADED(); { TagEntryPtr resolved = completer->code_complete("wxTheApp->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxApp"); } { TagEntryPtr resolved = completer->code_complete("wxTheClipboard->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxClipboard"); } return true; @@ -366,7 +366,7 @@ TEST_FUNC(test_cxx_code_complete_member_of_parent_class) // set our scope at MyPlugin::foo completer->set_text(wxEmptyString, member_of_parent_class_file, 8); TagEntryPtr resolved = completer->code_complete("m_mgr->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "IManager"); return true; } @@ -379,7 +379,7 @@ TEST_FUNC(TestCTagsManager_AutoCandidates) wxString fulltext = "wxCodeCompletionBoxManager::Get()."; auto resolved = completer->code_complete(fulltext, {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); completer->get_completions(resolved, wxEmptyString, wxEmptyString, candidates, {}); CHECK_BOOL(!candidates.empty()); @@ -388,7 +388,7 @@ TEST_FUNC(TestCTagsManager_AutoCandidates) vector candidates; CxxRemainder remainder; auto resolved = completer->code_complete("StringUtils::StripTerminalColouring", {}, &remainder); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "StringUtils"); CHECK_STRING(remainder.filter, "StripTerminalColouring"); completer->get_completions(resolved, remainder.operand_string, remainder.filter, candidates, {}); @@ -532,7 +532,7 @@ TEST_FUNC(test_cxx_code_completion_both_subscript_and_arrow_operator) { completer->set_text(cc_subscript_operator_2, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("my_json[1][2].", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "JSONItem"); } return true; @@ -546,7 +546,7 @@ TEST_FUNC(test_cxx_code_completion_anonymous_namespace) if(is_file_exists("ctagsd/tests/main.cpp", &filepath)) { completer->set_text(wxEmptyString, filepath, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("completer->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "CxxCodeCompletion"); } } @@ -589,7 +589,7 @@ TEST_FUNC(test_cxx_code_completion_static_member) if(is_file_exists("LiteEditor/frame.cpp", &filepath)) { completer->set_text(wxEmptyString, filepath, 1180); TagEntryPtr resolved = completer->code_complete("m_theFrame->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "clMainFrame"); } } @@ -622,7 +622,7 @@ TEST_FUNC(test_cxx_code_completion_overloaded_function) { ENSURE_DB_LOADED(); TagEntryPtr resolved = completer->code_complete("wxString::Append", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); // vector tags; @@ -665,7 +665,7 @@ TEST_FUNC(test_cxx_code_completion_init_from_ctor) wxString code = "JSONItem item = new JSONItem();"; completer->set_text(code, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("item->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "JSONItem"); } @@ -673,7 +673,7 @@ TEST_FUNC(test_cxx_code_completion_init_from_ctor) wxString code = "auto item = JSONItem();"; completer->set_text(code, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("item[0].", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "JSONItem"); } return true; @@ -697,17 +697,17 @@ TEST_FUNC(test_cxx_code_completion_arrow_operator) ENSURE_DB_LOADED(); { TagEntryPtr resolved = completer->code_complete("SmartPtr->", {}, nullptr); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { TagEntryPtr resolved = completer->code_complete("SmartPtr->", {}, nullptr); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "SmartPtr"); } { TagEntryPtr resolved = completer->code_complete("SmartPtr.Get()->", {}, nullptr); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "TagEntry"); } return true; @@ -869,7 +869,7 @@ TEST_FUNC(test_cxx_code_completion_word_completion) { CxxRemainder remainder; TagEntryPtr resolved = completer->code_complete("std::str", {}, &remainder); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "std"); CHECK_STRING(remainder.filter, "str"); vector candidates; @@ -964,7 +964,7 @@ TEST_FUNC(test_cxx_code_completion_class_enum) CxxRemainder remainder; vector candidates; TagEntryPtr resolved = completer->code_complete("eCxxStandard::", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "eCxxStandard"); CHECK_STRING(resolved->GetKind(), "enum"); @@ -985,19 +985,19 @@ TEST_FUNC(test_cxx_code_completion_this_and_global_scope) if(is_file_exists("CodeLite/ctags_manager.cpp", &filename)) { completer->set_text(wxEmptyString, filename, 149); resolved = completer->code_complete("this->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "TagsManager"); } if(is_file_exists("CodeLite/CxxCodeCompletion.cpp", &filename_2)) { completer->set_text(wxEmptyString, filename_2, 78); resolved = completer->code_complete("m_template_manager->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "TemplateManager"); } resolved = completer->code_complete("::", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), ""); CxxRemainder remainder; @@ -1013,7 +1013,7 @@ TEST_FUNC(test_cxx_code_completion_vector_of_pairs) completer->set_text(wxEmptyString, wxEmptyString, wxNOT_FOUND); auto resolved = completer->code_complete("vector>.at(0).", { "std" }, &remainder); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "std::pair"); return true; } @@ -1026,7 +1026,7 @@ TEST_FUNC(test_cxx_code_completion_pointer_type_in_template) wxString code = "vector m_tests;"; completer->set_text(code, wxEmptyString, wxNOT_FOUND); auto resolved = completer->code_complete("m_tests.at(i)->tes", { "std" }, &remainder); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "ITest"); CHECK_STRING(remainder.filter, "tes"); return true; @@ -1064,7 +1064,7 @@ TEST_FUNC(test_cxx_code_completion_global_method) { // try again, this time with the global namespace prefix auto resolved = completer->code_complete("::clGetManager()->", {}, nullptr); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "IManager"); } return true; @@ -1081,7 +1081,7 @@ TEST_FUNC(test_cxx_code_completion_after_adding_func_impl) { completer->set_text(wxEmptyString, filename, 1117); // inside clFileSystemWorkspace::ReloadWorkspace auto resolved = completer->code_complete("this->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "clFileSystemWorkspace"); vector candidates; @@ -1103,7 +1103,7 @@ TEST_FUNC(test_cxx_code_completion_member_variable_in_scope) { completer->set_text(wxEmptyString, filename, 210); // inside TagsManager::TreeFromTags auto resolved = completer->code_complete("m_watch.", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxStopWatch"); } return true; @@ -1157,7 +1157,7 @@ TEST_FUNC(test_cxx_code_completion_full_ns_path) { ENSURE_DB_LOADED(); auto resolved = completer->code_complete("LSP::Params::Ptr_t->", {}, nullptr); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "LSP::Params"); return true; } @@ -1172,14 +1172,14 @@ TEST_FUNC(test_cxx_code_completion_function_arguments) completer->set_text(wxEmptyString, filepath, 430); // ProtocolHandler::on_initialize(unique_ptr&& msg, Channel::ptr_t channel) TagEntryPtr resolved = completer->code_complete("msg->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "JSON"); } { completer->set_text(wxEmptyString, filepath, 430); // ProtocolHandler::on_initialize(unique_ptr&& msg, Channel::ptr_t channel) TagEntryPtr resolved = completer->code_complete("channel->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "Channel"); } { @@ -1210,7 +1210,7 @@ TEST_FUNC(test_cxx_code_completion_rvalue_reference) wxString text = "TagEntry&& entry;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("entry.m_path.", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } return true; @@ -1223,7 +1223,7 @@ TEST_FUNC(test_cxx_code_completion_member_variable) wxString text = "TagEntry entry;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("entry.m_path.", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } return true; @@ -1234,7 +1234,7 @@ TEST_FUNC(test_cxx_code_completion_template_function) ENSURE_DB_LOADED(); { TagEntryPtr resolved = completer->code_complete("get_as_type()->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } @@ -1242,7 +1242,7 @@ TEST_FUNC(test_cxx_code_completion_template_function) wxString code = "auto resolved = get_as_type();"; completer->set_text(code, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("resolved.", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } @@ -1256,13 +1256,13 @@ TEST_FUNC(test_cxx_code_completion_template_std_set) wxString text = "set S;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("S.begin()->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { TagEntryPtr resolved = completer->code_complete("wxStringSet_t::value_type::", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } return true; @@ -1275,13 +1275,13 @@ TEST_FUNC(test_cxx_code_completion_template_std_multiset) wxString text = "multiset S;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("S.begin()->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { TagEntryPtr resolved = completer->code_complete("multiset::value_type::", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } return true; @@ -1294,13 +1294,13 @@ TEST_FUNC(test_cxx_code_completion_template_std_unordered_multiset) wxString text = "unordered_multiset S;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("S.begin()->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { TagEntryPtr resolved = completer->code_complete("unordered_multiset::value_type::", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } return true; @@ -1313,13 +1313,13 @@ TEST_FUNC(test_cxx_code_completion_template_std_map) wxString text = "map M;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("M.begin()->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "std::pair"); } { TagEntryPtr resolved = completer->code_complete("wxStringMap_t::value_type.", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "std::pair"); } return true; @@ -1331,7 +1331,7 @@ TEST_FUNC(test_cxx_code_completion_typedef_using) wxString text = "ClangFormatMap compiledMap;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("ClangFormatMap.begin()->first.", { "FormatOptions" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); return true; } @@ -1344,7 +1344,7 @@ TEST_FUNC(test_cxx_code_completion_template) wxString text = "cJSON* json;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("json->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "cJSON"); vector tags; completer->get_completions(resolved, wxEmptyString, wxEmptyString, tags, {}); @@ -1356,7 +1356,7 @@ TEST_FUNC(test_cxx_code_completion_template) wxString text = "wxVector V;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("V.at(0).", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { @@ -1364,7 +1364,7 @@ TEST_FUNC(test_cxx_code_completion_template) // typedef Singleton ManagerST; completer->reset(); TagEntryPtr resolved = completer->code_complete("ManagerST::Get()->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "Manager"); } @@ -1374,7 +1374,7 @@ TEST_FUNC(test_cxx_code_completion_template) // ContextManager::Get()-> completer->reset(); TagEntryPtr resolved = completer->code_complete("ContextManager::Get()->", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "ContextManager"); } @@ -1382,7 +1382,7 @@ TEST_FUNC(test_cxx_code_completion_template) wxString text = "map M;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("M.at(str).", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxArrayString"); } @@ -1390,7 +1390,7 @@ TEST_FUNC(test_cxx_code_completion_template) wxString text = "shared_ptr P;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("P.", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "std::shared_ptr"); } @@ -1398,61 +1398,61 @@ TEST_FUNC(test_cxx_code_completion_template) wxString text = "shared_ptr P;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("P->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { wxString text = "unique_ptr P;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("P->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { completer->set_text("CxxVariable::Map_t varsMap;", wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("varsMap.begin()->first.", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { completer->set_text("CxxVariable::Map_t varsMap;", wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("varsMap.begin()->second->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "CxxVariable"); } { completer->set_text("CxxVariable::Map_t varsMap;", wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("varsMap.begin()->second.", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "SmartPtr"); } { completer->set_text("unordered_set varsSet;", wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("varsSet.begin()->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "CxxVariable"); } { TagEntryPtr resolved = completer->code_complete("map::begin()->first.", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { TagEntryPtr resolved = completer->code_complete("map::begin()->second.", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "SmartPtr"); } { TagEntryPtr resolved = completer->code_complete("map::begin()->second->", { "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "CxxVariable"); } return true; @@ -1466,49 +1466,49 @@ TEST_FUNC(test_cxx_code_completion) wxString text = "std::string str;"; completer->set_text(text, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("str.", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "std::basic_string"); } { completer->set_text(cc_text_auto_chained, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("str.", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { completer->set_text(cc_text_auto_simple, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("str.", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { completer->set_text(cc_text_simple, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("wxString::", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { completer->set_text(cc_text_simple, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("str.AfterFirst('(').", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { completer->set_text(cc_text_simple, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("str.AfterFirst('(').BeforeFirst().", {}); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "wxString"); } { completer->set_text(cc_text_lsp_event, wxEmptyString, wxNOT_FOUND); TagEntryPtr resolved = completer->code_complete("event.GetLocation().GetRange().GetStart().", { "LSP", "std" }); - CHECK_BOOL(resolved); + CHECK_NOT_NULL(resolved); CHECK_STRING(resolved->GetPath(), "LSP::Position"); } return true; diff --git a/ctagsd/tests/tester.hpp b/ctagsd/tests/tester.hpp index 8181390d7c..3a3e67a8e2 100644 --- a/ctagsd/tests/tester.hpp +++ b/ctagsd/tests/tester.hpp @@ -187,7 +187,7 @@ static int strcmp(const wxString& str, const wxString& expc) { { \ ++m_testCount; \ SET_FILE_LINE_NAME(); \ - set_passed((ptr)); \ + set_passed((ptr) != nullptr); \ if(!is_passed()) { \ set_summary(wxString() << #ptr << " is null!"); \ return false; \ diff --git a/wxcrafter/wxcLib/smart_ptr.h b/wxcrafter/wxcLib/smart_ptr.h deleted file mode 100644 index 25907866ae..0000000000 --- a/wxcrafter/wxcLib/smart_ptr.h +++ /dev/null @@ -1,253 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : smart_ptr.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 CODELITE_SMART_PTR_H -#define CODELITE_SMART_PTR_H - -/** - * A smart pointer class that provides a reference counting and auto delete memory. - * - * This class is similar to std::auto_ptr, with 2 exceptions: - * - This class uses reference counting - * - We dont provide a release() function (because of the reference counting) - * It is recommended to use this class instead of using raw pointer wherever possible. - * - * \note smart pointer to NULL is valid. - * - * \ingroup CodeLite - * \version 1.0 - * first version - * \date 09-17-2006 - * \author Eran - */ -template -class SmartPtr -{ - /** - * The reference counting class - * - * \ingroup CodeLite - * \version 1.0 - * first version - * - * \date 09-17-2006 - * \author Eran - */ - class SmartPtrRef - { - T* m_data; - int m_refCount; - - public: - /** - * Construct a reference counting class for row pointer data - * \param data pointer - */ - SmartPtrRef(T* data) - : m_data( data ) - , m_refCount( 1 ) - { - } - - /** - * Destructor - */ - virtual ~SmartPtrRef() - { - delete m_data; - } - - /** - * \return Pointer to the row data - */ - T* GetData() { return m_data; } - - const T* GetData() const { return m_data; } - /** - * Increase reference counting by 1 - */ - void IncRef() { m_refCount ++ ; } - - - /** - * Decrease reference counting by 1 - */ - void DecRef() { m_refCount -- ; } - /** - * Return the current reference counting - * \return current reference counting - */ - int GetRefCount() { return m_refCount; } - }; - - SmartPtrRef *m_ref; - -public: - /** - * Construct smart pointer from ptr - * \param ptr pointer - */ - SmartPtr(T* ptr) - { - // create a fresh copy - CreateFresh( ptr ); - } - - /** - * Default constructor - */ - SmartPtr() - : m_ref(NULL) - { - } - - /** - * Copy constructor - * \param rhs right hand side - */ - SmartPtr(const SmartPtr& rhs) - : m_ref(NULL) - { - *this = rhs; - } - - /** - * Assignment operator - * \param rhs right hand side - * \return reference to this - */ - SmartPtr& operator=(const SmartPtr& rhs) - { - // increase the reference count - if( m_ref == rhs.m_ref ) - return *this; - - // Delete previous reference - DeleteRefCount(); - - if( !rhs.m_ref ) - return *this; - - m_ref = rhs.m_ref; - if (m_ref) { - m_ref->IncRef(); - } - return *this; - } - - /** - * Destructor - */ - virtual ~SmartPtr() - { - DeleteRefCount(); - } - - /** - * Replace the current pointer with ptr - * if the current ptr is not NULL, it will be freed (reference counting free) before assingning the new ptr - * \param ptr new pointer - */ - void reset(T* ptr) - { - DeleteRefCount(); - CreateFresh( ptr ); - } - - /** - * Return pointer the row data pointer - * \return pointer to the row data pointer - */ - T* get() - { - return m_ref->GetData(); - } - - const T* get() const - { - return m_ref->GetData(); - } - /** - * Overload the '->' operator - * \return pointer to the row data pointer - */ - T* operator->() const - { - return m_ref->GetData(); - } - - /** - * Dereference operator - * \return dereference the row data - */ - T& operator*() const - { - return *(m_ref->GetData()); - } - - /** - * Test for NULL operator - * \return true if the internal row data or the reference counting class are NULL false otherwise - */ - bool operator!() const - { - if( !m_ref ) - return true; - - return m_ref->GetData() == NULL; - } - - /** - * test for bool operation - * \return true of the internal raw data exist and it is not null - */ - operator bool() const - { - return m_ref && m_ref->GetData(); - } - -private: - void DeleteRefCount() - { - // decrease the ref count (or delete pointer if it is 1) - if( m_ref ) - { - if( m_ref->GetRefCount() == 1 ) - { - delete m_ref; - m_ref = NULL; - } - else - m_ref->DecRef(); - } - }; - - void CreateFresh(T* ptr) - { - m_ref = new SmartPtrRef( ptr ); - } -}; - - -#endif // CODELITE_SMART_PTR_H diff --git a/wxcrafter/wxcLib/wxcLib.project b/wxcrafter/wxcLib/wxcLib.project index 281b6ff65e..3288747a3a 100644 --- a/wxcrafter/wxcLib/wxcLib.project +++ b/wxcrafter/wxcLib/wxcLib.project @@ -69,7 +69,6 @@ -