untested PyColor base implementation

This commit is contained in:
John McCardle 2024-03-23 23:07:10 -04:00
commit 2cac6f03c6
2 changed files with 82 additions and 0 deletions

40
src/PyColor.h Normal file
View file

@ -0,0 +1,40 @@
#pragma once
#include "Common.h"
#include "Python.h"
class PyColor;
typedef struct {
sf::Color* target; // color target to set/get
std::weak_ptr<UIDrawable> parent; // lifetime management: parent must still exist
int index; // specific to the parent class, which color is it?
} _PyColorData;
typedef struct {
PyObject_HEAD
_PyColorData data;
} PyTextureObject;
class PyColor
{
private:
_PyColorData data;
public:
PyObject* pyObject();
static Py_hash_t hash(PyObject*);
static int init(PyColorObject*, PyObject*, PyObject*);
static PyObject* pynew(PyTypeObject* type, PyObject* args=NULL, PyObject* kwds=NULL);
};
namespace mcrfpydef {
static PyTypeObject PyColorType = {
.tp_name = "mcrfpy.Color",
.tp_basicsize = sizeof(PyColorObject),
.tp_itemsize = 0,
.tp_hash = PyColor::hash,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = PyDoc_STR("SFML Color Object"),
.tp_init = (initproc)PyColor::init,
.tp_new = PyTColor::pynew,
};
}