-
Notifications
You must be signed in to change notification settings - Fork 1
/
typemap
50 lines (45 loc) · 1.74 KB
/
typemap
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
38
39
40
41
42
43
44
45
46
47
48
49
50
TYPEMAP
optionblk T_PTROBJ_OPTIONBLK
sparsegraph T_PTROBJ_SPARSEGRAPH
statsblk T_PTROBJ_STATSBLK
int * SPECIAL_INT
INPUT
SPECIAL_INT
$var = malloc( sizeof(int) * (av_len((AV*)SvRV($arg))+1) );
ssize_t ix_$var;
for( ix_$var = 0; ix_$var < av_len((AV*)SvRV($arg))+1; ix_$var++ ) {
$var [ix_$var] = (int)SvIV(*av_fetch((AV*)SvRV($arg), ix_$var, 0));
}
T_PTROBJ_SPARSEGRAPH
STMT_START {
if( SvOK($arg) ) {
int vertices_$var = (int)SvIV(*hv_fetch((HV*)SvRV($arg), \"nv\", 2, 0));
int edges_$var = (size_t)SvIV(*hv_fetch((HV*)SvRV($arg), \"nde\", 3, 0));
SG_INIT( $var );
SG_ALLOC( $var, vertices_$var, edges_$var, \"malloc\" );
$var.nde = edges_$var;
$var.nv = vertices_$var;
SV *v = (SV*)*hv_fetch((HV*)SvRV($arg), \"v\", 1, 0);
SV *d = (SV*)*hv_fetch((HV*)SvRV($arg), \"d\", 1, 0);
SV *e = (SV*)*hv_fetch((HV*)SvRV($arg), \"e\", 1, 0);
size_t ix_$var;
for( ix_$var = 0; ix_$var < $var.vlen; ix_$var++ ) {
$var.v[ix_$var] = (size_t)SvIV(*av_fetch((AV*)SvRV(v), ix_$var, 0));
}
for( ix_$var = 0; ix_$var < $var.dlen; ix_$var++ ) {
$var.d[ix_$var] = (int)SvIV(*av_fetch((AV*)SvRV(d), ix_$var, 0));
}
for( ix_$var = 0; ix_$var < $var.elen; ix_$var++ ) {
$var.e[ix_$var] = (int)SvIV(*av_fetch((AV*)SvRV(e), ix_$var, 0));
}
}
} STMT_END
T_PTROBJ_OPTIONBLK
DEFAULTOPTIONS_SPARSEGRAPH( new_$var );
$var = new_$var;
$var.defaultptn = FALSE;
if( SvOK($arg) ) {
if( hv_exists((HV*)SvRV($arg), \"getcanon\", 8) ) {
$var.getcanon = TRUE;
}
}