Squashed commit of the following: [standardize_vector_handling]
closes #13 Deferring class standardization for the UI.h overhaul. commit5edebdd643Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 31 14:21:07 2024 -0400 PyVector init should be pretty reliable now commitc13e185289Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 31 13:51:29 2024 -0400 PyColor fix - Init corrections commit8871f6be6eAuthor: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 30 22:51:55 2024 -0400 Parse arguments: no args & Vector object args work, tuples and bare numerics still do not commit1c12e8719cAuthor: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 30 22:32:28 2024 -0400 Not bad for a quick first salvo, but I cannot figure out why init isn't cooperating.
This commit is contained in:
parent
f82508b753
commit
fbf263a038
5 changed files with 201 additions and 50 deletions
42
src/PyVector.h
Normal file
42
src/PyVector.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
#include "Common.h"
|
||||
#include "Python.h"
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
sf::Vector2f data;
|
||||
} PyVectorObject;
|
||||
|
||||
class PyVector
|
||||
{
|
||||
public:
|
||||
sf::Vector2f data;
|
||||
PyVector(sf::Vector2f);
|
||||
PyVector();
|
||||
PyObject* pyObject();
|
||||
static sf::Vector2f fromPy(PyObject*);
|
||||
static sf::Vector2f fromPy(PyVectorObject*);
|
||||
static PyObject* repr(PyObject*);
|
||||
static Py_hash_t hash(PyObject*);
|
||||
static int init(PyVectorObject*, PyObject*, PyObject*);
|
||||
static PyObject* pynew(PyTypeObject* type, PyObject* args=NULL, PyObject* kwds=NULL);
|
||||
static PyObject* get_member(PyObject*, void*);
|
||||
static int set_member(PyObject*, PyObject*, void*);
|
||||
|
||||
static PyGetSetDef getsetters[];
|
||||
};
|
||||
|
||||
namespace mcrfpydef {
|
||||
static PyTypeObject PyVectorType = {
|
||||
.tp_name = "mcrfpy.Vector",
|
||||
.tp_basicsize = sizeof(PyVectorObject),
|
||||
.tp_itemsize = 0,
|
||||
.tp_repr = PyVector::repr,
|
||||
.tp_hash = PyVector::hash,
|
||||
.tp_flags = Py_TPFLAGS_DEFAULT,
|
||||
.tp_doc = PyDoc_STR("SFML Vector Object"),
|
||||
.tp_getset = PyVector::getsetters,
|
||||
.tp_init = (initproc)PyVector::init,
|
||||
.tp_new = PyVector::pynew,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue