Mike Lambert wrote: [ Unifying Buffer and PMC ]
> As jason said in another message, Dan has changed his mind from > yesteryear, and decided that buffers and pmcs should be the same > structure. Roadmap ------- 1) Hide Buffer and PMC internals, namely - buflen - bufstart - flags - cache inside access macros and #defines and unify common flags (e.g. BUFFER_live_flag <=> PMC_live_flag) to have the same value. E.g. str->flags & BUFFER_constant_FLAG => get_constant_FLAG(str) pmc->flags |= BUFFER_live_FLAG => set_live_FLAG(pmc) pmc->flags &= ~BUFFER_live_FLAG => reset_live_FLAG(pmc) The actual changes in *.c can be done file by file, are equally readable and don't disrupt functionallity. 2) Change Buffer, PMC to a common structure, adjust above access macros. This change would not be seen from the outside. 3) Cleanup, use the common base object, wherever appropriate, e.g. headers, smallobject, dod. Proposal for a common structure ------------------------------- The base object is Pobj (Parrot object), it's very similar to a current Buffer: typedef struct _Buffer { void * bufstart; size_t buflen; } _Buffer; typedef union UnionVal { int int_val; double num_val; void* struct_val; char* string_val; struct PMC* pmc_val; _Buffer b; } UnionVal; typedef struct Pobj { UnionVal u; unsigned int flags; } Pobj; typedef struct Buffer { Pobj o; } Buffer; A PMC is derived from this structure and has additional fields like the VTABLE amd next_for_GC (if we really need this). typedef struct PMC { Pobj o; VTABLE *vtable; } PMC; It would be also possible to have an extended PMC type for aggregates: typedef struct APMC { Pobj o; VTABLE *vtable; void *data; } APMC; .... or just use the latter for both. Comments welcome, leo