BGE Py API using python3 c/api calls. include bpy_compat.h to support py2.x

This commit is contained in:
2009-06-29 02:25:54 +00:00
parent bb1f24ac44
commit c50bbe5ae7
66 changed files with 317 additions and 325 deletions

View File

@@ -148,7 +148,7 @@ void SCA_PythonController::SetDictionary(PyObject* pythondictionary)
/* Without __file__ set the sys.argv[0] is used for the filename
* which ends up with lines from the blender binary being printed in the console */
PyDict_SetItemString(m_pythondictionary, "__file__", PyString_FromString(m_scriptName.Ptr()));
PyDict_SetItemString(m_pythondictionary, "__file__", PyUnicode_FromString(m_scriptName.Ptr()));
}
@@ -178,9 +178,9 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
std::vector<SCA_IActuator*> lacts = m_sCurrentController->GetLinkedActuators();
std::vector<SCA_IActuator*>::iterator it;
if (PyString_Check(value)) {
if (PyUnicode_Check(value)) {
/* get the actuator from the name */
char *name= PyString_AsString(value);
char *name= _PyUnicode_AsString(value);
for(it = lacts.begin(); it!= lacts.end(); ++it) {
if( name == (*it)->GetName() ) {
return *it;
@@ -198,7 +198,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
/* set the exception */
PyObject *value_str = PyObject_Repr(value); /* new ref */
PyErr_Format(PyExc_ValueError, "'%s' not in this python controllers actuator list", PyString_AsString(value_str));
PyErr_Format(PyExc_ValueError, "'%s' not in this python controllers actuator list", _PyUnicode_AsString(value_str));
Py_DECREF(value_str);
return false;
@@ -521,13 +521,13 @@ PyObject* SCA_PythonController::PyDeActivate(PyObject *value)
PyObject* SCA_PythonController::PyGetScript()
{
ShowDeprecationWarning("getScript()", "the script property");
return PyString_FromString(m_scriptText);
return PyUnicode_FromString(m_scriptText);
}
/* 2. setScript */
PyObject* SCA_PythonController::PySetScript(PyObject* value)
{
char *scriptArg = PyString_AsString(value);
char *scriptArg = _PyUnicode_AsString(value);
ShowDeprecationWarning("setScript()", "the script property");
@@ -550,7 +550,7 @@ PyObject* SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRI
// static_cast<void *>(dynamic_cast<Derived *>(obj)) - static_cast<void *>(obj)
SCA_PythonController* self= static_cast<SCA_PythonController*>(self_v);
return PyString_FromString(self->m_scriptText);
return PyUnicode_FromString(self->m_scriptText);
}
@@ -559,7 +559,7 @@ int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_D
{
SCA_PythonController* self= static_cast<SCA_PythonController*>(self_v);
char *scriptArg = PyString_AsString(value);
char *scriptArg = _PyUnicode_AsString(value);
if (scriptArg==NULL) {
PyErr_SetString(PyExc_TypeError, "controller.script = string: Python Controller, expected a string script text");