#!/bin/sh # shell script for generating classes from prototypes # # usage: genclass protodir cdir extension [-2] type1 {ref, val} # [type2 {ref, val}] proto # # modified by Carl Staelin to generate a single file (either the .h or # the .cc file, but not both in the same pass). This is useful when # there are user prototypes which are volatile, and whose implementations # are being debugged (less code is recompiled if the .h file is touched) # search in standard g++ prototype directory & in current #PROTODIR=/usr/local/lib/g++-proto PROTODIR=$1; shift; CURRENTDIR=`pwd` #OUTDIR=`pwd` OUTDIR=$1; shift; EXTNSN=$1; shift; #debug #echo protodir is $PROTODIR #echo outdir is $OUTDIR N="" T2="" T2ACC="" case $1 in -2) N="2"; shift;; *) ;; esac T1=$1 case $2 in ref) T1ACC="\&";; val) T1ACC=" ";; *) echo "Must specify type1 access: ref or val"; exit 1;; esac case $N in 2) T2=$3; case $4 in ref) T2ACC="\&";; val) T2ACC=" ";; *) echo "Must specify type2 access: ref or val"; exit 1;; esac; CLASS=$5;; *) CLASS=$3;; esac # .h and .cc parts done separately in case only a .h SRC=$CLASS.$EXTNSN.proto OUT=$OUTDIR/$T1$T2$CLASS.$EXTNSN #debug #echo h source file is $SRC #echo h outfile is $OUT if test -f $CURRENTDIR/$SRC then SRC=$CURRENTDIR/$SRC elif test -f $PROTODIR/$SRC then SRC=$PROTODIR/$SRC else echo "genclass: $SRC: no such file"; exit 1; fi sed < $SRC > $OUT -e "s//$T1/g" -e "s//$T1$T1ACC/g" -e "s//$T2/g" -e "s//$T2$T2ACC/g"