Python API improvements: Vectors, bounds, window singleton, hidden types

- #177: GridPoint.grid_pos property returns (x, y) tuple
- #179: Grid.grid_size returns Vector instead of tuple
- #181: Grid.center returns Vector instead of tuple
- #182: Caption.size/w/h read-only properties for text dimensions
- #184: mcrfpy.window singleton for window access
- #185: Removed get_bounds() method, use .bounds property instead
- #188: bounds/global_bounds return (pos, size) as pair of Vectors
- #189: Hide internal types from module namespace (iterators, collections)

Also fixed critical bug: Changed static PyTypeObject to inline in headers
to ensure single instance across translation units (was causing segfaults).

Closes #177, closes #179, closes #181, closes #182, closes #184, closes #185, closes #188, closes #189

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-01-05 23:00:48 -05:00
commit f9b6cdef1c
17 changed files with 448 additions and 87 deletions

View file

@ -53,6 +53,9 @@ public:
// #114 - entities property: list of entities at this cell
static PyObject* get_entities(PyUIGridPointObject* self, void* closure);
// #177 - grid_pos property: grid coordinates as tuple
static PyObject* get_grid_pos(PyUIGridPointObject* self, void* closure);
// #150 - Dynamic property access for named layers
static PyObject* getattro(PyUIGridPointObject* self, PyObject* name);
static int setattro(PyUIGridPointObject* self, PyObject* name, PyObject* value);
@ -74,7 +77,8 @@ public:
};
namespace mcrfpydef {
static PyTypeObject PyUIGridPointType = {
// #189 - Use inline instead of static to ensure single instance across translation units
inline PyTypeObject PyUIGridPointType = {
.ob_base = {.ob_base = {.ob_refcnt = 1, .ob_type = NULL}, .ob_size = 0},
.tp_name = "mcrfpy.GridPoint",
.tp_basicsize = sizeof(PyUIGridPointObject),
@ -90,7 +94,8 @@ namespace mcrfpydef {
.tp_new = NULL, // Prevent instantiation from Python - Issue #12
};
static PyTypeObject PyUIGridPointStateType = {
// #189 - Use inline instead of static to ensure single instance across translation units
inline PyTypeObject PyUIGridPointStateType = {
.ob_base = {.ob_base = {.ob_refcnt = 1, .ob_type = NULL}, .ob_size = 0},
.tp_name = "mcrfpy.GridPointState",
.tp_basicsize = sizeof(PyUIGridPointStateObject),