Changeset 6094 for perl5/Perl6-MetaModel/lib/Perl6/Class.pm
- Timestamp:
- 08/06/05 23:00:58 (3 years ago)
- Files:
-
- 1 modified
-
perl5/Perl6-MetaModel/lib/Perl6/Class.pm (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
perl5/Perl6-MetaModel/lib/Perl6/Class.pm
r6093 r6094 45 45 46 46 sub _apply_class_to_environment { 47 my ($self) = @_; 47 my ($self) = @_; 48 48 my ($name) = $self->{instance_data}->{name}; 49 49 # create the package ... … … 53 53 \$$name\:\:META = undef; 54 54 1; 55 |; 55 |; 56 56 eval $code || confess "Could not initialize class '$name'"; 57 _create_metaclass($self); 58 _build_class($self); 57 59 # alias the full name ... 58 60 eval { … … 61 63 }; 62 64 confess "Could not create full name " . $self->{instance_data}->{identifier} . " : $@" if $@; 63 _build_class($self);64 65 } 65 66 … … 93 94 } 94 95 95 sub _ build_class {96 sub _create_metaclass { 96 97 my ($self) = @_; 97 98 98 my ($name, $version, $authority) = ($self->{instance_data}->{name}, $self->{instance_data}->{version}, $self->{instance_data}->{authority}); 99 99 … … 129 129 $self->{instance_data}->{meta} = $meta; 130 130 }; 131 confess "Could not initialize the metaclass for $name : $@" if $@; 131 confess "Could not initialize the metaclass for $name : $@" if $@; 132 } 133 134 sub _build_class { 135 my ($self) = @_; 136 137 my $meta = $self->{instance_data}->{meta}; 132 138 133 139 my $superclasses = $self->{instance_data}->{params}->{is}; … … 136 142 if (my $instance = $self->{instance_data}->{params}->{instance}) { 137 143 138 ::dispatch($meta, 'add_method', ('BUILD' => Perl6::Method->create_submethod($ name=> $instance->{BUILD})))144 ::dispatch($meta, 'add_method', ('BUILD' => Perl6::Method->create_submethod($self => $instance->{BUILD}))) 139 145 if exists $instance->{BUILD}; 140 ::dispatch($meta, 'add_method', ('DESTROY' => Perl6::Method->create_submethod($ name=> $instance->{DESTROY})))146 ::dispatch($meta, 'add_method', ('DESTROY' => Perl6::Method->create_submethod($self => $instance->{DESTROY}))) 141 147 if exists $instance->{DESTROY}; 142 148 … … 144 150 foreach (keys %{$instance->{methods}}) { 145 151 if (/^_/) { 146 ::dispatch($meta, 'add_method', ($_ => Perl6::Method->create_private_method($ name, $instance->{methods}->{$_})));152 ::dispatch($meta, 'add_method', ($_ => Perl6::Method->create_private_method($self, $instance->{methods}->{$_}))); 147 153 } 148 154 else { 149 ::dispatch($meta, 'add_method', ($_ => Perl6::Method->create_instance_method($ name, $instance->{methods}->{$_})));155 ::dispatch($meta, 'add_method', ($_ => Perl6::Method->create_instance_method($self, $instance->{methods}->{$_}))); 150 156 } 151 157 } 152 158 } 153 159 if (exists $instance->{submethods}) { 154 ::dispatch($meta, 'add_method', ($_ => Perl6::Method->create_submethod($ name, $instance->{submethods}->{$_})))160 ::dispatch($meta, 'add_method', ($_ => Perl6::Method->create_submethod($self, $instance->{submethods}->{$_}))) 155 161 foreach keys %{$instance->{submethods}}; 156 162 } … … 162 168 } 163 169 ::dispatch($meta, 'add_attribute', ( 164 $attr => Perl6::Instance::Attribute->new($ name=> $attr, $props)170 $attr => Perl6::Instance::Attribute->new($self => $attr, $props) 165 171 )); 166 172 } … … 176 182 } 177 183 ::dispatch($meta, 'add_attribute', ( 178 $attr => Perl6::Class::Attribute->new($ name=> $attr, $props)184 $attr => Perl6::Class::Attribute->new($self => $attr, $props) 179 185 )); 180 186 } … … 184 190 foreach my $label (keys %{$class->{methods}}) { 185 191 if ($label =~ /^_/) { 186 ::dispatch($meta, 'add_method', ($label => Perl6::Method->create_private_method($ name, $class->{methods}->{$label})));192 ::dispatch($meta, 'add_method', ($label => Perl6::Method->create_private_method($self, $class->{methods}->{$label}))); 187 193 } 188 194 else { 189 ::dispatch($meta, 'add_method', ($label => Perl6::Method->create_class_method($ name, $class->{methods}->{$label})));195 ::dispatch($meta, 'add_method', ($label => Perl6::Method->create_class_method($self, $class->{methods}->{$label}))); 190 196 } 191 197 }
