| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 1 | /*********************************************************** | 
| Guido van Rossum | 6610ad9 | 1995-01-04 19:07:38 +0000 | [diff] [blame] | 2 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, | 
 | 3 | The Netherlands. | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 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 |  | 
| Guido van Rossum | 0dfcf75 | 1996-08-12 22:00:53 +0000 | [diff] [blame] | 25 | #ifdef SUPPORT_OBSOLETE_ACCESS /* This object type is no longer supported */ | 
 | 26 |  | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 27 | /* Access object implementation */ | 
 | 28 |  | 
| Guido van Rossum | 234f942 | 1993-06-17 12:35:49 +0000 | [diff] [blame] | 29 | /* XXX TO DO LIST | 
| Guido van Rossum | 234f942 | 1993-06-17 12:35:49 +0000 | [diff] [blame] | 30 |    - __init__ and __del__ (and all other similar methods) | 
| Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 31 |      should be usable even when private, not ignored | 
| Guido van Rossum | 234f942 | 1993-06-17 12:35:49 +0000 | [diff] [blame] | 32 | */ | 
 | 33 |  | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 34 | #include "allobjects.h" | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 35 | #include "ceval.h" | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 36 | #include "structmember.h" | 
 | 37 | #include "modsupport.h"		/* For getargs() etc. */ | 
 | 38 |  | 
 | 39 | typedef struct { | 
 | 40 | 	OB_HEAD | 
 | 41 | 	object		*ac_value; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 42 | 	object		*ac_owner; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 43 | 	typeobject	*ac_type; | 
 | 44 | 	int		ac_mode; | 
 | 45 | } accessobject; | 
 | 46 |  | 
 | 47 | /* Forward */ | 
 | 48 | static int typecheck PROTO((object *, typeobject *)); | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 49 | static int ownercheck PROTO((object *, object *, int, int)); | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 50 |  | 
 | 51 | object * | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 52 | newaccessobject(value, owner, type, mode) | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 53 | 	object *value; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 54 | 	object *owner; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 55 | 	typeobject *type; | 
 | 56 | 	int mode; | 
 | 57 | { | 
 | 58 | 	accessobject *ap; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 59 | 	if (!typecheck(value, type)) { | 
 | 60 | 		err_setstr(AccessError, | 
 | 61 | 		"access: initial value has inappropriate type"); | 
 | 62 | 		return NULL; | 
 | 63 | 	} | 
 | 64 | 	ap = NEWOBJ(accessobject, &Accesstype); | 
 | 65 | 	if (ap == NULL) | 
 | 66 | 		return NULL; | 
 | 67 | 	XINCREF(value); | 
 | 68 | 	ap->ac_value = value; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 69 | 	XINCREF(owner); | 
 | 70 | 	ap->ac_owner = owner; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 71 | 	XINCREF(type); | 
 | 72 | 	ap->ac_type = (typeobject *)type; | 
 | 73 | 	ap->ac_mode = mode; | 
 | 74 | 	return (object *)ap; | 
 | 75 | } | 
 | 76 |  | 
 | 77 | object * | 
 | 78 | cloneaccessobject(op) | 
 | 79 | 	object *op; | 
 | 80 | { | 
 | 81 | 	register accessobject *ap; | 
 | 82 | 	if (!is_accessobject(op)) { | 
 | 83 | 		err_badcall(); | 
 | 84 | 		return NULL; | 
 | 85 | 	} | 
 | 86 | 	ap = (accessobject *)op; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 87 | 	return newaccessobject(ap->ac_value, ap->ac_owner, | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 88 | 			       ap->ac_type, ap->ac_mode); | 
 | 89 | } | 
 | 90 |  | 
 | 91 | void | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 92 | setaccessowner(op, owner) | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 93 | 	object *op; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 94 | 	object *owner; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 95 | { | 
 | 96 | 	register accessobject *ap; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 97 | 	if (!is_accessobject(op)) | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 98 | 		return; /* XXX no error */ | 
 | 99 | 	ap = (accessobject *)op; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 100 | 	XDECREF(ap->ac_owner); | 
 | 101 | 	XINCREF(owner); | 
 | 102 | 	ap->ac_owner = owner; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 103 | } | 
 | 104 |  | 
