|| $class->throw_error("You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT");
my $self = bless {
'body' => undef,
'package_name' => $options{package_name},
'name' => $options{name},
-- # specific to this subclass
'options' => $options{options},
-- 'meta_instance' => $meta->get_meta_instance,
- 'attributes' => [ $meta->compute_all_applicable_attributes ],
- # ...
- 'attributes' => [ $meta->get_all_attributes ],
- # ...
'associated_metaclass' => $meta,
} => $class;
return 'Moose::Object';
}
--## accessors
--
--sub meta_instance { (shift)->{'meta_instance'} }
--sub attributes { (shift)->{'attributes'} }
--
## method
- sub initialize_body {
-sub _generate_params {
- my ($self, $var, $class_var) = @_;
- "my $var = " . $self->_generate_BUILDARGS($class_var, '@_') . ";\n";
-}
-
-sub _generate_instance {
- my ($self, $var, $class_var) = @_;
- "my $var = " . $self->meta_instance->inline_create_instance($class_var)
- . ";\n";
-}
-
-sub _generate_slot_initializers {
- my ($self) = @_;
- return (join ";\n" => map {
- $self->_generate_slot_initializer($_)
- } 0 .. (@{$self->attributes} - 1)) . ";\n";
-}
-
+ sub _initialize_body {
my $self = shift;
# TODO:
# the %options should also include a both
# because the inlined code is using the index of the attributes
# to determine where to find the type constraint
-- my $attrs = $self->attributes;
++ my $attrs = $self->_attributes;
my @type_constraints = map {
$_->can('type_constraint') ? $_->type_constraint : undef
$self->{'body'} = $code;
}
+sub _generate_params {
+ my ( $self, $var, $class_var ) = @_;
+ "my $var = " . $self->_generate_BUILDARGS( $class_var, '@_' ) . ";\n";
+}
+
+sub _generate_instance {
+ my ( $self, $var, $class_var ) = @_;
+ "my $var = "
- . $self->meta_instance->inline_create_instance($class_var) . ";\n";
++ . $self->_meta_instance->inline_create_instance($class_var) . ";\n";
+}
+
+sub _generate_slot_initializers {
+ my ($self) = @_;
+ return (join ";\n" => map {
+ $self->_generate_slot_initializer($_)
- } 0 .. (@{$self->attributes} - 1)) . ";\n";
++ } 0 .. (@{$self->_attributes} - 1)) . ";\n";
+}
+
sub _generate_BUILDARGS {
my ( $self, $class, $args ) = @_;
sub _generate_triggers {
my $self = shift;
my @trigger_calls;
-- foreach my $i ( 0 .. $#{ $self->attributes } ) {
-- my $attr = $self->attributes->[$i];
++ foreach my $i ( 0 .. $#{ $self->_attributes } ) {
++ my $attr = $self->_attributes->[$i];
next unless $attr->can('has_trigger') && $attr->has_trigger;
. $i
. ']->trigger->('
. '$instance, '
-- . $self->meta_instance->inline_get_slot_value(
++ . $self->_meta_instance->inline_get_slot_value(
'$instance',
$attr->name,
)
my $self = shift;
my $index = shift;
-- my $attr = $self->attributes->[$index];
++ my $attr = $self->_attributes->[$index];
my @source = ('## ' . $attr->name);
}
else {
$source = (
-- $self->meta_instance->inline_set_slot_value(
++ $self->_meta_instance->inline_set_slot_value(
'$instance',
$attr->name,
$value
if ($is_moose && $attr->is_weak_ref) {
$source .= (
"\n" .
-- $self->meta_instance->inline_weaken_slot_value(
++ $self->_meta_instance->inline_weaken_slot_value(
'$instance',
$attr->name
) .