diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-21 06:28:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-21 06:28:36 +0400 |
commit | 3fd388fb06e474a4e9e2f6816eb0a0b95ab433e7 (patch) | |
tree | 214a3ade3c842bc301aa6bedf7f3f826c873b2a6 /source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | |
parent | 387bb73e4343be164f167565cefebbee613cdb7b (diff) |
py api cleanup, replace use...
- PyLong_FromSsize_t --> PyLong_FromLong
- PyLong_AsSsize_t --> PyLong_AsLong
In all places except for those where python api expects PySsize_t (index lookups mainly).
- use PyBool_FromLong in a few areas of the BGE.
- fix incorrect assumption in the BGE that PySequence_Check() means PySequence_Fast_ functions can be used.
Diffstat (limited to 'source/gameengine/GameLogic/SCA_KeyboardSensor.cpp')
-rw-r--r-- | source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index b3346270b61..7005ea1ba5b 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -439,17 +439,18 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus, return NULL; } - int keycode = PyLong_AsSsize_t(value); + SCA_IInputDevice::KX_EnumInputs keycode = (SCA_IInputDevice::KX_EnumInputs)PyLong_AsLong(value); - if ((keycode < SCA_IInputDevice::KX_BEGINKEY) - || (keycode > SCA_IInputDevice::KX_ENDKEY)) { + if ((keycode < SCA_IInputDevice::KX_BEGINKEY) || + (keycode > SCA_IInputDevice::KX_ENDKEY)) + { PyErr_SetString(PyExc_AttributeError, "sensor.getKeyStatus(int): Keyboard Sensor, invalid keycode specified!"); return NULL; } SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); - const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) keycode); - return PyLong_FromSsize_t(inevent.m_status); + const SCA_InputEvent & inevent = inputdev->GetEventValue(keycode); + return PyLong_FromLong(inevent.m_status); } /* ------------------------------------------------------------------------- */ @@ -509,8 +510,8 @@ PyObject *SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBU if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS) { PyObject *keypair = PyList_New(2); - PyList_SET_ITEM(keypair,0,PyLong_FromSsize_t(i)); - PyList_SET_ITEM(keypair,1,PyLong_FromSsize_t(inevent.m_status)); + PyList_SET_ITEM(keypair,0,PyLong_FromLong(i)); + PyList_SET_ITEM(keypair,1,PyLong_FromLong(inevent.m_status)); PyList_Append(resultlist,keypair); } } |