Mercurial > cpython-lru_cache-weakref
annotate Objects/typeobject.c @ 6719:faebc1940432 legacy-trunk
Understand -Xlinker option.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 02 Dec 1997 20:38:11 +0000 |
| parents | d66304963ca7 |
| children | 916fb024ce94 |
| rev | line source |
|---|---|
| 145 | 1 /*********************************************************** |
|
2059
866c81068dbd
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1848
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
866c81068dbd
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1848
diff
changeset
|
3 The Netherlands. |
| 145 | 4 |
| 5 All Rights Reserved | |
| 6 | |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
| 145 | 9 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
| 145 | 11 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
14 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
15 permission. |
| 145 | 16 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
20 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2080
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
| 145 | 29 |
| 30 ******************************************************************/ | |
| 31 | |
| 6 | 32 /* Type object implementation */ |
| 33 | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
34 #include "Python.h" |
| 6 | 35 |
| 36 /* Type object implementation */ | |
| 37 | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
38 static PyObject * |
|
2080
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
39 type_getattr(t, name) |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
40 PyTypeObject *t; |
|
2080
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
41 char *name; |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
42 { |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
43 if (strcmp(name, "__name__") == 0) |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
44 return PyString_FromString(t->tp_name); |
|
2080
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
45 if (strcmp(name, "__doc__") == 0) { |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
46 char *doc = t->tp_doc; |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
47 if (doc != NULL) |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
48 return PyString_FromString(doc); |
|
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
49 Py_INCREF(Py_None); |
|
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
50 return Py_None; |
|
2080
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
51 } |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
52 if (strcmp(name, "__members__") == 0) |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
53 return Py_BuildValue("[ss]", "__doc__", "__name__"); |
|
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
54 PyErr_SetString(PyExc_AttributeError, name); |
|
2080
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
55 return NULL; |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
56 } |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
57 |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
58 static PyObject * |
| 86 | 59 type_repr(v) |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
60 PyTypeObject *v; |
| 6 | 61 { |
| 62 char buf[100]; | |
| 63 sprintf(buf, "<type '%.80s'>", v->tp_name); | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
64 return PyString_FromString(buf); |
| 6 | 65 } |
| 66 | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
67 PyTypeObject PyType_Type = { |
|
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
68 PyObject_HEAD_INIT(&PyType_Type) |
| 6 | 69 0, /* Number of items for varobject */ |
| 70 "type", /* Name of this type */ | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
71 sizeof(PyTypeObject), /* Basic object size */ |
| 6 | 72 0, /* Item size for varobject */ |
| 86 | 73 0, /*tp_dealloc*/ |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
74 0, /*tp_print*/ |
|
2080
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
75 (getattrfunc)type_getattr, /*tp_getattr*/ |
| 86 | 76 0, /*tp_setattr*/ |
| 77 0, /*tp_compare*/ | |
|
2080
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
78 (reprfunc)type_repr, /*tp_repr*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
79 0, /*tp_as_number*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
80 0, /*tp_as_sequence*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
81 0, /*tp_as_mapping*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
82 0, /*tp_hash*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
83 0, /*tp_call*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
84 0, /*tp_str*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
85 0, /*tp_xxx1*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
86 0, /*tp_xxx2*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
87 0, /*tp_xxx3*/ |
|
c21cc7b3ce28
added getattr(), supporting __doc__ and _name__
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
88 0, /*tp_xxx4*/ |
|
5671
d66304963ca7
American spelling in doc string.
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
89 "Define the behavior of a particular type of object.", |
| 6 | 90 }; |
