Permalink
Browse files

Protect CreatePyModule from CModule*

  • Loading branch information...
1 parent 62c9ac1 commit 85252f2f5bfc97ab4b2de795eb885b9ebb8e032d @DarthGandalf DarthGandalf committed Jul 26, 2012
Showing with 4 additions and 4 deletions.
  1. +1 −1 modules/modpython.cpp
  2. +3 −3 modules/modpython/module.h
View
@@ -146,7 +146,7 @@ class CModPython: public CModule {
(eType == CModInfo::GlobalModule ? Py_None : SWIG_NewInstanceObj(GetUser(), SWIG_TypeQuery("CUser*"), 0)),
(eType == CModInfo::NetworkModule ? SWIG_NewInstanceObj(GetNetwork(), SWIG_TypeQuery("CIRCNetwork*"), 0) : Py_None),
CPyRetString::wrap(sRetMsg),
- SWIG_NewInstanceObj(reinterpret_cast<CModule*>(this), SWIG_TypeQuery("CModule*"), 0));
+ SWIG_NewInstanceObj(reinterpret_cast<CModule*>(this), SWIG_TypeQuery("CModPython*"), 0));
if (!pyRes) {
sRetMsg = GetPyExceptionStr();
DEBUG("modpython: " << sRetMsg);
@@ -24,11 +24,11 @@ class CPyModule : public CModule {
VWebSubPages* _GetSubPages();
public:
CPyModule(CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, const CString& sDataPath,
- PyObject* pyObj, CModule* pModPython)
+ PyObject* pyObj, CModPython* pModPython)
: CModule(NULL, pUser, pNetwork, sModName, sDataPath) {
m_pyObj = pyObj;
Py_INCREF(pyObj);
- m_pModPython = reinterpret_cast<CModPython*>(pModPython);
+ m_pModPython = pModPython;
}
PyObject* GetPyObj() { // borrows
return m_pyObj;
@@ -128,7 +128,7 @@ static inline CPyModule* AsPyModule(CModule* p) {
return dynamic_cast<CPyModule*>(p);
}
-inline CPyModule* CreatePyModule(CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, const CString& sDataPath, PyObject* pyObj, CModule* pModPython) {
+inline CPyModule* CreatePyModule(CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, const CString& sDataPath, PyObject* pyObj, CModPython* pModPython) {
return new CPyModule(pUser, pNetwork, sModName, sDataPath, pyObj, pModPython);
}

0 comments on commit 85252f2

Please sign in to comment.