On Fri, May 25, 2001 at 06:30:03PM -0700, Doug MacEachern wrote:
> On Fri, 25 May 2001, barries wrote:
>  
> >    Apache::ap_add_output_filter( "foo", AP_FTYPE_CONTENT, $ctx )
> 
> you mean ${r,c}->add_output_filter("foo", $ctx), right?

Yeah. Getting late...

> > where Foo is not related to mod_perl, you better be passing an integer
> > in $ctx which is a pointer to some C struct you cooked up in XS that
> > filter foo is expecting.  This would allow mod_perl interfaces to C
> > level filters.
> 
> ah, ok.  $ctx would default to NULL, most of the filters check if their
> context == NULL, and create a new one if so.  hmm, maybe that would also
> be a good way to when the first brigade arrives.

Yeah, I think it comes free if we add a

   ((mod_filter_ctx *)f->ctx)->read_count
   
which (since it's calloced) defaults to 0, and which $filter->tell returns.

What I was after was twofold: being able to pass a Perl structure in
$ctx, which would be put in f->ctx->data, or bineg able to pass a simple
integer value, which would be put in f->ctx, preventing the creation
of the modperl_filter_ctx_t that normally goes in f->ctx, so that
manipulation of external, non-mod_perl filters is possible.

I guess one thought is to see if the named filter is a mod_perl filter,
and create the modperl_filter_ctx_t only if it is, then stuff $ctx in the
modperl_filter_ctx_t's data slot.  $ctx could be any kind of SV in this
case.

If it's not a modperl filter, then $ctx can just be treated as an int
and put in f->ctx.  If $ctx is not an SV that cleanly turns in to an
int, it could croak().

That way the $r->add_xxx_filter( $name, $ctx ) DWIMs what to do with
$ctx.

What do you think of enabling Apache::Filter instance subclassing, given
that filters have to inherit from it anyway to get the CODE attrs
working?

Seems like a $r->add_xxx_filter( new Foo::Filter ) is a very simple
interface.  It's a way of hiding the $ctx and $name in the same blessed
reference and getting all the context to "just work" using well
understood Perl OO semantics.  It'd probably mean giving $f some magic
to make it drive like a HASH ref for the subclasses.

- Barrie

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

Reply via email to