Skip to content

Commit

Permalink
Replace SmartPtr by std::shared_ptr/std::unique_ptr.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 authored and eranif committed Apr 6, 2024
1 parent 1fa7ca7 commit c16722e
Show file tree
Hide file tree
Showing 100 changed files with 438 additions and 899 deletions.
2 changes: 1 addition & 1 deletion CMakePlugin/CMake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CMakeBuilder>());
}

/* ************************************************************************ */
Expand Down
1 change: 0 additions & 1 deletion CodeLite/CodeLite.project
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@
<File Name="progress_dialog.h"/>
<File Name="readtags.h"/>
<File Name="singleton.h"/>
<File Name="smart_ptr.h"/>
<File Name="tag_tree.h"/>
<File Name="tokenizer.h"/>
<File Name="tree.h"/>
Expand Down
4 changes: 2 additions & 2 deletions CodeLite/CompletionHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<wxString>& keywords)
Expand Down
4 changes: 2 additions & 2 deletions CodeLite/CxxCodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CodeLite/CxxCodeCompletion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class WXDLLIMPEXP_CL CxxCodeCompletion
TagEntryPtr find_scope_tag(CxxExpression& curexp, const std::vector<wxString>& visible_scopes);
bool is_scope_tag(CxxExpression& curexp, const std::vector<wxString>& 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<wxString>& visible_scopes);
TagEntryPtr on_extern_var(CxxExpression& curexp, TagEntryPtr var, const std::vector<wxString>& visible_scopes);
Expand Down
8 changes: 4 additions & 4 deletions CodeLite/CxxVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include "CxxLexerAPI.h"
#include "codelite_exports.h"
#include "macros.h"
#include "smart_ptr.h"

#include <map>
#include <memory>
#include <set>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -65,9 +65,9 @@ class WXDLLIMPEXP_CL CxxVariable
int m_lineNumber = wxNOT_FOUND;

public:
typedef SmartPtr<CxxVariable> Ptr_t;
typedef std::vector<CxxVariable::Ptr_t> Vec_t;
typedef std::unordered_map<wxString, CxxVariable::Ptr_t> Map_t;
using Ptr_t = std::shared_ptr<CxxVariable>;
using Vec_t = std::vector<CxxVariable::Ptr_t>;
using Map_t = std::unordered_map<wxString, CxxVariable::Ptr_t>;

public:
CxxVariable(eCxxStandard standard);
Expand Down
15 changes: 8 additions & 7 deletions CodeLite/PHPDocVar.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#ifndef PHPDOCVAR_H
#define PHPDOCVAR_H

#include "codelite_exports.h"
#include <wx/string.h>
#include "PHPSourceFile.h"
#include "smart_ptr.h"
#include "codelite_exports.h"

#include <list>
#include <map>
#include "wx/wxsqlite3.h"
#include <memory>
#include <wx/string.h>
#include <wx/wxsqlite3.h>

class WXDLLIMPEXP_CL PHPDocVar
{
Expand All @@ -23,9 +24,9 @@ class WXDLLIMPEXP_CL PHPDocVar
void Parse(PHPSourceFile& sourceFile, const wxString& doc);

public:
typedef SmartPtr<PHPDocVar> Ptr_t;
typedef std::list<PHPDocVar::Ptr_t> List_t;
typedef std::map<wxString, PHPDocVar::Ptr_t> Map_t;
using Ptr_t = std::shared_ptr<PHPDocVar>;
using List_t = std::list<PHPDocVar::Ptr_t>;
using Map_t = std::map<wxString, PHPDocVar::Ptr_t>;

public:
PHPDocVar(PHPSourceFile& sourceFile, const wxString& doc);
Expand Down
2 changes: 1 addition & 1 deletion CodeLite/PHPDocVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PHPEntityVariable>();
child->SetFilename(m_sourceFile.GetFilename());
child->SetLine(entity->GetLine());
child->Cast<PHPEntityVariable>()->SetTypeHint(p.second.type);
Expand Down
25 changes: 13 additions & 12 deletions CodeLite/PHPEntityBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@
#ifndef PHPENTITYIMPL_H
#define PHPENTITYIMPL_H

#include "JSON.h"
#include "codelite_exports.h"
#include <wx/sharedptr.h>
#include "commentconfigdata.h"
#include "wxStringHash.h"

#include <iostream>
#include <list>
#include <map>
#include <wx/string.h>
#include <iostream>
#include <memory>
#include <set>
#include <wx/filename.h>
#include "wx/wxsqlite3.h"
#include <wx/sharedptr.h>
#include <wx/string.h>
#include <wx/wxcrtvararg.h> // Needed for wxPrintf
#include "smart_ptr.h"
#include <set>
#include "commentconfigdata.h"
#include "wxStringHash.h"
#include "JSON.h"
#include <wx/wxsqlite3.h>

// The entity type
class WXDLLIMPEXP_CL PHPLookupTable;
Expand Down Expand Up @@ -88,9 +89,9 @@ enum {
class WXDLLIMPEXP_CL PHPEntityBase
{
public:
typedef SmartPtr<PHPEntityBase> Ptr_t;
typedef std::vector<PHPEntityBase::Ptr_t> List_t;
typedef std::unordered_map<wxString, PHPEntityBase::Ptr_t> Map_t;
using Ptr_t = std::shared_ptr<PHPEntityBase>;
using List_t = std::vector<PHPEntityBase::Ptr_t>;
using Map_t = std::unordered_map<wxString, PHPEntityBase::Ptr_t>;

protected:
PHPEntityBase::Map_t m_childrenMap;
Expand Down
2 changes: 1 addition & 1 deletion CodeLite/PHPEntityFunctionAlias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PHPEntityFunction>();
m_func->FromJSON(func);
}
}
Expand Down
15 changes: 7 additions & 8 deletions CodeLite/PHPLookupTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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<PHPEntityNamespace>();
} else {
// class
match.Reset(new PHPEntityClass());
match = std::make_shared<PHPEntityClass>();
}
match->FromResultSet(res);
}
Expand Down Expand Up @@ -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<PHPEntityNamespace>();
} else {
// class
match.Reset(new PHPEntityClass());
match = std::make_shared<PHPEntityClass>();
}
match->FromResultSet(res);
return match;
Expand Down Expand Up @@ -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<PHPEntityFunction>();
match->FromResultSet(res);
}
return match;
Expand Down Expand Up @@ -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<PHPEntityNamespace>();
pNamespace->SetFullName(nameSpaceName);
pNamespace->SetShortName(nameSpaceName.AfterLast('\\'));
pNamespace->SetFilename(define->GetFilename());
Expand Down Expand Up @@ -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<PHPEntityFunction>();
match->FromResultSet(res);
}
return match;
Expand Down
5 changes: 2 additions & 3 deletions CodeLite/PHPLookupTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@
#include "file_logger.h"
#include "fileextmanager.h"
#include "fileutils.h"
#include "smart_ptr.h"
#include "wx/wxsqlite3.h"

