From: gfx Date: Tue, 23 Feb 2010 04:11:02 +0000 (+0900) Subject: Remove extra spaces and comments; no functionality changes X-Git-Tag: 0.50_04~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=72dc2c9d7f309b7e9216cdc7ab0e30feb0f2edd8;p=gitmo%2FMouse.git Remove extra spaces and comments; no functionality changes --- diff --git a/lib/Mouse/Exporter.pm b/lib/Mouse/Exporter.pm index 7444956..639b044 100644 --- a/lib/Mouse/Exporter.pm +++ b/lib/Mouse/Exporter.pm @@ -67,66 +67,64 @@ sub build_import_methods{ @export_from = ($exporting_package); } - { - my %exports; - my @removables; - my @all; - - my @init_meta_methods; - - foreach my $package(@export_from){ - my $spec = $SPEC{$package} or next; - - if(my $as_is = $spec->{as_is}){ - foreach my $thingy (@{$as_is}){ - my($code_package, $code_name, $code); - - if(ref($thingy)){ - $code = $thingy; - ($code_package, $code_name) = Mouse::Util::get_code_info($code); - } - else{ - no strict 'refs'; - $code_package = $package; - $code_name = $thingy; - $code = \&{ $code_package . '::' . $code_name }; - } - - push @all, $code_name; - $exports{$code_name} = $code; - if($code_package eq $package){ - push @removables, $code_name; - } - } - } + my %exports; + my @removables; + my @all; + + my @init_meta_methods; + + foreach my $package(@export_from){ + my $spec = $SPEC{$package} or next; - if(my $init_meta = $package->can('init_meta')){ - if(!grep{ $_ == $init_meta } @init_meta_methods){ - push @init_meta_methods, $init_meta; + if(my $as_is = $spec->{as_is}){ + foreach my $thingy (@{$as_is}){ + my($code_package, $code_name, $code); + + if(ref($thingy)){ + $code = $thingy; + ($code_package, $code_name) = Mouse::Util::get_code_info($code); + } + else{ + no strict 'refs'; + $code_package = $package; + $code_name = $thingy; + $code = \&{ $code_package . '::' . $code_name }; + } + + push @all, $code_name; + $exports{$code_name} = $code; + if($code_package eq $package){ + push @removables, $code_name; } } } - $args{EXPORTS} = \%exports; - $args{REMOVABLES} = \@removables; - $args{groups}{all} ||= \@all; - - if(my $default_list = $args{groups}{default}){ - my %default; - foreach my $keyword(@{$default_list}){ - $default{$keyword} = $exports{$keyword} - || confess(qq{The $exporting_package package does not export "$keyword"}); + if(my $init_meta = $package->can('init_meta')){ + if(!grep{ $_ == $init_meta } @init_meta_methods){ + push @init_meta_methods, $init_meta; } - $args{DEFAULT} = \%default; - } - else{ - $args{groups}{default} ||= \@all; - $args{DEFAULT} = $args{EXPORTS}; } + } + $args{EXPORTS} = \%exports; + $args{REMOVABLES} = \@removables; - if(@init_meta_methods){ - $args{INIT_META} = \@init_meta_methods; + $args{groups}{all} ||= \@all; + + if(my $default_list = $args{groups}{default}){ + my %default; + foreach my $keyword(@{$default_list}){ + $default{$keyword} = $exports{$keyword} + || confess(qq{The $exporting_package package does not export "$keyword"}); } + $args{DEFAULT} = \%default; + } + else{ + $args{groups}{default} ||= \@all; + $args{DEFAULT} = $args{EXPORTS}; + } + + if(@init_meta_methods){ + $args{INIT_META} = \@init_meta_methods; } return (\&do_import, \&do_unimport); diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index 7d2a1e9..14990ee 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -63,19 +63,6 @@ sub name; sub namespace; -# The followings are Class::MOP specific methods - -#sub version { no strict 'refs'; ${shift->name.'::VERSION'} } -#sub authority { no strict 'refs'; ${shift->name.'::AUTHORITY'} } -#sub identifier { -# my $self = shift; -# return join '-' => ( -# $self->name, -# ($self->version || ()), -# ($self->authority || ()), -# ); -#} - # add_attribute is an abstract method sub get_attribute_map { # DEPRECATED @@ -177,143 +164,140 @@ sub _collect_methods { # Mouse specific return @methods; } +my $ANON_SERIAL = 0; # anonymous class/role id +my %IMMORTALS; # immortal anonymous classes -{ - my $ANON_SERIAL = 0; - - my %IMMORTALS; - - sub create { - my($self, $package_name, %options) = @_; +sub create { + my($self, $package_name, %options) = @_; - my $class = ref($self) || $self; - $self->throw_error('You must pass a package name') if @_ < 2; + my $class = ref($self) || $self; + $self->throw_error('You must pass a package name') if @_ < 2; - my $superclasses; - if(exists $options{superclasses}){ - if(Mouse::Util::is_a_metarole($self)){ - delete $options{superclasses}; - } - else{ - $superclasses = delete $options{superclasses}; - (ref $superclasses eq 'ARRAY') - || $self->throw_error("You must pass an ARRAY ref of superclasses"); - } - } - - my $attributes = delete $options{attributes}; - if(defined $attributes){ - (ref $attributes eq 'ARRAY' || ref $attributes eq 'HASH') - || $self->throw_error("You must pass an ARRAY ref of attributes"); - } - my $methods = delete $options{methods}; - if(defined $methods){ - (ref $methods eq 'HASH') - || $self->throw_error("You must pass a HASH ref of methods"); + my $superclasses; + if(exists $options{superclasses}){ + if(Mouse::Util::is_a_metarole($self)){ + delete $options{superclasses}; } - my $roles = delete $options{roles}; - if(defined $roles){ - (ref $roles eq 'ARRAY') - || $self->throw_error("You must pass an ARRAY ref of roles"); - } - my $mortal; - my $cache_key; - - if(!defined $package_name){ # anonymous - $mortal = !$options{cache}; - - # anonymous but immortal - if(!$mortal){ - # something like Super::Class|Super::Class::2=Role|Role::1 - $cache_key = join '=' => ( - join('|', @{$superclasses || []}), - join('|', sort @{$roles || []}), - ); - return $IMMORTALS{$cache_key} if exists $IMMORTALS{$cache_key}; - } - $options{anon_serial_id} = ++$ANON_SERIAL; - $package_name = $class . '::__ANON__::' . $ANON_SERIAL; + else{ + $superclasses = delete $options{superclasses}; + (ref $superclasses eq 'ARRAY') + || $self->throw_error("You must pass an ARRAY ref of superclasses"); } + } - # instantiate a module - { - no strict 'refs'; - ${ $package_name . '::VERSION' } = delete $options{version} if exists $options{version}; - ${ $package_name . '::AUTHORITY' } = delete $options{authority} if exists $options{authority}; + my $attributes = delete $options{attributes}; + if(defined $attributes){ + (ref $attributes eq 'ARRAY' || ref $attributes eq 'HASH') + || $self->throw_error("You must pass an ARRAY ref of attributes"); + } + my $methods = delete $options{methods}; + if(defined $methods){ + (ref $methods eq 'HASH') + || $self->throw_error("You must pass a HASH ref of methods"); + } + my $roles = delete $options{roles}; + if(defined $roles){ + (ref $roles eq 'ARRAY') + || $self->throw_error("You must pass an ARRAY ref of roles"); + } + my $mortal; + my $cache_key; + + if(!defined $package_name){ # anonymous + $mortal = !$options{cache}; + + # anonymous but immortal + if(!$mortal){ + # something like Super::Class|Super::Class::2=Role|Role::1 + $cache_key = join '=' => ( + join('|', @{$superclasses || []}), + join('|', sort @{$roles || []}), + ); + return $IMMORTALS{$cache_key} if exists $IMMORTALS{$cache_key}; } + $options{anon_serial_id} = ++$ANON_SERIAL; + $package_name = $class . '::__ANON__::' . $ANON_SERIAL; + } - my $meta = $self->initialize( $package_name, %options); - - Scalar::Util::weaken $METAS{$package_name} - if $mortal; - - $meta->add_method(meta => sub{ - $self->initialize(ref($_[0]) || $_[0]); - }); - - $meta->superclasses(@{$superclasses}) - if defined $superclasses; - - # NOTE: - # process attributes first, so that they can - # install accessors, but locally defined methods - # can then overwrite them. It is maybe a little odd, but - # I think this should be the order of things. - if (defined $attributes) { - if(ref($attributes) eq 'ARRAY'){ - # array of Mouse::Meta::Attribute - foreach my $attr (@{$attributes}) { - $meta->add_attribute($attr); - } - } - else{ - # hash map of name and attribute spec pairs - while(my($name, $attr) = each %{$attributes}){ - $meta->add_attribute($name => $attr); - } + # instantiate a module + { + no strict 'refs'; + ${ $package_name . '::VERSION' } = delete $options{version} if exists $options{version}; + ${ $package_name . '::AUTHORITY' } = delete $options{authority} if exists $options{authority}; + } + + my $meta = $self->initialize( $package_name, %options); + + Scalar::Util::weaken $METAS{$package_name} + if $mortal; + + $meta->add_method(meta => sub{ + $self->initialize(ref($_[0]) || $_[0]); + }); + + $meta->superclasses(@{$superclasses}) + if defined $superclasses; + + # NOTE: + # process attributes first, so that they can + # install accessors, but locally defined methods + # can then overwrite them. It is maybe a little odd, but + # I think this should be the order of things. + if (defined $attributes) { + if(ref($attributes) eq 'ARRAY'){ + # array of Mouse::Meta::Attribute + foreach my $attr (@{$attributes}) { + $meta->add_attribute($attr); } } - if (defined $methods) { - while(my($method_name, $method_body) = each %{$methods}){ - $meta->add_method($method_name, $method_body); + else{ + # hash map of name and attribute spec pairs + while(my($name, $attr) = each %{$attributes}){ + $meta->add_attribute($name => $attr); } } - if (defined $roles){ - Mouse::Util::apply_all_roles($package_name, @{$roles}); - } - - if($cache_key){ - $IMMORTALS{$cache_key} = $meta; + } + if (defined $methods) { + while(my($method_name, $method_body) = each %{$methods}){ + $meta->add_method($method_name, $method_body); } + } + if (defined $roles){ + Mouse::Util::apply_all_roles($package_name, @{$roles}); + } - return $meta; + if($cache_key){ + $IMMORTALS{$cache_key} = $meta; } - sub DESTROY{ - my($self) = @_; + return $meta; +} - return if $Mouse::Util::in_global_destruction; +sub DESTROY{ + my($self) = @_; - my $serial_id = $self->{anon_serial_id}; + return if $Mouse::Util::in_global_destruction; - return if !$serial_id; + my $serial_id = $self->{anon_serial_id}; - # @ISA is a magical variable, so we clear it manually. - @{$self->{superclasses}} = () if exists $self->{superclasses}; + return if !$serial_id; + # mortal anonymous class - # Then, clear the symbol table hash - %{$self->namespace} = (); + # @ISA is a magical variable, so we clear it manually. + @{$self->{superclasses}} = () if exists $self->{superclasses}; - my $name = $self->name; - delete $METAS{$name}; + # Then, clear the symbol table hash + %{$self->namespace} = (); - $name =~ s/ $serial_id \z//xms; + my $name = $self->name; + delete $METAS{$name}; - no strict 'refs'; - delete ${$name}{ $serial_id . '::' }; + $name =~ s/ $serial_id \z//xms; - return; - } + no strict 'refs'; + delete ${$name}{ $serial_id . '::' }; + + return; } sub throw_error{ diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index 94d57d8..ad2d35b 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -528,14 +528,12 @@ sub name { $_[0]->{name} } sub parent { $_[0]->{parent} } sub message { $_[0]->{message} } -sub type_parameter { $_[0]->{type_parameter} } -sub __is_parameterized { exists $_[0]->{type_parameter} } - +sub type_parameter { $_[0]->{type_parameter} } sub _compiled_type_constraint{ $_[0]->{compiled_type_constraint} } - sub _compiled_type_coercion { $_[0]->{_compiled_type_coercion} } -sub has_coercion{ exists $_[0]->{_compiled_type_coercion} } +sub __is_parameterized { exists $_[0]->{type_parameter} } +sub has_coercion { exists $_[0]->{_compiled_type_coercion} } sub compile_type_constraint{ @@ -586,7 +584,6 @@ sub compile_type_constraint{ package Mouse::Object; - sub BUILDARGS { my $class = shift; @@ -634,7 +631,6 @@ sub DESTROY { my $e = do{ local $@; eval{ - # DEMOLISHALL # We cannot count on being able to retrieve a previously made diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index d1b68fa..0e0c2b3 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -101,7 +101,6 @@ sub list_all_builtin_type_constraints { @builtins } sub list_all_type_constraints { keys %TYPE } - sub _create_type{ my $mode = shift;