view release on metacpan or search on metacpan
sv_ref||5.015004|
sv_replace|||
sv_report_used|||
sv_resetpvn|||
sv_reset|||
sv_rvweaken||5.006000|
sv_sethek|||
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CallBackery.pm view on Meta::CPAN
use File::Basename;
use CallBackery::Config;
use CallBackery::Plugin::Doc;
use CallBackery::Database;
use CallBackery::User;
use Scalar::Util qw(weaken);
our $VERSION = '0.56.8';
=head2 config
lib/CallBackery.pm view on Meta::CPAN
my $app = shift;
# having a non-C locale for number will wreck all sorts of havoc
# when things get converted to string and back
setlocale(LC_NUMERIC, "C");
setlocale(LC_TIME, "C");
weaken($app);
$app->config->postProcessCfg();
my $gcfg = $app->config->cfgHash->{BACKEND};
if ($gcfg->{log_file}){
if (open my $file, '>>', $gcfg->{log_file}){
$app->log->handle($file);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Callback/Frame.pm view on Meta::CPAN
$new_frame->{catcher} = $catcher if defined $catcher;
$new_frame->{locals} = $locals if defined $locals;
$active_frames->{$cb_address} = $new_frame;
Scalar::Util::weaken($active_frames->{$cb_address});
}
$internal_cb = sub {
my $orig_error = $@;
lib/Callback/Frame.pm view on Meta::CPAN
return $val;
};
my $final_cb = $ret_cb;
Scalar::Util::weaken($ret_cb);
return $final_cb;
}
view all matches for this distribution
view release on metacpan or search on metacpan
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_resetpvn|||
sv_reset|||
sv_rvweaken||5.006000|
sv_sethek|||
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
view all matches for this distribution
view release on metacpan or search on metacpan
happens correctly (in the proper state, the proper order, etc...) and cannot
be part of the contract (for external users of the class) since clients cannot
check that the pre-condition is true, because it will not have access to the
internal attributes.
Furthermore, in object-oriented programming, a redefined feature must I<weaken>
the pre-condition of its parent feature and I<strengthen> its post-condition.
It can also keep them as-is. To fully understand why, it's best to read
Meyer. Intuitively, it's easy to understand why the pre-condition cannot
be strengthened, nor why the post-condition cannot be weakened: because of dynamic
binding, a caller of r() only has the static type of the object, not its
dynamic type. Therefore, it cannot know in advance which of the routines will
be called amongst the inheritance tree.
=head2 Common Pitfalls
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Cassandra/Client/Connection.pm view on Meta::CPAN
use Ref::Util qw/is_blessed_ref is_plain_arrayref/;
use IO::Socket::INET;
use IO::Socket::INET6;
use Errno qw/EAGAIN/;
use Socket qw/SOL_SOCKET IPPROTO_TCP SO_KEEPALIVE TCP_NODELAY/;
use Scalar::Util qw/weaken/;
use Net::SSLeay qw/ERROR_WANT_READ ERROR_WANT_WRITE ERROR_NONE/;
use Cassandra::Client::Util;
use Cassandra::Client::Protocol qw/
:constants
lib/Cassandra/Client/Connection.pm view on Meta::CPAN
tls_want_write => undef,
healthcheck => undef,
protocol_version => $args{options}{protocol_version},
}, $class;
weaken($self->{async_io});
weaken($self->{client});
return $self;
}
sub get_local_status {
my ($self, $callback)= @_;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Component/ACCEPT_CONTEXT.pm view on Meta::CPAN
package Catalyst::Component::ACCEPT_CONTEXT;
use warnings;
use strict;
use MRO::Compat;
use Scalar::Util qw(weaken);
=head1 NAME
Catalyst::Component::ACCEPT_CONTEXT - Make the current Catalyst
request context available in Models and Views.
lib/Catalyst/Component/ACCEPT_CONTEXT.pm view on Meta::CPAN
sub ACCEPT_CONTEXT {
my $self = shift;
my $context = shift;
$self->{context} = $context;
weaken($self->{context});
return $self->maybe::next::method($context, @_) || $self;
}
=head2 COMPONENT
lib/Catalyst/Component/ACCEPT_CONTEXT.pm view on Meta::CPAN
sub COMPONENT {
my $class = shift;
my $app = shift;
my $args = shift;
$args->{context} = $app;
weaken($args->{context}) if ref $args->{context};
return $class->maybe::next::method($app, $args, @_);
}
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Controller/FormBuilder/Action.pm view on Meta::CPAN
unless exists $self->attributes->{ActionClass}
&& $self->attributes->{ActionClass}[0] eq
$controller->_fb_setup->{action};
my $form = $self->_setup_form(@_);
Scalar::Util::weaken($form->{c});
$controller->_formbuilder($form);
$self->maybe::next::method(@_);
$controller->_formbuilder($form); # keep the same form in case of forwards
$self->setup_template_vars( @_ );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Controller/HTML/FormFu.pm view on Meta::CPAN
use Moose;
use HTML::FormFu;
use Config::Any;
use Regexp::Assemble;
use Scalar::Util qw/ isweak weaken /;
use Carp qw/ croak /;
use namespace::autoclean;
# see https://rt.cpan.org/Ticket/Display.html?id=55780
lib/Catalyst/Controller/HTML/FormFu.pm view on Meta::CPAN
sub build_per_context_instance {
my ( $self, $c ) = @_;
return $self unless ( ref $c );
$self->{c} = $c;
weaken( $self->{c} )
if !isweak( $self->{c} );
return $self;
}
lib/Catalyst/Controller/HTML/FormFu.pm view on Meta::CPAN
if /__config\(/;
}
}
);
weaken( $self->{c} )
if !isweak( $self->{c} );
}
if ( $config->{languages_from_context} ) {
$form->languages( $self->{c}->languages );
lib/Catalyst/Controller/HTML/FormFu.pm view on Meta::CPAN
$form->action($action);
}
my $context_stash = $config->{context_stash};
$form->stash->{$context_stash} = $self->{c};
weaken( $form->stash->{$context_stash} );
my $model_stash = $config->{model_stash};
for my $model ( keys %$model_stash ) {
$form->stash->{$model} = $self->{c}->model( $model_stash->{$model} );
lib/Catalyst/Controller/HTML/FormFu.pm view on Meta::CPAN
</Controller::HTML::FormFu>
=head2 context_stash
To allow your form validation packages, etc, access to the catalyst context, a
weakened reference of the context is copied into the form's stash.
$form->stash->{context};
This setting allows you to change the key name used in the form stash.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Controller/LeakTracker.pm view on Meta::CPAN
use Data::Dumper ();
use Devel::Cycle ();
use Devel::Size ();
use Tie::RefHash::Weak ();
use YAML::XS ();
use Scalar::Util qw(weaken);
use namespace::clean -except => "meta";
{
package Catalyst::Controller::LeakTracker::Template;
lib/Catalyst/Controller/LeakTracker.pm view on Meta::CPAN
$object->{foo}{self} = $object;
}
my $object2 = bless {}, "class::b";
$object2->{foo}{self} = $object2;
weaken($object2->{foo}{self});
my $object3 = bless [], "class::c";
push @$object3, $object3, map { [ 1 .. $n ] } 1 .. $n;
$c->res->body("it leaks " . ( $n + 1 ) . " objects");
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution
view release on metacpan or search on metacpan
- made more flexible configuration (thx to masaki)
0.03 Wed Nov 6 18:00:32 JST 2008
- modified Changes
0.02 Fri Jun 6 11:37:31 JST 2008
- fully refactored
- weaken context (thx to typester)
0.01 Thu Jun 5 0:32:10 JST 2008
- first release
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CatalystX/GlobalContext.pm view on Meta::CPAN
$CatalystX::GlobalContext::VERSION = '0.039';
use strict;
use warnings;
use parent 'Exporter';
use Scalar::Util 'weaken';
use vars '$c';
our @EXPORT_OK = '$c';
=head1 NAME
lib/CatalystX/GlobalContext.pm view on Meta::CPAN
=head1 CLASS METHODS
=head2 CatalystX::GlobalContext->set_context($c)
Saves a weakened reference to the Catalyst context,
which is accessible from other modules as an export.
=cut
sub set_context {
$c = $_[1];
weaken $c;
}
=head1 SEE ALSO
L<Catalyst::Controller::CGIBin>, L<Catalyst::Controller::WrapCGI>,
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/TestApp/View/Dump.pm view on Meta::CPAN
use strict;
use base 'Catalyst::View';
use Data::Dumper ();
use Scalar::Util qw(blessed weaken);
sub dump {
my ( $self, $reference, $purity ) = @_;
return unless $reference;
t/lib/TestApp/View/Dump.pm view on Meta::CPAN
$c->res->output($output);
if ($context) {
# Repair context
$reference->{_context} = $context;
weaken( $reference->{_context} );
}
if ($body) {
# Repair body
delete $reference->{__body_type};
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/TestApp/View/Dump.pm view on Meta::CPAN
use strict;
use base 'Catalyst::View';
use Data::Dumper ();
use Scalar::Util qw(blessed weaken);
sub dump {
my ( $self, $reference ) = @_;
return unless $reference;
t/lib/TestApp/View/Dump.pm view on Meta::CPAN
$c->res->output($output);
if ($context) {
# Repair context
$reference->{_context} = $context;
weaken( $reference->{_context} );
}
if ($body) {
# Repair body
delete $reference->{__body_type};
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/TestApp/View/Dump.pm view on Meta::CPAN
use strict;
use base 'Catalyst::Base';
use Data::Dumper ();
use Scalar::Util qw(weaken);
sub dump {
my ( $self, $reference ) = @_;
return unless $reference;
t/lib/TestApp/View/Dump.pm view on Meta::CPAN
$c->res->headers->content_type('text/plain');
$c->res->output($output);
# Repair context
$reference->{_context} = $context;
weaken( $reference->{_context} );
# Repair body
$reference->{_body} = $body;
return 1;
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/TestApp/View/Dump.pm view on Meta::CPAN
use strict;
use base 'Catalyst::Base';
use Data::Dumper ();
use Scalar::Util qw(weaken);
sub dump {
my ( $self, $reference ) = @_;
return unless $reference;
t/lib/TestApp/View/Dump.pm view on Meta::CPAN
$c->res->headers->content_type('text/plain');
$c->res->output($output);
# Repair context
$reference->{_context} = $context;
weaken( $reference->{_context} );
# Repair body
$reference->{_body} = $body;
return 1;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Manual/Intro.pod view on Meta::CPAN
if ( my $per_request = $c->my_model_instance ) {
return $per_request;
} else {
my $new_instance = bless { %$self, c => $c }, ref($self);
Scalar::Util::weaken($new_instance->{c}); # or we have a circular reference
$c->my_model_instance( $new_instance );
return $new_instance;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Model/FormFu.pm view on Meta::CPAN
use strict;
use warnings;
use HTML::FormFu;
use HTML::FormFu::Library;
use Scalar::Util qw(weaken);
use Moose;
use namespace::clean -except => 'meta';
extends 'Catalyst::Model';
with 'Catalyst::Component::InstancePerContext';
lib/Catalyst/Model/FormFu.pm view on Meta::CPAN
$args{cache} = $self->cache;
$args{query} = $c->request;
### stash
$args{stash}{$self->context_stash} = $c;
weaken $args{stash}{$self->context_stash};
$args{stash}{schema} = $c->model($self->model_stash->{schema}) if $self->model_stash;
### config_callback
$args{config_callback}{plain_value} = sub
{
lib/Catalyst/Model/FormFu.pm view on Meta::CPAN
$form->action = /foo/bar/1
=item context_stash
To allow your form validation packages, etc, access to the catalyst context,
a weakened reference of the context is copied into the form's stash.
$form->stash->{context};
This setting allows you to change the key name used in the form stash.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Model/KiokuDB.pm view on Meta::CPAN
package Catalyst::Model::KiokuDB;
use Moose;
use KiokuX::Model;
use Scope::Guard;
use Scalar::Util qw(weaken);
use overload ();
use Hash::Util::FieldHash::Compat qw(fieldhash);
use Carp;
sub format_table;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Model/MenuGrinder/Menu.pm view on Meta::CPAN
use Moose;
extends 'WWW::MenuGrinder';
use Scalar::Util qw(weaken);
has '_c' => (
is => 'rw',
);
lib/Catalyst/Model/MenuGrinder/Menu.pm view on Meta::CPAN
sub _accept_context {
my ($self, $c) = @_;
$self->_c($c);
weaken($self->_c);
$self->menu_vars( $self->_get_all_vars );
}
no Moose;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution