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-08-25 17:54:56 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-08-25 17:54:56 +0400
commit9521fa94569b0ab1fe5c9f451e8abf7dd2290b13 (patch)
treef96cf53c1ac46348e9437c0a00c4863ed7da81a0 /source/gameengine
parent855974dad931bcba8a63260d1f642da49902d569 (diff)
remove gameOb.has_key(key) method from KX_GameObject and ListValue since python 3.x removes has_key from dictionaries.
Instead use __contains__, eg. if key in gameOb: ... Mathutils returns from PyMath.cpp were incorrectly using wrapped Mathutils types. Wrapped types should only be used with a callback now.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Expressions/ListValue.cpp9
-rw-r--r--source/gameengine/Expressions/ListValue.h1
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h1
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.cpp8
-rw-r--r--source/gameengine/PyDoc/GameTypes.py18
6 files changed, 7 insertions, 39 deletions
diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp
index 5f45cdc48a2..002674450d1 100644
--- a/source/gameengine/Expressions/ListValue.cpp
+++ b/source/gameengine/Expressions/ListValue.cpp
@@ -300,7 +300,6 @@ PyMethodDef CListValue::Methods[] = {
/* Dict style access */
{"get", (PyCFunction)CListValue::sPyget,METH_VARARGS},
- {"has_key", (PyCFunction)CListValue::sPyhas_key,METH_O},
/* Own cvalue funcs */
{"from_id", (PyCFunction)CListValue::sPyfrom_id,METH_O},
@@ -594,14 +593,6 @@ PyObject* CListValue::Pyget(PyObject *args)
return def;
}
-/* Matches python dict.has_key() */
-PyObject* CListValue::Pyhas_key(PyObject* value)
-{
- if (PyUnicode_Check(value) && FindValue((const char *)_PyUnicode_AsString(value)))
- Py_RETURN_TRUE;
-
- Py_RETURN_FALSE;
-}
PyObject* CListValue::Pyfrom_id(PyObject* value)
{
diff --git a/source/gameengine/Expressions/ListValue.h b/source/gameengine/Expressions/ListValue.h
index 98e6f216f11..2dc458e0148 100644
--- a/source/gameengine/Expressions/ListValue.h
+++ b/source/gameengine/Expressions/ListValue.h
@@ -74,7 +74,6 @@ public:
KX_PYMETHOD_O(CListValue,index);
KX_PYMETHOD_O(CListValue,count);
KX_PYMETHOD_VARARGS(CListValue,get);
- KX_PYMETHOD_O(CListValue,has_key);
KX_PYMETHOD_O(CListValue,from_id);
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index a5217273b17..3aef41743a7 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1398,7 +1398,6 @@ PyMethodDef KX_GameObject::Methods[] = {
KX_PYMETHODTABLE(KX_GameObject, sendMessage),
// dict style access for props
- {"has_key",(PyCFunction) KX_GameObject::sPyhas_key, METH_O},
{"get",(PyCFunction) KX_GameObject::sPyget, METH_VARARGS},
// deprecated
@@ -2919,14 +2918,6 @@ PyObject* KX_GameObject::Pyget(PyObject *args)
return def;
}
-/* Matches python dict.has_key() */
-PyObject* KX_GameObject::Pyhas_key(PyObject* value)
-{
- // the ONLY error case is invalid data, this is checked by the macro'd static function
- // that calls this one. but make sure Seq_Contains doesnt add extra errors later on.
- return PyBool_FromLong(Seq_Contains((PyObject *)this, value));
-}
-
/* ---------------------------------------------------------------------
* Some stuff taken from the header
* --------------------------------------------------------------------- */
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index ba7451fdeef..a5cd084b4d4 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -844,7 +844,6 @@ public:
/* Dict access */
KX_PYMETHOD_VARARGS(KX_GameObject,get);
- KX_PYMETHOD_O(KX_GameObject,has_key);
/* attributes */
static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp
index 6d33c38190c..a41dab194dd 100644
--- a/source/gameengine/Ketsji/KX_PyMath.cpp
+++ b/source/gameengine/Ketsji/KX_PyMath.cpp
@@ -146,7 +146,7 @@ PyObject* PyObjectFrom(const MT_Quaternion &qrot)
{
/* NOTE, were re-ordering here for Mathutils compat */
float fvec[4]= {qrot[3], qrot[0], qrot[1], qrot[2]};
- return newQuaternionObject(fvec, Py_WRAP, NULL);
+ return newQuaternionObject(fvec, Py_NEW, NULL);
}
#endif
@@ -154,7 +154,7 @@ PyObject* PyObjectFrom(const MT_Tuple4 &vec)
{
#ifdef USE_MATHUTILS
float fvec[4]= {vec[0], vec[1], vec[2], vec[3]};
- return newVectorObject(fvec, 4, Py_WRAP, NULL);
+ return newVectorObject(fvec, 4, Py_NEW, NULL);
#else
PyObject *list = PyList_New(4);
PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
@@ -169,7 +169,7 @@ PyObject* PyObjectFrom(const MT_Tuple3 &vec)
{
#ifdef USE_MATHUTILS
float fvec[3]= {vec[0], vec[1], vec[2]};
- return newVectorObject(fvec, 3, Py_WRAP, NULL);
+ return newVectorObject(fvec, 3, Py_NEW, NULL);
#else
PyObject *list = PyList_New(3);
PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
@@ -183,7 +183,7 @@ PyObject* PyObjectFrom(const MT_Tuple2 &vec)
{
#ifdef USE_MATHUTILS
float fvec[2]= {vec[0], vec[1]};
- return newVectorObject(fvec, 2, Py_WRAP, NULL);
+ return newVectorObject(fvec, 2, Py_NEW, NULL);
#else
PyObject *list = PyList_New(2);
PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py
index 9c426aed8e0..c391d0c3dec 100644
--- a/source/gameengine/PyDoc/GameTypes.py
+++ b/source/gameengine/PyDoc/GameTypes.py
@@ -1023,12 +1023,6 @@ class CListValue(CPropValue):
Return the value matching key, or the default value if its not found.
@return: The key value or a default.
"""
- def has_key(key):
- """
- Return True if the key is found.
- @rtype: boolean
- @return: The key value or a default.
- """
def from_id(id):
"""
This is a funtion especially for the game engine to return a value with a spesific id.
@@ -1582,7 +1576,7 @@ class KX_GameObject(SCA_IObject):
@ivar childrenRecursive: all children of this object including childrens children, (read-only).
@type childrenRecursive: L{CListValue} of L{KX_GameObject}'s
@group Deprecated: getPosition, setPosition, setWorldPosition, getOrientation, setOrientation, getState, setState, getParent, getVisible, getMass, getMesh, getChildren, getChildrenRecursive
- @group Property Access: get, has_key, attrDict, getPropertyNames
+ @group Property Access: get, attrDict, getPropertyNames
"""
def endObject():
"""
@@ -2054,12 +2048,6 @@ class KX_GameObject(SCA_IObject):
Return the value matching key, or the default value if its not found.
@return: The key value or a default.
"""
- def has_key(key):
- """
- Return True if the key is found.
- @rtype: boolean
- @return: The key value or a default.
- """
class KX_IpoActuator(SCA_IActuator):
@@ -5745,7 +5733,7 @@ for name, val in locals().items():
# Store the mappings to new attributes in a list (because there
# could be collisions).
- if not depAttrs.has_key(attrName):
+ if attrName not in depAttrs:
depAttrs[attrName] = {}
mapping = depAttrs[attrName]
@@ -5770,7 +5758,7 @@ for name, val in locals().items():
# Another mapping, from a conversion tuple to lists of class
# names.
conversion = (func, newAttrName)
- if not mapping.has_key(conversion):
+ if conversion not in mapping:
mapping[conversion] = []
mapping[conversion].append(name)
break