Permalink
Browse files

fix end of line whitespace

  • Loading branch information...
1 parent e84c00c commit 355b16e7df628041f52f6957e3af201595bd2618 @doy doy committed Jul 15, 2013
View
@@ -1,13 +1,13 @@
A(nother) MOP for Perl 5
============
-This is a second attempt at building a MOP for Perl 5, this time with
+This is a second attempt at building a MOP for Perl 5, this time with
significantly scaled back ambition.
The goal is to still have the same syntax, but to make the MOP itself
-much less complicated, therefore hopefully making the implementation
-ultimately more maintainable. Additionally this is being built from
-the start to be compatible with old-style Perl 5 objects and to try
+much less complicated, therefore hopefully making the implementation
+ultimately more maintainable. Additionally this is being built from
+the start to be compatible with old-style Perl 5 objects and to try
to lean on existing Perl conventions instead of inventing a bunch of
new things.
View
@@ -37,9 +37,9 @@ sub import {
}
}
-sub get_meta {
+sub get_meta {
my $class = shift;
- die "Could not find metaclass for $class"
+ die "Could not find metaclass for $class"
unless mop::util::has_meta( $class );
mop::util::find_meta( $class );
}
@@ -60,27 +60,27 @@ sub bootstrap {
# At this point the metaclass
# layer class to role relationship
# is correct. And the following
- # - Class does Role
+ # - Class does Role
# - Role is instance of Class
# - Role does Role
# is true.
$Class->add_role( $Role );
$Role->compose_into( $Class );
- {
+ {
# NOTE:
# This is ugly, but we need to do
- # it to set the record straight
+ # it to set the record straight
# and make sure that the relationship
- # between mop::class and mop::role
+ # between mop::class and mop::role
# are correct and code is reused.
# - SL
my $Class_stash = mop::util::get_stash_for('mop::class');
foreach my $method ( values %{ $Role->methods }) {
$Class_stash->add_symbol( '&' . $method->name, $method->body )
unless $Class_stash->has_symbol( '&' . $method->name );
}
- # Here we finalize the rest of the
+ # Here we finalize the rest of the
# metaclass layer so that the following:
# - Class is an instance of Class
# - Object is an instance of Class
@@ -125,15 +125,15 @@ version 0.01
class Point {
has $x is ro = 0;
has $y is ro = 0;
-
+
method clear {
($x, $y) = (0, 0);
}
}
-
+
class Point3D extends Point {
has $z is ro = 0;
-
+
method clear {
$self->next::method;
$z = 0;
@@ -148,98 +148,98 @@ This is a prototype for a new object system for Perl 5.
class Object {
method new (%args) { ... }
-
+
method id { ... }
-
+
method can ($name) { ... }
method isa ($class) { ... }
method does ($role) { ... }
method DOES ($name) { ... }
-
+
method DESTROY { ... }
}
-
+
class Attribute extends Object {
has $name is ro;
has $default;
has $storage is ro = {};
-
+
method key_name { ... }
-
+
method has_default { ... }
method get_default { ... }
-
+
method fetch_data_in_slot_for ($instance) { ... }
method store_data_in_slot_for ($instance, $data) { ... }
method store_default_in_slot_for ($instance) { ... }
}
-
+
class Method extends Object {
has $name is ro;
has $body is ro;
-
+
method execute ($invocant, $args) { ... }
}
-
+
role Role {
has $name is ro;
has $version is ro;
has $authority is ro;
-
+
has $roles is ro = [];
has $attributes is ro = {};
has $methods is ro = {};
has $required_methods is ro = [];
-
+
method add_role ($role) { ... }
method does_role ($name) { ... }
-
+
method attribute_class { 'Attribute' }
-
+
method add_attribute ($attr) { ... }
method get_attribute ($name) { ... }
method has_attribute ($name) { ... }
-
+
method method_class { 'Method' }
-
+
method add_method ($attr) { ... }
method get_method ($name) { ... }
method has_method ($name) { ... }
method remove_method ($name) { ... }
-
+
method add_required_method ($required_method) { ... }
method requires_method ($name) { ... }
-
+
method compose_into ($other) { ... }
-
+
sub FINALIZE { ... }
}
-
+
class Class extends Object with Role {
has $superclass is ro;
has $submethods is ro = {};
has $is_abstract is ro;
method make_class_abstract { ... }
-
+
method new_instance { ... }
-
+
method submethod_class { 'Method' }
-
+
method add_submethod ($attr) { ... }
method get_submethod ($name) { ... }
method has_submethod ($name) { ... }
-
+
method FINALIZE { ... }
}
-
+
=head1 BOOTSTRAPPING GOALS
Class is an instance of Class
Object is an instance of Class
Class is a subclass of Object
- Class does Role
+ Class does Role
Role is an instance of Class
Role does Role
View
@@ -33,11 +33,11 @@ sub key_name {
}
# NOTE:
-# need to do a double de-ref for the
-# default value. first is to access
-# the value from the attribute, the
-# second is to actually dereference
-# the default value (which is stored
+# need to do a double de-ref for the
+# default value. first is to access
+# the value from the attribute, the
+# second is to actually dereference
+# the default value (which is stored
# as a ref of whatever the default is)
# - SL
sub has_default { defined( ${ ${ $default{ $_[0] } } } ) }
@@ -55,7 +55,7 @@ sub get_default {
die "References of type(" . ref $value . ") are not supported";
}
}
- $value
+ $value
}
sub storage { ${ $storage{ $_[0] } } }
@@ -88,18 +88,18 @@ sub __INIT_METACLASS__ {
superclass => 'mop::object'
);
- $METACLASS->add_attribute(mop::attribute->new(
- name => '$name',
+ $METACLASS->add_attribute(mop::attribute->new(
+ name => '$name',
storage => \%name
));
- $METACLASS->add_attribute(mop::attribute->new(
- name => '$default',
+ $METACLASS->add_attribute(mop::attribute->new(
+ name => '$default',
storage => \%default
));
- $METACLASS->add_attribute(mop::attribute->new(
- name => '$storage',
+ $METACLASS->add_attribute(mop::attribute->new(
+ name => '$storage',
storage => \%storage,
default => \(sub { init_attribute_storage(my %x) })
));
@@ -110,7 +110,7 @@ sub __INIT_METACLASS__ {
# from mop::object.
# - SL
$METACLASS->add_method( mop::method->new( name => 'name', body => \&name ) );
- $METACLASS->add_method( mop::method->new( name => 'key_name', body => \&key_name ) );
+ $METACLASS->add_method( mop::method->new( name => 'key_name', body => \&key_name ) );
$METACLASS->add_method( mop::method->new( name => 'has_default', body => \&has_default ) );
$METACLASS->add_method( mop::method->new( name => 'get_default', body => \&get_default ) );
$METACLASS->add_method( mop::method->new( name => 'storage', body => \&storage ) );
View
@@ -21,14 +21,14 @@ sub new {
my $class = shift;
my %args = @_;
my $self = $class->SUPER::new( @_ );
- $is_abstract{ $self } = \($args{'is_abstract'} // 0);
+ $is_abstract{ $self } = \($args{'is_abstract'} // 0);
$superclass{ $self } = \($args{'superclass'});
$submethods{ $self } = \({});
-
+
if ( defined( $args{'name'} ) && is_module_name( $args{'name'} ) ) {
$INC{ module_notional_filename( $args{'name'} ) } //= '(mop)';
}
-
+
$self;
}
@@ -78,16 +78,16 @@ sub FINALIZE {
@{ $self->required_methods } = uniq(
@{ $self->required_methods },
@{ $meta->required_methods }
- );
+ );
}
}
}
$self->mop::role::FINALIZE;
if (scalar @{ $self->required_methods } != 0 && not $self->is_abstract) {
- die 'Required methods are not allowed in '
- . $self->name
+ die 'Required methods are not allowed in '
+ . $self->name
. ' unless class is declared abstract';
}
}
@@ -100,23 +100,23 @@ sub __INIT_METACLASS__ {
$METACLASS = mop::class->new(
name => 'mop::class',
version => $VERSION,
- authority => $AUTHORITY,
+ authority => $AUTHORITY,
superclass => 'mop::object'
);
- $METACLASS->add_attribute(mop::attribute->new(
- name => '$is_abstract',
+ $METACLASS->add_attribute(mop::attribute->new(
+ name => '$is_abstract',
storage => \%is_abstract,
default => \(0)
));
- $METACLASS->add_attribute(mop::attribute->new(
- name => '$superclass',
+ $METACLASS->add_attribute(mop::attribute->new(
+ name => '$superclass',
storage => \%superclass
));
- $METACLASS->add_attribute(mop::attribute->new(
- name => '$submethods',
+ $METACLASS->add_attribute(mop::attribute->new(
+ name => '$submethods',
storage => \%submethods,
default => \({})
));
Oops, something went wrong.

0 comments on commit 355b16e

Please sign in to comment.