modpython: Switch from CSmartPtr to std::shared_ptr

Patch by DarthGandalf, I just committed it to git.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2014-09-15 12:07:13 +02:00
parent 62328b2c96
commit de96cd95d0
5 changed files with 8 additions and 7 deletions

View File

@@ -292,7 +292,7 @@ while (<$in>) {
say $out "Py_BuildValue(\"l\", (long int)$a->{var});";
}
}
when (/^CSmartPtr/) {
when (/^std::shared_ptr/) {
say $out "SWIG_NewInstanceObj(new $a->{type}($a->{var}), SWIG_TypeQuery(\"$a->{type}*\"), SWIG_POINTER_OWN);";
}
when (/\*$/) {

View File

@@ -78,4 +78,4 @@ EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg)
EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule, bool& bSuccess, CString& sRetMsg)
void OnGetAvailableMods(std::set<CModInfo>& ssMods, CModInfo::EModuleType eType)
void OnClientCapLs(CClient* pClient, SCString& ssCaps)
EModRet OnLoginAttempt(CSmartPtr<CAuthBase> Auth)
EModRet OnLoginAttempt(std::shared_ptr<CAuthBase> Auth)

View File

@@ -58,6 +58,7 @@ using std::allocator;
%include <std_list.i>
%include <std_set.i>
%include <std_deque.i>
%include <std_shared_ptr.i>
%include "modpython/cstring.i"
%template(_stringlist) std::list<CString>;
@@ -129,8 +130,8 @@ class MCString : public std::map<CString, CString> {};
%include "../include/znc/defines.h"
%include "../include/znc/Utils.h"
%include "../include/znc/Threads.h"
%template(PAuthBase) CSmartPtr<CAuthBase>;
%template(WebSession) CSmartPtr<CWebSession>;
%template(PAuthBase) std::shared_ptr<CAuthBase>;
%template(WebSession) std::shared_ptr<CWebSession>;
%include "../include/znc/Config.h"
%include "../include/znc/Csocket.h"
%template(ZNCSocketManager) TSocketManager<CZNCSock>;
@@ -308,7 +309,7 @@ typedef std::vector<std::pair<CString, CString> > VPair;
%inline %{
TWebSubPage CreateWebSubPage_(const CString& sName, const CString& sTitle, const VPair& vParams, unsigned int uFlags) {
return new CWebSubPage(sName, sTitle, vParams, uFlags);
return std::make_shared<CWebSubPage>(sName, sTitle, vParams, uFlags);
}
%}

View File

@@ -137,7 +137,7 @@ public:
bool& bSuccess, CString& sRetMsg);
virtual void OnGetAvailableMods(std::set<CModInfo>& ssMods, CModInfo::EModuleType eType);
virtual void OnClientCapLs(CClient* pClient, SCString& ssCaps);
virtual EModRet OnLoginAttempt(CSmartPtr<CAuthBase> Auth);
virtual EModRet OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
};
static inline CPyModule* AsPyModule(CModule* p) {