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-18 00:06:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-18 00:06:06 +0400
commitdf8cf26404c7e922751643b1095e38f1ab430811 (patch)
treeb4258cc6c90913c379f5cdd05edebd8785230647 /source/gameengine/Ketsji/KX_Scene.cpp
parent90c6cf77f10961de756f6ff06329d3fa65ce3da4 (diff)
Added m_zombie to the base python class (PyObjectPlus), when this is set all the subclasses will raise an error on access to their members.
Other small changes... - KX_Camera and KX_Light didnt have get/setitem access in their PyType definition. - CList.from_id() error checking for a long was checking for -1 against an unsigned value (own fault) - CValue::SpecialRelease was incrementing an int for no reason. - renamed m_attrlist to m_attr_dict since its a PyDict type. - removed custom getattro/setattro functions for KX_Scene and KX_GameObject, use py_base_getattro, py_base_setattro for all subclasses of PyObjectPlus. - lowercase windows.h in VideoBase.cpp for cross compiling.
Diffstat (limited to 'source/gameengine/Ketsji/KX_Scene.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp68
1 files changed, 51 insertions, 17 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index c63167e2d56..c99fa363ffe 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -196,7 +196,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
m_canvasDesignWidth = 0;
m_canvasDesignHeight = 0;
- m_attrlist = PyDict_New(); /* new ref */
+ m_attr_dict = PyDict_New(); /* new ref */
}
@@ -250,8 +250,8 @@ KX_Scene::~KX_Scene()
{
delete m_bucketmanager;
}
- PyDict_Clear(m_attrlist);
- Py_DECREF(m_attrlist);
+ PyDict_Clear(m_attr_dict);
+ Py_DECREF(m_attr_dict);
}
void KX_Scene::SetProjectionMatrix(MT_CmMatrix4x4& pmat)
@@ -924,6 +924,8 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
{
int ret;
KX_GameObject* newobj = (KX_GameObject*) gameobj;
+
+ gameobj->SetZombie(true); /* disallow future python access */
// keep the blender->game object association up to date
// note that all the replicas of an object will have the same
@@ -998,6 +1000,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
if (m_sceneConverter)
m_sceneConverter->UnregisterGameObject(newobj);
// return value will be 0 if the object is actually deleted (all reference gone)
+
return ret;
}
@@ -1591,7 +1594,7 @@ PyTypeObject KX_Scene::Type = {
py_base_repr,
0,0,0,0,0,0,
py_base_getattro,
- py_base_setattro_scene, /* unlike almost all other types we need out own because user attributes are supported */
+ py_base_setattro,
0,0,0,0,0,0,0,0,0,
Methods
};
@@ -1633,12 +1636,12 @@ PyObject* KX_Scene::pyattr_get_active_camera(void *self_v, const KX_PYATTRIBUTE_
PyObject* KX_Scene::pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_Scene* self= static_cast<KX_Scene*>(self_v);
- /* Useually done by py_getattro_up but in this case we want to include m_attrlist dict */
+ /* Useually done by py_getattro_up but in this case we want to include m_attr_dict dict */
PyObject *dict_str= PyString_FromString("__dict__");
PyObject *dict= py_getattr_dict(self->PyObjectPlus::py_getattro(dict_str), Type.tp_dict);
Py_DECREF(dict_str);
- PyDict_Update(dict, self->m_attrlist);
+ PyDict_Update(dict, self->m_attr_dict);
return dict;
}
@@ -1654,28 +1657,59 @@ PyAttributeDef KX_Scene::Attributes[] = {
{ NULL } //Sentinel
};
+
+PyObject* KX_Scene::py_getattro__internal(PyObject *attr)
+{
+ py_getattro_up(PyObjectPlus);
+}
+
+int KX_Scene::py_setattro__internal(PyObject *attr, PyObject *pyvalue)
+{
+ return PyObjectPlus::py_setattro(attr, pyvalue);
+}
+
PyObject* KX_Scene::py_getattro(PyObject *attr)
{
- PyObject *object = PyDict_GetItem(m_attrlist, attr);
- if (object)
+ PyObject *object = py_getattro__internal(attr);
+
+ if (object==NULL)
{
- Py_INCREF(object);
- return object;
+ PyErr_Clear();
+ object = PyDict_GetItem(m_attr_dict, attr);
+ if(object) {
+ Py_INCREF(object);
+ }
+ else {
+ PyErr_Format(PyExc_AttributeError, "KX_Scene attribute \"%s\" not found", PyString_AsString(attr));
+ }
}
- py_getattro_up(PyObjectPlus);
+ return object;
}
-int KX_Scene::py_delattro(PyObject *attr)
+
+int KX_Scene::py_setattro(PyObject *attr, PyObject *value)
{
- PyDict_DelItem(m_attrlist, attr);
- return 0;
+ int ret= py_setattro__internal(attr, value);
+
+ if (ret==PY_SET_ATTR_MISSING) {
+ if (PyDict_SetItem(m_attr_dict, attr, value)==0) {
+ PyErr_Clear();
+ ret= PY_SET_ATTR_SUCCESS;
+ }
+ else {
+ PyErr_SetString(PyExc_AttributeError, "failed assigning value to KX_Scenes internal dictionary");
+ ret= PY_SET_ATTR_FAIL;
+ }
+ }
+
+ return ret;
}
-/* py_base_setattro_scene deals with setting the dict, it will run if this returns an error */
-int KX_Scene::py_setattro(PyObject *attr, PyObject *pyvalue)
+int KX_Scene::py_delattro(PyObject *attr)
{
- return PyObjectPlus::py_setattro(attr, pyvalue);
+ PyDict_DelItem(m_attr_dict, attr);
+ return 0;
}
KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getLightList,