Ticket #789 (new todo) — at Version 2

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 (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.

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.

Change History

Changed 13 years ago by whiteknight

Here is a quick list of alternate types that appear in ATTR declarations:

void*
Parrot_Interp
struct parrot_interp_t *
char*
Parrot_mutex
UINTVAL
(various function pointers)
Parrot_Context
Hash *
PIOHANDLE
STRING**
PMC**
INTVAL* 
FLOATVAL*
unsigned char*
size_t
PIOOFF_T
BIGINT*
BIGNUM*
struct Parrot_cont *

Changed 13 years ago by Infinoid

  • description modified (diff)
Note: See TracTickets for help on using tickets.