Changeset 2910
- Timestamp:
- 05/10/05 02:02:04 (4 years ago)
- svk:copy_cache_prev:
- 4437
- Location:
- ext/Perl-MetaClass/lib/Perl
- Files:
-
- 2 modified
-
MetaClass.pm (modified) (1 diff)
-
MetaProperty.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ext/Perl-MetaClass/lib/Perl/MetaClass.pm
r2909 r2910 92 92 } 93 93 94 sub clsMethods(Str $inv: Hash ?%methods) returns Hash {94 sub clsMethods(Str $inv: Array *@methods) returns Hash { 95 95 my %self := get_instance($inv, "Perl::MetaClass"); 96 %self<methods> = \%methods if %methods.defined; 96 if @methods { 97 for @methods -> $key, $value { 98 ($value.instance_isa('Perl::MetaMethod')) 99 || die "Method values must be a Perl::MetaMethod instance (got: '$value')"; 100 my %methods = %self<methods>; 101 %methods{$key} = $value; 102 %self<methods> = \%methods; 103 } 104 } 97 105 return %self<methods>; 98 106 } 99 107 100 sub clsAssocs(Str $inv: Hash ?%assocs) returns Hash {108 sub clsAssocs(Str $inv: Array *@assocs) returns Hash { 101 109 my %self := get_instance($inv, "Perl::MetaClass"); 102 %self<assocs> = \%assocs if %assocs.defined; 110 if @assocs { 111 for @assocs -> $key, $value { 112 ($value.instance_isa('Perl::MetaAssoc')) 113 || die "Assoc values must be a Perl::MetaAssoc instance (got: '$value')"; 114 my %assocs = %self<assocs>; 115 %assocs{$key} = $value; 116 %self<assocs> = \%assocs; 117 } 118 } 103 119 return %self<assocs>; 104 120 } -
ext/Perl-MetaClass/lib/Perl/MetaProperty.pm
r2903 r2910 5 5 use Hack::Instances; 6 6 7 sub Perl::MetaProperty::new(Str $type, Any +$default ) returns Str is export {7 sub Perl::MetaProperty::new(Str $type, Any +$default, Str +$visibility) returns Str is export { 8 8 my $id = make_instance("Perl::MetaProperty", { 9 'type' => $type, 10 'default' => undef 9 'type' => $type, 10 'default' => undef, 11 'visibility' => undef, 11 12 }); 12 $id.propDefault($default) if $default.defined; 13 $id.propDefault($default) if $default.defined; 14 $id.propVisibility($visibility) if $visibility.defined; 13 15 return $id; 14 16 } … … 48 50 } 49 51 52 sub propVisibility(Str $inv: Str ?$visibility) returns Str { 53 my %self := get_instance($inv, "Perl::MetaProperty"); 54 if $visibility.defined { 55 ($visibility ~~ rx:perl5:i/(private|public)/) 56 || die "Visibility must be either 'Private' of 'Public' (got: '$visibility')"; 57 %self<visibility> = $visibility; 58 } 59 return %self<visibility>; 60 } 61 50 62 =pod 51 63 … … 70 82 =item B<propDefault($inv: ?$default)> 71 83 84 =item B<propVisibility($inv: ?$visibility)> 85 72 86 =back 73 87
