mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 12:30:19 +00:00
28 lines
703 B
C
28 lines
703 B
C
#pragma once
|
|
|
|
#include "pocketpy/objects/namedict.h"
|
|
#include "pocketpy/objects/base.h"
|
|
|
|
typedef struct PyObject {
|
|
py_Type type; // we have a duplicated type here for convenience
|
|
// bool _;
|
|
bool gc_marked;
|
|
int slots; // number of slots in the object
|
|
char flex[];
|
|
} PyObject;
|
|
|
|
// slots >= 0, allocate N slots
|
|
// slots == -1, allocate a dict
|
|
|
|
// | HEADER | <N slots> | <userdata>
|
|
// | HEADER | <dict> | <userdata>
|
|
|
|
py_TValue* PyObject__slots(PyObject* self);
|
|
NameDict* PyObject__dict(PyObject* self);
|
|
void* PyObject__userdata(PyObject* self);
|
|
|
|
#define PK_OBJ_SLOTS_SIZE(slots) ((slots) >= 0 ? sizeof(py_TValue) * (slots) : sizeof(NameDict))
|
|
|
|
void PyObject__dtor(PyObject* self);
|
|
|