Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | 123456789-123456789-123456789-123456789-123456789-123456789-123456789-12 |
| 3 | |
| 4 | Additional macros for modules that implement new object types. |
| 5 | You must first include "object.h". |
| 6 | |
| 7 | NEWOBJ(type, typeobj) allocates memory for a new object of the given |
| 8 | type; here 'type' must be the C structure type used to represent the |
| 9 | object and 'typeobj' the address of the corresponding type object. |
| 10 | Reference count and type pointer are filled in; the rest of the bytes of |
| 11 | the object are *undefined*! The resulting expression type is 'type *'. |
| 12 | The size of the object is actually determined by the tp_basicsize field |
| 13 | of the type object. |
| 14 | |
| 15 | NEWVAROBJ(type, typeobj, n) is similar but allocates a variable-size |
| 16 | object with n extra items. The size is computer as tp_basicsize plus |
| 17 | n * tp_itemsize. This fills in the ob_size field as well. |
| 18 | */ |
| 19 | |
| 20 | extern object *newobject PROTO((typeobject *)); |
| 21 | extern varobject *newvarobject PROTO((typeobject *, unsigned int)); |
| 22 | |
| 23 | #define NEWOBJ(type, typeobj) ((type *) newobject(typeobj)) |
| 24 | #define NEWVAROBJ(type, typeobj, n) ((type *) newvarobject(typeobj, n)) |
| 25 | |
| 26 | extern int StopPrint; /* Set when printing is interrupted */ |
| 27 | |
| 28 | /* Malloc interface */ |
| 29 | #include "malloc.h" |
| 30 | |
Guido van Rossum | 4ab9b4c | 1990-10-21 22:13:08 +0000 | [diff] [blame] | 31 | extern char *strdup PROTO((const char *)); |