=head1 TITLE docs/pmc.pod - PMC (PMC Makers Compendium) =head1 PMC Structure Items Access Don't use PMC structure items directly, always use the macros, which are defined in F. =head1 PMC Storage The PMC structure contains two places of data storage: the B and the B pointer. =head2 Storage memory washing During PMC recycling the B data members are B cleared. B or B is set to NULL. The flags are set to their default value, especially the private flags are 0. =head2 UnionVal usage There are no special rules, where to store what: use whatever fits best. If your PMC points to a B, hang it off the B, if it's an B, place it in B. If you need to store two items, try to use union members that have distinct storage like B / B or B / B in parallel with B. =head2 PMC_data() If your PMC contains other PMCs that possibly would allow the creation of self-referential or arbitrary deeply nested containers, you have to allocate the B structure by specifying the B flag on the B definition line. The B pointer is currently located in the B structure too. Using B therefore adds one more indirection to access these data. =head1 PMC flags Each PMC has 8 private flags B - B, which can be used for storing 8 bits. =head1 PMCs and DOD =head2 Overview The DOD system doesn't make any assumptions about your PMC's layout. Whenever a PMC is found in the root set, B is called with that PMC. The PMC is responsible to mark all contained or referenced active Parrot objects (Buffers or other PMCs). =head2 DOD related flags =over 4 =item PObj_is_buffer_ptr_FLAG B points to a B object. This PMC gets marked automatically. =item PObj_is_buffer_of_PMCs_ptr_FLAG B points to a buffer holding an array of Bs. =item PObj_custom_mark_FLAG If your PMC refers to any Parrot objects and above standard flags don't cover this usage, a custom B vtable has to be implemented, which has to call B for all contained Bs. =back =head1 PMCs and System Resources Whenever a PMC Bs system memory or opens a file or a database connection, it has to take care of freeing or closing these system resources. =head2 Flags for PMC destruction =over 4 =item PObj_active_destroy_FLAG The PMC's B vtable is called, when this PMC is found to be dead during DOD. =item PObj_needs_early_DOD_FLAG Set this flag too, if the PMC needs timely destruction, e.g. to close a file handle at the end of a block scope, if the PMC isn't alive any more. =back =head1 SEE ALSO F, F, F =head1 AUTHOR Leopold Toetsch C =head1 VERSION =over 4 =item 0.1 2004.06.14 - Initial =back