I am desesperated !
Assuming the following perl sub:
sub sub1 {
my %a ;
$a {a} = 1 ;
$a {b} = 2 ;
foreach (keys %a) {
print $_, " => ", $a {$_}, "\n" ;
}
return \%a ;
}
Using XS, I am tring to get the hash using:
PREINIT:
int count ;
SV *ret ;
HV *ptr ;
SV ** hv ;
CODE:
dSP ;
ENTER ;
SAVETMPS ;
count = call_pv ("sub_::sub1", G_ARRAY | G_NOARGS | G_EVAL) ;
SPAGAIN ;
if (SvTRUE (ERRSV)) {
printf ("An error occured in the Perl preprocessor: %s\n",
SvPV_nolen (ERRSV)) ;
}
else {
printf ("Nb values returned: %d\n", count) ;
ret = POPs ;
ptr = (HV*) SvRV (ret) ;
}
FREETMPS ;
LEAVE ;
But it is just wrong !!!
For example, how can I make a :
hv_fetch (ptr, "a", 1, FALSE) ;
Ultimately, I need to pass the reference to the hash to another
perl sub by using (a reference on a hash is expected):
XPUSHs ()
but I did not guessed the right syntax
I will appreciate a bit of help.
Thank
--
---
==========================================================================
Patrick DUPRÉ | |
Department of Chemistry | | Phone: (44)-(0)-1904-434384
The University of York | | Fax: (44)-(0)-1904-432516
Heslington | |
York YO10 5DD United Kingdom | | email: [EMAIL PROTECTED]
==========================================================================
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/