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-02 09:38:05 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-02 09:38:05 +0400
commitfcc23faa3a5ec3c697e85e9a6b604ac7db80a05b (patch)
tree83203f4bdf0f56d6de7b659449aade290fe0d90b /source/gameengine/Ketsji/KX_GameObject.h
parent48e4a4834092a8772141e6240e5e70d67110f126 (diff)
Added getitem/setitem access for KX_GameObject
ob.someProp = 10 can now be... ob["someProp"] = 10 For simple get/set test with an objects 10 properties, this is ~30% faster. Though I like the attribute access, its slower because it needs to lookup BGE attributes and methods (for parent classes as well as KX_GameObject class). This could also be an advantage if there are collisions between new attributes added for 2.49 and existing properties a game uses. Made some other small optimizations, - Getting and setting property can use const char* as well as STR_String (avoids making new STR_Strings just to do the lookup). - CValue::SetPropertiesModified() and CValue::SetPropertiesModified(), were looping through all items in the std::map, advancing from the beginning each time.
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.h')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index 326b3700ad7..774977f2ecf 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -822,7 +822,13 @@ public:
static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
+ /* getitem/setitem */
+ static int Map_Len(PyObject* self);
+ static PyMappingMethods Mapping;
+ static PyObject* Map_GetItem(PyObject *self_v, PyObject *item);
+ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val);
+
+
private :
/**