Class-XSAccessor

 view release on metacpan or  search on metacpan

author_scripts/refcount_constructor.pl  view on Meta::CPAN

#!/usr/bin/env perl

# confirm the refcounts/flags are correct for
# objects returned by the XS constructor

use Modern::Perl;
use Devel::Peek;

use blib;

use Class::XSAccessor {
    constructor => 'hash_cxa',
};

use Class::XSAccessor::Array {
    constructor => 'array_cxa',
};

sub hash_normal {
    my $class = shift;
    bless { @_ }, ref($class) || $class;
}

sub array_normal {
    my $class = shift;
    bless [], ref($class) || $class;
}

{
    Dump(__PACKAGE__->hash_cxa(foo => 'bar'));
    warn $/;
    Dump(__PACKAGE__->hash_normal(foo => 'bar'));
    warn $/;
    Dump(__PACKAGE__->array_cxa());
    warn $/;
    Dump(__PACKAGE__->array_normal());
}



( run in 0.227 second using v1.01-cache-2.11-cpan-0d8aa00de5b )