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-07 15:06:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-07 15:06:35 +0400
commit5d64dd019e7e8150db40505097d1b4048f4e0153 (patch)
tree65d3ac2f7d7d8a9e3aad5ba5331c43a5d1fca358 /source/gameengine/GameLogic
parentc054ea02039e9209095108c1b1f42250a7e85d8f (diff)
BGE Python API
Use each types dictionary to store attributes PyAttributeDef's so it uses pythons hash lookup (which it was already doing for methods) rather then doing a string lookup on the array each time. This also means attributes can be found in the type without having to do a dir() on the instance.
Diffstat (limited to 'source/gameengine/GameLogic')
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.cpp16
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp10
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp10
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp8
12 files changed, 17 insertions, 91 deletions
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
index ed7aa66d04b..945d473f937 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
@@ -162,10 +162,11 @@ PyAttributeDef SCA_ActuatorSensor::Attributes[] = {
};
PyObject* SCA_ActuatorSensor::py_getattro(PyObject *attr) {
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
- py_getattro_up(SCA_ISensor); /* implicit return! */
+ py_getattro_up(SCA_ISensor);
+}
+
+int SCA_ActuatorSensor::py_setattro(PyObject *attr, PyObject *value) {
+ py_setattro_up(SCA_ISensor);
}
int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
@@ -180,13 +181,6 @@ int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
return 1;
}
-int SCA_ActuatorSensor::py_setattro(PyObject *attr, PyObject *value) {
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_ISensor::py_setattro(attr, value);
-}
-
/* 3. getActuator */
const char SCA_ActuatorSensor::GetActuator_doc[] =
"getActuator()\n"
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
index 5082caacfd5..25161d21e72 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
@@ -179,17 +179,11 @@ PyAttributeDef SCA_DelaySensor::Attributes[] = {
};
PyObject* SCA_DelaySensor::py_getattro(PyObject *attr) {
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
py_getattro_up(SCA_ISensor);
}
int SCA_DelaySensor::py_setattro(PyObject *attr, PyObject *value) {
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_ISensor::py_setattro(attr, value);
+ py_setattro_up(SCA_ISensor);
}
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
index 45ebd874ea5..4b1f8b52bf5 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
@@ -280,18 +280,12 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef)
PyObject*
SCA_ILogicBrick::py_getattro(PyObject *attr)
{
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
py_getattro_up(CValue);
}
int SCA_ILogicBrick::py_setattro(PyObject *attr, PyObject *value)
{
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return CValue::py_setattro(attr, value);
+ py_setattro_up(CValue);
}
diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp
index a4f493d82c8..80d42d8344d 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ISensor.cpp
@@ -462,18 +462,12 @@ PyAttributeDef SCA_ISensor::Attributes[] = {
PyObject*
SCA_ISensor::py_getattro(PyObject *attr)
{
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
py_getattro_up(SCA_ILogicBrick);
}
int SCA_ISensor::py_setattro(PyObject *attr, PyObject *value)
{
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_ILogicBrick::py_setattro(attr, value);
+ py_setattro_up(SCA_ILogicBrick);
}
PyObject* SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index 1290b7c96ed..3df9b454b1d 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -336,18 +336,12 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
PyObject* SCA_JoystickSensor::py_getattro(PyObject *attr)
{
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
py_getattro_up(SCA_ISensor);
}
int SCA_JoystickSensor::py_setattro(PyObject *attr, PyObject *value)
{
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_ISensor::py_setattro(attr, value);
+ py_setattro_up(SCA_ISensor);
}
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index fc1b5be3540..3749bf2eda0 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -833,16 +833,10 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
PyObject*
SCA_KeyboardSensor::py_getattro(PyObject *attr)
{
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
py_getattro_up(SCA_ISensor);
}
int SCA_KeyboardSensor::py_setattro(PyObject *attr, PyObject *value)
{
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_ISensor::py_setattro(attr, value);
+ py_setattro_up(SCA_ISensor);
}
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
index 3cd32391ce2..86e64491f6a 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
@@ -343,18 +343,12 @@ PyAttributeDef SCA_MouseSensor::Attributes[] = {
PyObject* SCA_MouseSensor::py_getattro(PyObject *attr)
{
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
py_getattro_up(SCA_ISensor);
}
int SCA_MouseSensor::py_setattro(PyObject *attr, PyObject *value)
{
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_ISensor::py_setattro(attr, value);
+ py_setattro_up(SCA_ISensor);
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index e1f303430ec..fa8763a3932 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -261,17 +261,11 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = {
};
PyObject* SCA_PropertyActuator::py_getattro(PyObject *attr) {
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
py_getattro_up(SCA_IActuator);
}
int SCA_PropertyActuator::py_setattro(PyObject *attr, PyObject *value) {
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_IActuator::py_setattro(attr, value);
+ py_setattro_up(SCA_IActuator);
}
/* 1. setProperty */
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
index 659823f6fba..164e94b6597 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
@@ -353,17 +353,11 @@ PyAttributeDef SCA_PropertySensor::Attributes[] = {
PyObject* SCA_PropertySensor::py_getattro(PyObject *attr) {
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
- py_getattro_up(SCA_ISensor); /* implicit return! */
+ py_getattro_up(SCA_ISensor);
}
int SCA_PropertySensor::py_setattro(PyObject *attr, PyObject *value) {
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_ISensor::py_setattro(attr, value);
+ py_setattro_up(SCA_ISensor);
}
/* 1. getType */
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index 4b9248a908f..3c2a1d09f82 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -376,20 +376,12 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
PyObject* SCA_PythonController::py_getattro(PyObject *attr)
{
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
-
py_getattro_up(SCA_IController);
}
int SCA_PythonController::py_setattro(PyObject *attr, PyObject *value)
{
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
-
- return SCA_IController::py_setattro(attr, value);
+ py_setattro_up(SCA_IController);
}
PyObject* SCA_PythonController::PyActivate(PyObject* self, PyObject *value)
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index 7af116fad99..b1c0c7fec99 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
@@ -392,18 +392,12 @@ int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_
}
PyObject* SCA_RandomActuator::py_getattro(PyObject *attr) {
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
py_getattro_up(SCA_IActuator);
}
int SCA_RandomActuator::py_setattro(PyObject *attr, PyObject *value)
{
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_IActuator::py_setattro(attr, value);
+ py_setattro_up(SCA_IActuator);
}
/* 1. setSeed */
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
index bdee64430fa..fe4d88e2797 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
@@ -167,18 +167,12 @@ PyAttributeDef SCA_RandomSensor::Attributes[] = {
};
PyObject* SCA_RandomSensor::py_getattro(PyObject *attr) {
- PyObject* object = py_getattro_self(Attributes, this, attr);
- if (object != NULL)
- return object;
py_getattro_up(SCA_ISensor);
}
int SCA_RandomSensor::py_setattro(PyObject *attr, PyObject *value)
{
- int ret = py_setattro_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
- return SCA_ISensor::py_setattro(attr, value);
+ py_setattro_up(SCA_ISensor);
}
/* 1. setSeed */