summaryrefslogtreecommitdiffstats
path: root/Tools/modulator/Templates/object_structure
blob: 78daa62517753a53494b84ff447eaaadb3cdfbe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

/* Code to access structure members by accessing attributes */

#include "structmember.h"

#define OFF(x) offsetof(XXXXobject, x)

static PyMemberDef $abbrev$_memberlist[] = {
	/* XXXX Add lines like { "foo", T_INT, OFF(foo), READONLY }  */

	{NULL}	/* Sentinel */
};

static PyObject *
$abbrev$_getattr($abbrev$object *self, char *name)
{
	PyObject *rv;
	
	/* XXXX Add your own getattr code here */
	rv = PyMember_GetOne((char *)/*XXXX*/0, &$abbrev$_memberlist[i]);
	if (rv)
		return rv;
	PyErr_Clear();
	return Py_FindMethod($abbrev$_methods, (PyObject *)self, name);
}


static int
$abbrev$_setattr($abbrev$object *self, char *name, PyObject *v)
{
	/* XXXX Add your own setattr code here */
	if ( v == NULL ) {
		PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute");
		return -1;
	}
	return PyMember_SetOne((char *)/*XXXX*/0, &$abbrev$_memberlist[i], v);
}