G
Guenther Sohler
In my embedded perl I decided to handle a 2D coordinate as
a anonymous reference to an array of 2 numbers like
[ 5.6 , 3.4 ]
Therefore a list of points would be like
[ [ 1,2 ] , [ 3,4 ] , [ 5,6] ]
In C I want to put this onto the perl stack.
I have written this C code.
int j;
AV *points=newAV();
for(j=0;j<pars.points.len();j++)
{
AV *point=newAV();
av_push(point,newSVnv(pars.points[j].x*l.unit_db));
av_push(point,newSVnv(pars.points[j].y*l.unit_db));
av_push(points,newSVrv((SV *) point,NULL));
}
XPUSHs(sv_2mortal(newSVrv((SV *) points,NULL)));
But the data does not arrive in the perl function.
Did I do an error ?
Do I have to use more/less mortal ??
Do I have to free/not free any references, arrays :?
The perl code looks like
sub test
{
$coords=shift;
print scalar(@$coords)." coords found\n";
}
I expect the perl routine to display
"2 coords found"
but it just displays " coords found"
Whats wrong ?
a anonymous reference to an array of 2 numbers like
[ 5.6 , 3.4 ]
Therefore a list of points would be like
[ [ 1,2 ] , [ 3,4 ] , [ 5,6] ]
In C I want to put this onto the perl stack.
I have written this C code.
int j;
AV *points=newAV();
for(j=0;j<pars.points.len();j++)
{
AV *point=newAV();
av_push(point,newSVnv(pars.points[j].x*l.unit_db));
av_push(point,newSVnv(pars.points[j].y*l.unit_db));
av_push(points,newSVrv((SV *) point,NULL));
}
XPUSHs(sv_2mortal(newSVrv((SV *) points,NULL)));
But the data does not arrive in the perl function.
Did I do an error ?
Do I have to use more/less mortal ??
Do I have to free/not free any references, arrays :?
The perl code looks like
sub test
{
$coords=shift;
print scalar(@$coords)." coords found\n";
}
I expect the perl routine to display
"2 coords found"
but it just displays " coords found"
Whats wrong ?