]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/forms/fdfixh.sed
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / xforms / forms / fdfixh.sed
1 # file fdfixh.sed
2 # This file is part of LyX, the document processor.
3 # Licence details can be found in the file COPYING.
4 #
5 # author Angus Leeming
6 #
7 # Full author contact details are available in file CREDITS
8 #
9 # Use so:
10 # sed -f fdfixh.sed somefile.h > fixedfile.h
11 #
12 # It contains the instructions that sed requires to manipulate
13 # the .h files produced by fdesign into a form usable by LyX
14
15 # Pretty formatting; remove trailing whitespace.
16 s/[     ]*$//
17
18
19 # Delete blank lines, "extern void" function declarations and fdesign comments.
20 /^$/d
21 /^extern void/d
22 /Forms and Objects/d
23 /Callbacks, globals/d
24 /generated with fdesign/d
25
26
27 # Immediately before line "#endif", close namespace lyx::frontend
28 /#endif/i\
29 \
30 } // namespace frontend\
31 } // namespace lyx\
32
33 # Immediately after line "#define FD_xxx_h_" that starts off the header file,
34 # * #include "fdesign_base.h";
35 # * open namespace lyx::frontend and;
36 # * append the contents of file EXTERN_FUNCS.
37 # This latter is a sorted, unique list of any function declarations.
38 # The actual name of the file is inserted by the parent shell script.
39 /#define FD/{
40 a\
41 \
42 #include "fdesign_base.h"\
43 \
44 namespace lyx {\
45 namespace frontend {\
46
47 r EXTERN_FUNCS
48 }
49
50
51 # Rewrite FD_form_xxx as FD_xxx.
52 # This is done both for the structs and for the #define bounding the header.
53 s/\(.*\) FD_form_\(.*\)/\1 FD_\2/
54
55
56 # Rename the function create_form_form_xxx(void) as build_xxx(void *).
57 s/extern \(.*\) create_form_form_\(.*\)[(]void[)]/\1 build_\2(void *)/
58
59
60 # Manipulate the structs:
61 #
62 # Rewrite                       as
63 # typedef struct {              struct FD_xxx : public FD_base {
64 #       FL_FORM *form_xxx;              FL_OBJECT * some_obj;
65 #       void *vdata;                    ...
66 #       char *cdata;            };
67 #       long  ldata;
68 #       FL_OBJECT *some_obj;
69 #       ...
70 # } FD_xxx;
71 #
72 # This is detailed more closely below
73
74 # We retain only those lines in the struct that start " FL_OBJECT *",
75 # placing them in the hold space until the end of the struct is reached
76 # and we can ascertain the struct's name.
77
78 # All other lines are deleted:
79 /^typedef struct/d
80 /^      /{
81 /FL_OBJECT/!d
82 }
83
84
85 # For all lines starting with FL_OBJECT...
86 /^      FL_OBJECT/{
87
88 # 1. Perform a little pretty formatting.
89 s/\(FL_OBJECT \*\)/\1 /
90
91 # 2. Append to the hold space and delete from the pattern space.
92 H
93 d
94 }
95
96
97 # The struct is ended by "} FD_xxx;", so now's the time to paste back the
98 # contents of the hold space.
99 /^} FD_.*;/{
100
101 # 1. Rewrite "} FD_xxx;" as   "\nstruct FD_xxx : public FD_base {".
102 s/} \(.*\);/\
103 struct \1 : public FD_base {/
104
105 # 2. The hold space contains the FL_OBJECT lines, preceded by a new line.
106 #    To get rid of this new line, we exchange the contents of the hold and
107 #    pattern spaces, remove the new line and then exchange back.
108 x
109 s/^\n//
110 x
111
112 # 3. Paste the contents of the hold space beneath the "struct FD_xxx" line.
113 #    and empty the hold space
114 G
115 h
116 s/.*//
117 x
118
119 # 4. Close the struct and append an empty line.
120 a\
121 };\
122
123 }