Ticket #789 (closed todo: wontfix)
Make All PMCs Subclassable
|Reported by:||whiteknight||Owned by:||whiteknight|
Description (last modified by Infinoid) (diff)
Several core PMC types are not subclassable because they have attributes that are not the "register" types (P, S, N, I). What happens is that the subclass operation acts like normal, but Objects of the resultant class are not usable for normal operations.
Any other PMC type that uses a non-subclassable ATTR will have the same problem, although to my knowledge no tickets for these have been opened yet.
I had been working in #681 in a branch, but after talking with Allison we decided that the approach had the right idea but the wrong implementation.
From IRC today (paraphrased):
allison> give PIR Classes the ability to create a delegate or proxy structure for ATTRs that aren't register types allison> the basic problem is, attributes in PIR Classes are stored in an array allison> That array can only have PMC elements allison> so, it knows how to box and unbox the basic register types whiteknight> so do something like box C types into ManagedStruct or something similar? allison> the best place to start is probably with a list of C types in the current C PMCs, and how they can be represented as a PMC
See the whole discussion here: http://irclog.perlgeek.de/parrot/2009-06-24#i_1263385
So here's a quick list of tasks that we can do to fix this problem:
- Get a list together of all ATTRs in built-in PMC types that are not INTVAL, FLOATVAL, STRING* or PMC*
- Determine how to store each of those types in PMCs. This could mean using ManagedStruct or UnmanagedStruct, Pointer, CPointer, or some new type entirely
- Teach the GETATTR/SETATTR macros how to access values that are boxed like this.
This whole process probably requires a little bit more thought and planning, I'll try to create a page on the wiki somewhere so that we can plan this in more detail.