Re: Removing disabling of exceptions/properties/signal-handlers



On Sat, 2010-02-27 at 14:23 +0100, Murray Cumming wrote: 
> On Wed, 2009-12-30 at 09:51 +0100, Murray Cumming wrote:
> > For a couple of years, gtkmm (via glibmm) has had build-time options to
> > reduce code size by removing some not-often-used API. This is used on
> > Mameo (for instance on the Nokia N900) and on some other consumer
> > devices.
> > http://library.gnome.org/devel/gtkmm-tutorial/unstable/chapter-optional-api.html.en
> > 
> > I suspect that this will soon not be significantly useful on the latest
> > hardware. Is there any objection to removing some of these options. That
> > would reduce the ifdefs in applications code and make maintenance of
> > gtkmm easier.
> > 
> > 
> > I doubt that we can remove the no-exceptions build because disabling
> > exceptions is still very popular, mostly out of habit, and is often
> > enforced by awkward hand-built build systems.
> 
> I've talked to the company that was using this. It doesn't look like
> they will need this feature in future. So, if there are still no
> objections, we will remove _all_ the build-time options to disable API.
> 
> However, it's too late in the cycle to do this for the next stable
> release. But afterwards we can start stripping out those ifdefs:
> Hopefully we can write a script to do it.

The attached script is an attempt at stripping the ifdefs.
Unfortunately, it's a shell script that uses sed so it's not perfect.
Almost all the files are processed correctly, however a couple of files
that I could find in glibmm (exceptionhandler.h and ustring.cc) are not
processed exactly right so the files should be inspected after usage.

To use the script just run it on the files with the #ifdefs (ie
'./run-script file1 file2 ...').  The script changes the file(s) in
place, unless it is specified that the original file(s) should be kept
(-k) so changes should be saved before using it.  I run the script in
the main module directory as follows:

$ remove-optional-api-ifdefs.sh `grep -lr 'GLIBMM_.*_ENABLED' .`

Once the script is done, I check for left over #ifdefs from the main
module directory as follows:

$ $EDITOR `grep -lr 'GLIBMM_.*_ENABLED' .`

Which will edit the left over files with the editor in the EDITOR
variable (searching for the grep pattern in the files will show left
over #ifdefs).

Checking the modified files and the left over files, I think, is an okay
way to make sure the process turned out right.

The script assumes that "#ifdef/#else/#endif" are used in these blocks
so blocks that use '#if defined(...)/#elif defined(...)/#else/#endif' as
in glibmm's, dispatcher.cc are not processed.

Also, gmmproc's Output.pm includes these #ifdefs in generated files so
that would have to be changed as would method.m4 because if the ifdefs
are not on lines by themselves those lines are not processed.

I hope it's useful.  If I find a better, more reliable way to re-write
this script, and the ifdefs are still not removed, I may follow up with
a better version, but in the mean time, at least there's something to
get started with.

-- 
José



Attachment: remove-optional-api-ifdefs.sh
Description: application/shellscript



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]