| Guido van Rossum | b3f7258 | 1993-05-21 19:56:10 +0000 | [diff] [blame] | 105 | int | 
 | 106 | hasaccessvalue(op) | 
 | 107 | 	object *op; | 
 | 108 | {	 | 
 | 109 | 	if (!is_accessobject(op)) | 
 | 110 | 		return 0; | 
 | 111 | 	return ((accessobject *)op)->ac_value != NULL; | 
 | 112 | } | 
 | 113 |  | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 114 | object * | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 115 | getaccessvalue(op, caller) | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 116 | 	object *op; | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 117 | 	object *caller; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 118 | { | 
 | 119 | 	register accessobject *ap; | 
 | 120 | 	if (!is_accessobject(op)) { | 
 | 121 | 		err_badcall(); | 
 | 122 | 		return NULL; | 
 | 123 | 	} | 
 | 124 | 	ap = (accessobject *)op; | 
 | 125 | 	 | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 126 | 	if (!ownercheck(caller, ap->ac_owner, AC_R, ap->ac_mode)) { | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 127 | 		err_setstr(AccessError, "read access denied"); | 
 | 128 | 		return NULL; | 
 | 129 | 	} | 
 | 130 | 	 | 
 | 131 | 	if (ap->ac_value == NULL) { | 
 | 132 | 		err_setstr(AccessError, "no current value"); | 
 | 133 | 		return NULL; | 
 | 134 | 	} | 
 | 135 | 	INCREF(ap->ac_value); | 
 | 136 | 	return ap->ac_value; | 
 | 137 | } | 
 | 138 |  | 
 | 139 | int | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 140 | setaccessvalue(op, caller, value) | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 141 | 	object *op; | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 142 | 	object *caller; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 143 | 	object *value; | 
 | 144 | { | 
 | 145 | 	register accessobject *ap; | 
 | 146 | 	if (!is_accessobject(op)) { | 
 | 147 | 		err_badcall(); | 
 | 148 | 		return -1; | 
 | 149 | 	} | 
 | 150 | 	ap = (accessobject *)op; | 
 | 151 | 	 | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 152 | 	if (!ownercheck(caller, ap->ac_owner, AC_W, ap->ac_mode)) { | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 153 | 		err_setstr(AccessError, "write access denied"); | 
 | 154 | 		return -1; | 
 | 155 | 	} | 
 | 156 | 	 | 
 | 157 | 	if (!typecheck(value, ap->ac_type)) { | 
 | 158 | 		err_setstr(AccessError, "assign value of inappropriate type"); | 
 | 159 | 		return -1; | 
 | 160 | 	} | 
 | 161 | 	 | 
 | 162 | 	if (value == NULL) { /* Delete it */ | 
 | 163 | 		if (ap->ac_value == NULL) { | 
 | 164 | 			err_setstr(AccessError, "no current value"); | 
 | 165 | 			return -1; | 
 | 166 | 		} | 
 | 167 | 		DECREF(ap->ac_value); | 
 | 168 | 		ap->ac_value = NULL; | 
 | 169 | 		return 0; | 
 | 170 | 	} | 
 | 171 | 	XDECREF(ap->ac_value); | 
 | 172 | 	INCREF(value); | 
 | 173 | 	ap->ac_value = value; | 
 | 174 | 	return 0; | 
 | 175 | } | 
 | 176 |  | 
 | 177 | static int | 
 | 178 | typecheck(value, type) | 
 | 179 | 	object *value; | 
 | 180 | 	typeobject *type; | 
 | 181 | { | 
 | 182 | 	object *x; | 
 | 183 | 	if (value == NULL || type == NULL) | 
 | 184 | 		return 1; /* No check */ | 
 | 185 | 	if (value->ob_type == type) | 
 | 186 | 		return 1; /* Exact match */ | 
 | 187 | 	if (type == &Anynumbertype) { | 
 | 188 | 		if (value->ob_type->tp_as_number == NULL) | 
 | 189 | 			return 0; | 
 | 190 | 		if (!is_instanceobject(value)) | 
 | 191 | 			return 1; | 
 | 192 | 		/* For instances, make sure it really looks like a number */ | 
 | 193 | 		x = getattr(value, "__sub__"); | 
 | 194 | 		if (x == NULL) { | 
 | 195 | 			err_clear(); | 
 | 196 | 			return 0; | 
 | 197 | 		} | 
 | 198 | 		DECREF(x); | 
 | 199 | 		return 1; | 
 | 200 | 	} | 
 | 201 | 	if (type == &Anysequencetype) { | 
 | 202 | 		if (value->ob_type->tp_as_sequence == NULL) | 
 | 203 | 			return 0; | 
 | 204 | 		if (!is_instanceobject(value)) | 
 | 205 | 			return 1; | 
 | 206 | 		/* For instances, make sure it really looks like a sequence */ | 
 | 207 | 		x = getattr(value, "__getslice__"); | 
 | 208 | 		if (x == NULL) { | 
 | 209 | 			err_clear(); | 
 | 210 | 			return 0; | 
 | 211 | 		} | 
 | 212 | 		DECREF(x); | 
 | 213 | 		return 1; | 
 | 214 | 	} | 
 | 215 | 	if (type == &Anymappingtype) { | 
 | 216 | 		if (value->ob_type->tp_as_mapping == NULL) | 
 | 217 | 			return 0; | 
 | 218 | 		if (!is_instanceobject(value)) | 
 | 219 | 			return 1; | 
 | 220 | 		/* For instances, make sure it really looks like a mapping */ | 
 | 221 | 		x = getattr(value, "__getitem__"); | 
 | 222 | 		if (x == NULL) { | 
 | 223 | 			err_clear(); | 
 | 224 | 			return 0; | 
 | 225 | 		} | 
 | 226 | 		DECREF(x); | 
 | 227 | 		return 1; | 
 | 228 | 	} | 
 | 229 | 	return 0; | 
 | 230 | } | 
 | 231 |  | 
 | 232 | static int | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 233 | isprivileged(caller) | 
 | 234 | 	object *caller; | 
 | 235 | { | 
 | 236 | 	object *g; | 
| Sjoerd Mullender | 3bb8a05 | 1993-10-22 12:04:32 +0000 | [diff] [blame] | 237 | 	static char privileged[] = "__privileged__"; | 
 | 238 | 	if (caller != NULL && hasattr(caller, privileged)) | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 239 | 		return 1; | 
 | 240 | 	g = getglobals(); | 
| Sjoerd Mullender | 3bb8a05 | 1993-10-22 12:04:32 +0000 | [diff] [blame] | 241 | 	if (g != NULL && dictlookup(g, privileged)) | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 242 | 		return 1; | 
 | 243 | 	return 0; | 
 | 244 | } | 
 | 245 |  | 
 | 246 | static int | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 247 | ownercheck(caller, owner, access, mode) | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 248 | 	object *caller; | 
 | 249 | 	object *owner; | 
 | 250 | 	int access; | 
 | 251 | 	int mode; | 
 | 252 | { | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 253 | 	int mask = AC_PUBLIC; | 
| Guido van Rossum | ed18fdc | 1993-07-11 19:55:34 +0000 | [diff] [blame] | 254 | 	if (caller == owner || isprivileged(caller)) | 
 | 255 | 		mask |= AC_PRIVATE | AC_PROTECTED; | 
 | 256 | 	else if (caller != NULL && owner != NULL && | 
 | 257 | 		 is_classobject(owner) && is_classobject(caller) && | 
 | 258 | 		 (issubclass(caller, owner) || | 
 | 259 | 		  issubclass(owner, caller))) | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 260 | 			mask |= AC_PROTECTED; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 261 | 	return access & mode & mask; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 262 | } | 
 | 263 |  | 
 | 264 | /* Access methods */ | 
 | 265 |  | 
 | 266 | static void | 
 | 267 | access_dealloc(ap) | 
 | 268 | 	accessobject *ap; | 
 | 269 | { | 
 | 270 | 	XDECREF(ap->ac_value); | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 271 | 	XDECREF(ap->ac_owner); | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 272 | 	XDECREF(ap->ac_type); | 
 | 273 | 	DEL(ap); | 
 | 274 | } | 
 | 275 |  | 
 | 276 | #define OFF(x) offsetof(accessobject, x) | 
 | 277 |  | 
 | 278 | static struct memberlist access_memberlist[] = { | 
 | 279 | 	{"ac_value",	T_OBJECT,	OFF(ac_value)}, | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 280 | 	{"ac_owner",	T_OBJECT,	OFF(ac_owner)}, | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 281 | 	{"ac_type",	T_OBJECT,	OFF(ac_type)}, | 
 | 282 | 	{"ac_mode",	T_INT,		OFF(ac_mode)}, | 
 | 283 | 	{NULL}	/* Sentinel */ | 
 | 284 | }; | 
 | 285 |  | 
 | 286 | static object * | 
 | 287 | access_getattr(ap, name) | 
 | 288 | 	accessobject *ap; | 
 | 289 | 	char *name; | 
 | 290 | { | 
 | 291 | 	return getmember((char *)ap, access_memberlist, name); | 
 | 292 | } | 
 | 293 |  | 
 | 294 | static object * | 
 | 295 | access_repr(ap) | 
 | 296 | 	accessobject *ap; | 
 | 297 | { | 
 | 298 | 	char buf[300]; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 299 | 	char buf2[20]; | 
 | 300 | 	char *ownername; | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 301 | 	typeobject *type = ap->ac_type; | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 302 | 	if (is_classobject(ap->ac_owner)) { | 
 | 303 | 		ownername = | 
 | 304 | 			getstringvalue(((classobject *)ap->ac_owner)->cl_name); | 
 | 305 | 	} | 
 | 306 | 	else { | 
 | 307 | 		sprintf(buf2, "0x%lx", (long)ap->ac_owner); | 
 | 308 | 		ownername = buf2; | 
 | 309 | 	} | 
| Guido van Rossum | b3f7258 | 1993-05-21 19:56:10 +0000 | [diff] [blame] | 310 | 	sprintf(buf, | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 311 | 	"<access object, value 0x%lx, owner %.100s, type %.100s, mode %04o>", | 
| Guido van Rossum | b3f7258 | 1993-05-21 19:56:10 +0000 | [diff] [blame] | 312 | 		(long)(ap->ac_value), | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 313 | 		ownername, | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 314 | 		type ? type->tp_name : "-", | 
 | 315 | 		ap->ac_mode); | 
 | 316 | 	return newstringobject(buf); | 
 | 317 | } | 
 | 318 |  | 
 | 319 | typeobject Accesstype = { | 
 | 320 | 	OB_HEAD_INIT(&Typetype) | 
 | 321 | 	0,			/*ob_size*/ | 
 | 322 | 	"access",		/*tp_name*/ | 
 | 323 | 	sizeof(accessobject),	/*tp_size*/ | 
 | 324 | 	0,			/*tp_itemsize*/ | 
 | 325 | 	/* methods */ | 
| Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 326 | 	(destructor)access_dealloc, /*tp_dealloc*/ | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 327 | 	0,			/*tp_print*/ | 
| Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 328 | 	(getattrfunc)access_getattr, /*tp_getattr*/ | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 329 | 	0,			/*tp_setattr*/ | 
 | 330 | 	0,			/*tp_compare*/ | 
| Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 331 | 	(reprfunc)access_repr, /*tp_repr*/ | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 332 | 	0,			/*tp_as_number*/ | 
 | 333 | 	0,			/*tp_as_sequence*/ | 
 | 334 | 	0,			/*tp_as_mapping*/ | 
 | 335 | 	0,			/*tp_hash*/ | 
 | 336 | }; | 
 | 337 |  | 
| Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 338 |  | 
 | 339 | /* Pseudo type objects to indicate collections of types */ | 
| Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 340 |  | 
 | 341 | /* XXX This should be replaced by a more general "subclassing" | 
 | 342 |    XXX mechanism for type objects... */ | 
 | 343 |  | 
 | 344 | typeobject Anynumbertype = { | 
 | 345 | 	OB_HEAD_INIT(&Typetype) | 
 | 346 | 	0,			/*ob_size*/ | 
 | 347 | 	"*number*",		/*tp_name*/ | 
 | 348 | }; | 
 | 349 |  | 
 | 350 | /* XXX Should really distinguish mutable and immutable sequences as well */ | 
 | 351 |  | 
 | 352 | typeobject Anysequencetype = { | 
 | 353 | 	OB_HEAD_INIT(&Typetype) | 
 | 354 | 	0,			/*ob_size*/ | 
 | 355 | 	"*sequence*",		/*tp_name*/ | 
 | 356 | }; | 
 | 357 |  | 
 | 358 | typeobject Anymappingtype = { | 
 | 359 | 	OB_HEAD_INIT(&Typetype) | 
 | 360 | 	0,			/*ob_size*/ | 
 | 361 | 	"*mapping*",		/*tp_name*/ | 
 | 362 | }; | 
| Guido van Rossum | 0dfcf75 | 1996-08-12 22:00:53 +0000 | [diff] [blame] | 363 |  | 
 | 364 | #endif /* SUPPORT_OBSOLETE_ACCESS */ |