summaryrefslogtreecommitdiff
path: root/bin/class2info
blob: 752ced3ebce7242a1e0be83f6ed7670caec4c91c (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
#! /bin/sh
# =============================================================================
#
# = DESCRIPTION
#     Converts a C++ class header file into a classinfo description file.
#
# = AUTHOR(S)
#     Graham Dumpleton
#     K. Dorn
# 
# = COPYRIGHT
#     Copyright - OTC LIMITED (1991)
#
# =============================================================================

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"}

INFO2INFO="$BINDIR/info2info"

AWK="nawk"

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


FILES=
V2=

trap 'rm -f /tmp/ci.$$; exit' 1 2 3 13 15

#
# 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.h ..."
}

#
# Check usage.
#
if test $# = 0
then
  USAGE
fi

#
# Parse command line.
#
while test $# != 0
do
  case $1 in
#    -v2)
#      V2=YES
#      shift
#      ;;
    *.h|*.hh|*.H|*.hxx|*.hpp|*.h++)
      FILES="$FILES $1"
      shift
      ;;
    *)
      USAGE
      ;;
    esac
done

#
# Check usage again.
#
if test -z "$FILES"
then
  USAGE
fi

#
# Check for awk file.
#
CLASS2INFO=$LIBDIR/class2info.awk
HIDINGFMT=$LIBDIR/hiding.fmt

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


if ( test ! -f $CLASS2INFO )
then
  ERROR "Can't find $CLASS2INFO"
fi



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`

#echo " $VPUBL   $VPROT    $VPRIV "


#
# Parse each file.
#
#     $VARG publ=on $VARG prot=off $VARG priv=off \
for i in $FILES
do
  if test ! -f $i
  then
    ERROR "$i doesn't exist."
  fi
  FILENAME=`basename $i`
  INFOFILE=`echo $FILENAME | sed -e 's/\..*$//'`.ci
  rm -f $INFOFILE
  if test "$?" != 0
  then
    ERROR "Couldn't remove info file $INFOFILE."
  fi
  expand $i > /tmp/ci.$$
  $AWK \
     -f $CLASS2INFO $VARG filename=$i \
     $VARG $VPUBL $VARG $VPROT $VARG $VPRIV \
     /tmp/ci.$$ > $INFOFILE
  rm -f /tmp/ci.$$
#  if test ! -z "$V2"
#  then
#    $INFO2INFO $INFOFILE
#  fi
done