remove python2.x support
[blender.git] / source / gameengine / GameLogic / SCA_RandomActuator.cpp
index a272306bd1d3f8f602b4a776c07605a941ad3f43..2b10f49137807116c7f5ff915af0cdf73eda837f 100644 (file)
@@ -315,13 +315,7 @@ void SCA_RandomActuator::enforceConstraints() {
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_RandomActuator::Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
        PyVarObject_HEAD_INIT(NULL, 0)
-#else
-       /* python 2.5 and below */
-       PyObject_HEAD_INIT( NULL )  /* required py macro */
-       0,                          /* ob_size */
-#endif
        "SCA_RandomActuator",
        sizeof(PyObjectPlus_Proxy),
        0,
@@ -331,27 +325,26 @@ PyTypeObject SCA_RandomActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_RandomActuator::Methods[] = {
        //Deprecated functions ------>
-       {"setSeed",         (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc},
-       {"getSeed",         (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_NOARGS, (PY_METHODCHAR)GetSeed_doc},
-       {"getPara1",        (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_NOARGS, (PY_METHODCHAR)GetPara1_doc},
-       {"getPara2",        (PyCFunction) SCA_RandomActuator::sPyGetPara2, METH_NOARGS, (PY_METHODCHAR)GetPara2_doc},
-       {"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_NOARGS, (PY_METHODCHAR)GetDistribution_doc},
-       {"setProperty",     (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
-       {"getProperty",     (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc},
+       {"setSeed",         (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, (const char *)SetSeed_doc},
+       {"getSeed",         (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_NOARGS, (const char *)GetSeed_doc},
+       {"getPara1",        (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_NOARGS, (const char *)GetPara1_doc},
+       {"getPara2",        (PyCFunction) SCA_RandomActuator::sPyGetPara2, METH_NOARGS, (const char *)GetPara2_doc},
+       {"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_NOARGS, (const char *)GetDistribution_doc},
+       {"setProperty",     (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc},
+       {"getProperty",     (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc},
        //<----- Deprecated
        KX_PYMETHODTABLE(SCA_RandomActuator, setBoolConst),
        KX_PYMETHODTABLE_NOARGS(SCA_RandomActuator, setBoolUniform),
@@ -380,14 +373,14 @@ PyAttributeDef SCA_RandomActuator::Attributes[] = {
 PyObject* SCA_RandomActuator::pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_RandomActuator* act = static_cast<SCA_RandomActuator*>(self);
-       return PyInt_FromLong(act->m_base->GetSeed());
+       return PyLong_FromSsize_t(act->m_base->GetSeed());
 }
 
 int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
 {
        SCA_RandomActuator* act = static_cast<SCA_RandomActuator*>(self);
-       if (PyInt_Check(value)) {
-               int ival = PyInt_AsLong(value);
+       if (PyLong_Check(value))        {
+               int ival = PyLong_AsSsize_t(value);
                act->m_base->SetSeed(ival);
                return PY_SET_ATTR_SUCCESS;
        } else {
@@ -422,7 +415,7 @@ const char SCA_RandomActuator::GetSeed_doc[] =
 PyObject* SCA_RandomActuator::PyGetSeed()
 {
        ShowDeprecationWarning("getSeed()", "the seed property");
-       return PyInt_FromLong(m_base->GetSeed());
+       return PyLong_FromSsize_t(m_base->GetSeed());
 }
 
 /* 4. getPara1                                                           */
@@ -456,7 +449,7 @@ const char SCA_RandomActuator::GetDistribution_doc[] =
 PyObject* SCA_RandomActuator::PyGetDistribution()
 {
        ShowDeprecationWarning("getDistribution()", "the distribution property");
-       return PyInt_FromLong(m_distribution);
+       return PyLong_FromSsize_t(m_distribution);
 }
 
 /* 9. setProperty                                                        */
@@ -491,7 +484,7 @@ const char SCA_RandomActuator::GetProperty_doc[] =
 PyObject* SCA_RandomActuator::PyGetProperty()
 {
        ShowDeprecationWarning("getProperty()", "the 'propName' property");
-       return PyString_FromString(m_propname);
+       return PyUnicode_FromString(m_propname);
 }
 
 /* 11. setBoolConst */