long -> intptr_t for casts. WIP: mingw cross-compilation for Windows (see #162)
This commit is contained in:
parent
2f4ebf3420
commit
1f002e820c
15 changed files with 188 additions and 102 deletions
|
|
@ -767,7 +767,7 @@ void AnimationManager::addAnimation(std::shared_ptr<Animation> animation,
|
|||
}
|
||||
return; // Don't add to active animations yet
|
||||
|
||||
case AnimationConflictMode::ERROR:
|
||||
case AnimationConflictMode::RAISE_ERROR:
|
||||
// Raise Python exception
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ class UIEntity;
|
|||
* ConflictMode - How to handle multiple animations on the same property (#120)
|
||||
*/
|
||||
enum class AnimationConflictMode {
|
||||
REPLACE, // Stop/complete existing animation, start new one (default)
|
||||
QUEUE, // Queue new animation to run after existing one completes
|
||||
ERROR // Raise an error if property is already being animated
|
||||
REPLACE, // Stop/complete existing animation, start new one (default)
|
||||
QUEUE, // Queue new animation to run after existing one completes
|
||||
RAISE_ERROR // Raise an error if property is already being animated
|
||||
// Note: Can't use ERROR as it conflicts with Windows macro
|
||||
};
|
||||
|
||||
// Forward declare namespace
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ static bool parseConflictMode(const char* mode_str, AnimationConflictMode& mode)
|
|||
} else if (strcmp(mode_str, "queue") == 0) {
|
||||
mode = AnimationConflictMode::QUEUE;
|
||||
} else if (strcmp(mode_str, "error") == 0) {
|
||||
mode = AnimationConflictMode::ERROR;
|
||||
mode = AnimationConflictMode::RAISE_ERROR;
|
||||
} else {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Invalid conflict_mode '%s'. Must be 'replace', 'queue', or 'error'.", mode_str);
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ PyObject* PyColor::pynew(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
|||
PyObject* PyColor::get_member(PyObject* obj, void* closure)
|
||||
{
|
||||
PyColorObject* self = (PyColorObject*)obj;
|
||||
long member = (long)closure;
|
||||
intptr_t member = (intptr_t)closure;
|
||||
|
||||
switch (member) {
|
||||
case 0: // r
|
||||
|
|
@ -192,7 +192,7 @@ PyObject* PyColor::get_member(PyObject* obj, void* closure)
|
|||
int PyColor::set_member(PyObject* obj, PyObject* value, void* closure)
|
||||
{
|
||||
PyColorObject* self = (PyColorObject*)obj;
|
||||
long member = (long)closure;
|
||||
intptr_t member = (intptr_t)closure;
|
||||
|
||||
if (!PyLong_Check(value)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Color values must be integers");
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ PyObject* PyVector::pynew(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
|||
PyObject* PyVector::get_member(PyObject* obj, void* closure)
|
||||
{
|
||||
PyVectorObject* self = (PyVectorObject*)obj;
|
||||
if (reinterpret_cast<long>(closure) == 0) {
|
||||
if (reinterpret_cast<intptr_t>(closure) == 0) {
|
||||
// x
|
||||
return PyFloat_FromDouble(self->data.x);
|
||||
} else {
|
||||
|
|
@ -250,7 +250,7 @@ int PyVector::set_member(PyObject* obj, PyObject* value, void* closure)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (reinterpret_cast<long>(closure) == 0) {
|
||||
if (reinterpret_cast<intptr_t>(closure) == 0) {
|
||||
// x
|
||||
self->data.x = val;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ void UICaption::onPositionChanged()
|
|||
|
||||
PyObject* UICaption::get_float_member(PyUICaptionObject* self, void* closure)
|
||||
{
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr == 0)
|
||||
return PyFloat_FromDouble(self->data->text.getPosition().x);
|
||||
else if (member_ptr == 1)
|
||||
|
|
@ -115,7 +115,7 @@ PyObject* UICaption::get_float_member(PyUICaptionObject* self, void* closure)
|
|||
int UICaption::set_float_member(PyUICaptionObject* self, PyObject* value, void* closure)
|
||||
{
|
||||
float val;
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
val = PyFloat_AsDouble(value);
|
||||
|
|
@ -156,7 +156,7 @@ PyObject* UICaption::get_color_member(PyUICaptionObject* self, void* closure)
|
|||
// TODO: migrate this code to a switch statement - validate closure & return values in one tighter, more extensible structure
|
||||
|
||||
// validate closure (should be impossible to be wrong, but it's thorough)
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr != 0 && member_ptr != 1)
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, "Invalid attribute");
|
||||
|
|
@ -181,7 +181,7 @@ PyObject* UICaption::get_color_member(PyUICaptionObject* self, void* closure)
|
|||
|
||||
int UICaption::set_color_member(PyUICaptionObject* self, PyObject* value, void* closure)
|
||||
{
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
//TODO: this logic of (PyColor instance OR tuple -> sf::color) should be encapsulated for reuse
|
||||
int r, g, b, a;
|
||||
if (PyObject_IsInstance(value, PyObject_GetAttrString(McRFPy_API::mcrf_module, "Color") /*(PyObject*)&mcrfpydef::PyColorType)*/))
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ void UIDrawable::render()
|
|||
}
|
||||
|
||||
PyObject* UIDrawable::get_click(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure)); // trust me bro, it's an Enum
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure)); // trust me bro, it's an Enum
|
||||
PyObject* ptr;
|
||||
|
||||
switch (objtype)
|
||||
|
|
@ -228,7 +228,7 @@ PyObject* UIDrawable::get_click(PyObject* self, void* closure) {
|
|||
}
|
||||
|
||||
int UIDrawable::set_click(PyObject* self, PyObject* value, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure)); // trust me bro, it's an Enum
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure)); // trust me bro, it's an Enum
|
||||
UIDrawable* target;
|
||||
switch (objtype)
|
||||
{
|
||||
|
|
@ -305,7 +305,7 @@ void UIDrawable::on_move_unregister()
|
|||
}
|
||||
|
||||
PyObject* UIDrawable::get_int(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -339,7 +339,7 @@ PyObject* UIDrawable::get_int(PyObject* self, void* closure) {
|
|||
}
|
||||
|
||||
int UIDrawable::set_int(PyObject* self, PyObject* value, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -405,7 +405,7 @@ void UIDrawable::notifyZIndexChanged() {
|
|||
}
|
||||
|
||||
PyObject* UIDrawable::get_name(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -439,7 +439,7 @@ PyObject* UIDrawable::get_name(PyObject* self, void* closure) {
|
|||
}
|
||||
|
||||
int UIDrawable::set_name(PyObject* self, PyObject* value, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -639,7 +639,7 @@ int UIDrawable::set_float_member(PyObject* self, PyObject* value, void* closure)
|
|||
}
|
||||
|
||||
PyObject* UIDrawable::get_pos(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -686,7 +686,7 @@ PyObject* UIDrawable::get_pos(PyObject* self, void* closure) {
|
|||
}
|
||||
|
||||
int UIDrawable::set_pos(PyObject* self, PyObject* value, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -892,7 +892,7 @@ void UIDrawable::markDirty() {
|
|||
|
||||
// Python API - get parent drawable
|
||||
PyObject* UIDrawable::get_parent(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1003,7 +1003,7 @@ PyObject* UIDrawable::get_parent(PyObject* self, void* closure) {
|
|||
|
||||
// Python API - set parent drawable (or None to remove from parent)
|
||||
int UIDrawable::set_parent(PyObject* self, PyObject* value, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
std::shared_ptr<UIDrawable> drawable = nullptr;
|
||||
|
||||
// Get the shared_ptr for self
|
||||
|
|
@ -1125,7 +1125,7 @@ int UIDrawable::set_parent(PyObject* self, PyObject* value, void* closure) {
|
|||
|
||||
// Python API - get global position (read-only)
|
||||
PyObject* UIDrawable::get_global_pos(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1175,7 +1175,7 @@ PyObject* UIDrawable::get_global_pos(PyObject* self, void* closure) {
|
|||
|
||||
// #138, #188 - Python API for bounds property - returns (pos, size) as pair of Vectors
|
||||
PyObject* UIDrawable::get_bounds_py(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1236,7 +1236,7 @@ PyObject* UIDrawable::get_bounds_py(PyObject* self, void* closure) {
|
|||
|
||||
// #138, #188 - Python API for global_bounds property - returns (pos, size) as pair of Vectors
|
||||
PyObject* UIDrawable::get_global_bounds_py(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1297,7 +1297,7 @@ PyObject* UIDrawable::get_global_bounds_py(PyObject* self, void* closure) {
|
|||
|
||||
// #140 - Python API for on_enter property
|
||||
PyObject* UIDrawable::get_on_enter(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
PyObject* ptr = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1340,7 +1340,7 @@ PyObject* UIDrawable::get_on_enter(PyObject* self, void* closure) {
|
|||
}
|
||||
|
||||
int UIDrawable::set_on_enter(PyObject* self, PyObject* value, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* target = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1380,7 +1380,7 @@ int UIDrawable::set_on_enter(PyObject* self, PyObject* value, void* closure) {
|
|||
|
||||
// #140 - Python API for on_exit property
|
||||
PyObject* UIDrawable::get_on_exit(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
PyObject* ptr = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1423,7 +1423,7 @@ PyObject* UIDrawable::get_on_exit(PyObject* self, void* closure) {
|
|||
}
|
||||
|
||||
int UIDrawable::set_on_exit(PyObject* self, PyObject* value, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* target = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1463,7 +1463,7 @@ int UIDrawable::set_on_exit(PyObject* self, PyObject* value, void* closure) {
|
|||
|
||||
// #140 - Python API for hovered property (read-only)
|
||||
PyObject* UIDrawable::get_hovered(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* drawable = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1498,7 +1498,7 @@ PyObject* UIDrawable::get_hovered(PyObject* self, void* closure) {
|
|||
|
||||
// #141 - Python API for on_move property
|
||||
PyObject* UIDrawable::get_on_move(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
PyObject* ptr = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1541,7 +1541,7 @@ PyObject* UIDrawable::get_on_move(PyObject* self, void* closure) {
|
|||
}
|
||||
|
||||
int UIDrawable::set_on_move(PyObject* self, PyObject* value, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure));
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<intptr_t>(closure));
|
||||
UIDrawable* target = nullptr;
|
||||
|
||||
switch (objtype) {
|
||||
|
|
@ -1689,7 +1689,7 @@ PyObject* UIDrawable_animate_impl(std::shared_ptr<UIDrawable> self, PyObject* ar
|
|||
} else if (strcmp(conflict_mode_str, "queue") == 0) {
|
||||
conflict_mode = AnimationConflictMode::QUEUE;
|
||||
} else if (strcmp(conflict_mode_str, "error") == 0) {
|
||||
conflict_mode = AnimationConflictMode::ERROR;
|
||||
conflict_mode = AnimationConflictMode::RAISE_ERROR;
|
||||
} else {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Invalid conflict_mode '%s'. Must be 'replace', 'queue', or 'error'.", conflict_mode_str);
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ PyObject* UIGridPointStateVector_to_PyList(const std::vector<UIGridPointState>&
|
|||
}
|
||||
|
||||
PyObject* UIEntity::get_position(PyUIEntityObject* self, void* closure) {
|
||||
if (reinterpret_cast<long>(closure) == 0) {
|
||||
if (reinterpret_cast<intptr_t>(closure) == 0) {
|
||||
return sfVector2f_to_PyObject(self->data->position);
|
||||
} else {
|
||||
// Return integer-cast position for grid coordinates
|
||||
|
|
@ -373,7 +373,7 @@ int UIEntity::set_position(PyUIEntityObject* self, PyObject* value, void* closur
|
|||
float old_x = self->data->position.x;
|
||||
float old_y = self->data->position.y;
|
||||
|
||||
if (reinterpret_cast<long>(closure) == 0) {
|
||||
if (reinterpret_cast<intptr_t>(closure) == 0) {
|
||||
sf::Vector2f vec = PyObject_to_sfVector2f(value);
|
||||
if (PyErr_Occurred()) {
|
||||
return -1; // Error already set by PyObject_to_sfVector2f
|
||||
|
|
@ -418,7 +418,7 @@ int UIEntity::set_spritenumber(PyUIEntityObject* self, PyObject* value, void* cl
|
|||
|
||||
PyObject* UIEntity::get_float_member(PyUIEntityObject* self, void* closure)
|
||||
{
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr == 0) // x
|
||||
return PyFloat_FromDouble(self->data->position.x);
|
||||
else if (member_ptr == 1) // y
|
||||
|
|
@ -433,7 +433,7 @@ PyObject* UIEntity::get_float_member(PyUIEntityObject* self, void* closure)
|
|||
int UIEntity::set_float_member(PyUIEntityObject* self, PyObject* value, void* closure)
|
||||
{
|
||||
float val;
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
val = PyFloat_AsDouble(value);
|
||||
|
|
@ -540,7 +540,7 @@ PyObject* UIEntity::get_pixel_member(PyUIEntityObject* self, void* closure) {
|
|||
float cell_width, cell_height;
|
||||
get_cell_dimensions(self->data.get(), cell_width, cell_height);
|
||||
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr == 0) // x
|
||||
return PyFloat_FromDouble(self->data->position.x * cell_width);
|
||||
else // y
|
||||
|
|
@ -570,7 +570,7 @@ int UIEntity::set_pixel_member(PyUIEntityObject* self, PyObject* value, void* cl
|
|||
float old_x = self->data->position.x;
|
||||
float old_y = self->data->position.y;
|
||||
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr == 0) // x
|
||||
self->data->position.x = val / cell_width;
|
||||
else // y
|
||||
|
|
@ -584,7 +584,7 @@ int UIEntity::set_pixel_member(PyUIEntityObject* self, PyObject* value, void* cl
|
|||
|
||||
// #176 - Integer grid position (grid_x, grid_y)
|
||||
PyObject* UIEntity::get_grid_int_member(PyUIEntityObject* self, void* closure) {
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr == 0) // grid_x
|
||||
return PyLong_FromLong(static_cast<int>(self->data->position.x));
|
||||
else // grid_y
|
||||
|
|
@ -606,7 +606,7 @@ int UIEntity::set_grid_int_member(PyUIEntityObject* self, PyObject* value, void*
|
|||
float old_x = self->data->position.x;
|
||||
float old_y = self->data->position.y;
|
||||
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr == 0) // grid_x
|
||||
self->data->position.x = static_cast<float>(val);
|
||||
else // grid_y
|
||||
|
|
@ -1172,7 +1172,7 @@ PyObject* UIEntity::animate(PyUIEntityObject* self, PyObject* args, PyObject* kw
|
|||
} else if (strcmp(conflict_mode_str, "queue") == 0) {
|
||||
conflict_mode = AnimationConflictMode::QUEUE;
|
||||
} else if (strcmp(conflict_mode_str, "error") == 0) {
|
||||
conflict_mode = AnimationConflictMode::ERROR;
|
||||
conflict_mode = AnimationConflictMode::RAISE_ERROR;
|
||||
} else {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Invalid conflict_mode '%s'. Must be 'replace', 'queue', or 'error'.", conflict_mode_str);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ PyObject* UIFrame::get_children(PyUIFrameObject* self, void* closure)
|
|||
|
||||
PyObject* UIFrame::get_float_member(PyUIFrameObject* self, void* closure)
|
||||
{
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr == 0)
|
||||
return PyFloat_FromDouble(self->data->box.getPosition().x);
|
||||
else if (member_ptr == 1)
|
||||
|
|
@ -208,7 +208,7 @@ PyObject* UIFrame::get_float_member(PyUIFrameObject* self, void* closure)
|
|||
int UIFrame::set_float_member(PyUIFrameObject* self, PyObject* value, void* closure)
|
||||
{
|
||||
float val;
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
val = PyFloat_AsDouble(value);
|
||||
|
|
@ -258,7 +258,7 @@ int UIFrame::set_float_member(PyUIFrameObject* self, PyObject* value, void* clos
|
|||
PyObject* UIFrame::get_color_member(PyUIFrameObject* self, void* closure)
|
||||
{
|
||||
// validate closure (should be impossible to be wrong, but it's thorough)
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr != 0 && member_ptr != 1)
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, "Invalid attribute");
|
||||
|
|
@ -293,7 +293,7 @@ PyObject* UIFrame::get_color_member(PyUIFrameObject* self, void* closure)
|
|||
int UIFrame::set_color_member(PyUIFrameObject* self, PyObject* value, void* closure)
|
||||
{
|
||||
//TODO: this logic of (PyColor instance OR tuple -> sf::color) should be encapsulated for reuse
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
int r, g, b, a;
|
||||
if (PyObject_IsInstance(value, PyObject_GetAttrString(McRFPy_API::mcrf_module, "Color")))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1076,7 +1076,7 @@ int UIGrid::set_center(PyUIGridObject* self, PyObject* value, void* closure) {
|
|||
|
||||
PyObject* UIGrid::get_float_member(PyUIGridObject* self, void* closure)
|
||||
{
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr == 0) // x
|
||||
return PyFloat_FromDouble(self->data->box.getPosition().x);
|
||||
else if (member_ptr == 1) // y
|
||||
|
|
@ -1101,7 +1101,7 @@ PyObject* UIGrid::get_float_member(PyUIGridObject* self, void* closure)
|
|||
int UIGrid::set_float_member(PyUIGridObject* self, PyObject* value, void* closure)
|
||||
{
|
||||
float val;
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
val = PyFloat_AsDouble(value);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ sf::Color PyObject_to_sfColor(PyObject* obj) {
|
|||
// #150 - Removed get_color/set_color - now handled by layers
|
||||
|
||||
PyObject* UIGridPoint::get_bool_member(PyUIGridPointObject* self, void* closure) {
|
||||
if (reinterpret_cast<long>(closure) == 0) { // walkable
|
||||
if (reinterpret_cast<intptr_t>(closure) == 0) { // walkable
|
||||
return PyBool_FromLong(self->data->walkable);
|
||||
} else { // transparent
|
||||
return PyBool_FromLong(self->data->transparent);
|
||||
|
|
@ -66,13 +66,13 @@ PyObject* UIGridPoint::get_bool_member(PyUIGridPointObject* self, void* closure)
|
|||
|
||||
int UIGridPoint::set_bool_member(PyUIGridPointObject* self, PyObject* value, void* closure) {
|
||||
if (value == Py_True) {
|
||||
if (reinterpret_cast<long>(closure) == 0) { // walkable
|
||||
if (reinterpret_cast<intptr_t>(closure) == 0) { // walkable
|
||||
self->data->walkable = true;
|
||||
} else { // transparent
|
||||
self->data->transparent = true;
|
||||
}
|
||||
} else if (value == Py_False) {
|
||||
if (reinterpret_cast<long>(closure) == 0) { // walkable
|
||||
if (reinterpret_cast<intptr_t>(closure) == 0) { // walkable
|
||||
self->data->walkable = false;
|
||||
} else { // transparent
|
||||
self->data->transparent = false;
|
||||
|
|
@ -162,7 +162,7 @@ PyObject* UIGridPoint::repr(PyUIGridPointObject* self) {
|
|||
}
|
||||
|
||||
PyObject* UIGridPointState::get_bool_member(PyUIGridPointStateObject* self, void* closure) {
|
||||
if (reinterpret_cast<long>(closure) == 0) { // visible
|
||||
if (reinterpret_cast<intptr_t>(closure) == 0) { // visible
|
||||
return PyBool_FromLong(self->data->visible);
|
||||
} else { // discovered
|
||||
return PyBool_FromLong(self->data->discovered);
|
||||
|
|
@ -180,7 +180,7 @@ int UIGridPointState::set_bool_member(PyUIGridPointStateObject* self, PyObject*
|
|||
return -1; // PyObject_IsTrue returns -1 on error
|
||||
}
|
||||
|
||||
if (reinterpret_cast<long>(closure) == 0) { // visible
|
||||
if (reinterpret_cast<intptr_t>(closure) == 0) { // visible
|
||||
self->data->visible = truthValue;
|
||||
} else { // discovered
|
||||
self->data->discovered = truthValue;
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ void UISprite::onPositionChanged()
|
|||
|
||||
PyObject* UISprite::get_float_member(PyUISpriteObject* self, void* closure)
|
||||
{
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (member_ptr == 0)
|
||||
return PyFloat_FromDouble(self->data->getPosition().x);
|
||||
else if (member_ptr == 1)
|
||||
|
|
@ -203,7 +203,7 @@ PyObject* UISprite::get_float_member(PyUISpriteObject* self, void* closure)
|
|||
int UISprite::set_float_member(PyUISpriteObject* self, PyObject* value, void* closure)
|
||||
{
|
||||
float val;
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
val = PyFloat_AsDouble(value);
|
||||
|
|
@ -232,7 +232,7 @@ int UISprite::set_float_member(PyUISpriteObject* self, PyObject* value, void* cl
|
|||
|
||||
PyObject* UISprite::get_int_member(PyUISpriteObject* self, void* closure)
|
||||
{
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (true) {}
|
||||
else
|
||||
{
|
||||
|
|
@ -246,7 +246,7 @@ PyObject* UISprite::get_int_member(PyUISpriteObject* self, void* closure)
|
|||
int UISprite::set_int_member(PyUISpriteObject* self, PyObject* value, void* closure)
|
||||
{
|
||||
int val;
|
||||
auto member_ptr = reinterpret_cast<long>(closure);
|
||||
auto member_ptr = reinterpret_cast<intptr_t>(closure);
|
||||
if (PyLong_Check(value))
|
||||
{
|
||||
val = PyLong_AsLong(value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue