diff options
Diffstat (limited to 'source/gameengine/GameLogic/SCA_PythonController.cpp')
-rw-r--r-- | source/gameengine/GameLogic/SCA_PythonController.cpp | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 1f05846abe4..4e021141f22 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -1,4 +1,4 @@ -/** +/* * Execute Python scripts * * $Id$ @@ -29,16 +29,23 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file gameengine/GameLogic/SCA_PythonController.cpp + * \ingroup gamelogic + */ + + +#include <stddef.h> + #include "SCA_PythonController.h" #include "SCA_LogicManager.h" #include "SCA_ISensor.h" #include "SCA_IActuator.h" #include "PyObjectPlus.h" -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "compile.h" #include "eval.h" -#endif // DISABLE_PYTHON +#endif // WITH_PYTHON #include <algorithm> @@ -49,7 +56,7 @@ SCA_PythonController* SCA_PythonController::m_sCurrentController = NULL; SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode) : SCA_IController(gameobj), -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON m_bytecode(NULL), m_function(NULL), #endif @@ -57,7 +64,7 @@ SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode) m_bModified(true), m_debug(false), m_mode(mode) -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON , m_pythondictionary(NULL) #endif @@ -84,7 +91,7 @@ int SCA_PythonController::Release() SCA_PythonController::~SCA_PythonController() { -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON //printf("released python byte script\n"); Py_XDECREF(m_bytecode); @@ -104,7 +111,7 @@ CValue* SCA_PythonController::GetReplica() { SCA_PythonController* replica = new SCA_PythonController(*this); -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON /* why is this needed at all??? - m_bytecode is NULL'd below so this doesnt make sense * but removing it crashes blender (with YoFrankie). so leave in for now - Campbell */ Py_XINCREF(replica->m_bytecode); @@ -146,7 +153,7 @@ void SCA_PythonController::SetScriptName(const STR_String& name) } -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON void SCA_PythonController::SetNamespace(PyObject* pythondictionary) { if (m_pythondictionary) @@ -171,7 +178,7 @@ int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor) return 0; } -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON /* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */ PyObject* SCA_PythonController::sPyGetCurrentController(PyObject *self) @@ -214,7 +221,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value) PyErr_Format(PyExc_ValueError, "'%s' not in this python controllers actuator list", _PyUnicode_AsString(value_str)); Py_DECREF(value_str); - return false; + return NULL; } const char* SCA_PythonController::sPyGetCurrentController__doc__ = "getCurrentController()"; @@ -408,7 +415,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) */ excdict= PyDict_Copy(m_pythondictionary); - resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode, excdict, excdict); + +#if PY_VERSION_HEX >= 0x03020000 + resultobj = PyEval_EvalCode((PyObject *)m_bytecode, excdict, excdict); +#else + resultobj = PyEval_EvalCode((PyCodeObject *)m_bytecode, excdict, excdict); +#endif + /* PyRun_SimpleString(m_scriptText.Ptr()); */ break; } @@ -527,13 +540,13 @@ int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_D return PY_SET_ATTR_SUCCESS; } -#else // DISABLE_PYTHON +#else // WITH_PYTHON void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) { /* intentionally blank */ } -#endif // DISABLE_PYTHON +#endif // WITH_PYTHON /* eof */ |