Doug MacEachern wrote:
> On Fri, 8 Mar 2002, Stas Bekman wrote:
> 
> 
>>Doug,
>>
>>This kind of construct:
>>
>>   int mpxs_Apache__Foo_bar(pTHX_ I32 items, SV **MARK, SV **SP)
>>
>>is special to WrapXS, isn't it?
>>
> 
> dunno if i'd call it special.  usage is derived from PP() functions in the 
> perl core.

I meant special in a sense that you don't get the usual ST() behavior. 
Inside XS() functions if you say:

dXSARGS;

ST(0) points to the first argument on the stack. Inside the function 
like mpxs_Apache__Foo_bar(pTHX_ I32 items, SV **MARK, SV **SP)
plus the use of macro dAX; ST(0) returns the second element. That's why 
I've asked this question in first place.

I was documenting today the possible variations on retrieving arguments 
from the stack. So consider this example where I've tried to use ST() 
macros, where it didn't work for me, while MARK did work.

   static MP_INLINE
   int mpxs_Apache__Foo_subst_sp(pTHX_ I32 items, SV **MARK, SV **SP)
   {
       int a, b;

       if (items != 2) {
           Perl_croak(aTHX_ "usage: ...");
       }

       a = mp_xs_sv2_int(*MARK);
       b = mp_xs_sv2_int(*(MARK+1));

       return a - b;
   }

which simply does c=a-b, however if you add dAX and try to use ST() 
macros instead of using directly MARK 'b' will receive the value 
intended to 'a' and 'a' will receive garbage (most likely the 'mark' 
itself). Am I doing something wrong in this example?


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to