summaryrefslogtreecommitdiff
path: root/bin/info2headsrc
blob: cc2c1f999dda7aec0755c4a74a7248cbcda89fe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
#! /bin/sh
# =============================================================================
#
# = DESCRIPTION
#     Front end to awk script for generating <class>.hxx and <class>.hxx files
#     from classinfo files.
#
# = AUTHOR(S)
#     K. Dorn
# 
#
# =============================================================================

OSE_HOST=

OSE_RELEASE_NAME=
export OSE_RELEASE_NAME

OSE_ROOT=${OSE_ROOT-$WRAPPER_ROOT}
export OSE_ROOT

OSE_VERSION_ROOT=$OSE_ROOT
export OSE_VERSION_ROOT

BINDIR="$OSE_VERSION_ROOT/$OSE_HOST/bin"
LIBDIR=${CLASSINFOLIBDIR-"$OSE_VERSION_ROOT/bin"}

AWK="${AWK-nawk}"


if test "$AWK" = "nawk"
then
  VARG="-v"
fi

EXT="3"

#
# Error.
#
ERROR()
{
  echo "`basename $0`: $1" >&2
  shift
  while test $# != "0"
  do
    echo $1 >&2
    shift
  done
  exit 1
}

#
# Usage message.
#
USAGE()
{
  ERROR "Usage: `basename $0` file.ci"
} 

#
# Check usage.
#
if test $# != "1" -o "'basename $1 .ci'" = "$1"
then
  USAGE
fi


#
# Check for awk file etc.
#
INFO2SRC=$BINDIR/info2src.awk
INFO2DOC=$LIBDIR/info2doc.awk
MANFMT=$LIBDIR/info2head.fmt
HIDINGFMT=$LIBDIR/hiding.fmt
VENDORFMT=$LIBDIR/vendor.fmt

if test ! -f $VENDORFMT
then
  ERROR "Can't find $VENDORFMT"
fi

if test ! -f $HIDINGFMT
then
  ERROR "Can't find $HIDINGFMT"
fi

if test ! -f $INFO2DOC
then
  ERROR "Can't find $INFO2DOC"
fi

if test ! -f $MANFMT
then
  ERROR "Can't find $MANFMT"
fi

ADTS=`$AWK '
BEGIN {
  FS="\n"; RS=""
}
$1 ~ "^(CLASS|STRUCT|UNION)$" && $2 !~ "(::|<)" {
  printf( "%s\n", $2 )
}
$1 ~ "^TEMPLATE$" && $3 !~ "::" {
  printf( "%s\n", $3 )
}' $1`



VMERGE=`$AWK '
BEGIN {
  FS="\n"; RS=""
}
$1 ~ "^CSAMERGECXXHXX$" {
 if ( $2 ~ "on" )
  printf("%s","merge=on");
 else
  printf("%s","merge=");
}' $HIDINGFMT`

VCSA=`$AWK '
BEGIN {
  FS="\n"; RS=""
}
$1 ~ "^CSAHEADER$" {
 if ( $2 ~ "on" )
  printf("%s","csaprintheader=on");
 else
  printf("%s","csaprintheader=");
}' $HIDINGFMT`

VPUBL=`$AWK '
BEGIN {
  FS="\n"; RS=""
}
$1 ~ "^PUBLIC$" {
 if ( $2 ~ "on" )
  printf("%s","publ=on");
 else
  printf("%s","publ=");
}' $HIDINGFMT`

VPROT=`$AWK '
BEGIN {
  FS="\n"; RS=""
}
$1 ~ "^PROTECTED$" {
 if ( $2 ~ "on" )
  printf("%s","prot=on");
 else
  printf("%s","prot=");
}' $HIDINGFMT`

VPRIV=`$AWK '
BEGIN {
  FS="\n"; RS=""
}
$1 ~ "^PRIVATE$" {
 if ( $2 ~ "on" )
  printf("%s","priv=on");
 else
  printf("%s","priv=");
}' $HIDINGFMT`




VCOCXX=`$AWK '
BEGIN {
  FS=""; RS=""
}
/VENDOR_COMPILATION_HEADER_CXX_START/, /VENDOR_COMPILATION_HEADER_CXX_END/ {
sub("^VENDOR_COMPILATION_HEADER_CXX_START\n","",$0)
sub("VENDOR_COMPILATION_HEADER_CXX_END$","",$0)

gsub( / \\\" /, "999", $0 )
gsub( "\"\\[\t ]*", "234", $0 )
gsub( "234\\\n", "345", $0 )
gsub( /234.\n/, "456", $0 )
gsub( /456[\t ]*234/, "567", $0 )
gsub( /567/, "", $0 )
gsub( /234/, "", $0 )
gsub( /345/, "", $0 )
gsub( "999", "\"", $0 )

print $0
}' $VENDORFMT`


