Mercurial > cpython-lru_cache-weakref
annotate Tools/modulator/Templates/object_structure @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 847425d5bca8 |
| children | 74a3c6826683 |
| rev | line source |
|---|---|
|
2713
cd9d86ecc175
Templates converted to new naming conventions (thanks to Chak Tan)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2466
diff
changeset
|
1 |
|
2466
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 /* Code to access structure members by accessing attributes */ |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 #include "structmember.h" |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 #define OFF(x) offsetof(XXXXobject, x) |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 static struct memberlist $abbrev$_memberlist[] = { |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 /* XXXX Add lines like { "foo", T_INT, OFF(foo), RO } */ |
|
2713
cd9d86ecc175
Templates converted to new naming conventions (thanks to Chak Tan)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2466
diff
changeset
|
10 |
|
2466
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 {NULL} /* Sentinel */ |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 }; |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 |
|
2713
cd9d86ecc175
Templates converted to new naming conventions (thanks to Chak Tan)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2466
diff
changeset
|
14 static PyObject * |
|
21561
847425d5bca8
Patches by Jens B. Jorgensen with small mods by me:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2713
diff
changeset
|
15 $abbrev$_getattr($abbrev$object *self, char *name) |
|
2466
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 { |
|
2713
cd9d86ecc175
Templates converted to new naming conventions (thanks to Chak Tan)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2466
diff
changeset
|
17 PyObject *rv; |
|
2466
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 /* XXXX Add your own getattr code here */ |
|
2713
cd9d86ecc175
Templates converted to new naming conventions (thanks to Chak Tan)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2466
diff
changeset
|
20 rv = PyMember_Get((char *)/*XXXX*/0, $abbrev$_memberlist, name); |
|
2466
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 if (rv) |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 return rv; |
|
2713
cd9d86ecc175
Templates converted to new naming conventions (thanks to Chak Tan)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2466
diff
changeset
|
23 PyErr_Clear(); |
|
cd9d86ecc175
Templates converted to new naming conventions (thanks to Chak Tan)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2466
diff
changeset
|
24 return Py_FindMethod($abbrev$_methods, (PyObject *)self, name); |
|
2466
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 } |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 static int |
|
21561
847425d5bca8
Patches by Jens B. Jorgensen with small mods by me:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2713
diff
changeset
|
29 $abbrev$_setattr($abbrev$object *self, char *name, PyObject *v) |
|
2466
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 { |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 /* XXXX Add your own setattr code here */ |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 if ( v == NULL ) { |
|
2713
cd9d86ecc175
Templates converted to new naming conventions (thanks to Chak Tan)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2466
diff
changeset
|
33 PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute"); |
|
2466
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 return -1; |
|
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 } |
|
2713
cd9d86ecc175
Templates converted to new naming conventions (thanks to Chak Tan)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2466
diff
changeset
|
36 return PyMember_Set((char *)/*XXXX*/0, $abbrev$_memberlist, name, v); |
|
2466
322fc596f1c4
checkin of Jack's original version
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 } |
