]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/forms/fdfixh.sed
More pref work from Angus
[lyx.git] / src / frontends / xforms / forms / fdfixh.sed
1 # sed -f fdfixh.sed < somefile.h > fixedfile.h
2 #
3 # It contains the instructions that sed requires to manipulate
4 # the header files produced by fdesign into a form usable by LyX
5
6 s/\(extern \)\(.*\)/\1 "C" \2/
7 #
8 #  Replaces lines such as "extern void func(args);"
9 #  with "extern "C" void func(args);"
10
11 /create_form_/d
12 #
13 #  Deletes lines containing "create_form_"
14
15 s,\(generated with fdesign\)\(.*\)\(\*\*/\),\1 \3,
16 #
17 # Deletes the dated signature so we can rebuild everything as often
18 # as we want without silly clashes due to the date.
19
20 # Rewrites                      as
21 # typedef struct {              struct FD_form_xxx {
22 #       FL_FORM *form_xxx;              ~FD_form_xxx();
23 #       void *vdata;
24 #       char *cdata;                    FL_FORM *form;
25 #       long  ldata;                    ...
26 #        ...                    }
27 # } FD_form_xxx;
28 #
29 # This is detailed more closely below 
30
31 #Manipulate the struct
32 #=====================
33 /typedef struct {/,/} .*;/{
34
35 # delete lines containing ...
36         /typedef struct {/d
37         /vdata/d
38         /cdata/d
39         /ldata/d
40
41 # rewrite "FL_FORM *form_xxx;" as "FL_FORM *form;"
42         s/FL_FORM \(.*\);/FL_FORM *form;/
43
44 # copy remaining lines into the hold space
45         H
46
47 # rewrite "} someStruct;" as   "struct someStruct {"    and print
48 #                              "     ~someStruct();"
49         /} \(.*\);/{
50                 s/} \(.*\);/struct \1 {/p
51                 s/struct \(.*\) {/      ~\1();/p
52         }
53
54 # delete line from pattern space
55         d
56 }
57 # swap the hold space back into the pattern space and...
58 /^$/x
59
60 # rewrite "} someStruct;" as "};"
61 s/} \(.*\);/};/