Skip to content

Commit

Permalink
Implement trait_mod:<hides> and a trait_mod:<is> for is hidden, plus …
Browse files Browse the repository at this point in the history
…add some attributes in ClassHOW that we'll use to track these.
  • Loading branch information
jnthn committed Aug 14, 2009
1 parent e5d0a37 commit 1a5c5f3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/classes/ClassHOW.pir
Expand Up @@ -25,6 +25,11 @@ This class subclasses P6metaclass to give Perl 6 specific meta-class behaviors.
$P1 = p6meta.'get_parrotclass'($P1)
addparent $P0, $P1

# Couple of useful attributes for tracking interface consistency
# information.
addattribute $P0, '$!hides'
addattribute $P0, '$!hidden'

# Create proto-object for it.
classhowproto = p6meta.'register'($P0)

Expand Down Expand Up @@ -442,6 +447,39 @@ XXX Work out exactly why.
.tailcall $P0.'WHAT'()
.end
=item hides
Accessor for hides property.
=cut
.sub 'hides' :method
$P0 = getattribute self, '$!hides'
unless null $P0 goto done
$P0 = get_hll_global 'Array'
$P0 = $P0.'new'()
setattribute self, '$!hides', $P0
done:
.return ($P0)
.end
=item hidden
Accessor for hidden property.
=cut
.sub 'hidden' :method
$P0 = getattribute self, '$!hidden'
unless null $P0 goto done
$P0 = new ['Perl6Scalar']
setattribute self, '$!hidden', $P0
done:
.return ($P0)
.end
=back
=cut
Expand Down
9 changes: 9 additions & 0 deletions src/setting/traits.pm
Expand Up @@ -29,6 +29,10 @@ multi trait_mod:<is>(Class $child, Object $parent) {
};
}

multi trait_mod:<is>(Class $child, :$hidden!) {
$child.hidden = True;
}

multi trait_mod:<is>(Code $block, $arg?, :$export!) {
# Maybe we can re-write some more of this out of PIR and into Perl 6.
Q:PIR {
Expand Down Expand Up @@ -142,3 +146,8 @@ multi trait_mod:<returns>(Code $block is rw, Object $type) {
multi trait_mod:<will>($declarand, &arg, *%name) {
&trait_mod:<is>($declarand, &arg, |%name);
}

multi trait_mod:<hides>(Class $child, Object $parent) {
&trait_mod:<is>($child, $parent);
$child.hides.push($parent)
}

0 comments on commit 1a5c5f3

Please sign in to comment.