Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-04-04 06:57:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-04 06:57:35 +0400
commit6be69211843ee37ab9be763df0621db94dbfd69b (patch)
treee4efbb5bc2b60986bac5276881e11e54fdd5fb7d /source/gameengine/GameLogic/SCA_RandomSensor.cpp
parent29f5c7dd5d0871835e4d50b2b3018b9a24a93350 (diff)
moved more attributes from getattr into PyAttributeDef's
Diffstat (limited to 'source/gameengine/GameLogic/SCA_RandomSensor.cpp')
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
index 84a9ef95e84..bdee64430fa 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
@@ -162,6 +162,7 @@ PyMethodDef SCA_RandomSensor::Methods[] = {
PyAttributeDef SCA_RandomSensor::Attributes[] = {
KX_PYATTRIBUTE_BOOL_RO("lastDraw",SCA_RandomSensor,m_lastdraw),
+ KX_PYATTRIBUTE_RW_FUNCTION("seed", SCA_RandomSensor, pyattr_get_seed, pyattr_set_seed),
{NULL} //Sentinel
};
@@ -169,11 +170,6 @@ PyObject* SCA_RandomSensor::py_getattro(PyObject *attr) {
PyObject* object = py_getattro_self(Attributes, this, attr);
if (object != NULL)
return object;
-
- char *attr_str= PyString_AsString(attr);
- if (!strcmp(attr_str,"seed")) {
- return PyInt_FromLong(m_basegenerator->GetSeed());
- }
py_getattro_up(SCA_ISensor);
}
@@ -182,17 +178,6 @@ int SCA_RandomSensor::py_setattro(PyObject *attr, PyObject *value)
int ret = py_setattro_self(Attributes, this, attr, value);
if (ret >= 0)
return ret;
- char *attr_str= PyString_AsString(attr);
- if (!strcmp(attr_str,"seed")) {
- if (PyInt_Check(value)) {
- int ival = PyInt_AsLong(value);
- m_basegenerator->SetSeed(ival);
- return 0;
- } else {
- PyErr_SetString(PyExc_TypeError, "expected an integer");
- return 1;
- }
- }
return SCA_ISensor::py_setattro(attr, value);
}
@@ -234,4 +219,22 @@ PyObject* SCA_RandomSensor::PyGetLastDraw(PyObject* self, PyObject* args, PyObje
return PyInt_FromLong(m_lastdraw);
}
+
+PyObject* SCA_RandomSensor::pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v);
+ return PyInt_FromLong(self->m_basegenerator->GetSeed());
+}
+
+int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v);
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "expected an integer");
+ return -1;
+ }
+ self->m_basegenerator->SetSeed(PyInt_AsLong(value));
+ return 0;
+}
+
/* eof */