1995-05-16 15:47:03 +02:00
|
|
|
|
1995-03-02 15:05:29 +01:00
|
|
|
/* Code to access structure members by accessing attributes */
|
|
|
|
|
|
|
|
#include "structmember.h"
|
|
|
|
|
|
|
|
#define OFF(x) offsetof(XXXXobject, x)
|
|
|
|
|
|
|
|
static struct memberlist $abbrev$_memberlist[] = {
|
|
|
|
/* XXXX Add lines like { "foo", T_INT, OFF(foo), RO } */
|
1995-05-16 15:47:03 +02:00
|
|
|
|
1995-03-02 15:05:29 +01:00
|
|
|
{NULL} /* Sentinel */
|
|
|
|
};
|
|
|
|
|
1995-05-16 15:47:03 +02:00
|
|
|
static PyObject *
|
1995-03-02 15:05:29 +01:00
|
|
|
$abbrev$_getattr(self, name)
|
|
|
|
$abbrev$object *self;
|
|
|
|
char *name;
|
|
|
|
{
|
1995-05-16 15:47:03 +02:00
|
|
|
PyObject *rv;
|
1995-03-02 15:05:29 +01:00
|
|
|
|
|
|
|
/* XXXX Add your own getattr code here */
|
1995-05-16 15:47:03 +02:00
|
|
|
rv = PyMember_Get((char *)/*XXXX*/0, $abbrev$_memberlist, name);
|
1995-03-02 15:05:29 +01:00
|
|
|
if (rv)
|
|
|
|
return rv;
|
1995-05-16 15:47:03 +02:00
|
|
|
PyErr_Clear();
|
|
|
|
return Py_FindMethod($abbrev$_methods, (PyObject *)self, name);
|
1995-03-02 15:05:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
$abbrev$_setattr(self, name, v)
|
|
|
|
$abbrev$object *self;
|
|
|
|
char *name;
|
1995-05-16 15:47:03 +02:00
|
|
|
PyObject *v;
|
1995-03-02 15:05:29 +01:00
|
|
|
{
|
|
|
|
/* XXXX Add your own setattr code here */
|
|
|
|
if ( v == NULL ) {
|
1995-05-16 15:47:03 +02:00
|
|
|
PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute");
|
1995-03-02 15:05:29 +01:00
|
|
|
return -1;
|
|
|
|
}
|
1995-05-16 15:47:03 +02:00
|
|
|
return PyMember_Set((char *)/*XXXX*/0, $abbrev$_memberlist, name, v);
|
1995-03-02 15:05:29 +01:00
|
|
|
}
|