Boost logo

Boost :

Subject: Re: [boost] 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] Source-Code, Concepts & Idioms.

> 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


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 {

* allow conditional preprocesing

* 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
     . 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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at