diff --git a/modules/modpython/cstring.i b/modules/modpython/cstring.i index 925000a2..8afb4348 100644 --- a/modules/modpython/cstring.i +++ b/modules/modpython/cstring.i @@ -69,7 +69,7 @@ SWIG_AsVal_std_string (PyObject * obj, CString *val) } /*@SWIG@*/ /*@SWIG:/usr/share/swig1.3/typemaps/std_strings.swg,38,%std_string_from@*/ -%fragment("SWIG_" "From" "_" {CString},"header",fragment="SWIG_FromCharPtrAndSize") { +%fragment("SWIG_" "From" "_" {CString},"header",fragment="SWIG_FromCharPtrAndSize",fragment="StdTraits") { SWIGINTERNINLINE PyObject * SWIG_From_std_string (const CString& s) { @@ -82,6 +82,17 @@ SWIG_From_std_string (const CString& s) } /*@SWIG@*/ +%fragment("StdTraitsCString","header",fragment="SWIG_From_CString") { + namespace swig { + template<> struct traits_from { + static PyObject *from(const CString& s) { + return SWIG_From_std_string(s); + } + }; + } +} + + /*@SWIG:/usr/share/swig1.3/typemaps/ptrtypes.swg,204,%typemaps_asptrfromn@*/ /*@SWIG:/usr/share/swig1.3/typemaps/ptrtypes.swg,193,%typemaps_asptrfrom@*/ /*@SWIG:/usr/share/swig1.3/typemaps/ptrtypes.swg,163,%typemaps_asptr@*/ @@ -104,7 +115,7 @@ SWIG_From_std_string (const CString& s) } } /*@SWIG:/usr/share/swig1.3/typemaps/ptrtypes.swg,31,%ptr_in_typemap@*/ - %typemap(in,fragment="SWIG_" "AsPtr" "_" {CString}) CString { + %typemap(in,fragment="SWIG_" "AsPtr" "_" {CString},fragment="StdTraitsCString") CString { CString *ptr = (CString *)0; int res = SWIG_AsPtr_std_string($input, &ptr); if (!SWIG_IsOK(res) || !ptr) { @@ -329,4 +340,3 @@ SWIG_From_std_string (const CString& s) /*@SWIG@*/; - diff --git a/modules/modpython/modpython.i b/modules/modpython/modpython.i index 4c574447..df2cd6a5 100644 --- a/modules/modpython/modpython.i +++ b/modules/modpython/modpython.i @@ -28,6 +28,7 @@ #include "../include/znc/FileUtils.h" #include "../include/znc/ZNCDebug.h" #include "../include/znc/ExecSock.h" +#include "../include/znc/Buffer.h" #include "modpython/module.h" #include "modpython/retstring.h" @@ -67,6 +68,10 @@ namespace std { } %} +%template(VIRCNetworks) std::vector; +%template(VChannels) std::vector; +%template(MNicks) std::map; + %typemap(in) CString& { String* p; int res = SWIG_IsOK(SWIG_ConvertPtr($input, (void**)&p, SWIG_TypeQuery("String*"), 0)); @@ -111,6 +116,7 @@ namespace std { %include "../include/znc/Server.h" %include "../include/znc/ZNCDebug.h" %include "../include/znc/ExecSock.h" +%include "../include/znc/Buffer.h" %include "modpython/module.h" @@ -167,6 +173,9 @@ public: CString __repr__() { return "GetUserName() + ">"; } + std::vector GetNetworks_() { + return $self->GetNetworks(); + } }; %extend CIRCNetwork { @@ -176,6 +185,9 @@ public: CString __repr__() { return "GetName() + ">"; } + std::vector GetChans_() { + return $self->GetChans(); + } } %extend CChan { @@ -185,6 +197,9 @@ public: CString __repr__() { return "GetName() + ">"; } + std::map GetNicks_() { + return $self->GetNicks(); + } }; %extend CNick { diff --git a/modules/modpython/znc.py b/modules/modpython/znc.py index 5deb020a..fb0741d8 100644 --- a/modules/modpython/znc.py +++ b/modules/modpython/znc.py @@ -604,3 +604,7 @@ def CreateWebSubPage(name, title='', params=dict(), admin=False): if admin: flags |= CWebSubPage.F_ADMIN return CreateWebSubPage_(name, title, vpair, flags) + +CUser.GetNetworks = CUser.GetNetworks_ +CIRCNetwork.GetChans = CIRCNetwork.GetChans_ +CChan.GetNicks = CChan.GetNicks_