Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct {
- PyObject_HEAD
- int my_int;
- double my_double;
- PyObject *my_pyobject;
- } cvarobject;
- static PyTypeObject cvar_type;
- // If you want to make this non-static, make sure to avoid name clashes.
- static cvarobject globals = {
- PyObject_HEAD_INIT(&cvar_type)
- };
- static PyMemberDef cvar_members[] = {
- // see https://docs.python.org/3/c-api/structures.html#c.PyMethodDef
- {"my_int", T_INT, offsetof(cvarobject, my_int), 0},
- {"my_double", T_DOUBLE, offsetof(cvarobject, my_double), 0},
- {"my_pyobject", T_OBJECT_EX, offsetof(cvarobject, my_pyobject), 0}
- }
- static PyTypeObject cvar_type {
- PyObject_HEAD_INIT(NULL)
- "mymodule.cvar_type", /* tp_name */
- sizeof(cvarobject), /* tp_basicsize */
- // Designated initializer, to skip all the stuff in between
- // that should just be zeroed.
- .tp_members=cvar_members
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement