Boost logo

Boost :

Subject: Re: [boost] boost.org Source-Code, Concepts & Idioms.
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-10-14 18:49:36


----- Original Message -----
From: "Steven Watanabe" <watanabesj_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, October 14, 2008 9:12 PM
Subject: Re: [boost] boost.org Source-Code, Concepts & Idioms.

>
> AMDG
>
> Hartmut Kaiser wrote:
>>> Can this be made to format macro expansions nicely?
>>>
>>
>> What do you mean by that?
>>
>
> Since the point is to make the code more readable,
> if we do any macro expansion for instance:
>
> #define SOME_MACRO(...) \
> template<class T> \
> class C { \
> /*stuff*/ \
> };
>
> SOME_MACRO(x, y, z)
>
> We don't want this all to end up on one line.
>
> In Christ,
> Steven Watanabe

Hi,

I'm not sure to understand what exactly you want, which are the two
generated sources you are locking for.

Any way here they are my 2 cts.

If the problem is to have a single source able to generate the current
files, and on the other hand a more readable pseudo C++, I think that we
need a different preprocesor.

I've made something like that some years ago (lost now)

The preprocessor
* allow to define one line macros
@@define SOME_MACRO(...) XXXX

* allow to define multi line macros preserving white spaces and line breaks

@@define_begin SOME_MACRO(...)
  template<class T>
  class C {
    /*stuff*/
 };
@@define_end

* allow conditional preprocesing
@@if
@@else
@@endif

* file inclusion
@@include "file"

The preprocessing was done using some sed/awk and the CPP preprocessor, on
three phases.
1st. Prepare the input to the CPP
     . Replace all the CPP preprocessing # directives by $$
     . Add a end of line pattern $$
     . Replace n white spaces by " $$n$$ "
     . Add the \ at the end of the multi line macros and remove the
@@define_end
     . Replace the new preprocesing directives @@ by #
     . Replace C comments /* */ by $$* *$$
     . Replace C++ comments // by $$$$
2nd. apply the CPP preprocessor
3rd. restore the initial CPP directives
     . Replace all the CPP preprocessing $$ directives by #
     . Replace the pattern $$ by a end of line
     . Replace the pattern " $$n$$ " by n white spaces
     . Replace the patterns by $$* *$$ by /* */
     . Replace the pattern $$$$ by //

The problem is if library authors will use this preprocessing to get the two
required outputs.

I don't know if this can help.

Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk