0
0
mirror of https://github.com/python/cpython.git synced 2024-12-01 03:01:36 +01:00
cpython/Tools/modulator/Templates/object_structure

43 lines
903 B
Plaintext
Raw Normal View History

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-03-02 15:05:29 +01:00
{NULL} /* Sentinel */
};
static PyObject *
1995-03-02 15:05:29 +01:00
$abbrev$_getattr(self, name)
$abbrev$object *self;
char *name;
{
PyObject *rv;
1995-03-02 15:05:29 +01:00
/* XXXX Add your own getattr code here */
rv = PyMember_Get((char *)/*XXXX*/0, $abbrev$_memberlist, name);
1995-03-02 15:05:29 +01:00
if (rv)
return rv;
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;
PyObject *v;
1995-03-02 15:05:29 +01:00
{
/* XXXX Add your own setattr code here */
if ( v == NULL ) {
PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute");
1995-03-02 15:05:29 +01:00
return -1;
}
return PyMember_Set((char *)/*XXXX*/0, $abbrev$_memberlist, name, v);
1995-03-02 15:05:29 +01:00
}