]> git.lyx.org Git - lyx.git/blob - sigc++/macros/README
last try ... sigh
[lyx.git] / sigc++ / macros / README
1 This directory contains files associated with building large numbers
2 of templates needed to represent different numbers of parameters.
3 The file signal.macros.m4 defines all necessary macros for construction
4 of templates with variable arguments.
5
6 These files will be placed in $(INCLUDE_DIR)/sigc++/macros for
7 reuse.
8
9 Requires: 
10   Gnu M4 (others m4 may work)
11
12 Macros of particular interest:
13
14   IF(arg1,arg2[,arg3]) - if arg1 non-zero length print arg2, else arg3
15   LIST(arg0,cond0 [,arg1,cond1]) - generates comma seperated list with 
16     conditions for each argument
17   ARG_CLASS([P1,P2, ... ]) - generates string "class P1,class P2"
18   ARG_BOTH([P1,P2, ... ])  - generates string "P1 p1,P2 p2"
19   ARG_TYPE([P1,P2, ... ])  - generates string "P1,P2"
20   ARG_NAME([P1,P2, ... ])  - generates string "p1,p2"
21   [name]NUM(arg)           - prints name#, where # is items in arg
22   ARGS(P,n)                - generates string [P1,P2,...Pn]
23
24 example:
25
26   To generalize this...
27
28     template<class P1,class P2>  // needs to be inline for zero arguments
29       void Foo::func2(int (*f)(P1,P2),P1 p1,P2 p2)
30         {func(p1,p2);
31         }
32
33   Use this... 
34
35     include(template.macros.m4)
36     define([FOO_FUNC],
37     [
38     IF([$1],template<ARG_CLASS($1)>,inline) 
39       void Foo::[func]NUM($1)(LIST(int (*f)(ARG_TYPE($1)),1,ARG_BOTH($1),[$1]))
40         {func(ARG_NAME($1));
41         }
42     ])
43
44     FOO_FUNC(ARGS(P,0))
45     FOO_FUNC(ARGS(P,1))
46     FOO_FUNC(ARGS(P,2))
47
48   (to prove it m4 this README file.  Honest!)
49
50