Ticket #789 (new todo) — at Initial Version

Opened 13 years ago

Last modified 10 years ago

Make All PMCs Subclassable

Reported by: whiteknight Owned by:
Priority: normal Milestone:
Component: none Version: 1.3.0
Severity: medium Keywords: pmc subclass
Cc: Language:
Patch status: Platform:

Description

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.

Some examples:

  • FileHandle (see #681)
  • ExceptionHandler (See #154)

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.

Note: See TracTickets for help on using tickets.