Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame^] | 1 | /* Type object implementation */ |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | #include "PROTO.h" |
| 6 | #include "object.h" |
| 7 | #include "stringobject.h" |
| 8 | #include "objimpl.h" |
| 9 | |
| 10 | /* Type object implementation */ |
| 11 | |
| 12 | static void |
| 13 | typeprint(v, fp, flags) |
| 14 | typeobject *v; |
| 15 | FILE *fp; |
| 16 | int flags; |
| 17 | { |
| 18 | fprintf(fp, "<type '%s'>", v->tp_name); |
| 19 | } |
| 20 | |
| 21 | static object * |
| 22 | typerepr(v) |
| 23 | typeobject *v; |
| 24 | { |
| 25 | char buf[100]; |
| 26 | sprintf(buf, "<type '%.80s'>", v->tp_name); |
| 27 | return newstringobject(buf); |
| 28 | } |
| 29 | |
| 30 | typedef struct { |
| 31 | OB_HEAD |
| 32 | long ob_ival; |
| 33 | } intobject; |
| 34 | |
| 35 | typeobject Typetype = { |
| 36 | OB_HEAD_INIT(&Typetype) |
| 37 | 0, /* Number of items for varobject */ |
| 38 | "type", /* Name of this type */ |
| 39 | sizeof(typeobject), /* Basic object size */ |
| 40 | 0, /* Item size for varobject */ |
| 41 | 0, /*tp_dealloc*/ |
| 42 | typeprint, /*tp_print*/ |
| 43 | 0, /*tp_getattr*/ |
| 44 | 0, /*tp_setattr*/ |
| 45 | 0, /*tp_compare*/ |
| 46 | typerepr, /*tp_repr*/ |
| 47 | }; |