package SJT;
use 5.010000;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw(
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
);
our $VERSION = '0.01';
require XSLoader;
XSLoader::load('SJT', $VERSION);
sub new {
my ($class) = @_;
return bless {
permutation => [2,2,2,2,2,2,2,2,2,2,2],
},$class;
}
####
package SJT;
use 5.010000;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
MODULE = SJT PACKAGE = SJT
//THIS FUNCTION SHOULD JUST GET $self->permutation->[index]
int get(self,index)
SV* self
int index
CODE:
char* key = "permutation";
AV* array;
SV* hv = self;
if(sv_isobject(hv)) {
printf("self is object,moving on...\n");
} else {
printf("SJT::get was expecting self to be an object");
};
HV* q = (HV *)SvRV(hv);
array = *hv_fetch(q,"permutation",11,FALSE);
if(array==NULL) {
printf("array not found in self...\n");
exit(-1);
}else {
printf("array found in self %X\n",array);
};
SV** res = av_fetch(array,index,FALSE);
if(res==NULL) {
printf("item not found in array...\n");
exit(-1);
}else {
printf("also found item in array at: %X\n",res);
};
####
IV a = SvIV(SvRV(*res));
printf("right before return\n");
RETVAL = a;//SvIV(*av_fetch(array,index,FALSE));
OUTPUT:
RETVAL
void
set(self,index,value)
SV* self
int index;
int value;
CODE:
OUTPUT:
####
ok 1 - use SJT;
SV = RV(0x82807dc) at 0x82807d0
REFCNT = 1
FLAGS = (PADMY,ROK)
RV = 0x82bc750
SV = PVHV(0x8185174) at 0x82bc750
REFCNT = 1
FLAGS = (OBJECT,SHAREKEYS)
STASH = 0x82bc9e0 "SJT"
ARRAY = 0x82ccd20 (0:7, 1:1)
hash quality = 100.0%
KEYS = 1
FILL = 1
MAX = 7
RITER = -1
EITER = 0x0
Elt "permutation" HASH = 0x41573374
SV = RV(0x82bc6ac) at 0x82bc6a0
REFCNT = 1
FLAGS = (ROK)
RV = 0x8242ce0
SV = PVAV(0x828d814) at 0x8242ce0
REFCNT = 1
FLAGS = ()
ARRAY = 0x82cbcb8
FILL = 10
MAX = 10
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = IV(0x82bc88c) at 0x82bc890
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 2
Elt No. 1
SV = IV(0x82bc70c) at 0x82bc710
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 2
Elt No. 2
SV = IV(0x82bc6ec) at 0x82bc6f0
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 2
Elt No. 3
SV = IV(0x82bc6fc) at 0x82bc700
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 2
self is object,moving on...
array found in self 82BC6A0
also found item in array at: 8242CE4
19830 Segmentation fault
####
use Devel::Peek;
use Data::Dumper;
use Test::More tests => 1;
BEGIN {
use_ok('SJT');
my $s1 = SJT->new;
Dump($s1);
print "HERE be 2:".$s1->get(1)."\n";
print "\n";
};