diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-05-26 20:15:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-05-26 20:15:40 +0400 |
commit | 33b974ee43c2d6c131860efbe02fd478197b9fda (patch) | |
tree | 459ef7b438e969938baa3f6049e5d0668ea62926 /source/gameengine/Expressions/Value.cpp | |
parent | 7e48820a97a1cc5d806caa2c7ea5b47f4809aa58 (diff) |
BGE Py API
- Deprecation warnings for using attribute access
- Added dictionary functions to KX_GameObject and ListValue
ob.get(key, default=None)
ob.has_key(key)
ob.has_key is important since there was no way to do something like hasattr(ob, "attr") which can be replaced by ob.has_key("attr") - (both still work of course).
ob.get is just useful in many cases where you want a property if it exists but can fallback to a default.
- CListValue::FindValue was adding a reference but the ~3 places it was used were releasing the reference. added a FindValue that accepts a const char* type to avoid converting python strings to STR_String.
Diffstat (limited to 'source/gameengine/Expressions/Value.cpp')
-rw-r--r-- | source/gameengine/Expressions/Value.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 08249f92902..7f4ed388442 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -556,6 +556,8 @@ PyAttributeDef CValue::Attributes[] = { PyObject* CValue::py_getattro(PyObject *attr) { + ShowDeprecationWarning("val = ob.attr", "val = ob['attr']"); + char *attr_str= PyString_AsString(attr); CValue* resultattr = GetProperty(attr_str); if (resultattr) @@ -655,6 +657,8 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix) int CValue::py_delattro(PyObject *attr) { + ShowDeprecationWarning("del ob.attr", "del ob['attr']"); + char *attr_str= PyString_AsString(attr); if (RemoveProperty(attr_str)) return 0; @@ -665,6 +669,8 @@ int CValue::py_delattro(PyObject *attr) int CValue::py_setattro(PyObject *attr, PyObject* pyobj) { + ShowDeprecationWarning("ob.attr = val", "ob['attr'] = val"); + char *attr_str= PyString_AsString(attr); CValue* oldprop = GetProperty(attr_str); CValue* vallie; |