diff options
Diffstat (limited to 'Tools/modulator/Templates/object_structure')
-rw-r--r-- | Tools/modulator/Templates/object_structure | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Tools/modulator/Templates/object_structure b/Tools/modulator/Templates/object_structure new file mode 100644 index 0000000..6a54518 --- /dev/null +++ b/Tools/modulator/Templates/object_structure @@ -0,0 +1,41 @@ +/* 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 } */ + {NULL} /* Sentinel */ +}; + +static object * +$abbrev$_getattr(self, name) + $abbrev$object *self; + char *name; +{ + object *rv; + + /* XXXX Add your own getattr code here */ + rv = getmember((char *)/*XXXX*/0, $abbrev$_memberlist, name); + if (rv) + return rv; + err_clear(); + return findmethod($abbrev$_methods, (object *)self, name); +} + + +static int +$abbrev$_setattr(self, name, v) + $abbrev$object *self; + char *name; + object *v; +{ + /* XXXX Add your own setattr code here */ + if ( v == NULL ) { + err_setstr(AttributeError, "Cannot delete attribute"); + return -1; + } + return setmember((char *)/*XXXX*/0, $abbrev$_memberlist, name, v); +} + |