return hv_delete_ent((HV *)SvRV(self), attr->slot_sv, 0, attr->slot_u32);
}
-STATIC void setter_common(pTHX_ SV *self, ATTR *attr, SV *value);
+STATIC void writer_common(pTHX_ SV *self, ATTR *attr, SV *value);
STATIC SV *get_default(pTHX_ SV *self, ATTR *attr) {
return NULL;
}
-STATIC SV *getter_common(pTHX_ SV *self, ATTR *attr) {
+STATIC SV *reader_common(pTHX_ SV *self, ATTR *attr) {
SV *value = get_slot_value(aTHX_ self, attr);
if ( value ) {
return value;
} else if ( ATTR_ISLAZY(attr) ) {
value = get_default(aTHX_ self, attr);
- setter_common(aTHX_ self, attr, value);
+ writer_common(aTHX_ self, attr, value);
return value;
}
return NULL;
}
-STATIC void setter_common(pTHX_ SV *self, ATTR *attr, SV *value) {
+STATIC void writer_common(pTHX_ SV *self, ATTR *attr, SV *value) {
if ( ATTR_TYPE(attr) ) {
if ( !check_type_constraint(aTHX_ ATTR_TYPE(attr), attr->tc_check, attr->type_constraint, value) )
croak("Bad param");
/* simple high level api */
-STATIC XS(getter);
-STATIC XS(getter)
+STATIC XS(reader);
+STATIC XS(reader)
{
#ifdef dVAR
dVAR;
SP -= items;
- value = getter_common(aTHX_ ST(0), attr);
+ value = reader_common(aTHX_ ST(0), attr);
if (value) {
ST(0) = sv_mortalcopy(value); /* mortalcopy because $_ .= "blah" for $foo->bar */
}
}
-STATIC XS(setter);
-STATIC XS(setter)
+STATIC XS(writer);
+STATIC XS(writer)
{
#ifdef dVAR
dVAR;
SP -= items;
- setter_common(aTHX_ ST(0), attr, ST(1));
+ writer_common(aTHX_ ST(0), attr, ST(1));
ST(0) = ST(1); /* return value */
XSRETURN(1);
SP -= items;
if (items > 1) {
- setter_common(aTHX_ ST(0), attr, ST(1));
+ writer_common(aTHX_ ST(0), attr, ST(1));
ST(0) = ST(1); /* return value */
} else {
- SV *value = getter_common(aTHX_ ST(0), attr);
+ SV *value = reader_common(aTHX_ ST(0), attr);
if ( value ) {
ST(0) = value;
} else {
}
enum xs_body {
- xs_body_getter = 0,
- xs_body_setter,
+ xs_body_reader = 0,
+ xs_body_writer,
xs_body_accessor,
xs_body_predicate,
max_xs_body
};
STATIC XSPROTO ((*xs_bodies[])) = {
- getter,
- setter,
+ reader,
+ writer,
accessor,
predicate,
};
SV *attr;
SV *name;
ALIAS:
- new_getter = xs_body_getter
- new_setter = xs_body_setter
+ new_reader = xs_body_reader
+ new_writer = xs_body_writer
new_accessor = xs_body_accessor
new_predicate = xs_body_predicate
PREINIT:
}
}
-ok( defined &Moose::XS::new_getter, "new_getter" );
-ok( defined &Moose::XS::new_setter, "new_setter" );
+ok( defined &Moose::XS::new_reader, "new_reader" );
+ok( defined &Moose::XS::new_writer, "new_writer" );
ok( defined &Moose::XS::new_accessor, "new_accessor" );
ok( defined &Moose::XS::new_predicate, "new_predicate" );
has x => ( is => "rw", predicate => "has_x" );
has y => ( is => "ro" );
- has z => ( reader => "z", setter => "set_z" );
+ has z => ( reader => "z", writer => "set_z" );
has ref => ( is => "rw", weak_ref => 1 );
has i => ( isa => "Int", is => "rw" );
has s => ( isa => "Str", is => "rw" );
my ( $x, $y, $z, $ref, $a, $s, $i, $o, $f, $c, $b ) = map { Foo->meta->get_attribute($_) } qw(x y z ref a s i o f c b);
$x->Moose::XS::new_accessor("Foo::x");
$x->Moose::XS::new_predicate("Foo::has_x");
- $y->Moose::XS::new_getter("Foo::y");
- $z->Moose::XS::new_getter("Foo::z");
- $z->Moose::XS::new_setter("Foo::set_z");
+ $y->Moose::XS::new_reader("Foo::y");
+ $z->Moose::XS::new_reader("Foo::z");
+ $z->Moose::XS::new_writer("Foo::set_z");
$ref->Moose::XS::new_accessor("Foo::ref");
$a->Moose::XS::new_accessor("Foo::a");
$s->Moose::XS::new_accessor("Foo::s");