eĿlipsis
a language independent preprocessor
 
Loading...
Searching...
No Matches
ellipsis-do.dirs File Reference

Iterate in the preprocessor. More...

Macros

#define DO_BODY(X)
 The body that will be invoked for each iteration value X
 
#define DO_BOUNDS
 The bounds that must be set before entering this source.
 
#define DO_DIRECTIVES
 A name of a file that is included for its directives at each iteration.
 
#define DO_RESULT
 The name of the macro that will hold the result of the iteration.
 
#define DO_SEPARATOR
 A separator that is inserted between each iteration.
 

Detailed Description

Iterate in the preprocessor.

This needs the macros DO_BOUNDS to be set on entrance.

Use this as in

#include_directives 〈ellipsis-do.dirs〉 \
__prefix__(bind DO_BOUNDS 1, 7) \
__prefix__(bind DO_RESULT list) \
__prefix__(bind DO_BODY(…) __STRINGIFY__(__VA_ARGS__))

After that the macro list should expand to something similar to

"1" "2" "3" "4" "5" "6"

Macros DO_RESULT, DO_BODY, DO_SEPARATOR and DO_DIRECTIVES may optionally be defined to control the outcome of the inclusion.

  • DO_BODY(…), if defined, is expanded with the iteration count as argument and collected in DO_RESULT
  • DO_RESULT, if defined, should be a name that is used as a macro with the final collection of all DO_BODY expansions
  • DO_SEPARATOR, if defined, is expanded between successive DO_BODY expansions
  • DO_DIRECTIVES, if defined, is the name of of a file that is included for each iteration.

Obviously you should have one of DO_BODY and DO_DIRECTIVES such that this file has any effect at all.

So for example if you'd add

__prefix__(bind DO_SEPARATOR ,)
__directive__ bind
A local equivalent to #define.
Definition directives.c:150
#define DO_SEPARATOR
A separator that is inserted between each iteration.
Definition ellipsis-do.dirs:71

to the example above, the items would additionally separated by commas.

Macro Definition Documentation

◆ DO_BODY

#define DO_BODY (   X)

The body that will be invoked for each iteration value X

Remarks
This macro is optional.

◆ DO_BOUNDS

#define DO_BOUNDS

The bounds that must be set before entering this source.

It is used to determine three values, DO_START(), DO_END() and DO_INCR().

  • If only one number is given the iteration starts at 0 and ends before that number.
  • If two numbers are given they are start and end.
  • If three numbers are given they are start, end and increment.

If not provided, the increment is 1.

◆ DO_DIRECTIVES

#define DO_DIRECTIVES

A name of a file that is included for its directives at each iteration.

Within that file you may use the macro ::DO_START() to refer to the current iteration.

This can for example be used to define a macro at each iteration.

Remarks
This macro is optional.

◆ DO_RESULT

#define DO_RESULT

The name of the macro that will hold the result of the iteration.

Remarks
This macro is optional.

◆ DO_SEPARATOR

#define DO_SEPARATOR

A separator that is inserted between each iteration.

This macro is optional.