From 8aa67f228a63f8df7e334d63e5d283596a2c2f93 Mon Sep 17 00:00:00 2001 From: Mikhail Che Date: Mon, 9 Sep 2019 13:23:06 +0500 Subject: [PATCH] v8.23 --- Makefile.old | 34 ++++++++++---------- lib/Mojo/Base/Che.pm | 72 +++++++++++++++++++----------------------- lib/Mojolicious/Che.pm | 4 +-- 3 files changed, 51 insertions(+), 59 deletions(-) diff --git a/Makefile.old b/Makefile.old index a32e773..4010368 100644 --- a/Makefile.old +++ b/Makefile.old @@ -1,7 +1,7 @@ # This Makefile is for the Mojolicious::Che extension to perl. # # It was generated automatically by MakeMaker version -# 7.24 (Revision: 72400) from the contents of +# 7.36 (Revision: 73600) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # # ANY CHANGES MADE HERE WILL BE LOST! @@ -62,11 +62,11 @@ DIRFILESEP = / DFSEP = $(DIRFILESEP) NAME = Mojolicious::Che NAME_SYM = Mojolicious_Che -VERSION = 0.0812 +VERSION = 0.0823 VERSION_MACRO = VERSION -VERSION_SYM = 0_0812 +VERSION_SYM = 0_0823 DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" -XS_VERSION = 0.0812 +XS_VERSION = 0.0823 XS_VERSION_MACRO = XS_VERSION XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" INST_ARCHLIB = blib/arch @@ -143,9 +143,9 @@ PERM_DIR = 755 PERM_RW = 644 PERM_RWX = 755 -MAKEMAKER = /home/guest/perl5/perlbrew/perls/perl-5.26.1/lib/5.26.1/ExtUtils/MakeMaker.pm -MM_VERSION = 7.24 -MM_REVISION = 72400 +MAKEMAKER = /home/guest/perl5/perlbrew/perls/perl-5.26.1/lib/site_perl/5.26.1/ExtUtils/MakeMaker.pm +MM_VERSION = 7.36 +MM_REVISION = 73600 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) @@ -194,13 +194,12 @@ PERL_ARCHIVE_AFTER = TO_INST_PM = Config.pm \ - README.pod \ lib/Mojo/Base/Che.pm \ lib/Mojolicious/Che.pm # --- MakeMaker platform_constants section: -MM_Unix_VERSION = 7.24 +MM_Unix_VERSION = 7.36 PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc @@ -266,7 +265,7 @@ RCS_LABEL = rcs -Nv$(VERSION_SYM): -q DIST_CP = best DIST_DEFAULT = tardist DISTNAME = Mojolicious-Che -DISTVNAME = Mojolicious-Che-0.0812 +DISTVNAME = Mojolicious-Che-0.0823 # --- MakeMaker macro section: @@ -504,7 +503,7 @@ metafile : create_distdir $(NOECHO) $(ECHO) 'configure_requires:' >> META_new.yml $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: '\''0'\''' >> META_new.yml $(NOECHO) $(ECHO) 'dynamic_config: 1' >> META_new.yml - $(NOECHO) $(ECHO) 'generated_by: '\''ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010'\''' >> META_new.yml + $(NOECHO) $(ECHO) 'generated_by: '\''ExtUtils::MakeMaker version 7.36, CPAN::Meta::Converter version 2.150010'\''' >> META_new.yml $(NOECHO) $(ECHO) 'license: perl' >> META_new.yml $(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml $(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.4.html' >> META_new.yml @@ -520,7 +519,7 @@ metafile : create_distdir $(NOECHO) $(ECHO) ' perl: '\''5.006'\''' >> META_new.yml $(NOECHO) $(ECHO) 'resources:' >> META_new.yml $(NOECHO) $(ECHO) ' repository: git://github.com/mche/Mojolicious-Che.git' >> META_new.yml - $(NOECHO) $(ECHO) 'version: '\''0.0812'\''' >> META_new.yml + $(NOECHO) $(ECHO) 'version: '\''0.0823'\''' >> META_new.yml $(NOECHO) $(ECHO) 'x_serialization_backend: '\''CPAN::Meta::YAML version 0.018'\''' >> META_new.yml -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml $(NOECHO) $(ECHO) Generating META.json @@ -530,13 +529,13 @@ metafile : create_distdir $(NOECHO) $(ECHO) ' "Михаил Че "' >> META_new.json $(NOECHO) $(ECHO) ' ],' >> META_new.json $(NOECHO) $(ECHO) ' "dynamic_config" : 1,' >> META_new.json - $(NOECHO) $(ECHO) ' "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010",' >> META_new.json + $(NOECHO) $(ECHO) ' "generated_by" : "ExtUtils::MakeMaker version 7.36, CPAN::Meta::Converter version 2.150010",' >> META_new.json $(NOECHO) $(ECHO) ' "license" : [' >> META_new.json $(NOECHO) $(ECHO) ' "perl_5"' >> META_new.json $(NOECHO) $(ECHO) ' ],' >> META_new.json $(NOECHO) $(ECHO) ' "meta-spec" : {' >> META_new.json $(NOECHO) $(ECHO) ' "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",' >> META_new.json - $(NOECHO) $(ECHO) ' "version" : "2"' >> META_new.json + $(NOECHO) $(ECHO) ' "version" : 2' >> META_new.json $(NOECHO) $(ECHO) ' },' >> META_new.json $(NOECHO) $(ECHO) ' "name" : "Mojolicious-Che",' >> META_new.json $(NOECHO) $(ECHO) ' "no_index" : {' >> META_new.json @@ -572,8 +571,8 @@ metafile : create_distdir $(NOECHO) $(ECHO) ' "web" : "https://github.com/mche/Mojolicious-Che"' >> META_new.json $(NOECHO) $(ECHO) ' }' >> META_new.json $(NOECHO) $(ECHO) ' },' >> META_new.json - $(NOECHO) $(ECHO) ' "version" : "0.0812",' >> META_new.json - $(NOECHO) $(ECHO) ' "x_serialization_backend" : "JSON::PP version 2.27400_02"' >> META_new.json + $(NOECHO) $(ECHO) ' "version" : "0.0823",' >> META_new.json + $(NOECHO) $(ECHO) ' "x_serialization_backend" : "JSON::PP version 4.04"' >> META_new.json $(NOECHO) $(ECHO) '}' >> META_new.json -$(NOECHO) $(MV) META_new.json $(DISTVNAME)/META.json @@ -882,7 +881,7 @@ testdb_static :: static pure_all # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. ppd : - $(NOECHO) $(ECHO) '' > Mojolicious-Che.ppd + $(NOECHO) $(ECHO) '' > Mojolicious-Che.ppd $(NOECHO) $(ECHO) ' Мой базовый модуль для приложений Mojolicious. Нужен только развернутый конфиг.' >> Mojolicious-Che.ppd $(NOECHO) $(ECHO) ' Михаил Че <mche@cpan.org>' >> Mojolicious-Che.ppd $(NOECHO) $(ECHO) ' ' >> Mojolicious-Che.ppd @@ -900,7 +899,6 @@ ppd : pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM) $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', q[$(PM_FILTER)], '\''$(PERM_DIR)'\'')' -- \ 'Config.pm' '$(INST_LIB)/Mojolicious/Config.pm' \ - 'README.pod' '$(INST_LIB)/Mojolicious/README.pod' \ 'lib/Mojo/Base/Che.pm' 'blib/lib/Mojo/Base/Che.pm' \ 'lib/Mojolicious/Che.pm' 'blib/lib/Mojolicious/Che.pm' $(NOECHO) $(TOUCH) pm_to_blib diff --git a/lib/Mojo/Base/Che.pm b/lib/Mojo/Base/Che.pm index 0641ea8..85145b9 100644 --- a/lib/Mojo/Base/Che.pm +++ b/lib/Mojo/Base/Che.pm @@ -1,23 +1,24 @@ package Mojo::Base::Che; -# ABSTRACT: some patch for Mojo::Base(current 8.02) +# ABSTRACT: some patch for Mojo::Base(current 8.23) use Mojo::Base -strict; -use mro;# weak +#~ use mro;# weak -# copy-paste sub Mojo::Base::attr + patch 1 line +# copy-paste sub Mojo::Base::attr + patch 1 line #~ sub Mojo::Base::attr { my ($self, $attrs, $value, %kv) = @_; return unless (my $class = ref $self || $self) && $attrs; - + Carp::croak 'Default has to be a code reference or constant value' if ref $value && ref $value ne 'CODE'; - + Carp::croak 'Unsupported attribute option' if grep { $_ ne 'weak' } keys %kv; + # Weaken if ($kv{weak}) { state %weak_names; unless ($weak_names{$class}) { my $names = $weak_names{$class} = []; - my $sub = sub { + my $sub = sub { my $self = shift->next::method(@_); ref $self->{$_} and Scalar::Util::weaken $self->{$_} for @$names; return $self; @@ -27,16 +28,16 @@ sub Mojo::Base::attr { unshift @{"${class}::ISA"}, $base; } push @{$weak_names{$class}}, ref $attrs eq 'ARRAY' ? @$attrs : $attrs; -} - + } + for my $attr (@{ref $attrs eq 'ARRAY' ? $attrs : [$attrs]}) { - # patch #~ Carp::croak qq{Attribute "$attr" invalid} unless $attr =~ /^[a-zA-Z_]\w*$/; - + # Very performance-sensitive code with lots of micro-optimizations + my $sub; if ($kv{weak}) { if (ref $value) { - my $sub = sub { + $sub = sub { return exists $_[0]{$attr} ? $_[0]{$attr} : ( @@ -47,44 +48,37 @@ sub Mojo::Base::attr { ref($_[0]{$attr} = $_[1]) and Scalar::Util::weaken($_[0]{$attr}); $_[0]; }; - Mojo::Util::monkey_patch($class, $attr, $sub); } else { - my $sub = sub { + $sub = sub { return $_[0]{$attr} if @_ == 1; ref($_[0]{$attr} = $_[1]) and Scalar::Util::weaken($_[0]{$attr}); $_[0]; }; - Mojo::Util::monkey_patch($class, $attr, $sub); } } + elsif (ref $value) { + $sub = sub { + return + exists $_[0]{$attr} ? $_[0]{$attr} : ($_[0]{$attr} = $value->($_[0])) + if @_ == 1; + $_[0]{$attr} = $_[1]; + $_[0]; + }; + } + elsif (defined $value) { + $sub = sub { + return exists $_[0]{$attr} ? $_[0]{$attr} : ($_[0]{$attr} = $value) + if @_ == 1; + $_[0]{$attr} = $_[1]; + $_[0]; + }; + } else { - if (ref $value) { - my $sub = sub { - return - exists $_[0]{$attr} - ? $_[0]{$attr} - : ($_[0]{$attr} = $value->($_[0])) - if @_ == 1; - $_[0]{$attr} = $_[1]; - $_[0]; - }; - Mojo::Util::monkey_patch($class, $attr, $sub); - } - elsif (defined $value) { - my $sub = sub { - return exists $_[0]{$attr} ? $_[0]{$attr} : ($_[0]{$attr} = $value) - if @_ == 1; - $_[0]{$attr} = $_[1]; - $_[0]; - }; - Mojo::Util::monkey_patch($class, $attr, $sub); - } - else { - Mojo::Util::monkey_patch($class, $attr, - sub { return $_[0]{$attr} if @_ == 1; $_[0]{$attr} = $_[1]; $_[0] }); - } + $sub + = sub { return $_[0]{$attr} if @_ == 1; $_[0]{$attr} = $_[1]; $_[0] }; } + Mojo::Util::monkey_patch($class, $attr, $sub); } } diff --git a/lib/Mojolicious/Che.pm b/lib/Mojolicious/Che.pm index c5a63e1..352e374 100644 --- a/lib/Mojolicious/Che.pm +++ b/lib/Mojolicious/Che.pm @@ -289,7 +289,7 @@ sub Mojolicious::dispatch { } -our $VERSION = '0.0812';# as to Mojolicious/100+0.000 +our $VERSION = '0.0823';# as to Mojolicious/100+0.000 =pod @@ -303,7 +303,7 @@ our $VERSION = '0.0812';# as to Mojolicious/100+0.000 =head1 VERSION -0.0812 +0.0823 =head1 NAME