equal
deleted
inserted
replaced
|
1 |
|
2 /* Code to access structure members by accessing attributes */ |
|
3 |
|
4 #include "structmember.h" |
|
5 |
|
6 #define OFF(x) offsetof(XXXXobject, x) |
|
7 |
|
8 static struct memberlist $abbrev$_memberlist[] = { |
|
9 /* XXXX Add lines like { "foo", T_INT, OFF(foo), RO } */ |
|
10 |
|
11 {NULL} /* Sentinel */ |
|
12 }; |
|
13 |
|
14 static PyObject * |
|
15 $abbrev$_getattr($abbrev$object *self, char *name) |
|
16 { |
|
17 PyObject *rv; |
|
18 |
|
19 /* XXXX Add your own getattr code here */ |
|
20 rv = PyMember_Get((char *)/*XXXX*/0, $abbrev$_memberlist, name); |
|
21 if (rv) |
|
22 return rv; |
|
23 PyErr_Clear(); |
|
24 return Py_FindMethod($abbrev$_methods, (PyObject *)self, name); |
|
25 } |
|
26 |
|
27 |
|
28 static int |
|
29 $abbrev$_setattr($abbrev$object *self, char *name, PyObject *v) |
|
30 { |
|
31 /* XXXX Add your own setattr code here */ |
|
32 if ( v == NULL ) { |
|
33 PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute"); |
|
34 return -1; |
|
35 } |
|
36 return PyMember_Set((char *)/*XXXX*/0, $abbrev$_memberlist, name, v); |
|
37 } |