perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <joe+gm...@sunstarsys.com>
Subject Re: [Fwd: Re: [rfc] APR::Table & polymorphic values]
Date Thu, 05 Jun 2003 08:46:00 GMT
Stas Bekman <stas@stason.org> writes:

[...]

> so we can't simply alias FETCH to apr_table_get, the following sort
> of works (but breaks some other things):
> 
> static MP_INLINE
> const char *mpxs_APR__Table_FETCH(pTHX_ SV *tsv, const char *key)
> {
>      apr_table_t *t = mp_xs_sv2_APR__Table(tsv);
> 
>      if (!t) {
>          return "";
>      }
> 
>      if (!mpxs_apr_table_iterix(tsv)) {
>          return apr_table_get(t, key);
>      }
>      else {
>          const apr_array_header_t *arr = apr_table_elts(t);
>          apr_table_entry_t *elts  = (apr_table_entry_t *)arr->elts;
>          return elts[mpxs_apr_table_iterix(tsv)-1].val;
>      }
> }
> 
> I'm not sure if it's a good idea though.

Probably not as it is- testing mpxs_apr_table_iterix(tsv)
isn't what you want.  I think you really need to know something
about the calling context (iterator call or actual lookup?),
but I'm not sure if perl provides enough info.

It might be easiest to just change the comment at the bottom
of the docs, and just recommend do() for iterating over
the table values.  Short of that, someone might instead wrap
apr_table_elts() as an array.  For apreq, I'd just be concerned 
about how the value attribute of apr_table_entry_t were 
typemapped.

-- 
Joe Schaefer


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


Mime
View raw message