VMECXX=`$AWK '
BEGIN {
  FS=""; RS=""
}
/VENDOR_METHOD_HEADER_CXX_START/, /VENDOR_METHOD_HEADER_CXX_END/ {
sub("^VENDOR_METHOD_HEADER_CXX_START\n","",$0)
sub("VENDOR_METHOD_HEADER_CXX_END$","",$0)

gsub( / \\\" /, "999", $0 )
gsub( "\"\\[\t ]*", "234", $0 )
gsub( "234\\\n", "345", $0 )
gsub( /234.\n/, "456", $0 )
gsub( /456[\t ]*234/, "567", $0 )
gsub( /567/, "", $0 )
gsub( /234/, "", $0 )
gsub( /345/, "", $0 )
gsub( "999", "\"", $0 )

print $0
}' $VENDORFMT`

VCOHXX=`$AWK '
BEGIN {
  FS=""; RS=""
}
/VENDOR_COMPILATION_HEADER_HXX_START/, /VENDOR_COMPILATION_HEADER_HXX_END/ {
sub("^VENDOR_COMPILATION_HEADER_HXX_START\n","",$0)
sub("VENDOR_COMPILATION_HEADER_HXX_END$","",$0)

gsub( / \\\" /, "999", $0 )
gsub( "\"\\[\t ]*", "234", $0 )
gsub( "234\\\n", "345", $0 )
gsub( /234.\n/, "456", $0 )
gsub( /456[\t ]*234/, "567", $0 )
gsub( /567/, "", $0 )
gsub( /234/, "", $0 )
gsub( /345/, "", $0 )
gsub( "999", "\"", $0 )

print $0
}' $VENDORFMT`  


VCLHXX=`$AWK '
BEGIN {
  FS=""; RS=""
}
/VENDOR_CLASS_HEADER_HXX_START/, /VENDOR_CLASS_HEADER_HXX_END/ {
sub("^VENDOR_CLASS_HEADER_HXX_START\n","",$0)
sub("VENDOR_CLASS_HEADER_HXX_END$","",$0)

gsub( / \\\" /, "999", $0 )
gsub( "\"\\[\t ]*", "234", $0 )
gsub( "234\\\n", "345", $0 )
gsub( /234.\n/, "456", $0 )
gsub( /456[\t ]*234/, "567", $0 )
gsub( /567/, "", $0 )
gsub( /234/, "", $0 )
gsub( /345/, "", $0 )
gsub( "999", "\"", $0 )

print $0
}' $VENDORFMT` 


echo " $VCOCXX " > vcocxx.txt
echo " $VMECXX " > vmecxx.txt
echo " $VCOHXX " > vcohxx.txt
echo " $VCLHXX " > vclhxx.txt



echo " $VPUBL   $VPROT    $VPRIV    $VCSA    $VMERGE"

#
# get from *.ci file the classes that should separated
# and make the <class>.hxx and <class>.cxx files
#
if test ! -z "$ADTS"
then
  LASTADT=""
  LOPCNT=1
  BASEFILENAME=`basename $1`
  HXXMERGEFILE=`echo $BASEFILENAME | sed -e 's/\..*$//'`.mhxx
  CXXMERGEFILE=`echo $BASEFILENAME | sed -e 's/\..*$//'`.mcxx
  rm -f $HXXMERGEFILE
  rm -f $CXXMERGEFILE
  for ADT in $ADTS
  do
   if test "$LASTADT" != "$ADT"
   then
    echo "loop = $LOPCNT"
    echo "$ADT"

    echo "making $ADTS.hxx file ..."
    $AWK -f $INFO2DOC \
     $VARG fvclhxx=vclhxx.txt \
     $VARG fvcohxx=vcohxx.txt \
     $VARG $VPUBL $VARG $VPROT $VARG $VPRIV $VARG $VCSA $VARG $VMERGE \
     $VARG pass=0 $VARG device=text $VARG infile=$1 \
     $VARG class=$ADT  $VARG loop=$LOPCNT\
     $MANFMT $MANFMT > $ADT.hxx
    echo "$ADTS.hxx file done!"
    if test "$VMERGE" = "merge=on"
    then
     echo "merging $ADT.hxx into $HXXMERGEFILE"
     cat $ADT.hxx >> $HXXMERGEFILE
    fi

    echo "making $ADTS.cxx file ..."
    $AWK -f $INFO2SRC \
     $VARG fvmecxx=vmecxx.txt \
     $VARG fvcocxx=vcocxx.txt \
     $VARG $VPUBL $VARG $VPROT $VARG $VPRIV $VARG $VCSA $VARG $VMERGE \
     $VARG infile=$1 $VARG classext=$ADT $VARG mode=single $VARG loop=$LOPCNT\
     $1  > $ADT.cxx
    echo "$ADTS.cxx file done!"
    if test "$VMERGE" = "merge=on"
    then
     echo "merging $ADT.cxx into $CXXMERGEFILE"
     cat $ADT.cxx >> $CXXMERGEFILE
    fi

    LOPCNT=`expr $LOPCNT + 1`
    LASTADT=$ADT
   fi
  done
fi
#
# remove temporary vendor files
#
rm -f vcocxx.txt
rm -f vmecxx.txt
rm -f vcohxx.txt
rm -f vclhxx.txt