diff --git a/modules/modpython.cpp b/modules/modpython.cpp index 635f2f11..4c8a88b0 100644 --- a/modules/modpython.cpp +++ b/modules/modpython.cpp @@ -17,16 +17,7 @@ #include "modpython/swigpyrun.h" #include "modpython/module.h" - -class CPyRetString { -public: - CString& s; - CPyRetString(CString& S) : s(S) {} - static PyObject* wrap(CString& S) { - CPyRetString* x = new CPyRetString(S); - return SWIG_NewInstanceObj(x, SWIG_TypeQuery("CPyRetString*"), SWIG_POINTER_OWN); - } -}; +#include "modpython/retstring.h" class CModPython: public CGlobalModule { diff --git a/modules/modpython/modpython.i b/modules/modpython/modpython.i index 263f6ce8..9419bed7 100644 --- a/modules/modpython/modpython.i +++ b/modules/modpython/modpython.i @@ -28,15 +28,7 @@ #include "../FileUtils.h" #include "modpython/module.h" -class CPyRetString { -public: - CString& s; - CPyRetString(CString& S) : s(S) {} - static PyObject* wrap(CString& S) { - CPyRetString* x = new CPyRetString(S); - return SWIG_NewInstanceObj(x, SWIG_TypeQuery("CPyRetString*"), SWIG_POINTER_OWN); - } -}; +#include "modpython/retstring.h" #define stat struct stat using std::allocator; @@ -61,21 +53,6 @@ namespace std { %include "modpython/cstring.i" %template(_stringlist) std::list; -/*%typemap(out) std::list { - std::list::const_iterator i; - unsigned int j; - int len = $1.size(); - SV **svs = new SV*[len]; - for (i=$1.begin(), j=0; i!=$1.end(); i++, j++) { - svs[j] = sv_newmortal(); - SwigSvFromString(svs[j], *i); - } - AV *myav = av_make(len, svs); - delete[] svs; - $result = newRV_noinc((SV*) myav); - sv_2mortal($result); - argvi++; -}*/ %typemap(out) CModules::ModDirList %{ $result = PyList_New($1.size()); diff --git a/modules/modpython/retstring.h b/modules/modpython/retstring.h new file mode 100644 index 00000000..a562c8f3 --- /dev/null +++ b/modules/modpython/retstring.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2004-2011 See the AUTHORS file for details. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#pragma once + +class CPyRetString { +public: + CString& s; + CPyRetString(CString& S) : s(S) {} + static PyObject* wrap(CString& S) { + CPyRetString* x = new CPyRetString(S); + return SWIG_NewInstanceObj(x, SWIG_TypeQuery("CPyRetString*"), SWIG_POINTER_OWN); + } +}; + +