Mercurial > cpython-lru_cache-weakref
annotate Objects/funcobject.c @ 3216:d00a79ebb027 legacy-trunk
Added missing imgpbm and imgsgi modules
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Thu, 12 Oct 1995 10:23:27 +0000 |
| parents | 420874f7d8bd |
| children | 65d2d8e67da3 |
| 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 | |
| 7 Permission to use, copy, modify, and distribute this software and its | |
| 8 documentation for any purpose and without fee is hereby granted, | |
| 9 provided that the above copyright notice appear in all copies and that | |
| 10 both that copyright notice and this permission notice appear in | |
| 11 supporting documentation, and that the names of Stichting Mathematisch | |
| 12 Centrum or CWI not be used in advertising or publicity pertaining to | |
| 13 distribution of the software without specific, written prior permission. | |
| 14 | |
| 15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO | |
| 16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE | |
| 18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| 19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| 20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
| 21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 22 | |
| 23 ******************************************************************/ | |
| 24 | |
| 6 | 25 /* Function object implementation */ |
| 26 | |
| 86 | 27 #include "allobjects.h" |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
28 #include "compile.h" |
| 86 | 29 #include "structmember.h" |
| 6 | 30 |
| 31 object * | |
|
84
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
32 newfuncobject(code, globals) |
|
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
33 object *code; |
| 6 | 34 object *globals; |
| 35 { | |
| 36 funcobject *op = NEWOBJ(funcobject, &Functype); | |
| 37 if (op != NULL) { | |
|
2082
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
38 object *doc; |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
39 object *consts; |
|
84
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
40 INCREF(code); |
|
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
41 op->func_code = code; |
|
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
42 INCREF(globals); |
| 6 | 43 op->func_globals = globals; |
|
2082
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
44 op->func_name = ((codeobject *)code)->co_name; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
45 INCREF(op->func_name); |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
46 op->func_defaults = NULL; /* No default arguments */ |
|
2082
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
47 consts = ((codeobject *)code)->co_consts; |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
48 if (gettuplesize(consts) >= 1) { |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
49 doc = gettupleitem(consts, 0); |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
50 if (!is_stringobject(doc)) |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
51 doc = None; |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
52 } |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
53 else |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
54 doc = None; |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
55 INCREF(doc); |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
56 op->func_doc = doc; |
| 6 | 57 } |
| 58 return (object *)op; | |
| 59 } | |
| 60 | |
|
84
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
61 object * |
|
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
62 getfunccode(op) |
| 6 | 63 object *op; |
| 64 { | |
| 65 if (!is_funcobject(op)) { | |
| 27 | 66 err_badcall(); |
| 6 | 67 return NULL; |
| 68 } | |
|
84
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
69 return ((funcobject *) op) -> func_code; |
| 6 | 70 } |
| 71 | |
| 72 object * | |
| 73 getfuncglobals(op) | |
| 74 object *op; | |
| 75 { | |
| 76 if (!is_funcobject(op)) { | |
| 27 | 77 err_badcall(); |
| 6 | 78 return NULL; |
| 79 } | |
| 80 return ((funcobject *) op) -> func_globals; | |
| 81 } | |
| 82 | |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
83 object * |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
84 PyFunction_GetDefaults(op) |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
85 object *op; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
86 { |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
87 if (!is_funcobject(op)) { |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
88 err_badcall(); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
89 return NULL; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
90 } |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
91 return ((funcobject *) op) -> func_defaults; |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
92 } |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
93 |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
94 int |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
95 PyFunction_SetDefaults(op, defaults) |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
96 object *op; |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
97 object *defaults; |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
98 { |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
99 if (!is_funcobject(op)) { |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
100 err_badcall(); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
101 return -1; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
102 } |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
103 if (defaults == None) |
|
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
104 defaults = NULL; |
|
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
105 else if (is_tupleobject(defaults)) |
|
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
106 XINCREF(defaults); |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
107 else { |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
108 err_setstr(SystemError, "non-tuple default args"); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
109 return -1; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
110 } |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
111 XDECREF(((funcobject *) op) -> func_defaults); |
|
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
112 ((funcobject *) op) -> func_defaults = defaults; |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
113 return 0; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
114 } |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
115 |
| 6 | 116 /* Methods */ |
| 117 | |
| 86 | 118 #define OFF(x) offsetof(funcobject, x) |
| 119 | |
| 120 static struct memberlist func_memberlist[] = { | |
|
588
7d24de643fb5
Added READONLY specifier to data members.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
121 {"func_code", T_OBJECT, OFF(func_code), READONLY}, |
|
7d24de643fb5
Added READONLY specifier to data members.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
122 {"func_globals",T_OBJECT, OFF(func_globals), READONLY}, |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
123 {"func_name", T_OBJECT, OFF(func_name), READONLY}, |
|
2105
ea7b2bf0b521
add restrictions in restricted mode
Guido van Rossum <guido@python.org>
parents:
2082
diff
changeset
|
124 {"__name__", T_OBJECT, OFF(func_name), READONLY}, |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
125 {"func_defaults",T_OBJECT, OFF(func_defaults), READONLY}, |
|
2082
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
126 {"func_doc", T_OBJECT, OFF(func_doc)}, |
|
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
127 {"__doc__", T_OBJECT, OFF(func_doc)}, |
| 86 | 128 {NULL} /* Sentinel */ |
| 129 }; | |
| 130 | |
| 131 static object * | |
| 132 func_getattr(op, name) | |
| 133 funcobject *op; | |
| 134 char *name; | |
| 135 { | |
|
2105
ea7b2bf0b521
add restrictions in restricted mode
Guido van Rossum <guido@python.org>
parents:
2082
diff
changeset
|
136 if (name[0] != '_' && getrestricted()) { |
|
ea7b2bf0b521
add restrictions in restricted mode
Guido van Rossum <guido@python.org>
parents:
2082
diff
changeset
|
137 err_setstr(RuntimeError, |
|
ea7b2bf0b521
add restrictions in restricted mode
Guido van Rossum <guido@python.org>
parents:
2082
diff
changeset
|
138 "function attributes not accessible in restricted mode"); |
|
ea7b2bf0b521
add restrictions in restricted mode
Guido van Rossum <guido@python.org>
parents:
2082
diff
changeset
|
139 return NULL; |
|
ea7b2bf0b521
add restrictions in restricted mode
Guido van Rossum <guido@python.org>
parents:
2082
diff
changeset
|
140 } |
| 86 | 141 return getmember((char *)op, func_memberlist, name); |
| 142 } | |
| 143 | |
| 6 | 144 static void |
| 86 | 145 func_dealloc(op) |
| 6 | 146 funcobject *op; |
| 147 { | |
|
84
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
148 DECREF(op->func_code); |
| 6 | 149 DECREF(op->func_globals); |
|
2205
527889ae8450
fix leak in func_dealloc (forgot to decref name)
Guido van Rossum <guido@python.org>
parents:
2105
diff
changeset
|
150 DECREF(op->func_name); |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
151 XDECREF(op->func_defaults); |
|
2082
4afa7eb4734b
Added __doc__ attribute (alias func_doc), initialized from first
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
152 XDECREF(op->func_doc); |
|
84
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
153 DEL(op); |
| 6 | 154 } |
| 155 | |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
156 static object* |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
157 func_repr(op) |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
158 funcobject *op; |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
159 { |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
160 char buf[140]; |
|
1415
06570429f062
* import.c (get_module): pass .py filename to parse_file, not .pyc filename!
Guido van Rossum <guido@python.org>
parents:
1399
diff
changeset
|
161 if (op->func_name == None) |
|
06570429f062
* import.c (get_module): pass .py filename to parse_file, not .pyc filename!
Guido van Rossum <guido@python.org>
parents:
1399
diff
changeset
|
162 sprintf(buf, "<anonymous function at %lx>", (long)op); |
|
06570429f062
* import.c (get_module): pass .py filename to parse_file, not .pyc filename!
Guido van Rossum <guido@python.org>
parents:
1399
diff
changeset
|
163 else |
|
06570429f062
* import.c (get_module): pass .py filename to parse_file, not .pyc filename!
Guido van Rossum <guido@python.org>
parents:
1399
diff
changeset
|
164 sprintf(buf, "<function %.100s at %lx>", |
|
06570429f062
* import.c (get_module): pass .py filename to parse_file, not .pyc filename!
Guido van Rossum <guido@python.org>
parents:
1399
diff
changeset
|
165 getstringvalue(op->func_name), |
|
06570429f062
* import.c (get_module): pass .py filename to parse_file, not .pyc filename!
Guido van Rossum <guido@python.org>
parents:
1399
diff
changeset
|
166 (long)op); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
167 return newstringobject(buf); |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
168 } |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
169 |
|
1399
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
170 static int |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
171 func_compare(f, g) |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
172 funcobject *f, *g; |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
173 { |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
174 int c; |
|
1399
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
175 if (f->func_globals != g->func_globals) |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
176 return (f->func_globals < g->func_globals) ? -1 : 1; |
|
2842
420874f7d8bd
changes for keyword arguments and fast function call; added abstract.c
Guido van Rossum <guido@python.org>
parents:
2205
diff
changeset
|
177 c = cmpobject(f->func_defaults, g->func_defaults); |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
178 if (c != 0) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
179 return c; |
|
1399
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
180 return cmpobject(f->func_code, g->func_code); |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
181 } |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
182 |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
183 static long |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
184 func_hash(f) |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
185 funcobject *f; |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
186 { |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
187 long h; |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
188 h = hashobject(f->func_code); |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
189 if (h == -1) return h; |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
190 h = h ^ (long)f->func_globals; |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
191 if (h == -1) h = -2; |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
192 return h; |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
193 } |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
194 |
| 6 | 195 typeobject Functype = { |
| 196 OB_HEAD_INIT(&Typetype) | |
| 197 0, | |
| 198 "function", | |
| 199 sizeof(funcobject), | |
| 200 0, | |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
201 (destructor)func_dealloc, /*tp_dealloc*/ |
|
84
a79cbb2655ba
Function objects no longer contain a parse tree node, but intermediate
Guido van Rossum <guido@python.org>
parents:
27
diff
changeset
|
202 0, /*tp_print*/ |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
203 (getattrfunc)func_getattr, /*tp_getattr*/ |
| 6 | 204 0, /*tp_setattr*/ |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
205 (cmpfunc)func_compare, /*tp_compare*/ |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
206 (reprfunc)func_repr, /*tp_repr*/ |
|
1399
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
207 0, /*tp_as_number*/ |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
208 0, /*tp_as_sequence*/ |
|
cc172ce05561
Added compare operations for functions and code objects.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
209 0, /*tp_as_mapping*/ |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1415
diff
changeset
|
210 (hashfunc)func_hash, /*tp_hash*/ |
| 6 | 211 }; |
