Re: [RFC] gd, imagefilter

From: Date: Tue, 12 Nov 2002 19:59:30 +0000
Subject: Re: [RFC] gd, imagefilter
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-90886@lists.php.net to get a copy of this message
On Tue, 12 Nov 2002, Pierre-Alain Joye wrote: > Hello, > > That's it :) > > I did not find a sample privat function, now I do. For the ML archive, > here is how to do it: > > On Tue, 12 Nov 2002 17:48:08 +0100 (CET) > Derick Rethans <derick@php.net> wrote: > > > typedef image_filter { > > void (function*)(INTERNAL_FUNCTION_PARAMETERS); > > } image_filter; > > has to be: > typedef void (*image_filter)(INTERNAL_FUNCTION_PARAMETERS); > > We do not need a bidemensional array, except if we want to add the arg > number to avoid a useless call. > image_filter filters[] = {_php_image_filter_none, > _php_image_filter_negate, > _php_image_filter_blur > }; Sure, that works too :) > ] > the "_php_" prefix seems to be the std for privat function, confirmation? Yes. > > then the call itself: > > convert_to_long_ex(FILTERTYPE); > filtertype = Z_LVAL_PP(FILTERTYPE); > printf("filtertype:%i\n",filtertype); > if (filtertype>0 && filtertype<=IMAGE_FILTER_MAX) { If you also use the first filter entry, you can use >= 0 instead of > 0 of course. > filters[filtertype](INTERNAL_FUNCTION_PARAM_PASSTHRU); > } > > and the functions to be called: > > Function declaration: > static void _php_image_filter_negate (INTERNAL_FUNCTION_PARAMETERS); > > Function implementation: > static void _php_image_filter_negate (INTERNAL_FUNCTION_PARAMETERS) > { > /* do stuff */ > } > > voila, > > Any comments or better way to do it welcome, Nope, this looks like that best way :) Derick -- --------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ JDI Media Solutions --------------[ if you hold a unix shell to your ear, do you hear the c? ]-

« previous php.dev (#90886) next »