Commits

Anonymous committed 2ce6cc6

Convert from Class::Accessor to Class::XSAccessor.

  • Participants
  • Parent commits b8a2b63

Comments (0)

Files changed (4)

File nurikabe-solver/Games-Nurikabe-Solver/Build.PL

     },
     requires =>
     {
-        'Class::Accessor' => 0,
+        'Class::XSAccessor' => 0,
     },
     add_to_cleanup      => [ 'Games-Nurikabe-Solver-*' ],
     create_makefile_pl => 'traditional',

File nurikabe-solver/Games-Nurikabe-Solver/lib/Games/Nurikabe/Solver/Base.pm

 use warnings;
 use strict;
 
-use base 'Class::Accessor';
+use Class::XSAccessor;
 
 =head1 NAME
 
 Games::Nurikabe::Solver::Base - base class for Games::Nurikabe::Solver.
 
+=cut
+
+our $VERSION = '0.01';
+
 =head1 VERSION
 
 Version 0.01
 
 =cut
 
-our $VERSION = '0.01';
-
-__PACKAGE__->mk_accessors(qw(
-    ));
-
 =head1 SYNOPSIS
 
     use base 'Games::Nurikabe::Solver::Base';
     return $self;
 }
 
+=head2 __PACKAGE__->mk_accessors(qw(method1 method2 method3))
+
+Equivalent to L<Class::Accessor>'s mk_accessors only using Class::XSAccessor.
+It beats running an ugly script on my code, and can be done at run-time.
+
+Gotta love dynamic languages like Perl 5.
+
+=cut
+
+sub mk_accessors
+{
+    my $package = shift;
+    return $package->mk_acc_ref([@_]); 
+}
+
+=head2 __PACKAGE__->mk_acc_ref([qw(method1 method2 method3)])
+
+Creates the accessors in the array-ref of names at run-time.
+
+=cut
+
+sub mk_acc_ref
+{
+    my $package = shift;
+    my $names = shift;
+
+    my $mapping = +{ map { $_ => $_ } @$names };
+
+    eval <<"EOF";
+package $package;
+
+Class::XSAccessor->import(
+    accessors => \$mapping,            
+);
+EOF
+
+}
+
 sub _new_coords
 {
     my ($self, $yx) = @_;

File nurikabe-solver/Games-Nurikabe-Solver/lib/Games/Nurikabe/Solver/Cell.pm

     return 1;
 }
 
+=head2 my $bool = $self->already_processed()
+
+Indicates if the cell was already processed by the mark-and-sweep.
+
+=head2 my $island_idx = $self->island()
+
+The index of the island to which this cells belongs to.
+
+=head2 my $island_idx = $self->island_in_proximity()
+
+Island in proximity.
+
+=head2 my $status = $self->status()
+
+The status of the cell. Can be either $NK_BLACK , $NK_WHITE or $NK_UNKNOWN .
+
 =head1 AUTHOR
 
 Shlomi Fish, C<< <shlomif at cpan.org> >>

File nurikabe-solver/Games-Nurikabe-Solver/lib/Games/Nurikabe/Solver/Move.pm

     return $self->_reason_params()->{$param};
 }
 
+=head2 reason
+
+An ID for the reason.
+
+B<TODO>: fill in the various IDs.
+
 =head1 AUTHOR
 
 Shlomi Fish, C<< <shlomif at cpan.org> >>