diff --git a/src/UIGridPoint.cpp b/src/UIGridPoint.cpp index b30d493..e255c3a 100644 --- a/src/UIGridPoint.cpp +++ b/src/UIGridPoint.cpp @@ -98,6 +98,19 @@ PyGetSetDef UIGridPoint::getsetters[] = { {NULL} /* Sentinel */ }; +PyObject* UIGridPoint::repr(PyUIGridPointObject* self) { + std::ostringstream ss; + if (!self->data) ss << ""; + else { + auto gp = self->data; + ss << ""; + } + std::string repr_str = ss.str(); + return PyUnicode_DecodeUTF8(repr_str.c_str(), repr_str.size(), "replace"); +} + PyObject* UIGridPointState::get_bool_member(PyUIGridPointStateObject* self, void* closure) { if (reinterpret_cast(closure) == 0) { // visible return PyBool_FromLong(self->data->visible); @@ -132,3 +145,14 @@ PyGetSetDef UIGridPointState::getsetters[] = { {NULL} /* Sentinel */ }; +PyObject* UIGridPointState::repr(PyUIGridPointStateObject* self) { + std::ostringstream ss; + if (!self->data) ss << ""; + else { + auto gps = self->data; + ss << ""; + } + std::string repr_str = ss.str(); + return PyUnicode_DecodeUTF8(repr_str.c_str(), repr_str.size(), "replace"); +} diff --git a/src/UIGridPoint.h b/src/UIGridPoint.h index 8161df8..627c3d6 100644 --- a/src/UIGridPoint.h +++ b/src/UIGridPoint.h @@ -49,6 +49,7 @@ public: static int set_bool_member(PyUIGridPointObject* self, PyObject* value, void* closure); static PyObject* get_bool_member(PyUIGridPointObject* self, void* closure); static int set_color(PyUIGridPointObject* self, PyObject* value, void* closure); + static PyObject* repr(PyUIGridPointObject* self); }; // UIGridPointState - entity-specific info for each cell @@ -60,6 +61,7 @@ public: static PyObject* get_bool_member(PyUIGridPointStateObject* self, void* closure); static int set_bool_member(PyUIGridPointStateObject* self, PyObject* value, void* closure); static PyGetSetDef getsetters[]; + static PyObject* repr(PyUIGridPointStateObject* self); }; namespace mcrfpydef { @@ -68,7 +70,7 @@ namespace mcrfpydef { .tp_name = "mcrfpy.GridPoint", .tp_basicsize = sizeof(PyUIGridPointObject), .tp_itemsize = 0, - // Methods omitted for brevity + .tp_repr = (reprfunc)UIGridPoint::repr, .tp_flags = Py_TPFLAGS_DEFAULT, .tp_doc = "UIGridPoint object", .tp_getset = UIGridPoint::getsetters, @@ -81,7 +83,7 @@ namespace mcrfpydef { .tp_name = "mcrfpy.GridPointState", .tp_basicsize = sizeof(PyUIGridPointStateObject), .tp_itemsize = 0, - // Methods omitted for brevity + .tp_repr = (reprfunc)UIGridPointState::repr, .tp_flags = Py_TPFLAGS_DEFAULT, .tp_doc = "UIGridPointState object", // TODO: Add PyUIGridPointState tp_init .tp_getset = UIGridPointState::getsetters,