File: refcount_constructor.pl

package info (click to toggle)
libclass-xsaccessor-perl 1.19-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 504 kB
  • sloc: perl: 676; ansic: 359; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 664 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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());
}