Patrick Dupre wrote:
> Rob Dixon wrote:
>> 
>> It would be nice to have been told the symptoms you are getting, as your code
>> looks basically correct.
>>
>> All I can see that is wrong is that you need to add  PUSHMARK(SP) before the
>> call to the Perl subroutine to mark the end of any parameters you push onto 
>> the
>> stack.
>>
>> Presumably you have had the XS subroutine working at some point? In which 
>> case
>> you need to look at the last thing you added that stopped it working. In
>> addition it would be nice to see proper variable names: using things like 
>> 'ptr'
>> is bad practice, and it is even worse here where you have variables with
>> multiple levels of both C and Perl indirection and it is easy to get 
>> confused.
>
> I am trying to investigate more, but, one problem seems to that that the
> SvTYPE (ret) is 3, ie that it is a RV reference when it should be a
> hash reference. Am I correct ?

(Please bottom-post your responses. Thank you.)

No, your perl subroutine is returning a hash reference, so you should see an RV.
Dereference that using SvRV to get your HV. It should look something like this

    retval = POPs;

    if (! SvROK(retval) || SvTYPE(SvRV(retval)) != SVt_PVHV) {
      croak("Return value is not a hash reference");
    }

    hash = (HV*)SvRV(retval);

    ref_elem = hv_fetch(hash, "a", 1, FALSE);

which is pretty much what you had in the first place, so I'm still not sure what
your problem is. Can you describe what symptoms you're getting please?

Rob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to