Isabelle Henry <[EMAIL PROTECTED]> writes:
>Hi !

Sorry I missed something last time - I was looking at low level stuff 
and missed that what you had coded did not match what you said you wanted 
in the perl part.

>
>In the .h (see below), some C structures are defined. In Perl, I’ll use hash tables. 
>In .xs, I’ve
>tried to copy the Perl hash table in C structures in order to call the C function, 
>and then to copy
>back the result in hash tables.

>----------> Here is what I’d like to write in Perl
>
>$stereo = {x=>4.2, y=>6.5};
>$geo = StereoToGeoCoordinates($stereo) ;
>/* or StereoToGeoCoordinates($stereo,$geo) ;
>print � geo : latitude = $geo->latitude, longitude = $geo->longitude\n � ;

There are several things wrong with that to my eyes:
  1. As far as I know perl (even perl5.8) does not allow � ...� as quotes
     you have to write it english style using "".
  2. Those are not hash de-references they are method calls.
  3. Method calls don't interpollate in strings.

With your code "fixed" as per my earlier mail what you would have to 
write would be:

  my $geo;
  StereoToGeoCoordinates({x=>4.2, y=>6.5},$geo);
  print " geo : latitude = ",$geo->{latitude}," longitude = ",$geo->{longitude},"\n";

If you want $geo->latitude (without the {}) then $geo needs to be an object
and you need to define methods to "access" the object.

If you want to write 

 $geo =  StereoToGeoCoordinates({x=>4.2, y=>6.5});

Then the XS code should declare it as:

SV *
StereoToGeoCoordinates(SV *rv_stereo)
CODE:
{
  ...
  RETVAL = somesv; 
}
OUTPUT:
  RETVAL 

or 

void
StereoToGeoCoordinates(SV *rv_stereo)
CODE:
 {
  ...
  ST(0) = sv_2mortal(somesv);
  XSRETURN(1); 
 }


>
>MODULE = Util  PACKAGE = Util
>
>void
>StereoToGeoCoordinates(rv_stereo,rv_geo)
>        SV *rv_stereo
>        SV *rv_geo = NO_INIT
-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/

Reply via email to