Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

accept hdp's advice to use copy_ref, fixing a number of wonky reentra…

…nce bugs
  • Loading branch information...
commit 0e87dbe36172fa856c2a34dd4d0e4e880c078e52 1 parent 9b74bef
@rjbs authored
View
11 lib/metamethod.pm
@@ -1,4 +1,4 @@
-package mmmm; # make my methods meta!
+package metamethod; # make my methods meta!
use strict;
use warnings;
use Variable::Magic qw/wizard cast/;
@@ -10,12 +10,13 @@ sub import {
my $method_name;
my $wiz = wizard
+ copy_key => 1,
data => sub { \$method_name },
fetch => sub {
- return if (substr $_[2], 0, 1) eq '(';
- ${ $_[1] } = $_[2] unless $_[2] eq 'invoke_method';
- $_[2] = 'invoke_method';
- ();
+ return if (substr $_[2], 0, 1) eq '(';
+ ${ $_[1] } = $_[2];
+ $_[2] = 'invoke_method';
+ return;
};
no strict 'refs';
View
1  t/first-class.t
@@ -2,6 +2,7 @@ use strict;
use warnings;
use Test::More 'no_plan';
+use lib 't/lib';
require Class;
require Instance;
View
5 t/lib/Class.pm
@@ -11,8 +11,7 @@ my %STATIC = (
my %UNIVERSAL = (
new => sub {
- # XXX: Why does this panic and memory wrap? -- rjbs, 2009-03-21
- bless { __class__ => $_[0] } => 'Instance'; # $_[0]->instance_class
+ bless { __class__ => $_[0] } => $_[0]->instance_class,
},
name => sub { $_[0]->{name} },
base => sub { $_[0]->{base} },
@@ -40,7 +39,7 @@ my %UNIVERSAL = (
},
);
-use mmmm sub {
+use metamethod sub {
my ($invocant, $method_name, $args) = @_;
my $curr = $invocant;
my $code;
View
4 t/lib/Instance.pm
@@ -12,12 +12,12 @@ my %STATIC = (
my %UNIVERSAL = (
class => sub { $_[0]->{__class__} }, # shout out to my homies in python
isa => sub {
- my $class = $_[0]->{__class__};
+ my $class = $_[0]->class;
return $class->derives_from($_[1]);
},
);
-use mmmm sub {
+use metamethod sub {
my ($invocant, $method_name, $args) = @_;
my $code;
Please sign in to comment.
Something went wrong with that request. Please try again.