Christoph Otto wrote:
Allison Randal wrote:
(Actually, at the moment you're required to declare all parent attributes in the ATTR list before the child attributes, so inherited attributes *are* child attributes.)

When I say "attributes", I mean the things that are declared in .pmc files right after the pmclass line, e.g.
ATTR INTVAL foo_refs; /*foo refcount*/
These do not appear to be passed down to extending PMCs. This is a problem for e.g UnManagedStruct/ManagedStruct, where PMC_int_val is used the same way by both PMCs.

Right, at the moment it is absolutely required that the first ATTR declarations of the child are manual copies of the ATTR declarations of the parent. Otherwise, the inheritance won't work at all. (Ultimately, inheritance will automatically copy the parent's attributes and prepend them onto the front of the child's attribute list, but at the moment it has to be done manually.)

What I'd like is for the pmc2c code to be smart enough to make ATTRs from an extended PMC accessible by an extending PMC through the GET_ATTR/SET_ATTR macros. If I could get a description of how such a patch should behave from our architect, I'd be glad to write one up and submit it for review.

The fix actually goes in a different place. The GET_ATTR/SET_ATTR macros will be correctly generated for all child attributes. What really needs to change is to add the parent's attribute list to the child's attribute list during PMC parsing in Pmc2c. Take a look at lib/Parrot/Pmc2c/Parser.pm. (I can give more specific guidance after the release, working on milestone items at the moment.)

Allison

Reply via email to