~malept/ubuntu/lucid/python2.6/dev-dependency-fix

« back to all changes in this revision

Viewing changes to Tools/modulator/Templates/object_structure

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-13 12:51:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090213125100-uufgcb9yeqzujpqw
Tags: upstream-2.6.1
ImportĀ upstreamĀ versionĀ 2.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}