#include <set>
#include <unordered_set>
#include <vector>
#include <wx/longlong.h>
#include <wx/stopwatch.h>
#include <wx/string.h>
#include <wx/wxsqlite3.h>
#include <wxStringHash.h>

wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxPHP_PARSE_STARTED, clParseEvent);
Expand Down Expand Up @@ -89,7 +88,7 @@ class WXDLLIMPEXP_CL PHPLookupTable
kUpdateMode_Fast,
kUpdateMode_Full,
};
typedef SmartPtr<PHPLookupTable> Ptr_t;

static void DoSplitFullname(const wxString& fullname, wxString& ns, wxString& shortName);

private:
Expand Down
6 changes: 3 additions & 3 deletions CodeLite/PHPSourceFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PHPEntityClass>();
if(cls) {
Expand Down Expand Up @@ -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<PHPEntityVariable>();
member->Cast<PHPEntityVariable>()->SetFlag(kVar_Const);
member->Cast<PHPEntityVariable>()->SetFlag(kVar_Member);
member->SetFullName(token.Text());
Expand Down
5 changes: 3 additions & 2 deletions CodeLite/cl_calltip.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@

#include "codelite_exports.h"
#include "entry.h"
#include "smart_ptr.h"
#include "tokenizer.h"

#include <memory>

struct clTipInfo {
wxString str;
std::vector<std::pair<int, int>> paramLen;
Expand Down Expand Up @@ -144,5 +145,5 @@ class WXDLLIMPEXP_CL clCallTip
wxString TipAt(int at);
};

typedef SmartPtr<clCallTip> clCallTipPtr;
using clCallTipPtr = std::shared_ptr<clCallTip>;
#endif // CODELITE_CALLTIP_H
4 changes: 2 additions & 2 deletions CodeLite/comment.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#ifndef CODELITE_COMMENT_H
#define CODELITE_COMMENT_H

#include <memory>
#include <wx/string.h>
#include "smart_ptr.h"

class Comment
{
Expand Down Expand Up @@ -82,6 +82,6 @@ class Comment
}
};

typedef SmartPtr<Comment> CommentPtr;
using CommentPtr = std::unique_ptr<Comment>;

#endif // CODELITE_COMMENT_H
8 changes: 3 additions & 5 deletions CodeLite/comment_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@
#ifndef COMMENT_PARSER_H
#define COMMENT_PARSER_H

#include "codelite_exports.h"

#include <map>
#include <string>
#include "codelite_exports.h"
#include "smart_ptr.h"

class WXDLLIMPEXP_CL CommentParseResult
{
private:
std::map<size_t, std::string> m_comments;
std::string m_filename;
public:
typedef SmartPtr<CommentParseResult> Ptr_t;


public:
void addComment(const std::string& comment, size_t line, bool cppComment)
{
Expand Down
7 changes: 4 additions & 3 deletions CodeLite/cpp_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
#define CODELITE_CPPSCANNER_H

#include "FlexLexer.h"
#include "smart_ptr.h"
#include "codelite_exports.h"
#include "codelite_exports.h"

#include <memory>

class WXDLLIMPEXP_CL CppScanner : public flex::yyFlexLexer
{
Expand Down Expand Up @@ -61,5 +62,5 @@ class WXDLLIMPEXP_CL CppScanner : public flex::yyFlexLexer
int m_curr;
};

typedef SmartPtr<CppScanner> CppScannerPtr;
using CppScannerPtr = std::unique_ptr<CppScanner>;
#endif // CODELITE_CPPSCANNER_H
13 changes: 7 additions & 6 deletions CodeLite/cppwordscanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
#ifndef __cppwordscanner__
#define __cppwordscanner__

#include <wx/arrstr.h>
#include <vector>
#include "cpptoken.h"
#include "smart_ptr.h"
#include "codelite_exports.h"
#include <set>
#include "cpptoken.h"
#include "macros.h"
#include "wxStringHash.h"

#include <memory>
#include <set>
#include <vector>
#include <wx/arrstr.h>

struct ByteState {
short state; // Holds the current byte state (one of CppWordScanner::STATE_*)
short depth; // The current char depth
Expand Down Expand Up @@ -83,7 +84,7 @@ class WXDLLIMPEXP_CL TextStates
int LineToPos(int lineNo);
};

typedef SmartPtr<TextStates> TextStatesPtr;
using TextStatesPtr = std::shared_ptr<TextStates>;

class WXDLLIMPEXP_CL CppWordScanner
{
Expand Down

0 comments on commit c16722e

Please sign in to comment.