From: John L. <jl...@ma...> - 2007-06-06 21:13:09
|
On 06/06/2007 02:10 PM, Ben Allan wrote: > Here's a patch which introduces alternative mangler ability > without requiring changes to existing bindings. > As mentioned in another posting, it could also work without exposing > extern String *SwigType_manglestr_default(SwigType *s); > extern String *SwigType_manglestr_nounderscore(SwigType *s); > but I would prefer to expose all the manglings available if possible. Yeah, I think it is fine to expose the manglers > In the 'hidden' case, the SwigType_manglestr_nounderscore > would not be put in stype.c but instead off somewhere in my binding. No, they should be shared if possible. > +static Swig_manglertype Swig_mangler = SwigType_manglestr_default; > + > +/* ----------------------------------------------------------------------------- > + * SwigType_set_mangler() > + * > + * Replaces the current mangler function with a new one, returning the > + * old one to the caller. > + * Design note: Calling with NULL changes nothing but gives access to the > + * current mangler. The other alternative (if NULL, reset to default) does > + * not allow the caller to as easily handle obscure cases where a binding > + * may want to push/popd handlers on the stack midstream. > + * A separate get_mangler could be provided if desired on aesthetic grounds. > + * ----------------------------------------------------------------------------- */ I would rather see a separate get_mangler. Makes the code (in the module) clearer what is happening. And we don't really have a mandate to keep the exported functions small... the swig core API can get as big as it needs to. > +Swig_manglertype SwigType_set_mangler(Swig_manglertype mangler) { > + Swig_manglertype old = Swig_mangler; > + if (mangler==NULL) return Swig_mangler; > + Swig_mangler = mangler; > + return old; > +} Other than that, this code looks fine. John |