diff --git a/binaries/lib-macos/libgoopylib.dylib b/binaries/lib-macos/libgoopylib.dylib index e3f47b98..fb0a62bf 100755 Binary files a/binaries/lib-macos/libgoopylib.dylib and b/binaries/lib-macos/libgoopylib.dylib differ diff --git a/goopylib/objects/circle/circle.cpp b/goopylib/objects/circle/circle.cpp index 3bbbfef1..d90da139 100644 --- a/goopylib/objects/circle/circle.cpp +++ b/goopylib/objects/circle/circle.cpp @@ -6,51 +6,48 @@ #include "src/goopylib/objects/Circle.h" -PyObject *circle::new_(PyTypeObject *type, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)) { - CircleObject *self; - self = (CircleObject *) type->tp_alloc(type, 0); +namespace circle { + PyObject *new_(PyTypeObject *type, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)) { + CircleObject *self; + self = (CircleObject *) type->tp_alloc(type, 0); - if (self != nullptr) { + if (self != nullptr) { + } + return (PyObject *) self; } - return (PyObject *) self; -} - -int circle::init(CircleObject *self, PyObject *args, PyObject *Py_UNUSED(kwds)) { - GP_PY_INFO("gp.circle.Circle()"); - float x1, y1; - float radius; - if (!PyArg_ParseTuple(args, "(ff)f", &x1, &y1, &radius)) { - return -1; - } + int init(CircleObject *self, PyObject *args, PyObject *Py_UNUSED(kwds)) { + GP_PY_INFO("gp.circle.Circle()"); - self->circle = Ref(new gp::Circle({x1, y1}, radius)); - self->base.ellipse = self->circle; - self->base.base.renderable = self->circle; - return 0; -} + float x1, y1; + float radius; + if (!PyArg_ParseTuple(args, "(ff)f", &x1, &y1, &radius)) { + return -1; + } -PyObject *circle::repr(CircleObject *Py_UNUSED(self)) { - GP_PY_TRACE("gp.circle.Circle.__repr__()"); - return PyUnicode_FromString("Circle()"); -} + self->circle = Ref(new gp::Circle({x1, y1}, radius)); + self->base.ellipse = self->circle; + self->base.base.renderable = self->circle; + return 0; + } -int circle::traverse(CircleObject *Py_UNUSED(self), visitproc Py_UNUSED(visit), void *Py_UNUSED(arg)) { - return 0; -} + int traverse(CircleObject *Py_UNUSED(self), visitproc Py_UNUSED(visit), void *Py_UNUSED(arg)) { + return 0; + } -int circle::clear(CircleObject *Py_UNUSED(self)) { - GP_PY_TRACE("gp.circle.Circle.clear()"); - return 0; -} + int clear(CircleObject *Py_UNUSED(self)) { + GP_PY_TRACE("gp.circle.Circle.clear()"); + return 0; + } -void circle::dealloc(CircleObject *self) { - GP_PY_DEBUG("gp.circle.Circle.__dealloc__()"); + void dealloc(CircleObject *self) { + GP_PY_DEBUG("gp.circle.Circle.__dealloc__()"); - self->circle.reset(); + self->circle.reset(); - PyObject_GC_UnTrack(self); - clear(self); - Py_TYPE(self)->tp_free((PyObject *) self); + PyObject_GC_UnTrack(self); + clear(self); + Py_TYPE(self)->tp_free((PyObject *) self); + } } diff --git a/goopylib/objects/circle/circle.h b/goopylib/objects/circle/circle.h index 0929a2eb..035d831e 100644 --- a/goopylib/objects/circle/circle.h +++ b/goopylib/objects/circle/circle.h @@ -12,8 +12,6 @@ namespace circle { int init(CircleObject *self, PyObject *args, PyObject *kwds); - PyObject *repr(CircleObject *self); - int traverse(CircleObject *self, visitproc visit, void *arg); int clear(CircleObject *self); diff --git a/goopylib/objects/circle/type.cpp b/goopylib/objects/circle/type.cpp index 980f9509..bdcc1414 100644 --- a/goopylib/objects/circle/type.cpp +++ b/goopylib/objects/circle/type.cpp @@ -16,7 +16,7 @@ PyTypeObject CircleType = { nullptr, nullptr, nullptr, - (reprfunc) circle::repr, + nullptr, nullptr, nullptr, nullptr, diff --git a/goopylib/objects/ellipse/ellipse.cpp b/goopylib/objects/ellipse/ellipse.cpp index 8740afc4..dff7e3fa 100644 --- a/goopylib/objects/ellipse/ellipse.cpp +++ b/goopylib/objects/ellipse/ellipse.cpp @@ -41,11 +41,6 @@ namespace ellipse { return 0; } - PyObject *repr(EllipseObject *Py_UNUSED(self)) { - GP_PY_TRACE("gp.ellipse.Ellipse.__repr__()"); - return PyUnicode_FromString("Ellipse()"); - } - int traverse(EllipseObject *Py_UNUSED(self), visitproc Py_UNUSED(visit), void *Py_UNUSED(arg)) { return 0; } diff --git a/goopylib/objects/ellipse/ellipse.h b/goopylib/objects/ellipse/ellipse.h index 19f20f1e..5871300c 100644 --- a/goopylib/objects/ellipse/ellipse.h +++ b/goopylib/objects/ellipse/ellipse.h @@ -15,8 +15,6 @@ namespace ellipse { int init(EllipseObject *self, PyObject *args, PyObject *kwds); - PyObject *repr(EllipseObject *self); - int traverse(EllipseObject *self, visitproc visit, void *arg); int clear(EllipseObject *self); diff --git a/goopylib/objects/ellipse/type.cpp b/goopylib/objects/ellipse/type.cpp index b6ea372b..cf1facc8 100644 --- a/goopylib/objects/ellipse/type.cpp +++ b/goopylib/objects/ellipse/type.cpp @@ -25,7 +25,7 @@ PyTypeObject EllipseType = { nullptr, nullptr, nullptr, - (reprfunc) ellipse::repr, + nullptr, nullptr, nullptr, nullptr, diff --git a/goopylib/objects/image/image.cpp b/goopylib/objects/image/image.cpp index 21feeefc..1d75338e 100644 --- a/goopylib/objects/image/image.cpp +++ b/goopylib/objects/image/image.cpp @@ -64,11 +64,6 @@ namespace image { return 0; } - PyObject *repr(ImageObject *Py_UNUSED(self)) { - GP_PY_TRACE("gp.image.Image.__repr__()"); - return PyUnicode_FromString("Image()"); - } - int traverse(ImageObject *Py_UNUSED(self), visitproc Py_UNUSED(visit), void *Py_UNUSED(arg)) { return 0; } diff --git a/goopylib/objects/image/image.h b/goopylib/objects/image/image.h index a9f35fba..49e0e253 100644 --- a/goopylib/objects/image/image.h +++ b/goopylib/objects/image/image.h @@ -15,8 +15,6 @@ namespace image { int init(ImageObject *self, PyObject *args, PyObject *kwds); - PyObject *repr(ImageObject *self); - int traverse(ImageObject *self, visitproc visit, void *arg); int clear(ImageObject *self); diff --git a/goopylib/objects/image/type.cpp b/goopylib/objects/image/type.cpp index ef9c93b4..5c323758 100644 --- a/goopylib/objects/image/type.cpp +++ b/goopylib/objects/image/type.cpp @@ -22,7 +22,7 @@ PyTypeObject ImageType = { nullptr, nullptr, nullptr, - (reprfunc) image::repr, + nullptr, nullptr, nullptr, nullptr, diff --git a/goopylib/objects/line/line.cpp b/goopylib/objects/line/line.cpp index d7963374..78fb69b2 100644 --- a/goopylib/objects/line/line.cpp +++ b/goopylib/objects/line/line.cpp @@ -40,11 +40,6 @@ namespace line { return 0; } - PyObject *repr(LineObject *Py_UNUSED(self)) { - GP_PY_TRACE("gp.line.Line.__repr__()"); - return PyUnicode_FromString("Line()"); - } - int traverse(LineObject *Py_UNUSED(self), visitproc Py_UNUSED(visit), void *Py_UNUSED(arg)) { return 0; } diff --git a/goopylib/objects/line/line.h b/goopylib/objects/line/line.h index 4b641622..3ddcc293 100644 --- a/goopylib/objects/line/line.h +++ b/goopylib/objects/line/line.h @@ -15,8 +15,6 @@ namespace line { int init(LineObject *self, PyObject *args, PyObject *kwds); - PyObject *repr(LineObject *self); - int traverse(LineObject *self, visitproc visit, void *arg); int clear(LineObject *self); diff --git a/goopylib/objects/line/type.cpp b/goopylib/objects/line/type.cpp index cc7a9b7a..6d8682c8 100644 --- a/goopylib/objects/line/type.cpp +++ b/goopylib/objects/line/type.cpp @@ -26,7 +26,7 @@ PyTypeObject LineType = { nullptr, nullptr, nullptr, - (reprfunc) line::repr, + nullptr, nullptr, nullptr, nullptr, diff --git a/goopylib/objects/quad/quad.cpp b/goopylib/objects/quad/quad.cpp index 5c96fe23..41bcc18c 100644 --- a/goopylib/objects/quad/quad.cpp +++ b/goopylib/objects/quad/quad.cpp @@ -30,11 +30,6 @@ namespace quad { return 0; } - PyObject *repr(QuadObject *Py_UNUSED(self)) { - GP_PY_TRACE("gp.quad.Quad.__repr__()"); - return PyUnicode_FromString("Quad()"); - } - int traverse(QuadObject *Py_UNUSED(self), visitproc Py_UNUSED(visit), void *Py_UNUSED(arg)) { return 0; } diff --git a/goopylib/objects/quad/quad.h b/goopylib/objects/quad/quad.h index 06973502..66eee2dc 100644 --- a/goopylib/objects/quad/quad.h +++ b/goopylib/objects/quad/quad.h @@ -15,8 +15,6 @@ namespace quad { int init(QuadObject *self, PyObject *args, PyObject *kwds); - PyObject *repr(QuadObject *self); - int traverse(QuadObject *self, visitproc visit, void *arg); int clear(QuadObject *self); diff --git a/goopylib/objects/quad/type.cpp b/goopylib/objects/quad/type.cpp index d96d593d..194d465c 100644 --- a/goopylib/objects/quad/type.cpp +++ b/goopylib/objects/quad/type.cpp @@ -30,7 +30,7 @@ PyTypeObject QuadType = { nullptr, nullptr, nullptr, - (reprfunc) quad::repr, + nullptr, nullptr, nullptr, nullptr, diff --git a/goopylib/objects/rectangle/rectangle.cpp b/goopylib/objects/rectangle/rectangle.cpp index b8ce0c3a..2ce3ace0 100644 --- a/goopylib/objects/rectangle/rectangle.cpp +++ b/goopylib/objects/rectangle/rectangle.cpp @@ -39,12 +39,6 @@ namespace rectangle { return 0; } - PyObject *repr(RectangleObject *Py_UNUSED(self)) { - GP_PY_TRACE("gp.rectangle.Rectangle.__repr__()"); - // TODO object toString methods - return PyUnicode_FromString("Rectangle()"); - } - int traverse(RectangleObject *Py_UNUSED(self), visitproc Py_UNUSED(visit), void *Py_UNUSED(arg)) { return 0; } diff --git a/goopylib/objects/rectangle/rectangle.h b/goopylib/objects/rectangle/rectangle.h index ac504b58..1d9d28a7 100644 --- a/goopylib/objects/rectangle/rectangle.h +++ b/goopylib/objects/rectangle/rectangle.h @@ -12,8 +12,6 @@ namespace rectangle { int init(RectangleObject *self, PyObject *args, PyObject *kwds); - PyObject *repr(RectangleObject *self); - int traverse(RectangleObject *self, visitproc visit, void *arg); int clear(RectangleObject *self); diff --git a/goopylib/objects/rectangle/type.cpp b/goopylib/objects/rectangle/type.cpp index e6a8c5a0..0adad676 100644 --- a/goopylib/objects/rectangle/type.cpp +++ b/goopylib/objects/rectangle/type.cpp @@ -10,7 +10,7 @@ PyTypeObject RectangleType = { nullptr, nullptr, nullptr, - (reprfunc) rectangle::repr, + nullptr, nullptr, nullptr, nullptr, diff --git a/goopylib/objects/renderable/renderable.cpp b/goopylib/objects/renderable/renderable.cpp index 0f6cf1f4..6d8d432a 100644 --- a/goopylib/objects/renderable/renderable.cpp +++ b/goopylib/objects/renderable/renderable.cpp @@ -23,13 +23,12 @@ namespace renderable { int init(RenderableObject *Py_UNUSED(self), PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds)) { GP_PY_INFO("gp.renderable.Renderable()"); - return 0; } - PyObject *repr(RenderableObject *Py_UNUSED(self)) { + PyObject *repr(RenderableObject *self) { GP_PY_TRACE("gp.renderable.Renderable.__repr__()"); - return PyUnicode_FromString("Renderable()"); + return PyUnicode_FromString(self->renderable->toString().c_str()); } int traverse(RenderableObject *Py_UNUSED(self), visitproc Py_UNUSED(visit), void *Py_UNUSED(arg)) { diff --git a/goopylib/objects/triangle/triangle.cpp b/goopylib/objects/triangle/triangle.cpp index 33656a28..262506f1 100644 --- a/goopylib/objects/triangle/triangle.cpp +++ b/goopylib/objects/triangle/triangle.cpp @@ -35,11 +35,6 @@ namespace triangle { return 0; } - PyObject *repr(TriangleObject *Py_UNUSED(self)) { - GP_PY_TRACE("gp.triangle.Triangle.__repr__()"); - return PyUnicode_FromString("Triangle()"); - } - int traverse(TriangleObject *Py_UNUSED(self), visitproc Py_UNUSED(visit), void *Py_UNUSED(arg)) { return 0; } diff --git a/goopylib/objects/triangle/triangle.h b/goopylib/objects/triangle/triangle.h index ff48d964..d1f12ace 100644 --- a/goopylib/objects/triangle/triangle.h +++ b/goopylib/objects/triangle/triangle.h @@ -15,8 +15,6 @@ namespace triangle { int init(TriangleObject *self, PyObject *args, PyObject *kwds); - PyObject *repr(TriangleObject *self); - int traverse(TriangleObject *self, visitproc visit, void *arg); int clear(TriangleObject *self); diff --git a/goopylib/objects/triangle/type.cpp b/goopylib/objects/triangle/type.cpp index 944a5e6d..ee683cad 100644 --- a/goopylib/objects/triangle/type.cpp +++ b/goopylib/objects/triangle/type.cpp @@ -30,7 +30,7 @@ PyTypeObject TriangleType = { nullptr, nullptr, nullptr, - (reprfunc) triangle::repr, + nullptr, nullptr, nullptr, nullptr, diff --git a/src/goopylib/objects/Image.cpp b/src/goopylib/objects/Image.cpp index 7c4f889e..53570c5b 100644 --- a/src/goopylib/objects/Image.cpp +++ b/src/goopylib/objects/Image.cpp @@ -52,7 +52,7 @@ namespace gp { } std::string Image::toString() const { - return strformat("Image(%s, (%g, %g))", m_Path.c_str(), m_Position.x, m_Position.y); + return strformat("Image('%s', (%g, %g))", m_Path.c_str(), m_Position.x, m_Position.y); } } diff --git a/src/goopylib/objects/TexturedQuad.cpp b/src/goopylib/objects/TexturedQuad.cpp index d3356693..a7e742dc 100644 --- a/src/goopylib/objects/TexturedQuad.cpp +++ b/src/goopylib/objects/TexturedQuad.cpp @@ -47,7 +47,7 @@ namespace gp { } std::string TexturedQuad::toString() const { - return strformat("TexturedQuad(%s, (%g, %g), (%g, %g), (%g, %g), (%g, %g))", m_Texture.c_str(), + return strformat("TexturedQuad('%s', (%g, %g), (%g, %g), (%g, %g), (%g, %g))", m_Texture.c_str(), getP1().x, getP1().y, getP2().x, getP2().y, getP3().x, getP3().y, getP4().x, getP4().y); } } diff --git a/src/goopylib/objects/TexturedRectangle.cpp b/src/goopylib/objects/TexturedRectangle.cpp index 70ef02c8..40389a93 100644 --- a/src/goopylib/objects/TexturedRectangle.cpp +++ b/src/goopylib/objects/TexturedRectangle.cpp @@ -62,7 +62,7 @@ namespace gp { }; std::string TexturedRectangle::toString() const { - return strformat("TexturedQuad(%s, (%g, %g), (%g, %g))", m_Texture.c_str(), + return strformat("TexturedQuad('%s', (%g, %g), (%g, %g))", m_Texture.c_str(), getP1().x, getP1().y, getP3().x, getP3().y); } }