Fix several issues in modpython.

1. In several cases CString wasn't handled properly.
2. Some container-like object didn't return from functions properly.
3. Buffer.h was missing
This commit is contained in:
Alexey Sokolov
2012-01-02 14:39:17 +07:00
parent 13bfec0809
commit f374874b1a
3 changed files with 32 additions and 3 deletions

View File

@@ -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<CString> {
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@*/;

View File

@@ -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<CIRCNetwork*>;
%template(VChannels) std::vector<CChan*>;
%template(MNicks) std::map<CString, CNick>;
%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 "<CUser " + $self->GetUserName() + ">";
}
std::vector<CIRCNetwork*> GetNetworks_() {
return $self->GetNetworks();
}
};
%extend CIRCNetwork {
@@ -176,6 +185,9 @@ public:
CString __repr__() {
return "<CIRCNetwork " + $self->GetName() + ">";
}
std::vector<CChan*> GetChans_() {
return $self->GetChans();
}
}
%extend CChan {
@@ -185,6 +197,9 @@ public:
CString __repr__() {
return "<CChan " + $self->GetName() + ">";
}
std::map<CString, CNick> GetNicks_() {
return $self->GetNicks();
}
};
%extend CNick {

View File

@@ -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_