perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: $parms->info(), take 2
Date Fri, 30 May 2003 00:09:53 GMT
Geoffrey Young wrote:
> 
>>> +static XS(MPXS_Apache__CmdParms_info)
>>
> 
>> All you need is:
>>
>> SV *mpxs_Apache__CmdParms_info(pTHX_ cmd_params* cmd_parms)
> 
> 
>>
>> this is untested, but should give you an idea. of course you need to 
>> adjust the map file and Functions.pm.
>>
>> Doesn't it look much simpler?
> 
> 
> all those *.h files are full of both mpxs_ functions and static XS 
> functions, with functionaity implemented in one or the other seemingly 
> at random.  I have no idea how you would choose one format over the 
> other, but if the mpxs_ implementation makes you more comfortable, 
> that's fine - I'll commit that approach tomorrow.

Even though they look random, they aren't. I have tried to document some of 
these here:
http://perl.apache.org/docs/2.0/devel/core/explained.html#Adding_Wrappers_for_existing_APIs_and_Creating_New_APIs
Admittedly it's incomplete. I wrote that document when I was coping with this 
puzzle myself. As you are now coping with it, it'd help if you could improve 
that document.

I believe Doug's idea was to have to write (and maintain) the minimal amount 
of code. So if you have a simple function where the args and return values can 
be converted from perl to C and back automatically, you use just that. If you 
have an optional number of args you use (...) and manipulate the stack. If you 
have a variable number/type of return args you use XS(). If you read the above 
section, things might get more clear.

The ways you coded the function the first and second time weren't wrong, they 
were just unnecessary verbose. All we want is to keep the code as simple as 
possible, which simplifies the maintence and reduces the number of potential 
bugs. Hope this "noble" goal is understandable.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message