Skip to content

Commit

Permalink
Give ClassHOW an attribute for storing handles fallback info, and a m…
Browse files Browse the repository at this point in the history
…ethod for adding new ones, to encapsulate such functionality neatly in the metamodel rather than it being magic-y like in alpha.
  • Loading branch information
jnthn committed Jun 20, 2010
1 parent d6309ea commit 964d497
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/metamodel/ClassHOW.pir
Expand Up @@ -57,6 +57,7 @@ calls on it.
addattribute $P0, '$!done'
addattribute $P0, '$!ver'
addattribute $P0, '$!auth'
addattribute $P0, '$!handles_dispatchers'

# Create proto-object for it.
classhowproto = p6meta.'register'($P0)
Expand Down Expand Up @@ -165,6 +166,30 @@ Add an attribute.
.end


=item add_handles_fallback

=cut

.sub 'add_handles_fallback' :method
.param pmc obj
.param pmc attrname
.param pmc matcher

# Create info hash.
$P0 = root_new ['parrot';'Hash']
$P0['attrname'] = attrname
$P0['match_against'] = matcher

# Add to list, vivifying if needed.
$P1 = getattribute self, '$!handles_dispatchers'
unless null $P1 goto have_list
$P1 = root_new ['parrot';'ResizablePMCArray']
setattribute self, '$!handles_dispatchers', $P1
have_list:
push $P1, $P0
.end


=item attributes()

Gets the attributes that the class declares, returning a list of
Expand Down

0 comments on commit 964d497

Please sign in to comment.